diff --git a/Makefile b/Makefile index 8e727371..5f3d1546 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,8 @@ include Make.inc all: library -library: libdir mlp cbnd +library: libdir mlp +#cbnd libdir: (if test ! -d lib ; then mkdir lib; fi) diff --git a/cbind/Makefile b/cbind/Makefile index a7cc9917..74a5224f 100644 --- a/cbind/Makefile +++ b/cbind/Makefile @@ -1,3 +1,4 @@ + include ../Make.inc HERE=. diff --git a/cbind/mlprec/Makefile b/cbind/mlprec/Makefile index 21f7db31..bc9498c4 100644 --- a/cbind/mlprec/Makefile +++ b/cbind/mlprec/Makefile @@ -10,11 +10,11 @@ CINCLUDES=-I. -I$(LIBDIR) -I$(PSBLAS_INCDIR) FINCLUDES=$(FMFLAG)$(HERE) $(FMFLAG)$(INCDIR) $(FMFLAG)$(MODDIR) $(PSBLAS_INCLUDES) -OBJS=mld_prec_cbind_mod.o mld_dprec_cbind_mod.o mld_c_dprec.o mld_zprec_cbind_mod.o mld_c_zprec.o -CMOD=mld_cbind.h mld_c_dprec.h mld_c_zprec.h mld_const.h +OBJS=amg_prec_cbind_mod.o amg_dprec_cbind_mod.o amg_c_dprec.o amg_zprec_cbind_mod.o amg_c_zprec.o +CMOD=amg_cbind.h amg_c_dprec.h amg_c_zprec.h amg_const.h -LIBMOD=mld_prec_cbind_mod$(.mod) mld_dprec_cbind_mod$(.mod) mld_zprec_cbind_mod$(.mod) +LIBMOD=amg_prec_cbind_mod$(.mod) amg_dprec_cbind_mod$(.mod) amg_zprec_cbind_mod$(.mod) LOCAL_MODS=$(LIBMOD) #LIBNAME=$(CPRECLIBNAME) @@ -25,8 +25,8 @@ lib: $(OBJS) $(CMOD) /bin/cp -p $(HERE)/$(LIBNAME) $(DEST) /bin/cp -p $(LIBMOD) $(CMOD) $(DEST) -mld_prec_cbind_mod.o: mld_dprec_cbind_mod.o mld_zprec_cbind_mod.o -#mld_prec_cbind_mod.o: psb_prec_cbind_mod.o +amg_prec_cbind_mod.o: amg_dprec_cbind_mod.o amg_zprec_cbind_mod.o +#amg_prec_cbind_mod.o: psb_prec_cbind_mod.o veryclean: clean /bin/rm -f $(HERE)/$(LIBNAME) diff --git a/cbind/mlprec/mld_c_dprec.c b/cbind/mlprec/amg_c_dprec.c similarity index 100% rename from cbind/mlprec/mld_c_dprec.c rename to cbind/mlprec/amg_c_dprec.c diff --git a/cbind/mlprec/mld_c_dprec.h b/cbind/mlprec/amg_c_dprec.h similarity index 100% rename from cbind/mlprec/mld_c_dprec.h rename to cbind/mlprec/amg_c_dprec.h diff --git a/cbind/mlprec/mld_c_zprec.c b/cbind/mlprec/amg_c_zprec.c similarity index 100% rename from cbind/mlprec/mld_c_zprec.c rename to cbind/mlprec/amg_c_zprec.c diff --git a/cbind/mlprec/mld_c_zprec.h b/cbind/mlprec/amg_c_zprec.h similarity index 100% rename from cbind/mlprec/mld_c_zprec.h rename to cbind/mlprec/amg_c_zprec.h diff --git a/cbind/mlprec/mld_cbind.h b/cbind/mlprec/amg_cbind.h similarity index 100% rename from cbind/mlprec/mld_cbind.h rename to cbind/mlprec/amg_cbind.h diff --git a/cbind/mlprec/mld_const.h b/cbind/mlprec/amg_const.h similarity index 100% rename from cbind/mlprec/mld_const.h rename to cbind/mlprec/amg_const.h diff --git a/cbind/mlprec/mld_dprec_cbind_mod.F90 b/cbind/mlprec/amg_dprec_cbind_mod.F90 similarity index 100% rename from cbind/mlprec/mld_dprec_cbind_mod.F90 rename to cbind/mlprec/amg_dprec_cbind_mod.F90 diff --git a/cbind/mlprec/mld_prec_cbind_mod.F90 b/cbind/mlprec/amg_prec_cbind_mod.F90 similarity index 100% rename from cbind/mlprec/mld_prec_cbind_mod.F90 rename to cbind/mlprec/amg_prec_cbind_mod.F90 diff --git a/cbind/mlprec/mld_zprec_cbind_mod.F90 b/cbind/mlprec/amg_zprec_cbind_mod.F90 similarity index 100% rename from cbind/mlprec/mld_zprec_cbind_mod.F90 rename to cbind/mlprec/amg_zprec_cbind_mod.F90 diff --git a/cbind/test/pargen/mldec.c b/cbind/test/pargen/amgec.c similarity index 100% rename from cbind/test/pargen/mldec.c rename to cbind/test/pargen/amgec.c diff --git a/examples/fileread/mld_cexample_1lev.f90 b/examples/fileread/amg_cexample_1lev.f90 similarity index 100% rename from examples/fileread/mld_cexample_1lev.f90 rename to examples/fileread/amg_cexample_1lev.f90 diff --git a/examples/fileread/mld_cexample_ml.f90 b/examples/fileread/amg_cexample_ml.f90 similarity index 100% rename from examples/fileread/mld_cexample_ml.f90 rename to examples/fileread/amg_cexample_ml.f90 diff --git a/examples/fileread/mld_dexample_1lev.f90 b/examples/fileread/amg_dexample_1lev.f90 similarity index 100% rename from examples/fileread/mld_dexample_1lev.f90 rename to examples/fileread/amg_dexample_1lev.f90 diff --git a/examples/fileread/mld_dexample_ml.f90 b/examples/fileread/amg_dexample_ml.f90 similarity index 100% rename from examples/fileread/mld_dexample_ml.f90 rename to examples/fileread/amg_dexample_ml.f90 diff --git a/examples/fileread/mld_sexample_1lev.f90 b/examples/fileread/amg_sexample_1lev.f90 similarity index 100% rename from examples/fileread/mld_sexample_1lev.f90 rename to examples/fileread/amg_sexample_1lev.f90 diff --git a/examples/fileread/mld_sexample_ml.f90 b/examples/fileread/amg_sexample_ml.f90 similarity index 100% rename from examples/fileread/mld_sexample_ml.f90 rename to examples/fileread/amg_sexample_ml.f90 diff --git a/examples/fileread/mld_zexample_1lev.f90 b/examples/fileread/amg_zexample_1lev.f90 similarity index 100% rename from examples/fileread/mld_zexample_1lev.f90 rename to examples/fileread/amg_zexample_1lev.f90 diff --git a/examples/fileread/mld_zexample_ml.f90 b/examples/fileread/amg_zexample_ml.f90 similarity index 100% rename from examples/fileread/mld_zexample_ml.f90 rename to examples/fileread/amg_zexample_ml.f90 diff --git a/examples/pdegen/mld_dexample_1lev.f90 b/examples/pdegen/amg_dexample_1lev.f90 similarity index 100% rename from examples/pdegen/mld_dexample_1lev.f90 rename to examples/pdegen/amg_dexample_1lev.f90 diff --git a/examples/pdegen/mld_dexample_ml.f90 b/examples/pdegen/amg_dexample_ml.f90 similarity index 100% rename from examples/pdegen/mld_dexample_ml.f90 rename to examples/pdegen/amg_dexample_ml.f90 diff --git a/examples/pdegen/mld_dpde_mod.f90 b/examples/pdegen/amg_dpde_mod.f90 similarity index 100% rename from examples/pdegen/mld_dpde_mod.f90 rename to examples/pdegen/amg_dpde_mod.f90 diff --git a/examples/pdegen/mld_sexample_1lev.f90 b/examples/pdegen/amg_sexample_1lev.f90 similarity index 100% rename from examples/pdegen/mld_sexample_1lev.f90 rename to examples/pdegen/amg_sexample_1lev.f90 diff --git a/examples/pdegen/mld_sexample_ml.f90 b/examples/pdegen/amg_sexample_ml.f90 similarity index 100% rename from examples/pdegen/mld_sexample_ml.f90 rename to examples/pdegen/amg_sexample_ml.f90 diff --git a/examples/pdegen/mld_spde_mod.f90 b/examples/pdegen/amg_spde_mod.f90 similarity index 100% rename from examples/pdegen/mld_spde_mod.f90 rename to examples/pdegen/amg_spde_mod.f90 diff --git a/mlprec/Makefile b/mlprec/Makefile index 5964ec50..595e3497 100644 --- a/mlprec/Makefile +++ b/mlprec/Makefile @@ -7,50 +7,50 @@ HERE=. FINCLUDES=$(FMFLAG)$(HERE) $(FMFLAG)$(INCDIR) $(PSBLAS_INCLUDES) -DMODOBJS=mld_d_prec_type.o \ - mld_d_inner_mod.o mld_d_ilu_solver.o mld_d_diag_solver.o mld_d_jac_smoother.o mld_d_as_smoother.o \ - mld_d_umf_solver.o mld_d_slu_solver.o mld_d_sludist_solver.o mld_d_id_solver.o\ - mld_d_base_solver_mod.o mld_d_base_smoother_mod.o mld_d_onelev_mod.o \ - mld_d_gs_solver.o mld_d_mumps_solver.o \ - mld_d_base_aggregator_mod.o \ - mld_d_dec_aggregator_mod.o mld_d_symdec_aggregator_mod.o -#mld_d_bcmatch_aggregator_mod.o +DMODOBJS=amg_d_prec_type.o \ + amg_d_inner_mod.o amg_d_ilu_solver.o amg_d_diag_solver.o amg_d_jac_smoother.o amg_d_as_smoother.o \ + amg_d_umf_solver.o amg_d_slu_solver.o amg_d_sludist_solver.o amg_d_id_solver.o\ + amg_d_base_solver_mod.o amg_d_base_smoother_mod.o amg_d_onelev_mod.o \ + amg_d_gs_solver.o amg_d_mumps_solver.o \ + amg_d_base_aggregator_mod.o \ + amg_d_dec_aggregator_mod.o amg_d_symdec_aggregator_mod.o +#amg_d_bcmatch_aggregator_mod.o -SMODOBJS=mld_s_prec_type.o mld_s_ilu_fact_mod.o \ - mld_s_inner_mod.o mld_s_ilu_solver.o mld_s_diag_solver.o mld_s_jac_smoother.o mld_s_as_smoother.o \ - mld_s_slu_solver.o mld_s_id_solver.o\ - mld_s_base_solver_mod.o mld_s_base_smoother_mod.o mld_s_onelev_mod.o \ - mld_s_gs_solver.o mld_s_mumps_solver.o \ - mld_s_base_aggregator_mod.o \ - mld_s_dec_aggregator_mod.o mld_s_symdec_aggregator_mod.o +SMODOBJS=amg_s_prec_type.o amg_s_ilu_fact_mod.o \ + amg_s_inner_mod.o amg_s_ilu_solver.o amg_s_diag_solver.o amg_s_jac_smoother.o amg_s_as_smoother.o \ + amg_s_slu_solver.o amg_s_id_solver.o\ + amg_s_base_solver_mod.o amg_s_base_smoother_mod.o amg_s_onelev_mod.o \ + amg_s_gs_solver.o amg_s_mumps_solver.o \ + amg_s_base_aggregator_mod.o \ + amg_s_dec_aggregator_mod.o amg_s_symdec_aggregator_mod.o -ZMODOBJS=mld_z_prec_type.o mld_z_ilu_fact_mod.o \ - mld_z_inner_mod.o mld_z_ilu_solver.o mld_z_diag_solver.o mld_z_jac_smoother.o mld_z_as_smoother.o \ - mld_z_umf_solver.o mld_z_slu_solver.o mld_z_sludist_solver.o mld_z_id_solver.o\ - mld_z_base_solver_mod.o mld_z_base_smoother_mod.o mld_z_onelev_mod.o \ - mld_z_gs_solver.o mld_z_mumps_solver.o \ - mld_z_base_aggregator_mod.o \ - mld_z_dec_aggregator_mod.o mld_z_symdec_aggregator_mod.o +ZMODOBJS=amg_z_prec_type.o amg_z_ilu_fact_mod.o \ + amg_z_inner_mod.o amg_z_ilu_solver.o amg_z_diag_solver.o amg_z_jac_smoother.o amg_z_as_smoother.o \ + amg_z_umf_solver.o amg_z_slu_solver.o amg_z_sludist_solver.o amg_z_id_solver.o\ + amg_z_base_solver_mod.o amg_z_base_smoother_mod.o amg_z_onelev_mod.o \ + amg_z_gs_solver.o amg_z_mumps_solver.o \ + amg_z_base_aggregator_mod.o \ + amg_z_dec_aggregator_mod.o amg_z_symdec_aggregator_mod.o -CMODOBJS=mld_c_prec_type.o mld_c_ilu_fact_mod.o \ - mld_c_inner_mod.o mld_c_ilu_solver.o mld_c_diag_solver.o mld_c_jac_smoother.o mld_c_as_smoother.o \ - mld_c_slu_solver.o mld_c_id_solver.o\ - mld_c_base_solver_mod.o mld_c_base_smoother_mod.o mld_c_onelev_mod.o \ - mld_c_gs_solver.o mld_c_mumps_solver.o \ - mld_c_base_aggregator_mod.o \ - mld_c_dec_aggregator_mod.o mld_c_symdec_aggregator_mod.o +CMODOBJS=amg_c_prec_type.o amg_c_ilu_fact_mod.o \ + amg_c_inner_mod.o amg_c_ilu_solver.o amg_c_diag_solver.o amg_c_jac_smoother.o amg_c_as_smoother.o \ + amg_c_slu_solver.o amg_c_id_solver.o\ + amg_c_base_solver_mod.o amg_c_base_smoother_mod.o amg_c_onelev_mod.o \ + amg_c_gs_solver.o amg_c_mumps_solver.o \ + amg_c_base_aggregator_mod.o \ + amg_c_dec_aggregator_mod.o amg_c_symdec_aggregator_mod.o -MODOBJS=mld_base_prec_type.o mld_prec_type.o mld_prec_mod.o \ - mld_s_prec_mod.o mld_d_prec_mod.o mld_c_prec_mod.o mld_z_prec_mod.o \ +MODOBJS=amg_base_prec_type.o amg_prec_type.o amg_prec_mod.o \ + amg_s_prec_mod.o amg_d_prec_mod.o amg_c_prec_mod.o amg_z_prec_mod.o \ $(SMODOBJS) $(DMODOBJS) $(CMODOBJS) $(ZMODOBJS) OBJS=$(MODOBJS) LOCAL_MODS=$(MODOBJS:.o=$(.mod)) -LIBNAME=libmld_prec.a +LIBNAME=libamg_prec.a all: lib impld @@ -61,107 +61,107 @@ lib: $(OBJS) impld $(AR) $(HERE)/$(LIBNAME) $(OBJS) $(RANLIB) $(HERE)/$(LIBNAME) /bin/cp -p $(HERE)/$(LIBNAME) $(LIBDIR) - /bin/cp -p mld_const.h $(INCDIR) + /bin/cp -p amg_const.h $(INCDIR) /bin/cp -p *$(.mod) $(MODDIR) $(MODOBJS): $(PSBLAS_MODDIR)/$(BASEMODNAME)$(.mod) -mld_base_prec_type.o: mld_const.h -mld_s_prec_type.o mld_d_prec_type.o mld_c_prec_type.o mld_z_prec_type.o : mld_base_prec_type.o -mld_prec_type.o: mld_s_prec_type.o mld_d_prec_type.o mld_c_prec_type.o mld_z_prec_type.o -mld_prec_mod.o: mld_prec_type.o mld_s_prec_mod.o mld_d_prec_mod.o mld_c_prec_mod.o mld_z_prec_mod.o +amg_base_prec_type.o: amg_const.h +amg_s_prec_type.o amg_d_prec_type.o amg_c_prec_type.o amg_z_prec_type.o : amg_base_prec_type.o +amg_prec_type.o: amg_s_prec_type.o amg_d_prec_type.o amg_c_prec_type.o amg_z_prec_type.o +amg_prec_mod.o: amg_prec_type.o amg_s_prec_mod.o amg_d_prec_mod.o amg_c_prec_mod.o amg_z_prec_mod.o $(SINNEROBJS) $(SOUTEROBJS): $(SMODOBJS) $(DINNEROBJS) $(DOUTEROBJS): $(DMODOBJS) $(CINNEROBJS) $(COUTEROBJS): $(CMODOBJS) $(ZINNEROBJS) $(ZOUTEROBJS): $(ZMODOBJS) -mld_s_inner_mod.o: mld_s_prec_type.o -mld_d_inner_mod.o: mld_d_prec_type.o -mld_c_inner_mod.o: mld_c_prec_type.o -mld_z_inner_mod.o: mld_z_prec_type.o +amg_s_inner_mod.o: amg_s_prec_type.o +amg_d_inner_mod.o: amg_d_prec_type.o +amg_c_inner_mod.o: amg_c_prec_type.o +amg_z_inner_mod.o: amg_z_prec_type.o -mld_s_prec_mod.o: $(SMODOBJS) -mld_d_prec_mod.o: $(DMODOBJS) -mld_c_prec_mod.o: $(CMODOBJS) -mld_z_prec_mod.o: $(ZMODOBJS) +amg_s_prec_mod.o: $(SMODOBJS) +amg_d_prec_mod.o: $(DMODOBJS) +amg_c_prec_mod.o: $(CMODOBJS) +amg_z_prec_mod.o: $(ZMODOBJS) -mld_s_prec_type.o: mld_s_onelev_mod.o -mld_d_prec_type.o: mld_d_onelev_mod.o -mld_c_prec_type.o: mld_c_onelev_mod.o -mld_z_prec_type.o: mld_z_onelev_mod.o +amg_s_prec_type.o: amg_s_onelev_mod.o +amg_d_prec_type.o: amg_d_onelev_mod.o +amg_c_prec_type.o: amg_c_onelev_mod.o +amg_z_prec_type.o: amg_z_onelev_mod.o -mld_s_onelev_mod.o: mld_s_base_smoother_mod.o mld_s_dec_aggregator_mod.o -mld_d_onelev_mod.o: mld_d_base_smoother_mod.o mld_d_dec_aggregator_mod.o -mld_c_onelev_mod.o: mld_c_base_smoother_mod.o mld_c_dec_aggregator_mod.o -mld_z_onelev_mod.o: mld_z_base_smoother_mod.o mld_z_dec_aggregator_mod.o +amg_s_onelev_mod.o: amg_s_base_smoother_mod.o amg_s_dec_aggregator_mod.o +amg_d_onelev_mod.o: amg_d_base_smoother_mod.o amg_d_dec_aggregator_mod.o +amg_c_onelev_mod.o: amg_c_base_smoother_mod.o amg_c_dec_aggregator_mod.o +amg_z_onelev_mod.o: amg_z_base_smoother_mod.o amg_z_dec_aggregator_mod.o -mld_s_base_aggregator_mod.o: mld_base_prec_type.o -mld_s_dec_aggregator_mod.o: mld_s_base_aggregator_mod.o -mld_s_hybrid_aggregator_mod.o mld_s_symdec_aggregator_mod.o: mld_s_dec_aggregator_mod.o +amg_s_base_aggregator_mod.o: amg_base_prec_type.o +amg_s_dec_aggregator_mod.o: amg_s_base_aggregator_mod.o +amg_s_hybrid_aggregator_mod.o amg_s_symdec_aggregator_mod.o: amg_s_dec_aggregator_mod.o -mld_d_base_aggregator_mod.o: mld_base_prec_type.o -mld_d_dec_aggregator_mod.o: mld_d_base_aggregator_mod.o -mld_d_hybrid_aggregator_mod.o mld_d_symdec_aggregator_mod.o: mld_d_dec_aggregator_mod.o +amg_d_base_aggregator_mod.o: amg_base_prec_type.o +amg_d_dec_aggregator_mod.o: amg_d_base_aggregator_mod.o +amg_d_hybrid_aggregator_mod.o amg_d_symdec_aggregator_mod.o: amg_d_dec_aggregator_mod.o -mld_c_base_aggregator_mod.o: mld_base_prec_type.o -mld_c_dec_aggregator_mod.o: mld_c_base_aggregator_mod.o -mld_c_hybrid_aggregator_mod.o mld_c_symdec_aggregator_mod.o: mld_c_dec_aggregator_mod.o +amg_c_base_aggregator_mod.o: amg_base_prec_type.o +amg_c_dec_aggregator_mod.o: amg_c_base_aggregator_mod.o +amg_c_hybrid_aggregator_mod.o amg_c_symdec_aggregator_mod.o: amg_c_dec_aggregator_mod.o -mld_z_base_aggregator_mod.o: mld_base_prec_type.o -mld_z_dec_aggregator_mod.o: mld_z_base_aggregator_mod.o -mld_z_hybrid_aggregator_mod.o mld_z_symdec_aggregator_mod.o: mld_z_dec_aggregator_mod.o +amg_z_base_aggregator_mod.o: amg_base_prec_type.o +amg_z_dec_aggregator_mod.o: amg_z_base_aggregator_mod.o +amg_z_hybrid_aggregator_mod.o amg_z_symdec_aggregator_mod.o: amg_z_dec_aggregator_mod.o -mld_s_base_smoother_mod.o: mld_s_base_solver_mod.o -mld_d_base_smoother_mod.o: mld_d_base_solver_mod.o -mld_c_base_smoother_mod.o: mld_c_base_solver_mod.o -mld_z_base_smoother_mod.o: mld_z_base_solver_mod.o +amg_s_base_smoother_mod.o: amg_s_base_solver_mod.o +amg_d_base_smoother_mod.o: amg_d_base_solver_mod.o +amg_c_base_smoother_mod.o: amg_c_base_solver_mod.o +amg_z_base_smoother_mod.o: amg_z_base_solver_mod.o -mld_s_base_solver_mod.o mld_d_base_solver_mod.o mld_c_base_solver_mod.o mld_z_base_solver_mod.o: mld_base_prec_type.o +amg_s_base_solver_mod.o amg_d_base_solver_mod.o amg_c_base_solver_mod.o amg_z_base_solver_mod.o: amg_base_prec_type.o -mld_d_mumps_solver.o mld_d_gs_solver.o mld_d_id_solver.o mld_d_sludist_solver.o mld_d_slu_solver.o \ -mld_d_umf_solver.o mld_d_diag_solver.o mld_d_ilu_solver.o: mld_d_base_solver_mod.o mld_d_prec_type.o +amg_d_mumps_solver.o amg_d_gs_solver.o amg_d_id_solver.o amg_d_sludist_solver.o amg_d_slu_solver.o \ +amg_d_umf_solver.o amg_d_diag_solver.o amg_d_ilu_solver.o: amg_d_base_solver_mod.o amg_d_prec_type.o -#mld_d_ilu_fact_mod.o: mld_base_prec_type.o mld_d_base_solver_mod.o -#mld_d_ilu_solver.o mld_d_iluk_fact.o: mld_d_ilu_fact_mod.o -mld_d_as_smoother.o mld_d_jac_smoother.o: mld_d_base_smoother_mod.o -mld_d_jac_smoother.o: mld_d_diag_solver.o -mld_dprecinit.o mld_dprecset.o: mld_d_diag_solver.o mld_d_ilu_solver.o \ - mld_d_umf_solver.o mld_d_as_smoother.o mld_d_jac_smoother.o \ - mld_d_id_solver.o mld_d_slu_solver.o mld_d_sludist_solver.o +#amg_d_ilu_fact_mod.o: amg_base_prec_type.o amg_d_base_solver_mod.o +#amg_d_ilu_solver.o amg_d_iluk_fact.o: amg_d_ilu_fact_mod.o +amg_d_as_smoother.o amg_d_jac_smoother.o: amg_d_base_smoother_mod.o +amg_d_jac_smoother.o: amg_d_diag_solver.o +amg_dprecinit.o amg_dprecset.o: amg_d_diag_solver.o amg_d_ilu_solver.o \ + amg_d_umf_solver.o amg_d_as_smoother.o amg_d_jac_smoother.o \ + amg_d_id_solver.o amg_d_slu_solver.o amg_d_sludist_solver.o -mld_s_mumps_solver.o mld_s_gs_solver.o mld_s_id_solver.o mld_s_slu_solver.o \ -mld_s_diag_solver.o mld_s_ilu_solver.o: mld_s_base_solver_mod.o mld_s_prec_type.o -mld_s_ilu_fact_mod.o: mld_base_prec_type.o mld_s_base_solver_mod.o -mld_s_ilu_solver.o mld_s_iluk_fact.o: mld_s_ilu_fact_mod.o -mld_s_as_smoother.o mld_s_jac_smoother.o: mld_s_base_smoother_mod.o -mld_s_jac_smoother.o: mld_s_diag_solver.o -mld_sprecinit.o mld_sprecset.o: mld_s_diag_solver.o mld_s_ilu_solver.o \ - mld_s_as_smoother.o mld_s_jac_smoother.o \ - mld_s_id_solver.o mld_s_slu_solver.o +amg_s_mumps_solver.o amg_s_gs_solver.o amg_s_id_solver.o amg_s_slu_solver.o \ +amg_s_diag_solver.o amg_s_ilu_solver.o: amg_s_base_solver_mod.o amg_s_prec_type.o +amg_s_ilu_fact_mod.o: amg_base_prec_type.o amg_s_base_solver_mod.o +amg_s_ilu_solver.o amg_s_iluk_fact.o: amg_s_ilu_fact_mod.o +amg_s_as_smoother.o amg_s_jac_smoother.o: amg_s_base_smoother_mod.o +amg_s_jac_smoother.o: amg_s_diag_solver.o +amg_sprecinit.o amg_sprecset.o: amg_s_diag_solver.o amg_s_ilu_solver.o \ + amg_s_as_smoother.o amg_s_jac_smoother.o \ + amg_s_id_solver.o amg_s_slu_solver.o -mld_z_mumps_solver.o mld_z_gs_solver.o mld_z_id_solver.o mld_z_sludist_solver.o mld_z_slu_solver.o \ -mld_z_umf_solver.o mld_z_diag_solver.o mld_z_ilu_solver.o: mld_z_base_solver_mod.o mld_z_prec_type.o -mld_z_ilu_fact_mod.o: mld_base_prec_type.o mld_z_base_solver_mod.o -mld_z_ilu_solver.o mld_z_iluk_fact.o: mld_z_ilu_fact_mod.o -mld_z_as_smoother.o mld_z_jac_smoother.o: mld_z_base_smoother_mod.o -mld_z_jac_smoother.o: mld_z_diag_solver.o -mld_zprecinit.o mld_zprecset.o: mld_z_diag_solver.o mld_z_ilu_solver.o \ - mld_z_umf_solver.o mld_z_as_smoother.o mld_z_jac_smoother.o \ - mld_z_id_solver.o mld_z_slu_solver.o mld_z_sludist_solver.o +amg_z_mumps_solver.o amg_z_gs_solver.o amg_z_id_solver.o amg_z_sludist_solver.o amg_z_slu_solver.o \ +amg_z_umf_solver.o amg_z_diag_solver.o amg_z_ilu_solver.o: amg_z_base_solver_mod.o amg_z_prec_type.o +amg_z_ilu_fact_mod.o: amg_base_prec_type.o amg_z_base_solver_mod.o +amg_z_ilu_solver.o amg_z_iluk_fact.o: amg_z_ilu_fact_mod.o +amg_z_as_smoother.o amg_z_jac_smoother.o: amg_z_base_smoother_mod.o +amg_z_jac_smoother.o: amg_z_diag_solver.o +amg_zprecinit.o amg_zprecset.o: amg_z_diag_solver.o amg_z_ilu_solver.o \ + amg_z_umf_solver.o amg_z_as_smoother.o amg_z_jac_smoother.o \ + amg_z_id_solver.o amg_z_slu_solver.o amg_z_sludist_solver.o -mld_c_mumps_solver.o mld_c_gs_solver.o mld_c_id_solver.o mld_c_sludist_solver.o mld_c_slu_solver.o \ -mld_c_diag_solver.o mld_c_ilu_solver.o: mld_c_base_solver_mod.o mld_c_prec_type.o -mld_c_ilu_fact_mod.o: mld_base_prec_type.o mld_c_base_solver_mod.o -mld_c_ilu_solver.o mld_c_iluk_fact.o: mld_c_ilu_fact_mod.o -mld_c_as_smoother.o mld_c_jac_smoother.o: mld_c_base_smoother_mod.o -mld_c_jac_smoother.o: mld_c_diag_solver.o -mld_cprecinit.o mld_cprecset.o: mld_c_diag_solver.o mld_c_ilu_solver.o \ - mld_c_as_smoother.o mld_c_jac_smoother.o \ - mld_c_id_solver.o mld_c_slu_solver.o mld_c_sludist_solver.o +amg_c_mumps_solver.o amg_c_gs_solver.o amg_c_id_solver.o amg_c_sludist_solver.o amg_c_slu_solver.o \ +amg_c_diag_solver.o amg_c_ilu_solver.o: amg_c_base_solver_mod.o amg_c_prec_type.o +amg_c_ilu_fact_mod.o: amg_base_prec_type.o amg_c_base_solver_mod.o +amg_c_ilu_solver.o amg_c_iluk_fact.o: amg_c_ilu_fact_mod.o +amg_c_as_smoother.o amg_c_jac_smoother.o: amg_c_base_smoother_mod.o +amg_c_jac_smoother.o: amg_c_diag_solver.o +amg_cprecinit.o amg_cprecset.o: amg_c_diag_solver.o amg_c_ilu_solver.o \ + amg_c_as_smoother.o amg_c_jac_smoother.o \ + amg_c_id_solver.o amg_c_slu_solver.o amg_c_sludist_solver.o diff --git a/mlprec/amg_base_prec_type.F90 b/mlprec/amg_base_prec_type.F90 new file mode 100644 index 00000000..01a2d5a4 --- /dev/null +++ b/mlprec/amg_base_prec_type.F90 @@ -0,0 +1,1210 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_base_prec_type.F90 +! +! Module: amg_base_prec_type +! +! Constants and utilities in common to all type variants of MLD preconditioners. +! - integer constants defining the preconditioner; +! - character constants describing the preconditioner (used by the routines +! printing out a preconditioner description); +! - the interfaces to the routines for the management of the preconditioner +! data structure (see below); +! - The data type encapsulating the parameters defining the ML preconditioner +! - The data type encapsulating the basic aggregation map. +! +! It contains routines for +! - converting character constants defining the preconditioner into integer +! constants; +! - checking if the preconditioner is correctly defined; +! - printing a description of the preconditioner; +! - deallocating the preconditioner data structure. +! + +module amg_base_prec_type + + ! + ! This reduces the size of .mod file. Without the ONLY clause compilation + ! blows up on some systems. + ! + use psb_const_mod + use psb_base_mod, only :& + & psb_desc_type, psb_i_vect_type, psb_i_base_vect_type,& + & psb_ipk_, psb_dpk_, psb_spk_, psb_epk_, & + & psb_cdfree, psb_halo_, psb_none_, psb_sum_, psb_avg_, & + & psb_nohalo_, psb_square_root_, psb_toupper, psb_root_,& + & psb_sizeof_ip, psb_sizeof_lp, psb_sizeof_sp, & + & psb_sizeof_dp, psb_sizeof,& + & psb_cd_get_context, psb_info, psb_min, psb_sum, psb_bcast,& + & psb_sizeof, psb_free, psb_cdfree, & + & psb_errpush, psb_act_abort_, psb_act_ret_,& + & psb_erractionsave, psb_erractionrestore, psb_error, psb_get_errstatus, & + & psb_get_erraction, psb_success_, psb_err_alloc_dealloc_,& + & psb_err_from_subroutine_, psb_err_missing_override_method_, & + & psb_error_handler, psb_out_unit, psb_err_unit + + ! + ! Version numbers + ! + character(len=*), parameter :: amg_version_string_ = "2.3.0" + integer(psb_ipk_), parameter :: amg_version_major_ = 2 + integer(psb_ipk_), parameter :: amg_version_minor_ = 3 + integer(psb_ipk_), parameter :: amg_patchlevel_ = 0 + + type amg_ml_parms + integer(psb_ipk_) :: sweeps_pre, sweeps_post + integer(psb_ipk_) :: ml_cycle + integer(psb_ipk_) :: aggr_type, par_aggr_alg + integer(psb_ipk_) :: aggr_ord, aggr_prol + integer(psb_ipk_) :: aggr_omega_alg, aggr_eig, aggr_filter + integer(psb_ipk_) :: coarse_mat, coarse_solve + contains + procedure, pass(pm) :: get_coarse => ml_parms_get_coarse + procedure, pass(pm) :: clone => ml_parms_clone + procedure, pass(pm) :: descr => ml_parms_descr + procedure, pass(pm) :: mlcycledsc => ml_parms_mlcycledsc + procedure, pass(pm) :: mldescr => ml_parms_mldescr + procedure, pass(pm) :: coarsedescr => ml_parms_coarsedescr + procedure, pass(pm) :: printout => ml_parms_printout + end type amg_ml_parms + + + type, extends(amg_ml_parms) :: amg_sml_parms + real(psb_spk_) :: aggr_omega_val, aggr_thresh + contains + procedure, pass(pm) :: clone => s_ml_parms_clone + procedure, pass(pm) :: descr => s_ml_parms_descr + procedure, pass(pm) :: printout => s_ml_parms_printout + end type amg_sml_parms + + type, extends(amg_ml_parms) :: amg_dml_parms + real(psb_dpk_) :: aggr_omega_val, aggr_thresh + contains + procedure, pass(pm) :: clone => d_ml_parms_clone + procedure, pass(pm) :: descr => d_ml_parms_descr + procedure, pass(pm) :: printout => d_ml_parms_printout + end type amg_dml_parms + + type amg_saggr_data + ! + ! Aggregation data and defaults: + ! + ! 1. min_coarse_size = 0 Default target size will be computed as + ! 40*(N_fine)**(1./3.) + ! We are assuming that the coarse size fits in + ! integer range of psb_ipk_, but this is + ! not very restrictive + integer(psb_ipk_) :: min_coarse_size = izero + ! 2. maximum number of levels. Defaults to 20 + integer(psb_ipk_) :: max_levs = 20_psb_ipk_ + ! 3. min_cr_ratio = 1.5 + real(psb_spk_) :: min_cr_ratio = 1.5_psb_spk_ + real(psb_spk_) :: op_complexity = szero + real(psb_spk_) :: avg_cr = szero + end type amg_saggr_data + + type amg_daggr_data + ! + ! Aggregation data and defaults: + ! + ! + ! 1. min_coarse_size = 0 Default target size will be computed as + ! 40*(N_fine)**(1./3.) + ! We are assuming that the coarse size fits in + ! integer range of psb_ipk_, but this is + ! not very restrictive + integer(psb_ipk_) :: min_coarse_size = izero + ! 2. maximum number of levels. Defaults to 20 + integer(psb_ipk_) :: max_levs = 20_psb_ipk_ + ! 3. min_cr_ratio = 1.5 + real(psb_dpk_) :: min_cr_ratio = 1.5_psb_dpk_ + real(psb_dpk_) :: op_complexity = dzero + real(psb_dpk_) :: avg_cr = dzero + end type amg_daggr_data + + + + ! + ! Entries in iprcparm + ! + ! These are in baseprec + ! + integer(psb_ipk_), parameter :: amg_smoother_type_ = 1 + integer(psb_ipk_), parameter :: amg_sub_solve_ = 2 + integer(psb_ipk_), parameter :: amg_sub_restr_ = 3 + integer(psb_ipk_), parameter :: amg_sub_prol_ = 4 + integer(psb_ipk_), parameter :: amg_sub_ovr_ = 6 + integer(psb_ipk_), parameter :: amg_sub_fillin_ = 7 + integer(psb_ipk_), parameter :: amg_ilu_scale_ = 8 + + ! + ! These are in onelev + ! + integer(psb_ipk_), parameter :: amg_ml_cycle_ = 20 + integer(psb_ipk_), parameter :: amg_smoother_sweeps_pre_ = 21 + integer(psb_ipk_), parameter :: amg_smoother_sweeps_post_ = 22 + integer(psb_ipk_), parameter :: amg_aggr_type_ = 23 + integer(psb_ipk_), parameter :: amg_aggr_prol_ = 24 + integer(psb_ipk_), parameter :: amg_par_aggr_alg_ = 25 + integer(psb_ipk_), parameter :: amg_aggr_ord_ = 26 + integer(psb_ipk_), parameter :: amg_aggr_omega_alg_ = 27 + integer(psb_ipk_), parameter :: amg_aggr_eig_ = 28 + integer(psb_ipk_), parameter :: amg_aggr_filter_ = 29 + integer(psb_ipk_), parameter :: amg_coarse_mat_ = 30 + integer(psb_ipk_), parameter :: amg_coarse_solve_ = 31 + integer(psb_ipk_), parameter :: amg_coarse_sweeps_ = 32 + integer(psb_ipk_), parameter :: amg_coarse_fillin_ = 33 + integer(psb_ipk_), parameter :: amg_coarse_subsolve_ = 34 + integer(psb_ipk_), parameter :: amg_smoother_sweeps_ = 36 + integer(psb_ipk_), parameter :: amg_solver_sweeps_ = 37 + integer(psb_ipk_), parameter :: amg_min_coarse_size_ = 38 + integer(psb_ipk_), parameter :: amg_n_prec_levs_ = 39 + integer(psb_ipk_), parameter :: amg_max_levs_ = 40 + integer(psb_ipk_), parameter :: amg_min_cr_ratio_ = 41 + integer(psb_ipk_), parameter :: amg_outer_sweeps_ = 42 + integer(psb_ipk_), parameter :: amg_ifpsz_ = 43 + + ! + ! Legal values for entry: amg_smoother_type_ + ! + integer(psb_ipk_), parameter :: amg_min_prec_ = 0 + integer(psb_ipk_), parameter :: amg_noprec_ = 0 + integer(psb_ipk_), parameter :: amg_base_smooth_ = 0 + integer(psb_ipk_), parameter :: amg_jac_ = 1 + integer(psb_ipk_), parameter :: amg_l1_jac_ = 2 + integer(psb_ipk_), parameter :: amg_bjac_ = 3 + integer(psb_ipk_), parameter :: amg_l1_bjac_ = 4 + integer(psb_ipk_), parameter :: amg_as_ = 5 + integer(psb_ipk_), parameter :: amg_fbgs_ = 6 + integer(psb_ipk_), parameter :: amg_l1_gs_ = 7 + integer(psb_ipk_), parameter :: amg_l1_fbgs_ = 8 + integer(psb_ipk_), parameter :: amg_max_prec_ = 8 + ! + ! Constants for pre/post signaling. Now only used internally + ! + integer(psb_ipk_), parameter :: amg_smooth_pre_ = 1 + integer(psb_ipk_), parameter :: amg_smooth_post_ = 2 + integer(psb_ipk_), parameter :: amg_smooth_both_ = 3 + + ! + ! This is a quick&dirty fix, but I have nothing better now... + ! + ! Legal values for entry: amg_sub_solve_ + ! + integer(psb_ipk_), parameter :: amg_slv_delta_ = amg_max_prec_+1 + integer(psb_ipk_), parameter :: amg_f_none_ = amg_slv_delta_+0 + integer(psb_ipk_), parameter :: amg_diag_scale_ = amg_slv_delta_+1 + integer(psb_ipk_), parameter :: amg_l1_diag_scale_ = amg_slv_delta_+2 + integer(psb_ipk_), parameter :: amg_gs_ = amg_slv_delta_+3 + ! !$ integer(psb_ipk_), parameter :: amg_ilu_n_ = amg_slv_delta_+4 + ! !$ integer(psb_ipk_), parameter :: amg_milu_n_ = amg_slv_delta_+5 + ! !$ integer(psb_ipk_), parameter :: amg_ilu_t_ = amg_slv_delta_+6 + integer(psb_ipk_), parameter :: amg_slu_ = amg_slv_delta_+7 + integer(psb_ipk_), parameter :: amg_umf_ = amg_slv_delta_+8 + integer(psb_ipk_), parameter :: amg_sludist_ = amg_slv_delta_+9 + integer(psb_ipk_), parameter :: amg_mumps_ = amg_slv_delta_+10 + integer(psb_ipk_), parameter :: amg_bwgs_ = amg_slv_delta_+11 + integer(psb_ipk_), parameter :: amg_max_sub_solve_ = amg_slv_delta_+11 + integer(psb_ipk_), parameter :: amg_min_sub_solve_ = amg_diag_scale_ + + ! + ! Legal values for entry: amg_ilu_scale_ + ! + integer(psb_ipk_), parameter :: amg_ilu_scale_none_ = 0 + integer(psb_ipk_), parameter :: amg_ilu_scale_maxval_ = 1 + integer(psb_ipk_), parameter :: amg_ilu_scale_diag_ = 2 + integer(psb_ipk_), parameter :: amg_ilu_scale_arwsum_ = 3 + integer(psb_ipk_), parameter :: amg_ilu_scale_aclsum_ = 4 + integer(psb_ipk_), parameter :: amg_ilu_scale_arcsum_ = 5 + ! For the time being enable only maxval scale + integer(psb_ipk_), parameter :: amg_max_ilu_scale_ = 1 + ! + ! Legal values for entry: amg_ml_cycle_ + ! + integer(psb_ipk_), parameter :: amg_no_ml_ = 0 + integer(psb_ipk_), parameter :: amg_add_ml_ = 1 + integer(psb_ipk_), parameter :: amg_mult_ml_ = 2 + integer(psb_ipk_), parameter :: amg_vcycle_ml_ = 3 + integer(psb_ipk_), parameter :: amg_wcycle_ml_ = 4 + integer(psb_ipk_), parameter :: amg_kcycle_ml_ = 5 + integer(psb_ipk_), parameter :: amg_kcyclesym_ml_ = 6 + integer(psb_ipk_), parameter :: amg_new_ml_prec_ = 7 + integer(psb_ipk_), parameter :: amg_mult_dev_ml_ = 7 + integer(psb_ipk_), parameter :: amg_max_ml_cycle_ = 8 + ! + ! Legal values for entry: amg_par_aggr_alg_ + ! + integer(psb_ipk_), parameter :: amg_dec_aggr_ = 0 + integer(psb_ipk_), parameter :: amg_sym_dec_aggr_ = 1 + integer(psb_ipk_), parameter :: amg_ext_aggr_ = 2 + integer(psb_ipk_), parameter :: amg_max_par_aggr_alg_ = amg_ext_aggr_ + ! + ! Legal values for entry: amg_aggr_type_ + ! + integer(psb_ipk_), parameter :: amg_noalg_ = 0 + integer(psb_ipk_), parameter :: amg_soc1_ = 1 + integer(psb_ipk_), parameter :: amg_soc2_ = 2 + ! + ! Legal values for entry: amg_aggr_prol_ + ! + integer(psb_ipk_), parameter :: amg_no_smooth_ = 0 + integer(psb_ipk_), parameter :: amg_smooth_prol_ = 1 + integer(psb_ipk_), parameter :: amg_min_energy_ = 2 + ! Disabling min_energy for the time being. + integer(psb_ipk_), parameter :: amg_max_aggr_prol_=amg_smooth_prol_ + ! + ! Legal values for entry: amg_aggr_filter_ + ! + integer(psb_ipk_), parameter :: amg_no_filter_mat_ = 0 + integer(psb_ipk_), parameter :: amg_filter_mat_ = 1 + integer(psb_ipk_), parameter :: amg_max_filter_mat_ = amg_filter_mat_ + ! + ! Legal values for entry: amg_aggr_ord_ + ! + integer(psb_ipk_), parameter :: amg_aggr_ord_nat_ = 0 + integer(psb_ipk_), parameter :: amg_aggr_ord_desc_deg_ = 1 + integer(psb_ipk_), parameter :: amg_max_aggr_ord_ = amg_aggr_ord_desc_deg_ + ! + ! Legal values for entry: amg_aggr_omega_alg_ + ! + integer(psb_ipk_), parameter :: amg_eig_est_ = 0 + integer(psb_ipk_), parameter :: amg_user_choice_ = 999 + ! + ! Legal values for entry: amg_aggr_eig_ + ! + integer(psb_ipk_), parameter :: amg_max_norm_ = 0 + ! + ! Legal values for entry: amg_coarse_mat_ + ! + integer(psb_ipk_), parameter :: amg_distr_mat_ = 0 + integer(psb_ipk_), parameter :: amg_repl_mat_ = 1 + integer(psb_ipk_), parameter :: amg_max_coarse_mat_ = amg_repl_mat_ + ! + ! Legal values for entry: amg_prec_status_ + ! + integer(psb_ipk_), parameter :: amg_prec_built_ = 98765 + + ! + ! Entries in rprcparm: ILU(k,t) threshold, smoothed aggregation omega + ! + integer(psb_ipk_), parameter :: amg_sub_iluthrs_ = 1 + integer(psb_ipk_), parameter :: amg_aggr_omega_val_ = 2 + integer(psb_ipk_), parameter :: amg_aggr_thresh_ = 3 + integer(psb_ipk_), parameter :: amg_coarse_iluthrs_ = 4 + integer(psb_ipk_), parameter :: amg_solver_eps_ = 6 + integer(psb_ipk_), parameter :: amg_rfpsz_ = 8 + ! + ! Is the current solver local or global + ! + integer(psb_ipk_), parameter :: amg_local_solver_ = 0 + integer(psb_ipk_), parameter :: amg_global_solver_ = 1 + + ! + ! Entries for mumps + ! + ! Size of the control vectors + integer, parameter :: amg_mumps_icntl_size=40 + integer, parameter :: amg_mumps_rcntl_size=15 + + ! + ! Fields for sparse matrices ensembles stored in av() + ! + integer(psb_ipk_), parameter :: amg_l_pr_ = 1 + integer(psb_ipk_), parameter :: amg_u_pr_ = 2 + integer(psb_ipk_), parameter :: amg_bp_ilu_avsz_ = 2 + integer(psb_ipk_), parameter :: amg_ap_nd_ = 3 + integer(psb_ipk_), parameter :: amg_ac_ = 4 + integer(psb_ipk_), parameter :: amg_sm_pr_t_ = 5 + integer(psb_ipk_), parameter :: amg_sm_pr_ = 6 + integer(psb_ipk_), parameter :: amg_smth_avsz_ = 6 + integer(psb_ipk_), parameter :: amg_max_avsz_ = amg_smth_avsz_ + + ! + ! Character constants used by amg_file_prec_descr + ! + character(len=19), parameter, private :: & + & eigen_estimates(0:0)=(/'infinity norm '/) + character(len=15), parameter, private :: & + & aggr_prols(0:3)=(/'unsmoothed ','smoothed ',& + & 'min energy ','bizr. smoothed'/) + character(len=15), parameter, private :: & + & aggr_filters(0:1)=(/'no filtering ','filtering '/) + character(len=15), parameter, private :: & + & matrix_names(0:1)=(/'distributed ','replicated '/) + character(len=18), parameter, private :: & + & aggr_type_names(0:2)=(/'None ',& + & 'SOC measure 1 ', 'SOC Measure 2 '/) + character(len=18), parameter, private :: & + & par_aggr_alg_names(0:2)=(/& + & 'decoupled aggr. ', 'sym. dec. aggr. ',& + & 'user defined aggr.'/) + character(len=18), parameter, private :: & + & ord_names(0:1)=(/'Natural ordering ','Desc. degree ord. '/) + character(len=6), parameter, private :: & + & restrict_names(0:4)=(/'none ','halo ',' ',' ',' '/) + character(len=12), parameter, private :: & + & prolong_names(0:3)=(/'none ','sum ', & + & 'average ','square root'/) + character(len=15), parameter, private :: & + & ml_names(0:7)=(/'none ','additive ',& + & 'multiplicative', 'VCycle ','WCycle ',& + & 'KCycle ','KCycleSym ','new ML '/) + character(len=15), parameter :: & + & amg_fact_names(0:amg_max_sub_solve_)=(/& + & 'none ','Jacobi ',& + & 'L1-Jacobi ','none ','none ',& + & 'none ','none ','L1-GS ',& + & 'L1-FBGS ','none ','Point Jacobi ',& + & 'L1-Jacobi ','Gauss-Seidel ','ILU(n) ',& + & 'MILU(n) ','ILU(t,n) ',& + & 'SuperLU ','UMFPACK LU ',& + & 'SuperLU_Dist ','MUMPS ',& + & 'Backward GS '/) + + interface amg_check_def + module procedure amg_icheck_def, amg_scheck_def, amg_dcheck_def + end interface + + interface psb_bcast + module procedure amg_ml_bcast, amg_sml_bcast, amg_dml_bcast + end interface psb_bcast + + interface amg_equal_aggregation + module procedure amg_d_equal_aggregation, amg_s_equal_aggregation + end interface amg_equal_aggregation + +contains + + ! + ! Function: amg_stringval + ! + ! This routine converts the string contained into string into the corresponding + ! integer value. + ! + ! Arguments: + ! string - character(len=*), input. + ! The string to be converted. + ! val - integer, output. + ! The integer value corresponding to the string + ! + function amg_stringval(string) result(val) + use psb_prec_const_mod + implicit none + ! Arguments + character(len=*), intent(in) :: string + integer(psb_ipk_) :: val + character(len=*), parameter :: name='amg_stringval' + ! Local variable + integer :: index_tab + character(len=15) ::string2 + index_tab=index(string,char(9)) + if (index_tab.NE.0) then + string2=string(1:index_tab-1) + else + string2=string + endif + select case(psb_toupper(trim(string2))) + case('NONE') + val = 0 + case('HALO') + val = psb_halo_ + case('SUM') + val = psb_sum_ + case('AVG') + val = psb_avg_ + case('FACT_NONE') + val = amg_f_none_ + case('FBGS') + val = amg_fbgs_ + case('GS','FGS','FWGS') + val = amg_gs_ + case('BGS','BWGS') + val = amg_bwgs_ + case('ILU') + val = psb_ilu_n_ + case('MILU') + val = psb_milu_n_ + case('ILUT') + val = psb_ilu_t_ + case('MUMPS') + val = amg_mumps_ + case('UMF') + val = amg_umf_ + case('SLU') + val = amg_slu_ + case('SLUDIST') + val = amg_sludist_ + case('DIAG') + val = amg_diag_scale_ + case('L1-DIAG') + val = amg_l1_diag_scale_ + case('ADD') + val = amg_add_ml_ + case('MULT_DEV') + val = amg_mult_dev_ml_ + case('MULT') + val = amg_mult_ml_ + case('VCYCLE') + val = amg_vcycle_ml_ + case('WCYCLE') + val = amg_wcycle_ml_ + case('KCYCLE') + val = amg_kcycle_ml_ + case('KCYCLESYM') + val = amg_kcyclesym_ml_ + case('SOC2') + val = amg_soc2_ + case('SOC1') + val = amg_soc1_ + case('DEC') + val = amg_dec_aggr_ + case('SYMDEC') + val = amg_sym_dec_aggr_ + case('NAT','NATURAL') + val = amg_aggr_ord_nat_ + case('DESC','RDEGREE','DEGREE') + val = amg_aggr_ord_desc_deg_ + case('REPL') + val = amg_repl_mat_ + case('DIST') + val = amg_distr_mat_ + case('UNSMOOTHED','NONSMOOTHED') + val = amg_no_smooth_ + case('SMOOTHED') + val = amg_smooth_prol_ + case('MINENERGY') + val = amg_min_energy_ + case('NOPREC') + val = amg_noprec_ + case('BJAC') + val = amg_bjac_ + case('L1-GS') + val = amg_l1_gs_ + case('L1-FBGS') + val = amg_l1_fbgs_ + case('L1-BJAC') + val = amg_l1_bjac_ + case('JAC','JACOBI') + val = amg_jac_ + case('L1-JACOBI') + val = amg_l1_jac_ + case('AS') + val = amg_as_ + case('A_NORMI') + val = amg_max_norm_ + case('USER_CHOICE') + val = amg_user_choice_ + case('EIG_EST') + val = amg_eig_est_ + case('FILTER') + val = amg_filter_mat_ + case('NOFILTER','NO_FILTER') + val = amg_no_filter_mat_ + case('OUTER_SWEEPS') + val = amg_outer_sweeps_ + case('LOCAL_SOLVER') + val = amg_local_solver_ + case('GLOBAL_SOLVER') + val = amg_global_solver_ + case default + val = -1 + end select + end function amg_stringval + + subroutine ml_parms_get_coarse(pm,pmin) + implicit none + class(amg_ml_parms), intent(inout) :: pm + class(amg_ml_parms), intent(in) :: pmin + pm%coarse_mat = pmin%coarse_mat + pm%coarse_solve = pmin%coarse_solve + end subroutine ml_parms_get_coarse + + + + subroutine ml_parms_printout(pm,iout) + implicit none + class(amg_ml_parms), intent(in) :: pm + integer(psb_ipk_), intent(in) :: iout + + write(iout,*) 'ML : ',pm%ml_cycle + write(iout,*) 'Sweeps: ',pm%sweeps_pre,pm%sweeps_post + write(iout,*) 'AGGR : ',pm%par_aggr_alg,pm%aggr_prol, pm%aggr_ord + write(iout,*) ' : ',pm%aggr_omega_alg,pm%aggr_eig,pm%aggr_filter + write(iout,*) 'COARSE: ',pm%coarse_mat,pm%coarse_solve + end subroutine ml_parms_printout + + + subroutine s_ml_parms_printout(pm,iout) + implicit none + class(amg_sml_parms), intent(in) :: pm + integer(psb_ipk_), intent(in) :: iout + + call pm%amg_ml_parms%printout(iout) + write(iout,*) 'REAL : ',pm%aggr_omega_val,pm%aggr_thresh + end subroutine s_ml_parms_printout + + + subroutine d_ml_parms_printout(pm,iout) + implicit none + class(amg_dml_parms), intent(in) :: pm + integer(psb_ipk_), intent(in) :: iout + + call pm%amg_ml_parms%printout(iout) + write(iout,*) 'REAL : ',pm%aggr_omega_val,pm%aggr_thresh + end subroutine d_ml_parms_printout + + + ! + ! Routines printing out a description of the preconditioner + ! + subroutine ml_parms_mlcycledsc(pm,iout,info) + + Implicit None + + ! Arguments + class(amg_ml_parms), intent(in) :: pm + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + info = psb_success_ + if ((pm%ml_cycle>=amg_no_ml_).and.(pm%ml_cycle<=amg_max_ml_cycle_)) then + + + write(iout,*) ' Multilevel cycle: ',& + & ml_names(pm%ml_cycle) + select case (pm%ml_cycle) + case (amg_add_ml_) + write(iout,*) ' Number of smoother sweeps : ',& + & pm%sweeps_pre + case (amg_mult_ml_,amg_vcycle_ml_, amg_wcycle_ml_, amg_kcycle_ml_, amg_kcyclesym_ml_) + write(iout,*) ' Number of smoother sweeps : pre: ',& + & pm%sweeps_pre ,' post: ', pm%sweeps_post + end select + + end if + end subroutine ml_parms_mlcycledsc + + subroutine ml_parms_mldescr(pm,iout,info) + + Implicit None + + ! Arguments + class(amg_ml_parms), intent(in) :: pm + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + info = psb_success_ + if ((pm%ml_cycle>=amg_no_ml_).and.(pm%ml_cycle<=amg_max_ml_cycle_)) then + + + write(iout,*) ' Parallel aggregation algorithm: ',& + & par_aggr_alg_names(pm%par_aggr_alg) + if (pm%aggr_type>0) write(iout,*) ' Aggregation type: ',& + & aggr_type_names(pm%aggr_type) + !if (pm%par_aggr_alg /= amg_ext_aggr_) then + if ( pm%aggr_ord /= amg_aggr_ord_nat_) & + & write(iout,*) ' with initial ordering: ',& + & ord_names(pm%aggr_ord) + write(iout,*) ' Aggregation prolongator: ', & + & aggr_prols(pm%aggr_prol) + if (pm%aggr_prol /= amg_no_smooth_) then + write(iout,*) ' with: ', aggr_filters(pm%aggr_filter) + if (pm%aggr_omega_alg == amg_eig_est_) then + write(iout,*) ' Damping omega computation: spectral radius estimate' + write(iout,*) ' Spectral radius estimate: ', & + & eigen_estimates(pm%aggr_eig) + else if (pm%aggr_omega_alg == amg_user_choice_) then + write(iout,*) ' Damping omega computation: user defined value.' + else + write(iout,*) ' Damping omega computation: unknown value in iprcparm!!' + end if + end if + !end if + else + write(iout,*) ' Multilevel type: Unkonwn value. Something is amiss....',& + & pm%ml_cycle + end if + + return + + end subroutine ml_parms_mldescr + + subroutine ml_parms_descr(pm,iout,info,coarse) + + Implicit None + + ! Arguments + class(amg_ml_parms), intent(in) :: pm + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + logical, intent(in), optional :: coarse + logical :: coarse_ + + info = psb_success_ + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + + if (coarse_) then + call pm%coarsedescr(iout,info) + end if + + return + + end subroutine ml_parms_descr + + + subroutine ml_parms_coarsedescr(pm,iout,info) + + + Implicit None + + ! Arguments + class(amg_ml_parms), intent(in) :: pm + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + + info = psb_success_ + write(iout,*) ' Coarse matrix: ',& + & matrix_names(pm%coarse_mat) + select case(pm%coarse_solve) + case (amg_bjac_,amg_as_) + write(iout,*) ' Number of sweeps : ',& + & pm%sweeps_pre + write(iout,*) ' Coarse solver: ',& + & 'Block Jacobi' + case (amg_l1_bjac_) + write(iout,*) ' Number of sweeps : ',& + & pm%sweeps_pre + write(iout,*) ' Coarse solver: ',& + & 'L1-Block Jacobi' + case (amg_jac_) + write(iout,*) ' Number of sweeps : ',& + & pm%sweeps_pre + write(iout,*) ' Coarse solver: ',& + & 'Point Jacobi' + case default + write(iout,*) ' Coarse solver: ',& + & amg_fact_names(pm%coarse_solve) + end select + + end subroutine ml_parms_coarsedescr + + subroutine s_ml_parms_descr(pm,iout,info,coarse) + + Implicit None + + ! Arguments + class(amg_sml_parms), intent(in) :: pm + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + logical, intent(in), optional :: coarse + + info = psb_success_ + + call pm%amg_ml_parms%descr(iout,info,coarse) + if (pm%aggr_prol /= amg_no_smooth_) then + write(iout,*) ' Damping omega value :',pm%aggr_omega_val + end if + write(iout,*) ' Aggregation threshold:',pm%aggr_thresh + + return + + end subroutine s_ml_parms_descr + + subroutine d_ml_parms_descr(pm,iout,info,coarse) + + Implicit None + + ! Arguments + class(amg_dml_parms), intent(in) :: pm + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + logical, intent(in), optional :: coarse + + info = psb_success_ + + call pm%amg_ml_parms%descr(iout,info,coarse) + if (pm%aggr_prol /= amg_no_smooth_) then + write(iout,*) ' Damping omega value :',pm%aggr_omega_val + end if + write(iout,*) ' Aggregation threshold:',pm%aggr_thresh + + return + + end subroutine d_ml_parms_descr + + + ! + ! Functions/subroutines checking if the preconditioner is correctly defined + ! + + function is_legal_base_prec(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_legal_base_prec + + is_legal_base_prec = ((ip>=amg_noprec_).and.(ip<=amg_max_prec_)) + return + end function is_legal_base_prec + function is_int_non_negative(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_int_non_negative + + is_int_non_negative = (ip >= 0) + return + end function is_int_non_negative + function is_legal_ilu_scale(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_legal_ilu_scale + is_legal_ilu_scale = ((ip >= amg_ilu_scale_none_).and.(ip <= amg_max_ilu_scale_)) + return + end function is_legal_ilu_scale + function is_int_positive(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_int_positive + + is_int_positive = (ip >= 1) + return + end function is_int_positive + function is_legal_prolong(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_legal_prolong + is_legal_prolong = ((ip>=psb_none_).and.(ip<=psb_square_root_)) + return + end function is_legal_prolong + function is_legal_restrict(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_legal_restrict + is_legal_restrict = ((ip == psb_nohalo_).or.(ip==psb_halo_)) + return + end function is_legal_restrict + function is_legal_ml_cycle(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_legal_ml_cycle + + is_legal_ml_cycle = ((ip>=amg_no_ml_).and.(ip<=amg_max_ml_cycle_)) + return + end function is_legal_ml_cycle + function is_legal_ml_par_aggr_alg(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_legal_ml_par_aggr_alg + + is_legal_ml_par_aggr_alg = ((ip>=amg_dec_aggr_).and.(ip<=amg_max_par_aggr_alg_)) + return + end function is_legal_ml_par_aggr_alg + function is_legal_ml_aggr_type(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_legal_ml_aggr_type + + is_legal_ml_aggr_type = (ip >= amg_soc1_) .and. (ip <= amg_soc2_) + return + end function is_legal_ml_aggr_type + function is_legal_ml_aggr_ord(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_legal_ml_aggr_ord + + is_legal_ml_aggr_ord = ((amg_aggr_ord_nat_<=ip).and.(ip<=amg_max_aggr_ord_)) + return + end function is_legal_ml_aggr_ord + function is_legal_ml_aggr_omega_alg(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_legal_ml_aggr_omega_alg + + is_legal_ml_aggr_omega_alg = ((ip == amg_eig_est_).or.(ip==amg_user_choice_)) + return + end function is_legal_ml_aggr_omega_alg + function is_legal_ml_aggr_eig(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_legal_ml_aggr_eig + + is_legal_ml_aggr_eig = (ip == amg_max_norm_) + return + end function is_legal_ml_aggr_eig + function is_legal_ml_aggr_prol(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_legal_ml_aggr_prol + + is_legal_ml_aggr_prol = ((ip>=0).and.(ip<=amg_max_aggr_prol_)) + return + end function is_legal_ml_aggr_prol + function is_legal_ml_coarse_mat(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_legal_ml_coarse_mat + + is_legal_ml_coarse_mat = ((ip>=0).and.(ip<=amg_max_coarse_mat_)) + return + end function is_legal_ml_coarse_mat + function is_legal_aggr_filter(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_legal_aggr_filter + + is_legal_aggr_filter = ((ip>=0).and.(ip<=amg_max_filter_mat_)) + return + end function is_legal_aggr_filter + function is_distr_ml_coarse_mat(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_distr_ml_coarse_mat + + is_distr_ml_coarse_mat = (ip == amg_distr_mat_) + return + end function is_distr_ml_coarse_mat + function is_legal_ml_fact(ip) + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_legal_ml_fact + ! Here the minimum is really 1, amg_fact_none_ is not acceptable. + is_legal_ml_fact = ((ip>=amg_min_sub_solve_)& + & .and.(ip<=amg_max_sub_solve_)) + return + end function is_legal_ml_fact + function is_legal_ilu_fact(ip) + use psb_prec_const_mod + implicit none + integer(psb_ipk_), intent(in) :: ip + logical :: is_legal_ilu_fact + + is_legal_ilu_fact = ((ip==psb_ilu_n_).or.& + & (ip==psb_milu_n_).or.(ip==psb_ilu_t_)) + return + end function is_legal_ilu_fact + function is_legal_d_omega(ip) + implicit none + real(psb_dpk_), intent(in) :: ip + logical :: is_legal_d_omega + is_legal_d_omega = ((ip>=0.0d0).and.(ip<=2.0d0)) + return + end function is_legal_d_omega + function is_legal_d_fact_thrs(ip) + implicit none + real(psb_dpk_), intent(in) :: ip + logical :: is_legal_d_fact_thrs + + is_legal_d_fact_thrs = (ip>=0.0d0) + return + end function is_legal_d_fact_thrs + function is_legal_d_aggr_thrs(ip) + implicit none + real(psb_dpk_), intent(in) :: ip + logical :: is_legal_d_aggr_thrs + + is_legal_d_aggr_thrs = (ip>=0.0d0) + return + end function is_legal_d_aggr_thrs + + function is_legal_s_omega(ip) + implicit none + real(psb_spk_), intent(in) :: ip + logical :: is_legal_s_omega + is_legal_s_omega = ((ip>=0.0).and.(ip<=2.0)) + return + end function is_legal_s_omega + function is_legal_s_fact_thrs(ip) + implicit none + real(psb_spk_), intent(in) :: ip + logical :: is_legal_s_fact_thrs + + is_legal_s_fact_thrs = (ip>=0.0) + return + end function is_legal_s_fact_thrs + function is_legal_s_aggr_thrs(ip) + implicit none + real(psb_spk_), intent(in) :: ip + logical :: is_legal_s_aggr_thrs + + is_legal_s_aggr_thrs = (ip>=0.0) + return + end function is_legal_s_aggr_thrs + + + subroutine amg_icheck_def(ip,name,id,is_legal) + implicit none + integer(psb_ipk_), intent(inout) :: ip + integer(psb_ipk_), intent(in) :: id + character(len=*), intent(in) :: name + interface + function is_legal(i) + import :: psb_ipk_ + integer(psb_ipk_), intent(in) :: i + logical :: is_legal + end function is_legal + end interface + character(len=20), parameter :: rname='amg_check_def' + + if (.not.is_legal(ip)) then + write(0,*)trim(rname),': Error: Illegal value for ',& + & name,' :',ip, '. defaulting to ',id + ip = id + end if + end subroutine amg_icheck_def + + subroutine amg_scheck_def(ip,name,id,is_legal) + implicit none + real(psb_spk_), intent(inout) :: ip + real(psb_spk_), intent(in) :: id + character(len=*), intent(in) :: name + interface + function is_legal(i) + use psb_base_mod, only : psb_spk_ + real(psb_spk_), intent(in) :: i + logical :: is_legal + end function is_legal + end interface + character(len=20), parameter :: rname='amg_check_def' + + if (.not.is_legal(ip)) then + write(0,*)trim(rname),': Error: Illegal value for ',& + & name,' :',ip, '. defaulting to ',id + ip = id + end if + end subroutine amg_scheck_def + + subroutine amg_dcheck_def(ip,name,id,is_legal) + implicit none + real(psb_dpk_), intent(inout) :: ip + real(psb_dpk_), intent(in) :: id + character(len=*), intent(in) :: name + interface + function is_legal(i) + use psb_base_mod, only : psb_dpk_ + real(psb_dpk_), intent(in) :: i + logical :: is_legal + end function is_legal + end interface + character(len=20), parameter :: rname='amg_check_def' + + if (.not.is_legal(ip)) then + write(0,*)trim(rname),': Error: Illegal value for ',& + & name,' :',ip, '. defaulting to ',id + ip = id + end if + end subroutine amg_dcheck_def + + + function pr_to_str(iprec) + implicit none + + integer(psb_ipk_), intent(in) :: iprec + character(len=10) :: pr_to_str + + select case(iprec) + case(amg_noprec_) + pr_to_str='NOPREC' + case(amg_jac_) + pr_to_str='JAC' + case(amg_bjac_) + pr_to_str='BJAC' + case(amg_as_) + pr_to_str='AS' + end select + + end function pr_to_str + + subroutine amg_ml_bcast(ictxt,dat,root) + + implicit none + integer(psb_ipk_), intent(in) :: ictxt + type(amg_ml_parms), intent(inout) :: dat + integer(psb_ipk_), intent(in), optional :: root + + call psb_bcast(ictxt,dat%sweeps_pre,root) + call psb_bcast(ictxt,dat%sweeps_post,root) + call psb_bcast(ictxt,dat%ml_cycle,root) + call psb_bcast(ictxt,dat%aggr_type,root) + call psb_bcast(ictxt,dat%par_aggr_alg,root) + call psb_bcast(ictxt,dat%aggr_ord,root) + call psb_bcast(ictxt,dat%aggr_prol,root) + call psb_bcast(ictxt,dat%aggr_omega_alg,root) + call psb_bcast(ictxt,dat%aggr_eig,root) + call psb_bcast(ictxt,dat%aggr_filter,root) + call psb_bcast(ictxt,dat%coarse_mat,root) + call psb_bcast(ictxt,dat%coarse_solve,root) + + end subroutine amg_ml_bcast + + subroutine amg_sml_bcast(ictxt,dat,root) + + implicit none + integer(psb_ipk_), intent(in) :: ictxt + type(amg_sml_parms), intent(inout) :: dat + integer(psb_ipk_), intent(in), optional :: root + + call psb_bcast(ictxt,dat%amg_ml_parms,root) + call psb_bcast(ictxt,dat%aggr_omega_val,root) + call psb_bcast(ictxt,dat%aggr_thresh,root) + end subroutine amg_sml_bcast + + subroutine amg_dml_bcast(ictxt,dat,root) + implicit none + integer(psb_ipk_), intent(in) :: ictxt + type(amg_dml_parms), intent(inout) :: dat + integer(psb_ipk_), intent(in), optional :: root + + call psb_bcast(ictxt,dat%amg_ml_parms,root) + call psb_bcast(ictxt,dat%aggr_omega_val,root) + call psb_bcast(ictxt,dat%aggr_thresh,root) + end subroutine amg_dml_bcast + + subroutine ml_parms_clone(pm,pmout,info) + + implicit none + class(amg_ml_parms), intent(inout) :: pm + class(amg_ml_parms), intent(out) :: pmout + integer(psb_ipk_), intent(out) :: info + + info = psb_success_ + pmout%sweeps_pre = pm%sweeps_pre + pmout%sweeps_post = pm%sweeps_post + pmout%ml_cycle = pm%ml_cycle + pmout%aggr_type = pm%aggr_type + pmout%par_aggr_alg = pm%par_aggr_alg + pmout%aggr_ord = pm%aggr_ord + pmout%aggr_prol = pm%aggr_prol + pmout%aggr_omega_alg = pm%aggr_omega_alg + pmout%aggr_eig = pm%aggr_eig + pmout%aggr_filter = pm%aggr_filter + pmout%coarse_mat = pm%coarse_mat + pmout%coarse_solve = pm%coarse_solve + + end subroutine ml_parms_clone + + subroutine s_ml_parms_clone(pm,pmout,info) + + implicit none + class(amg_sml_parms), intent(inout) :: pm + class(amg_ml_parms), intent(out) :: pmout + integer(psb_ipk_), intent(out) :: info + + + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ierr(5) + character(len=20) :: name='clone' + + info = 0 + select type(pout => pmout) + class is (amg_sml_parms) + call pm%amg_ml_parms%clone(pout%amg_ml_parms,info) + pout%aggr_omega_val = pm%aggr_omega_val + pout%aggr_thresh = pm%aggr_thresh + class default + info = psb_err_invalid_dynamic_type_ + ierr(1) = 2 + info = psb_err_missing_override_method_ + call psb_errpush(info,name,i_err=ierr) + call psb_get_erraction(err_act) + call psb_error_handler(err_act) + end select + + end subroutine s_ml_parms_clone + + subroutine d_ml_parms_clone(pm,pmout,info) + + implicit none + class(amg_dml_parms), intent(inout) :: pm + class(amg_ml_parms), intent(out) :: pmout + integer(psb_ipk_), intent(out) :: info + + + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ierr(5) + character(len=20) :: name='clone' + + info = 0 + select type(pout => pmout) + class is (amg_dml_parms) + call pm%amg_ml_parms%clone(pout%amg_ml_parms,info) + pout%aggr_omega_val = pm%aggr_omega_val + pout%aggr_thresh = pm%aggr_thresh + class default + info = psb_err_invalid_dynamic_type_ + ierr(1) = 2 + info = psb_err_missing_override_method_ + call psb_errpush(info,name,i_err=ierr) + call psb_get_erraction(err_act) + call psb_error_handler(err_act) + return + end select + + end subroutine d_ml_parms_clone + + function amg_s_equal_aggregation(parms1, parms2) result(val) + type(amg_sml_parms), intent(in) :: parms1, parms2 + logical :: val + + val = (parms1%par_aggr_alg == parms2%par_aggr_alg ) .and. & + & (parms1%aggr_type == parms2%aggr_type ) .and. & + & (parms1%aggr_ord == parms2%aggr_ord ) .and. & + & (parms1%aggr_prol == parms2%aggr_prol ) .and. & + & (parms1%aggr_omega_alg == parms2%aggr_omega_alg ) .and. & + & (parms1%aggr_eig == parms2%aggr_eig ) .and. & + & (parms1%aggr_filter == parms2%aggr_filter ) .and. & + & (parms1%aggr_omega_val == parms2%aggr_omega_val ) .and. & + & (parms1%aggr_thresh == parms2%aggr_thresh ) + end function amg_s_equal_aggregation + + function amg_d_equal_aggregation(parms1, parms2) result(val) + type(amg_dml_parms), intent(in) :: parms1, parms2 + logical :: val + + val = (parms1%par_aggr_alg == parms2%par_aggr_alg ) .and. & + & (parms1%aggr_type == parms2%aggr_type ) .and. & + & (parms1%aggr_ord == parms2%aggr_ord ) .and. & + & (parms1%aggr_prol == parms2%aggr_prol ) .and. & + & (parms1%aggr_omega_alg == parms2%aggr_omega_alg ) .and. & + & (parms1%aggr_eig == parms2%aggr_eig ) .and. & + & (parms1%aggr_filter == parms2%aggr_filter ) .and. & + & (parms1%aggr_omega_val == parms2%aggr_omega_val ) .and. & + & (parms1%aggr_thresh == parms2%aggr_thresh ) + end function amg_d_equal_aggregation + +end module amg_base_prec_type diff --git a/mlprec/amg_c_as_smoother.f90 b/mlprec/amg_c_as_smoother.f90 new file mode 100644 index 00000000..e8c5a6e6 --- /dev/null +++ b/mlprec/amg_c_as_smoother.f90 @@ -0,0 +1,471 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_c_as_smoother_mod.f90 +! +! Module: amg_c_as_smoother_mod +! +! This module defines: +! the amg_c_as_smoother_type data structure containing the +! smoother for an Additive Schwarz smoother. +! +! To begin with, the build procedure constructs the extended +! matrix A and its corresponding descriptor (this has multiple +! halo layers duplicated across different processes); it then +! stores in ND the block off-diagonal matrix, and builds the solver +! on the (extended) block diagonal matrix. +! +! The code allows for the variations of Additive Schwartz, Restricted +! Additive Schwartz and Additive Schwartz with Harmonic Extensions. +! From an implementation point of view, these are handled by +! combining application/non-application of the prolongator/restrictor +! operators. +! +module amg_c_as_smoother + + use amg_c_base_smoother_mod + + type, extends(amg_c_base_smoother_type) :: amg_c_as_smoother_type + ! The local solver component is inherited from the + ! parent type. + ! class(amg_c_base_solver_type), allocatable :: sv + ! + type(psb_cspmat_type) :: nd + type(psb_desc_type) :: desc_data + integer(psb_ipk_) :: novr, restr, prol + integer(psb_lpk_) :: nd_nnz_tot + contains + procedure, pass(sm) :: apply_v => amg_c_as_smoother_apply_vect + procedure, pass(sm) :: apply_a => amg_c_as_smoother_apply + procedure, pass(sm) :: check => amg_c_as_smoother_check + procedure, pass(sm) :: dump => amg_c_as_smoother_dmp + procedure, pass(sm) :: build => amg_c_as_smoother_bld + procedure, pass(sm) :: cnv => amg_c_as_smoother_cnv + procedure, pass(sm) :: clone => amg_c_as_smoother_clone + procedure, pass(sm) :: clone_settings => amg_c_as_smoother_clone_settings + procedure, pass(sm) :: clear_data => amg_c_as_smoother_clear_data + procedure, pass(sm) :: restr_a => amg_c_as_smoother_restr_a + procedure, pass(sm) :: prol_a => amg_c_as_smoother_prol_a + procedure, pass(sm) :: restr_v => amg_c_as_smoother_restr_v + procedure, pass(sm) :: prol_v => amg_c_as_smoother_prol_v + generic, public :: apply_restr => restr_v, restr_a + generic, public :: apply_prol => prol_v, prol_a + procedure, pass(sm) :: free => amg_c_as_smoother_free + procedure, pass(sm) :: cseti => amg_c_as_smoother_cseti + procedure, pass(sm) :: csetc => amg_c_as_smoother_csetc + procedure, pass(sm) :: descr => c_as_smoother_descr + procedure, pass(sm) :: sizeof => c_as_smoother_sizeof + procedure, pass(sm) :: default => c_as_smoother_default + procedure, pass(sm) :: get_nzeros => c_as_smoother_get_nzeros + procedure, pass(sm) :: get_wrksz => c_as_smoother_get_wrksize + procedure, nopass :: get_fmt => c_as_smoother_get_fmt + procedure, nopass :: get_id => c_as_smoother_get_id + end type amg_c_as_smoother_type + + + private :: c_as_smoother_descr, c_as_smoother_sizeof, & + & c_as_smoother_default, c_as_smoother_get_nzeros, & + & c_as_smoother_get_fmt, c_as_smoother_get_id, & + & c_as_smoother_get_wrksize + + character(len=6), parameter, private :: & + & restrict_names(0:4)=(/'none ','halo ',' ',' ',' '/) + character(len=12), parameter, private :: & + & prolong_names(0:3)=(/'none ','sum ','average ','square root'/) + + + interface + subroutine amg_c_as_smoother_check(sm,info) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_spk_, amg_c_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_c_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_as_smoother_check + end interface + + interface + subroutine amg_c_as_smoother_restr_v(sm,x,trans,work,info,data) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_spk_, amg_c_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + class(amg_c_as_smoother_type), intent(inout) :: sm + type(psb_c_vect_type),intent(inout) :: x + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + end subroutine amg_c_as_smoother_restr_v + end interface + + interface + subroutine amg_c_as_smoother_restr_a(sm,x,trans,work,info,data) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_spk_, amg_c_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + class(amg_c_as_smoother_type), intent(inout) :: sm + complex(psb_spk_), intent(inout) :: x(:) + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + end subroutine amg_c_as_smoother_restr_a + end interface + + interface + subroutine amg_c_as_smoother_prol_v(sm,x,trans,work,info,data) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_spk_, amg_c_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + class(amg_c_as_smoother_type), intent(inout) :: sm + type(psb_c_vect_type),intent(inout) :: x + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + end subroutine amg_c_as_smoother_prol_v + end interface + + interface + subroutine amg_c_as_smoother_prol_a(sm,x,trans,work,info,data) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_spk_, amg_c_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + class(amg_c_as_smoother_type), intent(inout) :: sm + complex(psb_spk_), intent(inout) :: x(:) + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + end subroutine amg_c_as_smoother_prol_a + end interface + + + interface + subroutine amg_c_as_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,wv,info,init,initu) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_spk_, amg_c_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_as_smoother_type), intent(inout) :: sm + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + end subroutine amg_c_as_smoother_apply_vect + end interface + + interface + subroutine amg_c_as_smoother_apply(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,info,init,initu) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_spk_, amg_c_as_smoother_type, psb_epk_,& + & psb_desc_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_as_smoother_type), intent(inout) :: sm + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_c_as_smoother_apply + end interface + + interface + subroutine amg_c_as_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_spk_, amg_c_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_c_base_sparse_mat, psb_ipk_,& + & psb_i_base_vect_type + implicit none + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_as_smoother_bld + end interface + + interface + subroutine amg_c_as_smoother_cnv(sm,info,amold,vmold,imold) + import :: psb_c_base_vect_type, & + & psb_spk_, amg_c_as_smoother_type, psb_epk_, & + & psb_c_base_sparse_mat, psb_ipk_, psb_i_base_vect_type + implicit none + class(amg_c_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_as_smoother_cnv + end interface + + interface + subroutine amg_c_as_smoother_cseti(sm,what,val,info,idx) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_spk_, amg_c_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_c_as_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_c_as_smoother_cseti + end interface + + interface + subroutine amg_c_as_smoother_csetc(sm,what,val,info,idx) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_spk_, amg_c_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_c_as_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_c_as_smoother_csetc + end interface + + interface + subroutine amg_c_as_smoother_free(sm,info) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_spk_, amg_c_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_c_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_as_smoother_free + end interface + + interface + subroutine amg_c_as_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_spk_, amg_c_as_smoother_type, psb_epk_, psb_desc_type, & + & psb_ipk_ + implicit none + class(amg_c_as_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + end subroutine amg_c_as_smoother_dmp + end interface + + interface + subroutine amg_c_as_smoother_clone(sm,smout,info) + import :: amg_c_as_smoother_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_ + class(amg_c_as_smoother_type), intent(inout) :: sm + class(amg_c_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_as_smoother_clone + end interface + + + interface + subroutine amg_c_as_smoother_clone_settings(sm,smout,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_smoother_type, amg_c_as_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_as_smoother_type), intent(inout) :: sm + class(amg_c_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_as_smoother_clone_settings + end interface + + interface + subroutine amg_c_as_smoother_clear_data(sm,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_as_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_as_smoother_clear_data + end interface + + +contains + + function c_as_smoother_sizeof(sm) result(val) + implicit none + ! Arguments + class(amg_c_as_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 3*psb_sizeof_ip + psb_sizeof_lp + if (allocated(sm%sv)) val = val + sm%sv%sizeof() + val = val + sm%nd%sizeof() + + return + end function c_as_smoother_sizeof + + function c_as_smoother_get_nzeros(sm) result(val) + implicit none + class(amg_c_as_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + if (allocated(sm%sv)) & + & val = sm%sv%get_nzeros() + val = val + sm%nd%get_nzeros() + + end function c_as_smoother_get_nzeros + + subroutine c_as_smoother_default(sm) + + use psb_base_mod, only : psb_halo_, psb_none_ + + Implicit None + + ! Arguments + class(amg_c_as_smoother_type), intent(inout) :: sm + + ! + ! Default: AS with 1 overlap layer + ! + sm%restr = psb_halo_ + sm%prol = psb_sum_ + sm%novr = 1 + + if (allocated(sm%sv)) then + call sm%sv%default() + end if + + return + end subroutine c_as_smoother_default + + + subroutine c_as_smoother_descr(sm,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_c_as_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_c_as_smoother_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (.not.coarse_) then + write(iout_,*) ' Additive Schwarz with ',& + & sm%novr, ' overlap layers.' + write(iout_,*) ' Restrictor: ',restrict_names(sm%restr) + write(iout_,*) ' Prolongator: ',prolong_names(sm%prol) + write(iout_,*) ' Local solver:' + endif + if (allocated(sm%sv)) then + call sm%sv%descr(info,iout_,coarse=coarse) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine c_as_smoother_descr + + function c_as_smoother_get_wrksize(sm) result(val) + implicit none + class(amg_c_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_) :: val + + val = 3 + if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() + + end function c_as_smoother_get_wrksize + + function c_as_smoother_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Additive Schwarz" + end function c_as_smoother_get_fmt + + function c_as_smoother_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_as_ + end function c_as_smoother_get_id + +end module amg_c_as_smoother diff --git a/mlprec/amg_c_base_aggregator_mod.f90 b/mlprec/amg_c_base_aggregator_mod.f90 new file mode 100644 index 00000000..14dd4643 --- /dev/null +++ b/mlprec/amg_c_base_aggregator_mod.f90 @@ -0,0 +1,519 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! The aggregator object hosts the aggregation method for building +! the multilevel hierarchy. +! +module amg_c_base_aggregator_mod + + use amg_base_prec_type, only : amg_sml_parms, amg_saggr_data + use psb_base_mod, only : psb_cspmat_type, psb_lcspmat_type, psb_c_vect_type, & + & psb_c_base_vect_type, psb_clinmap_type, psb_spk_, & + & psb_lc_csr_sparse_mat, psb_lc_coo_sparse_mat, & + & psb_c_csr_sparse_mat, psb_c_coo_sparse_mat, & + & psb_ipk_, psb_epk_, psb_lpk_, psb_desc_type, psb_i_base_vect_type, & + & psb_erractionsave, psb_error_handler, psb_success_, psb_toupper + ! + ! + ! + !> \class amg_c_base_aggregator_type + !! + !! It is the data type containing the basic interface definition for + !! building a multigrid hierarchy by aggregation. The base object has no attributes, + !! it is intended to be essentially an abstract type. + !! + !! + !! type amg_c_base_aggregator_type + !! end type + !! + !! + !! Methods: + !! + !! bld_tprol - Build a tentative prolongator + !! + !! mat_bld - Build prolongator/restrictor and coarse matrix ac + !! + !! mat_asb - Convert prolongator/restrictor/coarse matrix + !! and fix their descriptor(s) + !! + !! update_next - Transfer information to the next level; default is + !! to do nothing, i.e. aggregators at different + !! levels are independent. + !! + !! default - Apply defaults + !! set_aggr_type - For aggregator that have internal options. + !! fmt - Return a short string description + !! descr - Print a more detailed description + !! + !! cseti, csetr, csetc - Set internal parameters, if any + ! + type amg_c_base_aggregator_type + ! Do we want to purge explicit zeros when aggregating? + logical :: do_clean_zeros + contains + procedure, pass(ag) :: bld_tprol => amg_c_base_aggregator_build_tprol + procedure, pass(ag) :: mat_bld => amg_c_base_aggregator_mat_bld + procedure, pass(ag) :: mat_asb => amg_c_base_aggregator_mat_asb + procedure, pass(ag) :: bld_map => amg_c_base_aggregator_bld_map + procedure, pass(ag) :: update_next => amg_c_base_aggregator_update_next + procedure, pass(ag) :: clone => amg_c_base_aggregator_clone + procedure, pass(ag) :: free => amg_c_base_aggregator_free + procedure, pass(ag) :: default => amg_c_base_aggregator_default + procedure, pass(ag) :: descr => amg_c_base_aggregator_descr + procedure, pass(ag) :: sizeof => amg_c_base_aggregator_sizeof + procedure, pass(ag) :: set_aggr_type => amg_c_base_aggregator_set_aggr_type + procedure, nopass :: fmt => amg_c_base_aggregator_fmt + procedure, pass(ag) :: cseti => amg_c_base_aggregator_cseti + procedure, pass(ag) :: csetr => amg_c_base_aggregator_csetr + procedure, pass(ag) :: csetc => amg_c_base_aggregator_csetc + generic, public :: set => cseti, csetr, csetc + procedure, nopass :: xt_desc => amg_c_base_aggregator_xt_desc + end type amg_c_base_aggregator_type + + abstract interface + subroutine amg_c_soc_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, psb_ipk_, psb_lpk_ + implicit none + integer(psb_ipk_), intent(in) :: iorder + logical, intent(in) :: clean_zeros + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + real(psb_spk_), intent(in) :: theta + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_soc_map_bld + end interface + + interface amg_ptap + subroutine amg_c_ptap(a_csr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_cprol,coo_restr,info,desc_ax) + import :: psb_c_csr_sparse_mat, psb_cspmat_type, psb_desc_type, & + & psb_c_coo_sparse_mat, amg_sml_parms, psb_spk_, psb_ipk_, psb_lpk_ + implicit none + type(psb_c_csr_sparse_mat), intent(inout) :: a_csr + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + type(amg_sml_parms), intent(inout) :: parms + type(psb_c_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr + type(psb_desc_type), intent(inout) :: desc_cprol + type(psb_cspmat_type), intent(out) :: ac + integer(psb_ipk_), intent(out) :: info + type(psb_desc_type), intent(inout), optional :: desc_ax + end subroutine amg_c_ptap +!!$ subroutine amg_c_lc_ptap(a_csr,desc_a,nlaggr,parms,ac,& +!!$ & coo_prol,desc_cprol,coo_restr,info,desc_ax) +!!$ import :: psb_c_csr_sparse_mat, psb_lcspmat_type, psb_desc_type, & +!!$ & psb_lc_coo_sparse_mat, amg_sml_parms, psb_spk_, psb_ipk_, psb_lpk_ +!!$ implicit none +!!$ type(psb_c_csr_sparse_mat), intent(inout) :: a_csr +!!$ type(psb_desc_type), intent(in) :: desc_a +!!$ integer(psb_lpk_), intent(inout) :: nlaggr(:) +!!$ type(amg_sml_parms), intent(inout) :: parms +!!$ type(psb_lc_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr +!!$ type(psb_desc_type), intent(inout) :: desc_cprol +!!$ type(psb_lcspmat_type), intent(out) :: ac +!!$ integer(psb_ipk_), intent(out) :: info +!!$ type(psb_desc_type), intent(inout), optional :: desc_ax +!!$ end subroutine amg_c_lc_ptap +!!$ subroutine amg_lc_ptap(a_csr,desc_a,nlaggr,parms,ac,& +!!$ & coo_prol,desc_cprol,coo_restr,info,desc_ax) +!!$ import :: psb_lc_csr_sparse_mat, psb_lcspmat_type, psb_desc_type, & +!!$ & psb_lc_coo_sparse_mat, amg_sml_parms, psb_spk_, psb_ipk_, psb_lpk_ +!!$ implicit none +!!$ type(psb_lc_csr_sparse_mat), intent(inout) :: a_csr +!!$ type(psb_desc_type), intent(in) :: desc_a +!!$ integer(psb_lpk_), intent(inout) :: nlaggr(:) +!!$ type(amg_sml_parms), intent(inout) :: parms +!!$ type(psb_lc_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr +!!$ type(psb_desc_type), intent(inout) :: desc_cprol +!!$ type(psb_lcspmat_type), intent(out) :: ac +!!$ integer(psb_ipk_), intent(out) :: info +!!$ type(psb_desc_type), intent(inout), optional :: desc_ax +!!$ end subroutine amg_lc_ptap + end interface amg_ptap + +contains + + subroutine amg_c_base_aggregator_cseti(ag,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_c_base_aggregator_type), intent(inout) :: ag + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + ! Do nothing + info = 0 + end subroutine amg_c_base_aggregator_cseti + + subroutine amg_c_base_aggregator_csetr(ag,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_c_base_aggregator_type), intent(inout) :: ag + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + ! Do nothing + info = 0 + end subroutine amg_c_base_aggregator_csetr + + subroutine amg_c_base_aggregator_csetc(ag,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_c_base_aggregator_type), intent(inout) :: ag + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + ! Set clean zeros, or do nothing. + select case (psb_toupper(trim(what))) + case('AGGR_CLEAN_ZEROS') + select case (psb_toupper(trim(val))) + case('TRUE','T') + ag%do_clean_zeros = .true. + case('FALSE','F') + ag%do_clean_zeros = .false. + end select + end select + info = 0 + end subroutine amg_c_base_aggregator_csetc + + + subroutine amg_c_base_aggregator_update_next(ag,agnext,info) + implicit none + class(amg_c_base_aggregator_type), target, intent(inout) :: ag, agnext + integer(psb_ipk_), intent(out) :: info + + ! + ! Base version does nothing. + ! + info = 0 + end subroutine amg_c_base_aggregator_update_next + + subroutine amg_c_base_aggregator_clone(ag,agnext,info) + implicit none + class(amg_c_base_aggregator_type), intent(inout) :: ag + class(amg_c_base_aggregator_type), allocatable, intent(inout) :: agnext + integer(psb_ipk_), intent(out) :: info + + info = 0 + if (allocated(agnext)) then + call agnext%free(info) + if (info == 0) deallocate(agnext,stat=info) + end if + if (info /= 0) return + allocate(agnext,source=ag,stat=info) + + end subroutine amg_c_base_aggregator_clone + + subroutine amg_c_base_aggregator_free(ag,info) + implicit none + class(amg_c_base_aggregator_type), intent(inout) :: ag + integer(psb_ipk_), intent(out) :: info + + info = psb_success_ + return + end subroutine amg_c_base_aggregator_free + + subroutine amg_c_base_aggregator_default(ag) + implicit none + class(amg_c_base_aggregator_type), intent(inout) :: ag + ! Only one default setting + ag%do_clean_zeros = .true. + + return + end subroutine amg_c_base_aggregator_default + + function amg_c_base_aggregator_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Default aggregator " + end function amg_c_base_aggregator_fmt + + function amg_c_base_aggregator_sizeof(ag) result(val) + implicit none + class(amg_c_base_aggregator_type), intent(in) :: ag + integer(psb_epk_) :: val + + val = 1 + end function amg_c_base_aggregator_sizeof + + function amg_c_base_aggregator_xt_desc() result(val) + implicit none + logical :: val + + val = .false. + end function amg_c_base_aggregator_xt_desc + + subroutine amg_c_base_aggregator_descr(ag,parms,iout,info) + implicit none + class(amg_c_base_aggregator_type), intent(in) :: ag + type(amg_sml_parms), intent(in) :: parms + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + + write(iout,*) 'Aggregator object type: ',ag%fmt() + call parms%mldescr(iout,info) + + return + end subroutine amg_c_base_aggregator_descr + + subroutine amg_c_base_aggregator_set_aggr_type(ag,parms,info) + implicit none + class(amg_c_base_aggregator_type), intent(inout) :: ag + type(amg_sml_parms), intent(in) :: parms + integer(psb_ipk_), intent(out) :: info + + ! Do nothing + + return + end subroutine amg_c_base_aggregator_set_aggr_type + + ! + !> Function bld_tprol: + !! \memberof amg_c_base_aggregator_type + !! \brief Build a tentative prolongator. + !! The routine will map the local matrix entries to aggregates. + !! The mapping is store in ILAGGR; for each local row index I, + !! ILAGGR(I) contains the index of the aggregate to which index I + !! will contribute, in global numbering. + !! Many aggregations produce a binary tentative prolongator, but some + !! do not, hence we also need the OP_PROL output. + !! AG_DATA is passed here just in case some of the + !! aggregators need it internally, most of them will ignore. + !! + !! \param ag The input aggregator object + !! \param parms The auxiliary parameters object + !! \param ag_data Auxiliary global aggregation info + !! \param a The local matrix part + !! \param desc_a The descriptor + !! \param ilaggr Output aggregation map + !! \param nlaggr Sizes of ilaggr on all processes + !! \param op_prol The tentative prolongator operator + !! \param info Return code + !! + ! + subroutine amg_c_base_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,t_prol,info) + use psb_base_mod + implicit none + class(amg_c_base_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(amg_saggr_data), intent(in) :: ag_data + type(psb_cspmat_type), intent(inout) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lcspmat_type), intent(out) :: t_prol + integer(psb_ipk_), intent(out) :: info + + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_aggregator_build_tprol' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + + end subroutine amg_c_base_aggregator_build_tprol + + ! + !> Function mat_bld + !! \memberof amg_c_base_aggregator_type + !! \brief Build prolongator/restrictor/coarse matrix. + !! + !! + !! \param ag The input aggregator object + !! \param parms The auxiliary parameters object + !! \param a The local matrix part + !! \param desc_a The descriptor + !! \param ilaggr Aggregation map + !! \param nlaggr Sizes of ilaggr on all processes + !! \param ac On output the coarse matrix + !! \param op_prol On input, the tentative prolongator operator, on output + !! the final prolongator + !! \param op_restr On output, the restrictor operator; + !! in many cases it is the transpose of the prolongator. + !! \param info Return code + !! + subroutine amg_c_base_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + use psb_base_mod + implicit none + class(amg_c_base_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(psb_lcspmat_type), intent(inout) :: t_prol + type(psb_cspmat_type), intent(out) :: op_prol, ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_aggregator_mat_bld' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + end subroutine amg_c_base_aggregator_mat_bld + + ! + !> Function mat_asb + !! \memberof amg_c_base_aggregator_type + !! \brief Build prolongator/restrictor/coarse matrix. + !! + !! + !! \param ag The input aggregator object + !! \param parms The auxiliary parameters object + !! \param a The local matrix part + !! \param desc_a The descriptor + !! \param ilaggr Aggregation map + !! \param nlaggr Sizes of ilaggr on all processes + !! \param ac On output the coarse matrix + !! \param op_prol On input, the tentative prolongator operator, on output + !! the final prolongator + !! \param op_restr On output, the restrictor operator; + !! in many cases it is the transpose of the prolongator. + !! \param info Return code + !! + subroutine amg_c_base_aggregator_mat_asb(ag,parms,a,desc_a,& + & ac,desc_ac, op_prol,op_restr,info) + use psb_base_mod + implicit none + class(amg_c_base_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + type(psb_cspmat_type), intent(inout) :: op_prol,ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_aggregator_mat_asb' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + end subroutine amg_c_base_aggregator_mat_asb + + ! + !> Function bld_map + !! \memberof amg_c_base_aggregator_type + !! \brief Build linear map between hierarchy levels + !! + !! + !! \param ag The input aggregator object + !! \param desc_a The fine space descriptor + !! \param desc_ac The coarse space descriptor + !! \param ilaggr Aggregation map vector + !! \param nlaggr Sizes of ilaggr on all processes + !! \param op_prol The prolongator operator + !! \param op_restr The restrictor operator + !! \param map The output map + !! \param info Return code + !! + subroutine amg_c_base_aggregator_bld_map(ag,desc_a,desc_ac,ilaggr,nlaggr,& + & op_restr,op_prol,map,info) + use psb_base_mod + implicit none + class(amg_c_base_aggregator_type), target, intent(inout) :: ag + type(psb_desc_type), intent(in), target :: desc_a, desc_ac + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(psb_cspmat_type), intent(inout) :: op_restr, op_prol + type(psb_clinmap_type), intent(out) :: map + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_aggregator_bld_map' + + call psb_erractionsave(err_act) + ! + ! Copy the prolongation/restriction matrices into the descriptor map. + ! op_restr => PR^T i.e. restriction operator + ! op_prol => PR i.e. prolongation operator + ! + ! WARNING: need to check whether the copy into IOP_RESTR/IOP_PROL + ! is safe or not. + ! + ! This default implementation reuses desc_a/desc_ac through + ! pointers in the map structure. + ! + map = psb_linmap(psb_map_aggr_,desc_a,& + & desc_ac,op_restr,op_prol,ilaggr,nlaggr) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + end subroutine amg_c_base_aggregator_bld_map + + +end module amg_c_base_aggregator_mod diff --git a/mlprec/amg_c_base_smoother_mod.f90 b/mlprec/amg_c_base_smoother_mod.f90 new file mode 100644 index 00000000..2832ee55 --- /dev/null +++ b/mlprec/amg_c_base_smoother_mod.f90 @@ -0,0 +1,412 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_c_base_smoother_mod.f90 +! +! Module: amg_c_base_smoother_mod +! +! This module defines: +! - the amg_c_base_smoother_type data structure containing the +! smoother and related data structures; +! +! It contains routines for +! - Building and applying; +! - checking if the smoother is correctly defined; +! - printing a description of the preconditioner; +! - deallocating the preconditioner data structure. +! +! What is the difference between a smoother and a solver? +! In the mathematics literature the two concepts are treated +! essentially as synonymous, but here we are using them in a more +! computer-science oriented fashion. In particular, a SMOOTHER object +! contains a SOLVER object: the SOLVER operates locally within the +! current process, whereas the SMOOTHER object accounts for (possible) +! interactions between processes. +! Some solvers (MUMPS and SuperLU_DIST) can also operate on the entire +! distributed matrix, in which case the smoother object essentially +! becomes transparent. +! +module amg_c_base_smoother_mod + + use amg_c_base_solver_mod + use psb_base_mod, only : psb_desc_type, psb_cspmat_type, psb_epk_,& + & psb_c_vect_type, psb_c_base_vect_type, psb_c_base_sparse_mat, & + & psb_spk_, psb_i_base_vect_type, psb_erractionsave, psb_error_handler + + ! + ! + ! + ! Type: amg_T_base_smoother_type. + ! + ! It holds the smoother a single level. Its only mandatory component is a solver + ! object which holds a local solver; this decoupling allows to have the same solver + ! e.g ILU to work with Jacobi with multiple sweeps as well as with any AS variant. + ! + ! type amg_T_base_smoother_type + ! class(amg_T_base_solver_type), allocatable :: sv + ! end type amg_T_base_smoother_type + ! + ! Methods: + ! + ! build - Compute the actual contents of the smoother; includes + ! invocation of the build method on the solver component. + ! free - Release memory + ! apply - Apply the smoother to a vector (or to an array); includes + ! invocation of the apply method on the solver component. + ! descr - Prints a description of the object. + ! default - Set default values + ! dump - Dump to file object contents + ! set - Sets various parameters; when a request is unknown + ! it is passed to the solver object for further processing. + ! check - Sanity checks. + ! sizeof - Total memory occupation in bytes + ! get_nzeros - Number of nonzeros + ! stringval - convert string to val for internal parms + ! get_fmt - short string descriptor + ! get_id - numeric id descriptro + ! get_wrksz - How many workspace vector does apply_vect need + ! + ! + ! + + type amg_c_base_smoother_type + class(amg_c_base_solver_type), allocatable :: sv + contains + procedure, pass(sm) :: apply_v => amg_c_base_smoother_apply_vect + procedure, pass(sm) :: apply_a => amg_c_base_smoother_apply + generic, public :: apply => apply_a, apply_v + procedure, pass(sm) :: check => amg_c_base_smoother_check + procedure, pass(sm) :: dump => amg_c_base_smoother_dmp + procedure, pass(sm) :: clone => amg_c_base_smoother_clone + procedure, pass(sm) :: build => amg_c_base_smoother_bld + procedure, pass(sm) :: cnv => amg_c_base_smoother_cnv + procedure, pass(sm) :: free => amg_c_base_smoother_free + procedure, pass(sm) :: clone_settings => amg_c_base_smoother_clone_settings + procedure, pass(sm) :: clear_data => amg_c_base_smoother_clear_data + procedure, pass(sm) :: cseti => amg_c_base_smoother_cseti + procedure, pass(sm) :: csetc => amg_c_base_smoother_csetc + procedure, pass(sm) :: csetr => amg_c_base_smoother_csetr + generic, public :: set => cseti, csetc, csetr + procedure, pass(sm) :: default => c_base_smoother_default + procedure, pass(sm) :: descr => amg_c_base_smoother_descr + procedure, pass(sm) :: sizeof => c_base_smoother_sizeof + procedure, pass(sm) :: get_nzeros => c_base_smoother_get_nzeros + procedure, pass(sm) :: get_wrksz => c_base_smoother_get_wrksize + procedure, nopass :: stringval => amg_stringval + procedure, nopass :: get_fmt => c_base_smoother_get_fmt + procedure, nopass :: get_id => c_base_smoother_get_id + end type amg_c_base_smoother_type + + + private :: c_base_smoother_sizeof, c_base_smoother_get_fmt, & + & c_base_smoother_default, c_base_smoother_get_nzeros, & + & c_base_smoother_get_id, c_base_smoother_get_wrksize + + + + interface + subroutine amg_c_base_smoother_apply(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,info,init,initu) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_base_smoother_type), intent(inout) :: sm + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_c_base_smoother_apply + end interface + + interface + subroutine amg_c_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,wv,info,init,initu) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_base_smoother_type), intent(inout) :: sm + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + end subroutine amg_c_base_smoother_apply_vect + end interface + + interface + subroutine amg_c_base_smoother_check(sm,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_base_smoother_check + end interface + + interface + subroutine amg_c_base_smoother_cseti(sm,what,val,info,idx) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_c_base_smoother_cseti + end interface + + interface + subroutine amg_c_base_smoother_csetc(sm,what,val,info,idx) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_ + class(amg_c_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_c_base_smoother_csetc + end interface + + interface + subroutine amg_c_base_smoother_csetr(sm,what,val,info,idx) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_c_base_smoother_csetr + end interface + + interface + subroutine amg_c_base_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_, psb_i_base_vect_type + ! Arguments + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_base_smoother_bld + end interface + + interface + subroutine amg_c_base_smoother_cnv(sm,info,amold,vmold,imold) + import :: psb_c_base_sparse_mat, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_, psb_i_base_vect_type + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_base_smoother_cnv + end interface + + interface + subroutine amg_c_base_smoother_free(sm,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_base_smoother_free + end interface + + interface + subroutine amg_c_base_smoother_descr(sm,info,iout,coarse) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_c_base_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + end subroutine amg_c_base_smoother_descr + end interface + + interface + subroutine amg_c_base_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_ + class(amg_c_base_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + end subroutine amg_c_base_smoother_dmp + end interface + + interface + subroutine amg_c_base_smoother_clone(sm,smout,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + class(amg_c_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_base_smoother_clone + end interface + + interface + subroutine amg_c_base_smoother_clone_settings(sm,smout,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + class(amg_c_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_base_smoother_clone_settings + end interface + + interface + subroutine amg_c_base_smoother_clear_data(sm,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_base_smoother_clear_data + end interface + +contains + ! + ! Function returning the size of the amg_prec_type data structure + ! in bytes or in number of nonzeros of the operator(s) involved. + ! + + function c_base_smoother_get_nzeros(sm) result(val) + implicit none + class(amg_c_base_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + if (allocated(sm%sv)) & + & val = sm%sv%get_nzeros() + end function c_base_smoother_get_nzeros + + function c_base_smoother_sizeof(sm) result(val) + implicit none + ! Arguments + class(amg_c_base_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + if (allocated(sm%sv)) then + val = sm%sv%sizeof() + end if + + return + end function c_base_smoother_sizeof + + ! + ! Set sensible defaults. + ! To be called immediately after allocation + ! + subroutine c_base_smoother_default(sm) + implicit none + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + ! Do nothing for base version + + if (allocated(sm%sv)) call sm%sv%default() + + return + end subroutine c_base_smoother_default + + function c_base_smoother_get_wrksize(sm) result(val) + implicit none + class(amg_c_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_) :: val + + val = 0 + if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() + + end function c_base_smoother_get_wrksize + + function c_base_smoother_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Base smoother" + end function c_base_smoother_get_fmt + + function c_base_smoother_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_base_smooth_ + end function c_base_smoother_get_id + +end module amg_c_base_smoother_mod diff --git a/mlprec/amg_c_base_solver_mod.f90 b/mlprec/amg_c_base_solver_mod.f90 new file mode 100644 index 00000000..e3aab809 --- /dev/null +++ b/mlprec/amg_c_base_solver_mod.f90 @@ -0,0 +1,421 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_c_base_solver_mod.f90 +! +! Module: amg_c_base_solver_mod +! +! This module defines: +! - the amg_c_base_solver_type data structure containing the +! basic solver type acting on a subdomain +! +! It contains routines for +! - Building and applying; +! - checking if the solver is correctly defined; +! - printing a description of the solver; +! - deallocating the data structure. +! + +module amg_c_base_solver_mod + + use amg_base_prec_type + use psb_base_mod, only : psb_cspmat_type, & + & psb_c_vect_type, psb_c_base_vect_type, psb_c_base_sparse_mat, & + & psb_spk_, psb_i_base_vect_type, psb_erractionsave, psb_error_handler + ! + ! + ! Type: amg_T_base_solver_type. + ! + ! It holds the local solver; it has no mandatory components. + ! + ! type amg_T_base_solver_type + ! end type amg_T_base_solver_type + ! + ! build - Compute the actual contents of the smoother; includes + ! invocation of the build method on the solver component. + ! free - Release memory + ! apply - Apply the smoother to a vector (or to an array); includes + ! invocation of the apply method on the solver component. + ! descr - Prints a description of the object. + ! default - Set default values + ! dump - Dump to file object contents + ! set - Sets various parameters; when a request is unknown + ! it is passed to the smoother object for further processing. + ! check - Sanity checks. + ! sizeof - Total memory occupation in bytes + ! get_nzeros - Number of nonzeros + ! stringval - convert string to val for internal parms + ! get_fmt - short string descriptor + ! get_id - numeric id descriptro + ! get_wrksz - How many workspace vector does apply_vect need + ! + ! + + type amg_c_base_solver_type + contains + procedure, pass(sv) :: apply_v => amg_c_base_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_c_base_solver_apply + generic, public :: apply => apply_a, apply_v + procedure, pass(sv) :: check => amg_c_base_solver_check + procedure, pass(sv) :: dump => amg_c_base_solver_dmp + procedure, pass(sv) :: clone => amg_c_base_solver_clone + procedure, pass(sv) :: clone_settings => amg_c_base_solver_clone_settings + procedure, pass(sv) :: clear_data => amg_c_base_solver_clear_data + procedure, pass(sv) :: build => amg_c_base_solver_bld + procedure, pass(sv) :: cnv => amg_c_base_solver_cnv + procedure, pass(sv) :: free => amg_c_base_solver_free + procedure, pass(sv) :: cseti => amg_c_base_solver_cseti + procedure, pass(sv) :: csetc => amg_c_base_solver_csetc + procedure, pass(sv) :: csetr => amg_c_base_solver_csetr + generic, public :: set => cseti, csetc, csetr + procedure, pass(sv) :: default => c_base_solver_default + procedure, pass(sv) :: descr => amg_c_base_solver_descr + procedure, pass(sv) :: sizeof => c_base_solver_sizeof + procedure, pass(sv) :: get_nzeros => c_base_solver_get_nzeros + procedure, nopass :: get_wrksz => c_base_solver_get_wrksize + procedure, nopass :: stringval => amg_stringval + procedure, nopass :: get_fmt => c_base_solver_get_fmt + procedure, nopass :: get_id => c_base_solver_get_id + procedure, nopass :: is_iterative => c_base_solver_is_iterative + procedure, pass(sv) :: is_global => c_base_solver_is_global + end type amg_c_base_solver_type + + private :: c_base_solver_sizeof, c_base_solver_default,& + & c_base_solver_get_nzeros, c_base_solver_get_fmt, & + & c_base_solver_is_iterative, c_base_solver_get_id, & + & c_base_solver_get_wrksize, c_base_solver_is_global + + + interface + subroutine amg_c_base_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_base_solver_type), intent(inout) :: sv + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_c_base_solver_apply + end interface + + + interface + subroutine amg_c_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_base_solver_type), intent(inout) :: sv + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + end subroutine amg_c_base_solver_apply_vect + end interface + + interface + subroutine amg_c_base_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, psb_ipk_, psb_i_base_vect_type + Implicit None + + ! Arguments + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type), intent(in), target, optional :: b + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_base_solver_bld + end interface + + interface + subroutine amg_c_base_solver_cnv(sv,info,amold,vmold,imold) + import :: psb_c_base_sparse_mat, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, psb_ipk_, psb_i_base_vect_type + Implicit None + + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_base_solver_cnv + end interface + + interface + subroutine amg_c_base_solver_check(sv,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_base_solver_check + end interface + + interface + subroutine amg_c_base_solver_cseti(sv,what,val,info,idx) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_c_base_solver_cseti + end interface + + interface + subroutine amg_c_base_solver_csetc(sv,what,val,info,idx) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_c_base_solver_csetc + end interface + + interface + subroutine amg_c_base_solver_csetr(sv,what,val,info,idx) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, psb_ipk_ + Implicit None + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_c_base_solver_csetr + end interface + + interface + subroutine amg_c_base_solver_free(sv,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_base_solver_free + end interface + + interface + subroutine amg_c_base_solver_descr(sv,info,iout,coarse) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_base_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + end subroutine amg_c_base_solver_descr + end interface + + interface + subroutine amg_c_base_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, psb_ipk_ + implicit none + class(amg_c_base_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_c_base_solver_dmp + end interface + + interface + subroutine amg_c_base_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_base_solver_clone + end interface + + interface + subroutine amg_c_base_solver_clone_settings(sv,svout,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_base_solver_clone_settings + end interface + + interface + subroutine amg_c_base_solver_clear_data(sv,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_base_solver_clear_data + end interface + +contains + ! + ! Function returning the size of the data structure + ! in bytes or in number of nonzeros of the operator(s) involved. + ! + + function c_base_solver_sizeof(sv) result(val) + implicit none + ! Arguments + class(amg_c_base_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + + return + end function c_base_solver_sizeof + + function c_base_solver_get_nzeros(sv) result(val) + implicit none + class(amg_c_base_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + end function c_base_solver_get_nzeros + + subroutine c_base_solver_default(sv) + implicit none + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + ! Do nothing for base version + + return + end subroutine c_base_solver_default + + function c_base_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Base solver" + end function c_base_solver_get_fmt + + ! + ! If this is true, then the solver needs a starting + ! guess. Currently only handled in JAC smoother. + ! + function c_base_solver_is_iterative() result(val) + implicit none + logical :: val + + val = .false. + end function c_base_solver_is_iterative + ! + ! Is the solver acting globally? In most cases + ! not, SuperLU_Dist does, MUMPS can do either. + ! + function c_base_solver_is_global(sv) result(val) + implicit none + class(amg_c_base_solver_type), intent(in) :: sv + logical :: val + + val = .false. + end function c_base_solver_is_global + + function c_base_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_f_none_ + end function c_base_solver_get_id + + function c_base_solver_get_wrksize() result(val) + implicit none + integer(psb_ipk_) :: val + + val = 0 + end function c_base_solver_get_wrksize + +end module amg_c_base_solver_mod diff --git a/mlprec/amg_c_dec_aggregator_mod.f90 b/mlprec/amg_c_dec_aggregator_mod.f90 new file mode 100644 index 00000000..f1b36bc6 --- /dev/null +++ b/mlprec/amg_c_dec_aggregator_mod.f90 @@ -0,0 +1,201 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! Basic (decoupled) aggregation algorithm. Based on the ideas in +! M. Brezina and P. Vanek, A black-box iterative solver based on a +! two-level Schwarz method, Computing, 63 (1999), 233-263. +! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed +! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 +! (1996), 179-196. +! +module amg_c_dec_aggregator_mod + + use amg_c_base_aggregator_mod + !> \namespace amg_c_dec_aggregator_mod \class amg_c_dec_aggregator_type + !! \extends amg_c_base_aggregator_mod::amg_c_base_aggregator_type + !! + !! type, extends(amg_c_base_aggregator_type) :: amg_c_dec_aggregator_type + !! procedure(amg_c_soc_map_bld), nopass, pointer :: soc_map_bld => null() + !! end type + !! + !! This is the simplest aggregation method: starting from the + !! strength-of-connection measure for defining the aggregation + !! presented in + !! + !! M. Brezina and P. Vanek, A black-box iterative solver based on a + !! two-level Schwarz method, Computing, 63 (1999), 233-263. + !! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed + !! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 + !! (1996), 179-196. + !! + !! it achieves parallelization by simply acting on the local matrix, + !! i.e. by "decoupling" the subdomains. + !! The data structure hosts a "map_bld" function pointer which allows to + !! choose other ways to measure "strength-of-connection", of which the + !! Vanek-Brezina-Mandel is the default. More details are available in + !! + !! P. D'Ambra, D. di Serafino and S. Filippone, On the development of + !! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math. + !! 57 (2007), 1181-1196. + !! + !! The soc_map_bld method is used inside the implementation of build_tprol + !! + ! + ! + type, extends(amg_c_base_aggregator_type) :: amg_c_dec_aggregator_type + procedure(amg_c_soc_map_bld), nopass, pointer :: soc_map_bld => null() + + contains + procedure, pass(ag) :: bld_tprol => amg_c_dec_aggregator_build_tprol + procedure, pass(ag) :: mat_bld => amg_c_dec_aggregator_mat_bld + procedure, pass(ag) :: mat_asb => amg_c_dec_aggregator_mat_asb + procedure, pass(ag) :: default => amg_c_dec_aggregator_default + procedure, pass(ag) :: set_aggr_type => amg_c_dec_aggregator_set_aggr_type + procedure, pass(ag) :: descr => amg_c_dec_aggregator_descr + procedure, nopass :: fmt => amg_c_dec_aggregator_fmt + end type amg_c_dec_aggregator_type + + + procedure(amg_c_soc_map_bld) :: amg_c_soc1_map_bld, amg_c_soc2_map_bld + + interface + subroutine amg_c_dec_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,t_prol,info) + import :: amg_c_dec_aggregator_type, psb_desc_type, psb_cspmat_type, psb_spk_, & + & psb_ipk_, psb_lpk_, psb_lcspmat_type, amg_sml_parms, amg_saggr_data + implicit none + class(amg_c_dec_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(amg_saggr_data), intent(in) :: ag_data + type(psb_cspmat_type), intent(inout) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lcspmat_type), intent(out) :: t_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_dec_aggregator_build_tprol + end interface + + interface + subroutine amg_c_dec_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + import :: amg_c_dec_aggregator_type, psb_desc_type, psb_cspmat_type, psb_spk_, & + & psb_ipk_, psb_lpk_, psb_lcspmat_type, amg_sml_parms + implicit none + class(amg_c_dec_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(psb_lcspmat_type), intent(inout) :: t_prol + type(psb_cspmat_type), intent(out) :: op_prol, ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_dec_aggregator_mat_bld + end interface + + interface + subroutine amg_c_dec_aggregator_mat_asb(ag,parms,a,desc_a,& + & ac,desc_ac,op_prol,op_restr,info) + import :: amg_c_dec_aggregator_type, psb_desc_type, psb_cspmat_type, psb_spk_, & + & psb_ipk_, psb_lpk_, psb_lcspmat_type, amg_sml_parms + implicit none + class(amg_c_dec_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + type(psb_cspmat_type), intent(inout) :: op_prol,ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_dec_aggregator_mat_asb + end interface + +contains + + subroutine amg_c_dec_aggregator_set_aggr_type(ag,parms,info) + use amg_base_prec_type + implicit none + class(amg_c_dec_aggregator_type), intent(inout) :: ag + type(amg_sml_parms), intent(in) :: parms + integer(psb_ipk_), intent(out) :: info + + select case(parms%aggr_type) + case (amg_noalg_) + ag%soc_map_bld => null() + case (amg_soc1_) + ag%soc_map_bld => amg_c_soc1_map_bld + case (amg_soc2_) + ag%soc_map_bld => amg_c_soc2_map_bld + case default + write(0,*) 'Unknown aggregation type, defaulting to SOC1' + ag%soc_map_bld => amg_c_soc1_map_bld + end select + + return + end subroutine amg_c_dec_aggregator_set_aggr_type + + + subroutine amg_c_dec_aggregator_default(ag) + implicit none + class(amg_c_dec_aggregator_type), intent(inout) :: ag + + call ag%amg_c_base_aggregator_type%default() + ag%soc_map_bld => amg_c_soc1_map_bld + + return + end subroutine amg_c_dec_aggregator_default + + function amg_c_dec_aggregator_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Decoupled aggregation" + end function amg_c_dec_aggregator_fmt + + subroutine amg_c_dec_aggregator_descr(ag,parms,iout,info) + implicit none + class(amg_c_dec_aggregator_type), intent(in) :: ag + type(amg_sml_parms), intent(in) :: parms + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + + write(iout,*) 'Decoupled Aggregator' + write(iout,*) 'Aggregator object type: ',ag%fmt() + call parms%mldescr(iout,info) + + return + end subroutine amg_c_dec_aggregator_descr + +end module amg_c_dec_aggregator_mod diff --git a/mlprec/amg_c_diag_solver.f90 b/mlprec/amg_c_diag_solver.f90 new file mode 100644 index 00000000..a5341728 --- /dev/null +++ b/mlprec/amg_c_diag_solver.f90 @@ -0,0 +1,398 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_c_diag_solver_mod.f90 +! +! Module: amg_c_diag_solver_mod +! +! This module defines: +! - the amg_c_diag_solver_type data structure containing the +! simple diagonal solver. This extracts the main diagonal of a matrix +! and precomputes its inverse. Combined with a Jacobi "smoother" generates +! what are commonly known as the classic Jacobi iterations +! +module amg_c_diag_solver + + use amg_c_base_solver_mod + + type, extends(amg_c_base_solver_type) :: amg_c_diag_solver_type + type(psb_c_vect_type), allocatable :: dv + complex(psb_spk_), allocatable :: d(:) + contains + procedure, pass(sv) :: dump => amg_c_diag_solver_dmp + procedure, pass(sv) :: build => amg_c_diag_solver_bld + procedure, pass(sv) :: cnv => amg_c_diag_solver_cnv + procedure, pass(sv) :: clone => amg_c_diag_solver_clone + procedure, pass(sv) :: clear_data => amg_c_diag_solver_clear_data + procedure, pass(sv) :: apply_v => amg_c_diag_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_c_diag_solver_apply + procedure, pass(sv) :: free => c_diag_solver_free + procedure, pass(sv) :: descr => c_diag_solver_descr + procedure, pass(sv) :: sizeof => c_diag_solver_sizeof + procedure, pass(sv) :: get_nzeros => c_diag_solver_get_nzeros + procedure, nopass :: get_fmt => c_diag_solver_get_fmt + procedure, nopass :: get_id => c_diag_solver_get_id + end type amg_c_diag_solver_type + + + private :: c_diag_solver_free, c_diag_solver_descr, & + & c_diag_solver_sizeof, c_diag_solver_get_nzeros, & + & c_diag_solver_get_fmt, c_diag_solver_get_id + + + interface + subroutine amg_c_diag_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_diag_solver_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_diag_solver_type), intent(inout) :: sv + type(psb_c_vect_type), intent(inout) :: x + type(psb_c_vect_type), intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + end subroutine amg_c_diag_solver_apply_vect + end interface + + interface + subroutine amg_c_diag_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_diag_solver_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_diag_solver_type), intent(inout) :: sv + complex(psb_spk_), intent(inout) :: x(:) + complex(psb_spk_), intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_c_diag_solver_apply + end interface + + interface + subroutine amg_c_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_diag_solver_type, psb_ipk_, psb_i_base_vect_type + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type), intent(in), target, optional :: b + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_diag_solver_bld + end interface + + interface + subroutine amg_c_diag_solver_cnv(sv,info,amold,vmold,imold) + import :: psb_c_base_sparse_mat, psb_c_base_vect_type, psb_spk_, & + & amg_c_diag_solver_type, psb_ipk_, psb_i_base_vect_type + class(amg_c_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_diag_solver_cnv + end interface + + interface + subroutine amg_c_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, amg_c_diag_solver_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, & + & psb_ipk_ + implicit none + class(amg_c_diag_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_c_diag_solver_dmp + end interface + + interface + subroutine amg_c_diag_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, amg_c_diag_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_diag_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_diag_solver_clone + end interface + + interface + subroutine amg_c_diag_solver_clear_data(sv,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_diag_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_diag_solver_clear_data + end interface + + +contains + + subroutine c_diag_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_c_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_diag_solver_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sv%dv)) call sv%dv%free(info) + + if (allocated(sv%d)) then + deallocate(sv%d,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine c_diag_solver_free + + subroutine c_diag_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_c_diag_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_c_diag_solver_descr' + integer(psb_ipk_) :: iout_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' Diagonal local solver ' + + return + + end subroutine c_diag_solver_descr + + function c_diag_solver_sizeof(sv) result(val) + implicit none + ! Arguments + class(amg_c_diag_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + if (allocated(sv%dv)) val = val + sv%dv%sizeof() + + return + end function c_diag_solver_sizeof + + function c_diag_solver_get_nzeros(sv) result(val) + implicit none + ! Arguments + class(amg_c_diag_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + if (allocated(sv%dv)) val = val + sv%dv%get_nrows() + + return + end function c_diag_solver_get_nzeros + + function c_diag_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Diag solver" + end function c_diag_solver_get_fmt + + function c_diag_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_diag_scale_ + end function c_diag_solver_get_id + +end module amg_c_diag_solver + +! +! Module: amg_c_l1_diag_solver_mod +! +! This module defines: +! - the amg_c_l1_diag_solver_type data structure containing the +! L1 diagonal solver. +! The solver is defined as a diagonal containing in each element the +! inverse of the sum of the absolute values of the matrix entries +! along the corresponding row. +! Combined with a Jacobi "smoother" generates +! what are commonly known as the L1-Jacobi iterations +! + +module amg_c_l1_diag_solver + + use amg_c_diag_solver + + type, extends(amg_c_diag_solver_type) :: amg_c_l1_diag_solver_type + contains + procedure, pass(sv) :: dump => amg_c_l1_diag_solver_dmp + procedure, pass(sv) :: build => amg_c_l1_diag_solver_bld + procedure, pass(sv) :: descr => c_l1_diag_solver_descr + procedure, nopass :: get_fmt => c_l1_diag_solver_get_fmt + procedure, nopass :: get_id => c_l1_diag_solver_get_id + end type amg_c_l1_diag_solver_type + + + private :: c_l1_diag_solver_descr, & + & c_l1_diag_solver_get_fmt, c_l1_diag_solver_get_id + + interface + subroutine amg_c_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_l1_diag_solver_type, psb_ipk_, psb_i_base_vect_type + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_l1_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type), intent(in), target, optional :: b + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_l1_diag_solver_bld + end interface + + interface + subroutine amg_c_l1_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, amg_c_l1_diag_solver_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, & + & psb_ipk_ + implicit none + class(amg_c_l1_diag_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_c_l1_diag_solver_dmp + end interface + +contains + + subroutine c_l1_diag_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_c_l1_diag_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_c_l1_diag_solver_descr' + integer(psb_ipk_) :: iout_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' L1 Diagonal solver ' + + return + + end subroutine c_l1_diag_solver_descr + + function c_l1_diag_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "L1 Diag solver" + end function c_l1_diag_solver_get_fmt + + function c_l1_diag_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_l1_diag_scale_ + end function c_l1_diag_solver_get_id + +end module amg_c_l1_diag_solver + diff --git a/mlprec/amg_c_gs_solver.f90 b/mlprec/amg_c_gs_solver.f90 new file mode 100644 index 00000000..92195fca --- /dev/null +++ b/mlprec/amg_c_gs_solver.f90 @@ -0,0 +1,588 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! File: amg_c_gs_solver_mod.f90 +! +! Module: amg_c_gs_solver_mod +! +! This module defines: +! - the amg_c_gs_solver_type data structure containing the ingredients +! for a local Gauss-Seidel iteration. We provide Forward GS (FWGS) and +! backward GS (BWGS). The iterations are local to a process (they operate +! on the block diagonal). Combined with a Jacobi smoother will generate a +! hybrid-Gauss-Seidel solver, i.e. Gauss-Seidel within each process, Jacobi +! among the processes. +! With two objects as pre- and post-smoothers it is possible to build a +! Forward-Backward smoother, suitable for symmetric iterations. +! +module amg_c_gs_solver + + use amg_c_base_solver_mod + + type, extends(amg_c_base_solver_type) :: amg_c_gs_solver_type + type(psb_cspmat_type) :: l, u + integer(psb_ipk_) :: sweeps + real(psb_spk_) :: eps + contains + procedure, pass(sv) :: dump => amg_c_gs_solver_dmp + procedure, pass(sv) :: check => c_gs_solver_check + procedure, pass(sv) :: clone => amg_c_gs_solver_clone + procedure, pass(sv) :: clone_settings => amg_c_gs_solver_clone_settings + procedure, pass(sv) :: clear_data => amg_c_gs_solver_clear_data + procedure, pass(sv) :: build => amg_c_gs_solver_bld + procedure, pass(sv) :: cnv => amg_c_gs_solver_cnv + procedure, pass(sv) :: apply_v => amg_c_gs_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_c_gs_solver_apply + procedure, pass(sv) :: free => c_gs_solver_free + procedure, pass(sv) :: cseti => c_gs_solver_cseti + procedure, pass(sv) :: csetc => c_gs_solver_csetc + procedure, pass(sv) :: csetr => c_gs_solver_csetr + procedure, pass(sv) :: descr => c_gs_solver_descr + procedure, pass(sv) :: default => c_gs_solver_default + procedure, pass(sv) :: sizeof => c_gs_solver_sizeof + procedure, pass(sv) :: get_nzeros => c_gs_solver_get_nzeros + procedure, nopass :: get_wrksz => c_gs_solver_get_wrksize + procedure, nopass :: get_fmt => c_gs_solver_get_fmt + procedure, nopass :: get_id => c_gs_solver_get_id + procedure, nopass :: is_iterative => c_gs_solver_is_iterative + end type amg_c_gs_solver_type + + type, extends(amg_c_gs_solver_type) :: amg_c_bwgs_solver_type + contains + procedure, pass(sv) :: build => amg_c_bwgs_solver_bld + procedure, pass(sv) :: apply_v => amg_c_bwgs_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_c_bwgs_solver_apply + procedure, nopass :: get_fmt => c_bwgs_solver_get_fmt + procedure, nopass :: get_id => c_bwgs_solver_get_id + procedure, pass(sv) :: descr => c_bwgs_solver_descr + end type amg_c_bwgs_solver_type + + + private :: c_gs_solver_bld, c_gs_solver_apply, & + & c_gs_solver_free, & + & c_gs_solver_descr, c_gs_solver_sizeof, & + & c_gs_solver_default, c_gs_solver_dmp, & + & c_gs_solver_apply_vect, c_gs_solver_get_nzeros, & + & c_gs_solver_get_fmt, c_gs_solver_check,& + & c_gs_solver_is_iterative, & + & c_bwgs_solver_get_fmt, c_bwgs_solver_descr, & + & c_gs_solver_get_id, c_bwgs_solver_get_id, c_gs_solver_get_wrksize + + interface + subroutine amg_c_gs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, amg_c_gs_solver_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_gs_solver_type), intent(inout) :: sv + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + end subroutine amg_c_gs_solver_apply_vect + subroutine amg_c_bwgs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, amg_c_bwgs_solver_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_bwgs_solver_type), intent(inout) :: sv + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + end subroutine amg_c_bwgs_solver_apply_vect + end interface + + interface + subroutine amg_c_gs_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info,init,initu) + import :: psb_desc_type, amg_c_gs_solver_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_gs_solver_type), intent(inout) :: sv + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_c_gs_solver_apply + subroutine amg_c_bwgs_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, amg_c_bwgs_solver_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_bwgs_solver_type), intent(inout) :: sv + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_c_bwgs_solver_apply + end interface + + interface + subroutine amg_c_gs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, amg_c_gs_solver_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type), intent(in), target, optional :: b + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_gs_solver_bld + subroutine amg_c_bwgs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, amg_c_bwgs_solver_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_bwgs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type), intent(in), target, optional :: b + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_bwgs_solver_bld + end interface + + interface + subroutine amg_c_gs_solver_cnv(sv,info,amold,vmold,imold) + import :: amg_c_gs_solver_type, psb_spk_, & + & psb_c_base_sparse_mat, psb_c_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + class(amg_c_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_gs_solver_cnv + end interface + + interface + subroutine amg_c_gs_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, amg_c_gs_solver_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, & + & psb_ipk_ + implicit none + class(amg_c_gs_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_c_gs_solver_dmp + end interface + + interface + subroutine amg_c_gs_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, amg_c_gs_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_gs_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_gs_solver_clone + end interface + + interface + subroutine amg_c_gs_solver_clone_settings(sv,svout,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, amg_c_gs_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_gs_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_gs_solver_clone_settings + end interface + + interface + subroutine amg_c_gs_solver_clear_data(sv,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_gs_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_gs_solver_clear_data + end interface + +contains + + subroutine c_gs_solver_default(sv) + + Implicit None + + ! Arguments + class(amg_c_gs_solver_type), intent(inout) :: sv + + sv%sweeps = ione + sv%eps = dzero + + return + end subroutine c_gs_solver_default + + subroutine c_gs_solver_check(sv,info) + + Implicit None + + ! Arguments + class(amg_c_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_gs_solver_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + call amg_check_def(sv%sweeps,& + & 'GS Sweeps',ione,is_int_positive) + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine c_gs_solver_check + + subroutine c_gs_solver_cseti(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_c_gs_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_gs_solver_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) + case('SOLVER_SWEEPS') + sv%sweeps = val + case default + call sv%amg_c_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine c_gs_solver_cseti + + subroutine c_gs_solver_csetc(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_c_gs_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='c_gs_solver_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + + + call sv%amg_c_base_solver_type%set(what,val,info,idx=idx) + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info, name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine c_gs_solver_csetc + + subroutine c_gs_solver_csetr(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_c_gs_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_gs_solver_csetr' + + call psb_erractionsave(err_act) + info = psb_success_ + + select case(psb_toupper(what)) + case('SOLVER_EPS') + sv%eps = val + case default + call sv%amg_c_base_solver_type%set(what,val,info,idx=idx) + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine c_gs_solver_csetr + + subroutine c_gs_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_c_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_gs_solver_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + call sv%l%free() + call sv%u%free() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine c_gs_solver_free + + subroutine c_gs_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_c_gs_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_c_gs_solver_descr' + integer(psb_ipk_) :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (sv%eps<=dzero) then + write(iout_,*) ' Forward Gauss-Seidel iterative solver with ',& + & sv%sweeps,' sweeps' + else + write(iout_,*) ' Forward Gauss-Seidel iterative solver with tolerance',& + & sv%eps,' and maxit', sv%sweeps + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine c_gs_solver_descr + + function c_gs_solver_get_nzeros(sv) result(val) + + implicit none + ! Arguments + class(amg_c_gs_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + val = val + sv%l%get_nzeros() + val = val + sv%u%get_nzeros() + + return + end function c_gs_solver_get_nzeros + + function c_gs_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_c_gs_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = psb_sizeof_ip + val = val + sv%l%sizeof() + val = val + sv%u%sizeof() + + return + end function c_gs_solver_sizeof + + function c_gs_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Forward Gauss-Seidel solver" + end function c_gs_solver_get_fmt + + function c_gs_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_gs_ + end function c_gs_solver_get_id + + ! + ! If this is true, then the solver needs a starting + ! guess. Currently only handled in JAC smoother. + ! + function c_gs_solver_is_iterative() result(val) + implicit none + logical :: val + + val = .true. + end function c_gs_solver_is_iterative + + subroutine c_bwgs_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_c_bwgs_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_c_bwgs_solver_descr' + integer(psb_ipk_) :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (sv%eps<=dzero) then + write(iout_,*) ' Backward Gauss-Seidel iterative solver with ',& + & sv%sweeps,' sweeps' + else + write(iout_,*) ' Backward Gauss-Seidel iterative solver with tolerance',& + & sv%eps,' and maxit', sv%sweeps + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine c_bwgs_solver_descr + + function c_bwgs_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Backward Gauss-Seidel solver" + end function c_bwgs_solver_get_fmt + + function c_bwgs_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_bwgs_ + end function c_bwgs_solver_get_id + + function c_gs_solver_get_wrksize() result(val) + implicit none + integer(psb_ipk_) :: val + + val = 2 + end function c_gs_solver_get_wrksize + +end module amg_c_gs_solver diff --git a/mlprec/amg_c_hybrid_aggregator_mod.F90 b/mlprec/amg_c_hybrid_aggregator_mod.F90 new file mode 100644 index 00000000..d83447f0 --- /dev/null +++ b/mlprec/amg_c_hybrid_aggregator_mod.F90 @@ -0,0 +1,125 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! The aggregator object hosts the aggregation method for building +! the multilevel hierarchy. This variant is based on the hybrid method +! presented in +! +! S. Gratton, P. Henon, P. Jiranek and X. Vasseur: +! Reducing complexity of algebraic multigrid by aggregation +! Numerical Lin. Algebra with Applications, 2016, 23:501-518 +! +module amg_c_hybrid_aggregator_mod + + use amg_c_dec_aggregator_mod + ! + ! sm - class(amg_T_base_smoother_type), allocatable + ! The current level preconditioner (aka smoother). + ! parms - type(amg_RTml_parms) + ! The parameters defining the multilevel strategy. + ! ac - The local part of the current-level matrix, built by + ! coarsening the previous-level matrix. + ! desc_ac - type(psb_desc_type). + ! The communication descriptor associated to the matrix + ! stored in ac. + ! base_a - type(psb_Tspmat_type), pointer. + ! Pointer (really a pointer!) to the local part of the current + ! matrix (so we have a unified treatment of residuals). + ! We need this to avoid passing explicitly the current matrix + ! to the routine which applies the preconditioner. + ! base_desc - type(psb_desc_type), pointer. + ! Pointer to the communication descriptor associated to the + ! matrix pointed by base_a. + ! map - Stores the maps (restriction and prolongation) between the + ! vector spaces associated to the index spaces of the previous + ! and current levels. + ! + ! Methods: + ! Most methods follow the encapsulation hierarchy: they take whatever action + ! is appropriate for the current object, then call the corresponding method for + ! the contained object. + ! As an example: the descr() method prints out a description of the + ! level. It starts by invoking the descr() method of the parms object, + ! then calls the descr() method of the smoother object. + ! + ! descr - Prints a description of the object. + ! default - Set default values + ! dump - Dump to file object contents + ! set - Sets various parameters; when a request is unknown + ! it is passed to the smoother object for further processing. + ! check - Sanity checks. + ! sizeof - Total memory occupation in bytes + ! get_nzeros - Number of nonzeros + ! + ! + type, extends(amg_c_dec_aggregator_type) :: amg_c_hybrid_aggregator_type + + contains + procedure, pass(ag) :: bld_tprol => amg_c_hybrid_aggregator_build_tprol + procedure, nopass :: fmt => amg_c_hybrid_aggregator_fmt + end type amg_c_hybrid_aggregator_type + + + interface + subroutine amg_c_hybrid_aggregator_build_tprol(ag,parms,a,desc_a,ilaggr,nlaggr,op_prol,info) + import :: amg_c_hybrid_aggregator_type, psb_desc_type, psb_cspmat_type, psb_spk_, & + & psb_ipk_, psb_long_int_k_, amg_sml_parms + implicit none + class(amg_c_hybrid_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + integer(psb_ipk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_cspmat_type), intent(out) :: op_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_hybrid_aggregator_build_tprol + end interface + +contains + + + function amg_c_hybrid_aggregator_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Hybrid Decoupled aggregation" + end function amg_c_hybrid_aggregator_fmt + + +end module amg_c_hybrid_aggregator_mod diff --git a/mlprec/amg_c_id_solver.f90 b/mlprec/amg_c_id_solver.f90 new file mode 100644 index 00000000..c058101b --- /dev/null +++ b/mlprec/amg_c_id_solver.f90 @@ -0,0 +1,202 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! +! Identity solver. Reference for nullprec. +! +! +module amg_c_id_solver + + use amg_c_base_solver_mod + + type, extends(amg_c_base_solver_type) :: amg_c_id_solver_type + contains + procedure, pass(sv) :: build => c_id_solver_bld + procedure, pass(sv) :: clone => amg_c_id_solver_clone + procedure, pass(sv) :: apply_v => amg_c_id_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_c_id_solver_apply + procedure, pass(sv) :: free => c_id_solver_free + procedure, pass(sv) :: descr => c_id_solver_descr + procedure, nopass :: get_fmt => c_id_solver_get_fmt + procedure, nopass :: get_id => c_id_solver_get_id + end type amg_c_id_solver_type + + + private :: c_id_solver_bld, & + & c_id_solver_free, c_id_solver_get_fmt, & + & c_id_solver_descr, c_id_solver_get_id + + interface + subroutine amg_c_id_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_id_solver_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_id_solver_type), intent(inout) :: sv + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + end subroutine amg_c_id_solver_apply_vect + end interface + + interface + subroutine amg_c_id_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_id_solver_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_id_solver_type), intent(inout) :: sv + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_c_id_solver_apply + end interface + + interface + subroutine amg_c_id_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, amg_c_id_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_id_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_id_solver_clone + end interface + +contains + + + subroutine c_id_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + Implicit None + + ! Arguments + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_id_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type), intent(in), target, optional :: b + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: i, err_act, debug_unit, debug_level + character(len=20) :: name='c_id_solver_bld', ch_err + + info=psb_success_ + + return + end subroutine c_id_solver_bld + + subroutine c_id_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_c_id_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_id_solver_free' + + info = psb_success_ + + return + end subroutine c_id_solver_free + + subroutine c_id_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_c_id_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_c_id_solver_descr' + integer(psb_ipk_) :: iout_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' Identity local solver ' + + return + + end subroutine c_id_solver_descr + + function c_id_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Identity solver" + end function c_id_solver_get_fmt + + function c_id_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_f_none_ + end function c_id_solver_get_id + +end module amg_c_id_solver diff --git a/mlprec/amg_c_ilu_fact_mod.f90 b/mlprec/amg_c_ilu_fact_mod.f90 new file mode 100644 index 00000000..6657bd28 --- /dev/null +++ b/mlprec/amg_c_ilu_fact_mod.f90 @@ -0,0 +1,91 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! File: amg_c_ilu_fact_mod.f90 +! +! Module: amg_c_ilu_fact_mod +! +! This module defines some interfaces used internally by the implementation of +! amg_c_ilu_solver, but not visible to the end user. +! +! +module amg_c_ilu_fact_mod + + use amg_c_base_solver_mod + + interface amg_ilu0_fact + subroutine amg_cilu0_fact(ialg,a,l,u,d,info,blck,upd) + import psb_cspmat_type, psb_spk_, psb_ipk_ + integer(psb_ipk_), intent(in) :: ialg + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type),intent(in) :: a + type(psb_cspmat_type),intent(inout) :: l,u + type(psb_cspmat_type),intent(in), optional, target :: blck + character, intent(in), optional :: upd + complex(psb_spk_), intent(inout) :: d(:) + end subroutine amg_cilu0_fact + end interface + + interface amg_iluk_fact + subroutine amg_ciluk_fact(fill_in,ialg,a,l,u,d,info,blck) + import psb_cspmat_type, psb_spk_, psb_ipk_ + integer(psb_ipk_), intent(in) :: fill_in,ialg + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type),intent(in) :: a + type(psb_cspmat_type),intent(inout) :: l,u + type(psb_cspmat_type),intent(in), optional, target :: blck + complex(psb_spk_), intent(inout) :: d(:) + end subroutine amg_ciluk_fact + end interface + + interface amg_ilut_fact + subroutine amg_cilut_fact(fill_in,thres,a,l,u,d,info,blck,iscale) + import psb_cspmat_type, psb_spk_, psb_ipk_ + integer(psb_ipk_), intent(in) :: fill_in + real(psb_spk_), intent(in) :: thres + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type),intent(in) :: a + type(psb_cspmat_type),intent(inout) :: l,u + complex(psb_spk_), intent(inout) :: d(:) + type(psb_cspmat_type),intent(in), optional, target :: blck + integer(psb_ipk_), intent(in), optional :: iscale + end subroutine amg_cilut_fact + end interface + +end module amg_c_ilu_fact_mod diff --git a/mlprec/amg_c_ilu_solver.f90 b/mlprec/amg_c_ilu_solver.f90 new file mode 100644 index 00000000..ca182860 --- /dev/null +++ b/mlprec/amg_c_ilu_solver.f90 @@ -0,0 +1,502 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! File: amg_c_ilu_solver_mod.f90 +! +! Module: amg_c_ilu_solver_mod +! +! This module defines: +! - the amg_c_ilu_solver_type data structure containing the ingredients +! for a local Incomplete LU factorization. +! 1. The factorization is always restricted to the diagonal block of the +! current image (coherently with the definition of a SOLVER as a local +! object) +! 2. The code provides support for both pattern-based ILU(K) and +! threshold base ILU(T,L) +! 3. The diagonal is stored separately, so strictly speaking this is +! an incomplete LDU factorization; +! 4. The application phase is shared among all variants; +! +! +module amg_c_ilu_solver + + use amg_base_prec_type, only : amg_fact_names + use amg_c_base_solver_mod + use psb_c_ilu_fact_mod + + type, extends(amg_c_base_solver_type) :: amg_c_ilu_solver_type + type(psb_cspmat_type) :: l, u + complex(psb_spk_), allocatable :: d(:) + type(psb_c_vect_type) :: dv + integer(psb_ipk_) :: fact_type, fill_in + real(psb_spk_) :: thresh + contains + procedure, pass(sv) :: dump => amg_c_ilu_solver_dmp + procedure, pass(sv) :: check => c_ilu_solver_check + procedure, pass(sv) :: clone => amg_c_ilu_solver_clone + procedure, pass(sv) :: clone_settings => amg_c_ilu_solver_clone_settings + procedure, pass(sv) :: clear_data => amg_c_ilu_solver_clear_data + procedure, pass(sv) :: build => amg_c_ilu_solver_bld + procedure, pass(sv) :: cnv => amg_c_ilu_solver_cnv + procedure, pass(sv) :: apply_v => amg_c_ilu_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_c_ilu_solver_apply + procedure, pass(sv) :: free => c_ilu_solver_free + procedure, pass(sv) :: cseti => c_ilu_solver_cseti + procedure, pass(sv) :: csetc => c_ilu_solver_csetc + procedure, pass(sv) :: csetr => c_ilu_solver_csetr + procedure, pass(sv) :: descr => c_ilu_solver_descr + procedure, pass(sv) :: default => c_ilu_solver_default + procedure, pass(sv) :: sizeof => c_ilu_solver_sizeof + procedure, pass(sv) :: get_nzeros => c_ilu_solver_get_nzeros + procedure, nopass :: get_wrksz => c_ilu_solver_get_wrksize + procedure, nopass :: get_fmt => c_ilu_solver_get_fmt + procedure, nopass :: get_id => c_ilu_solver_get_id + end type amg_c_ilu_solver_type + + + private :: c_ilu_solver_bld, c_ilu_solver_apply, & + & c_ilu_solver_free, & + & c_ilu_solver_descr, c_ilu_solver_sizeof, & + & c_ilu_solver_default, c_ilu_solver_dmp, & + & c_ilu_solver_apply_vect, c_ilu_solver_get_nzeros, & + & c_ilu_solver_get_fmt, c_ilu_solver_check, & + & c_ilu_solver_get_id, c_ilu_solver_get_wrksize + + + interface + subroutine amg_c_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, amg_c_ilu_solver_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_ilu_solver_type), intent(inout) :: sv + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + end subroutine amg_c_ilu_solver_apply_vect + end interface + + interface + subroutine amg_c_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, amg_c_ilu_solver_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_ilu_solver_type), intent(inout) :: sv + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_c_ilu_solver_apply + end interface + + interface + subroutine amg_c_ilu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, amg_c_ilu_solver_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type), intent(in), target, optional :: b + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_ilu_solver_bld + end interface + + interface + subroutine amg_c_ilu_solver_cnv(sv,info,amold,vmold,imold) + import :: amg_c_ilu_solver_type, psb_spk_, & + & psb_c_base_sparse_mat, psb_c_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + class(amg_c_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_ilu_solver_cnv + end interface + + interface + subroutine amg_c_ilu_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, amg_c_ilu_solver_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, & + & psb_ipk_ + implicit none + class(amg_c_ilu_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_c_ilu_solver_dmp + end interface + + interface + subroutine amg_c_ilu_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, amg_c_ilu_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_ilu_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_ilu_solver_clone + end interface + + interface + subroutine amg_c_ilu_solver_clone_settings(sv,svout,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_base_solver_type, amg_c_ilu_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_ilu_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_ilu_solver_clone_settings + end interface + + interface + subroutine amg_c_ilu_solver_clear_data(sv,info) + import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & + & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & + & amg_c_ilu_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_c_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_ilu_solver_clear_data + end interface + +contains + + subroutine c_ilu_solver_default(sv) + + Implicit None + + ! Arguments + class(amg_c_ilu_solver_type), intent(inout) :: sv + + sv%fact_type = psb_ilu_n_ + sv%fill_in = 0 + sv%thresh = szero + + return + end subroutine c_ilu_solver_default + + subroutine c_ilu_solver_check(sv,info) + + Implicit None + + ! Arguments + class(amg_c_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_ilu_solver_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + call amg_check_def(sv%fact_type,& + & 'Factorization',psb_ilu_n_,is_legal_ilu_fact) + + select case(sv%fact_type) + case(psb_ilu_n_,psb_milu_n_) + call amg_check_def(sv%fill_in,& + & 'Level',izero,is_int_non_negative) + case(psb_ilu_t_) + call amg_check_def(sv%thresh,& + & 'Eps',szero,is_legal_s_fact_thrs) + end select + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine c_ilu_solver_check + + subroutine c_ilu_solver_cseti(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_c_ilu_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_ilu_solver_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(trim((what)))) + case('SUB_SOLVE') + sv%fact_type = val + case('SUB_FILLIN') + sv%fill_in = val + case default + call sv%amg_c_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine c_ilu_solver_cseti + + subroutine c_ilu_solver_csetc(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_c_ilu_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='c_ilu_solver_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + ival = amg_stringval(val) + select case(psb_toupper(trim((what)))) + case('SUB_SOLVE') + sv%fact_type = ival + case default + call sv%amg_c_base_solver_type%set(what,val,info,idx=idx) + end select + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info, name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine c_ilu_solver_csetc + + subroutine c_ilu_solver_csetr(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_c_ilu_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_ilu_solver_csetr' + + call psb_erractionsave(err_act) + info = psb_success_ + + select case(psb_toupper(what)) + case('SUB_ILUTHRS') + sv%thresh = val + case default + call sv%amg_c_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine c_ilu_solver_csetr + + subroutine c_ilu_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_c_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_ilu_solver_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sv%d)) then + deallocate(sv%d,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + end if + call sv%l%free() + call sv%u%free() + call sv%dv%free(info) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine c_ilu_solver_free + + subroutine c_ilu_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_c_ilu_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_c_ilu_solver_descr' + integer(psb_ipk_) :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' Incomplete factorization solver: ',& + & amg_fact_names(sv%fact_type) + select case(sv%fact_type) + case(psb_ilu_n_,psb_milu_n_) + write(iout_,*) ' Fill level:',sv%fill_in + case(psb_ilu_t_) + write(iout_,*) ' Fill level:',sv%fill_in + write(iout_,*) ' Fill threshold :',sv%thresh + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine c_ilu_solver_descr + + function c_ilu_solver_get_nzeros(sv) result(val) + + implicit none + ! Arguments + class(amg_c_ilu_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + val = val + sv%dv%get_nrows() + val = val + sv%l%get_nzeros() + val = val + sv%u%get_nzeros() + + return + end function c_ilu_solver_get_nzeros + + function c_ilu_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_c_ilu_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 2*psb_sizeof_ip + (2*psb_sizeof_sp) + val = val + sv%dv%sizeof() + val = val + sv%l%sizeof() + val = val + sv%u%sizeof() + + return + end function c_ilu_solver_sizeof + + function c_ilu_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "ILU solver" + end function c_ilu_solver_get_fmt + + function c_ilu_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = psb_ilu_n_ + end function c_ilu_solver_get_id + + function c_ilu_solver_get_wrksize() result(val) + implicit none + integer(psb_ipk_) :: val + + val = 2 + end function c_ilu_solver_get_wrksize + +end module amg_c_ilu_solver diff --git a/mlprec/amg_c_inner_mod.f90 b/mlprec/amg_c_inner_mod.f90 new file mode 100644 index 00000000..a8c18c8e --- /dev/null +++ b/mlprec/amg_c_inner_mod.f90 @@ -0,0 +1,131 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_inner_mod.f90 +! +! Module: amg_inner_mod +! +! This module defines the interfaces to inner MLD2P4 routines. +! The interfaces of the user level routines are defined in amg_prec_mod.f90. +! +module amg_c_inner_mod + + use psb_base_mod, only : psb_cspmat_type, psb_desc_type, psb_i_base_vect_type, & + & psb_spk_, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_, & + & psb_c_vect_type, psb_lpk_, psb_lcspmat_type + use amg_c_prec_type, only : amg_cprec_type, amg_sml_parms, & + & amg_c_onelev_type, amg_cmlprec_wrk_type + + interface amg_mlprec_bld + subroutine amg_cmlprec_bld(a,desc_a,prec,info, amold, vmold,imold) + import :: psb_cspmat_type, psb_desc_type, psb_i_base_vect_type, & + & psb_spk_, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ + import :: amg_cprec_type + implicit none + type(psb_cspmat_type), intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + type(amg_cprec_type), intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_cmlprec_bld + end interface amg_mlprec_bld + + interface amg_mlprec_aply + subroutine amg_cmlprec_aply(alpha,p,x,beta,y,desc_data,trans,work,info) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, psb_ipk_ + import :: amg_cprec_type + implicit none + type(psb_desc_type),intent(in) :: desc_data + type(amg_cprec_type), intent(inout) :: p + complex(psb_spk_),intent(in) :: alpha,beta + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + character,intent(in) :: trans + complex(psb_spk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + end subroutine amg_cmlprec_aply + subroutine amg_cmlprec_aply_vect(alpha,p,x,beta,y,desc_data,trans,work,info) + import :: psb_cspmat_type, psb_desc_type, & + & psb_spk_, psb_c_vect_type, psb_ipk_ + import :: amg_cprec_type + implicit none + type(psb_desc_type),intent(in) :: desc_data + type(amg_cprec_type), intent(inout) :: p + complex(psb_spk_),intent(in) :: alpha,beta + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + character,intent(in) :: trans + complex(psb_spk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + end subroutine amg_cmlprec_aply_vect + end interface amg_mlprec_aply + + interface amg_map_to_tprol + subroutine amg_c_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, psb_ipk_, psb_lpk_, psb_lcspmat_type + import :: amg_c_onelev_type + implicit none + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), allocatable, intent(inout) :: ilaggr(:),nlaggr(:) + type(psb_lcspmat_type), intent(out) :: op_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_map_to_tprol + end interface amg_map_to_tprol + + abstract interface + subroutine amg_caggrmat_var_bld(a,desc_a,ilaggr,nlaggr,parms,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, psb_ipk_, psb_lpk_, psb_lcspmat_type + import :: amg_c_onelev_type, amg_sml_parms + implicit none + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(amg_sml_parms), intent(inout) :: parms + type(psb_cspmat_type), intent(inout) :: op_prol,ac,op_restr + type(psb_lcspmat_type), intent(inout) :: t_prol + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + end subroutine amg_caggrmat_var_bld + end interface + + procedure(amg_caggrmat_var_bld) :: amg_caggrmat_nosmth_bld, & + & amg_caggrmat_smth_bld, amg_caggrmat_minnrg_bld + +end module amg_c_inner_mod diff --git a/mlprec/amg_c_jac_smoother.f90 b/mlprec/amg_c_jac_smoother.f90 new file mode 100644 index 00000000..ad8cd3e2 --- /dev/null +++ b/mlprec/amg_c_jac_smoother.f90 @@ -0,0 +1,454 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_c_jac_smoother_mod.f90 +! +! Module: amg_c_jac_smoother_mod +! +! This module defines: +! the amg_c_jac_smoother_type data structure containing the +! smoother for a Jacobi/block Jacobi smoother. +! The smoother stores in ND the block off-diagonal matrix. +! One special case is treated separately, when the solver is DIAG or L1-DIAG +! then the ND is the entire off-diagonal part of the matrix (including the +! main diagonal block), so that it becomes possible to implement +! a pure Jacobi or L1-Jacobi global solver. +! +module amg_c_jac_smoother + + use amg_c_base_smoother_mod + + type, extends(amg_c_base_smoother_type) :: amg_c_jac_smoother_type + ! The local solver component is inherited from the + ! parent type. + ! class(amg_c_base_solver_type), allocatable :: sv + ! + type(psb_cspmat_type), pointer :: pa => null() + type(psb_cspmat_type) :: nd + integer(psb_lpk_) :: nd_nnz_tot + logical :: checkres + logical :: printres + integer(psb_ipk_) :: checkiter + integer(psb_ipk_) :: printiter + real(psb_dpk_) :: tol + contains + procedure, pass(sm) :: apply_v => amg_c_jac_smoother_apply_vect + procedure, pass(sm) :: apply_a => amg_c_jac_smoother_apply + procedure, pass(sm) :: dump => amg_c_jac_smoother_dmp + procedure, pass(sm) :: build => amg_c_jac_smoother_bld + procedure, pass(sm) :: cnv => amg_c_jac_smoother_cnv + procedure, pass(sm) :: clone => amg_c_jac_smoother_clone + procedure, pass(sm) :: clone_settings => amg_c_jac_smoother_clone_settings + procedure, pass(sm) :: clear_data => amg_c_jac_smoother_clear_data + procedure, pass(sm) :: free => c_jac_smoother_free + procedure, pass(sm) :: cseti => amg_c_jac_smoother_cseti + procedure, pass(sm) :: csetc => amg_c_jac_smoother_csetc + procedure, pass(sm) :: csetr => amg_c_jac_smoother_csetr + procedure, pass(sm) :: descr => amg_c_jac_smoother_descr + procedure, pass(sm) :: sizeof => c_jac_smoother_sizeof + procedure, pass(sm) :: default => c_jac_smoother_default + procedure, pass(sm) :: get_nzeros => c_jac_smoother_get_nzeros + procedure, pass(sm) :: get_wrksz => c_jac_smoother_get_wrksize + procedure, nopass :: get_fmt => c_jac_smoother_get_fmt + procedure, nopass :: get_id => c_jac_smoother_get_id + end type amg_c_jac_smoother_type + + type, extends(amg_c_jac_smoother_type) :: amg_c_l1_jac_smoother_type + contains + procedure, pass(sm) :: build => amg_c_l1_jac_smoother_bld + procedure, pass(sm) :: clone => amg_c_l1_jac_smoother_clone + procedure, pass(sm) :: descr => amg_c_l1_jac_smoother_descr + procedure, nopass :: get_fmt => c_l1_jac_smoother_get_fmt + procedure, nopass :: get_id => c_l1_jac_smoother_get_id + end type amg_c_l1_jac_smoother_type + + private :: c_jac_smoother_free, & + & c_jac_smoother_sizeof, c_jac_smoother_get_nzeros, & + & c_jac_smoother_get_fmt, c_jac_smoother_get_id, & + & c_jac_smoother_get_wrksize + private :: c_l1_jac_smoother_get_fmt, c_l1_jac_smoother_get_id + + + interface + subroutine amg_c_jac_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,wv,info,init,initu) + import :: psb_desc_type, amg_c_jac_smoother_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type,& + & psb_ipk_ + + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_jac_smoother_type), intent(inout) :: sm + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + end subroutine amg_c_jac_smoother_apply_vect + end interface + + interface + subroutine amg_c_jac_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,info,init,initu) + import :: psb_desc_type, amg_c_jac_smoother_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, & + & psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_jac_smoother_type), intent(inout) :: sm + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_c_jac_smoother_apply + end interface + + interface + subroutine amg_c_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + import :: psb_desc_type, amg_c_jac_smoother_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_jac_smoother_bld + end interface + + interface + subroutine amg_c_jac_smoother_cnv(sm,info,amold,vmold,imold) + import :: amg_c_jac_smoother_type, psb_spk_, & + & psb_c_base_sparse_mat, psb_c_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + class(amg_c_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_jac_smoother_cnv + end interface + + interface + subroutine amg_c_jac_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_spk_, amg_c_jac_smoother_type, psb_epk_, psb_desc_type, & + & psb_ipk_ + implicit none + class(amg_c_jac_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + end subroutine amg_c_jac_smoother_dmp + end interface + + interface + subroutine amg_c_jac_smoother_clone(sm,smout,info) + import :: amg_c_jac_smoother_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_ + class(amg_c_jac_smoother_type), intent(inout) :: sm + class(amg_c_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_jac_smoother_clone + end interface + + interface + subroutine amg_c_jac_smoother_clone_settings(sm,smout,info) + import :: amg_c_jac_smoother_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_ + class(amg_c_jac_smoother_type), intent(inout) :: sm + class(amg_c_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_jac_smoother_clone_settings + end interface + + interface + subroutine amg_c_jac_smoother_clear_data(sm,info) + import :: amg_c_jac_smoother_type, psb_spk_, & + & amg_c_base_smoother_type, psb_ipk_ + class(amg_c_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_jac_smoother_clear_data + end interface + + interface + subroutine amg_c_jac_smoother_descr(sm,info,iout,coarse) + import :: amg_c_jac_smoother_type, psb_ipk_ + class(amg_c_jac_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + end subroutine amg_c_jac_smoother_descr + end interface + + interface + subroutine amg_c_jac_smoother_cseti(sm,what,val,info,idx) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_spk_, amg_c_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_c_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_c_jac_smoother_cseti + end interface + + interface + subroutine amg_c_jac_smoother_csetc(sm,what,val,info,idx) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_spk_, amg_c_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_c_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_c_jac_smoother_csetc + end interface + + interface + subroutine amg_c_jac_smoother_csetr(sm,what,val,info,idx) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_spk_, amg_c_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_c_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_c_jac_smoother_csetr + end interface + + + interface + subroutine amg_c_l1_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + import :: psb_desc_type, amg_c_l1_jac_smoother_type, psb_c_vect_type, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_l1_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_l1_jac_smoother_bld + end interface + + interface + subroutine amg_c_l1_jac_smoother_clone(sm,smout,info) + import :: amg_c_l1_jac_smoother_type, & + & amg_c_base_smoother_type, psb_ipk_ + class(amg_c_l1_jac_smoother_type), intent(inout) :: sm + class(amg_c_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_l1_jac_smoother_clone + end interface + + interface + subroutine amg_c_l1_jac_smoother_clone_settings(sm,smout,info) + import :: amg_c_l1_jac_smoother_type, & + & amg_c_base_smoother_type, psb_ipk_ + class(amg_c_l1_jac_smoother_type), intent(inout) :: sm + class(amg_c_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_l1_jac_smoother_clone_settings + end interface + + interface + subroutine amg_c_l1_jac_smoother_clear_data(sm,info) + import :: amg_c_l1_jac_smoother_type, & + & amg_c_base_smoother_type, psb_ipk_ + class(amg_c_l1_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_l1_jac_smoother_clear_data + end interface + + interface + subroutine amg_c_l1_jac_smoother_descr(sm,info,iout,coarse) + import :: amg_c_l1_jac_smoother_type, psb_ipk_ + class(amg_c_l1_jac_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + end subroutine amg_c_l1_jac_smoother_descr + end interface + +contains + + + subroutine c_jac_smoother_free(sm,info) + + + Implicit None + + ! Arguments + class(amg_c_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_jac_smoother_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + + + if (allocated(sm%sv)) then + call sm%sv%free(info) + if (info == psb_success_) deallocate(sm%sv,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + end if + call sm%nd%free() + sm%pa => null() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine c_jac_smoother_free + + function c_jac_smoother_sizeof(sm) result(val) + + implicit none + ! Arguments + class(amg_c_jac_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = psb_sizeof_lp + if (allocated(sm%sv)) val = val + sm%sv%sizeof() + val = val + sm%nd%sizeof() + + return + end function c_jac_smoother_sizeof + + subroutine c_jac_smoother_default(sm) + + Implicit None + + ! Arguments + class(amg_c_jac_smoother_type), intent(inout) :: sm + + ! + ! Default: BJAC with no residual check + ! + sm%checkres = .false. + sm%printres = .false. + sm%checkiter = -1 + sm%printiter = -1 + sm%tol = 0 + + if (allocated(sm%sv)) then + call sm%sv%default() + end if + + return + end subroutine c_jac_smoother_default + + function c_jac_smoother_get_nzeros(sm) result(val) + + implicit none + ! Arguments + class(amg_c_jac_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + if (allocated(sm%sv)) val = val + sm%sv%get_nzeros() + val = val + sm%nd%get_nzeros() + + return + end function c_jac_smoother_get_nzeros + + function c_jac_smoother_get_wrksize(sm) result(val) + implicit none + class(amg_c_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_) :: val + + val = 2 + if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() + + end function c_jac_smoother_get_wrksize + + function c_jac_smoother_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Jacobi smoother" + end function c_jac_smoother_get_fmt + + function c_jac_smoother_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_jac_ + end function c_jac_smoother_get_id + + function c_l1_jac_smoother_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "L1-Jacobi smoother" + end function c_l1_jac_smoother_get_fmt + + function c_l1_jac_smoother_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_l1_jac_ + end function c_l1_jac_smoother_get_id + +end module amg_c_jac_smoother diff --git a/mlprec/amg_c_mumps_solver.F90 b/mlprec/amg_c_mumps_solver.F90 new file mode 100644 index 00000000..418a509b --- /dev/null +++ b/mlprec/amg_c_mumps_solver.F90 @@ -0,0 +1,590 @@ + +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +! File: amg_c_mumps_solver_mod.f90 +! +! Module: amg_c_mumps_solver_mod +! +! This module defines: +! - the amg_c_mumps_solver_type data structure containing the ingredients +! to interface with the MUMPS package. +! 1. The factorization can be either restricted to the diagonal block of the +! current image or distributed (and thus exact). +! +module amg_c_mumps_solver + use amg_c_base_solver_mod +#if defined(HAVE_MUMPS_) && defined(HAVE_MUMPS_MODULES_) + use cmumps_struc_def +#endif +#if defined(HAVE_MUMPS_) && defined(HAVE_MUMPS_INCLUDES_) + include 'cmumps_struc.h' +#endif + + + type :: amg_c_mumps_icntl_item + integer(psb_ipk_), allocatable :: item + end type amg_c_mumps_icntl_item + type :: amg_c_mumps_rcntl_item + real(psb_spk_), allocatable :: item + end type amg_c_mumps_rcntl_item + + type, extends(amg_c_base_solver_type) :: amg_c_mumps_solver_type +#if defined(HAVE_MUMPS_) + type(cmumps_struc), allocatable :: id +#else + integer, allocatable :: id +#endif + type(amg_c_mumps_icntl_item), allocatable :: icntl(:) + type(amg_c_mumps_rcntl_item), allocatable :: rcntl(:) + ! + ! Controls to be set before MUMPS instantiation: + ! + ! IPAR(1) : MUMPS_LOC_GLOB 0==amg_local_solver_: LOCAL 1==amg_global_solver_: GLOBAL + ! IPAR(2) : MUMPS_PRINT_ERR print verbosity (see MUMPS) + ! IPAR(3) : MUMPS_SYM 0: non-symmetric 2: symmetric + integer(psb_ipk_), dimension(3) :: ipar + integer(psb_ipk_), allocatable :: local_ictxt + logical :: built = .false. + contains + procedure, pass(sv) :: build => c_mumps_solver_bld + procedure, pass(sv) :: apply_a => c_mumps_solver_apply + procedure, pass(sv) :: apply_v => c_mumps_solver_apply_vect + procedure, pass(sv) :: clone_settings => c_mumps_solver_clone_settings + procedure, pass(sv) :: clear_data => c_mumps_solver_clear_data + procedure, pass(sv) :: free => c_mumps_solver_free + procedure, pass(sv) :: descr => c_mumps_solver_descr + procedure, pass(sv) :: sizeof => c_mumps_solver_sizeof + procedure, pass(sv) :: csetc => c_mumps_solver_csetc + procedure, pass(sv) :: cseti => c_mumps_solver_cseti + procedure, pass(sv) :: csetr => c_mumps_solver_csetr + procedure, pass(sv) :: default => c_mumps_solver_default + procedure, nopass :: get_fmt => c_mumps_solver_get_fmt + procedure, nopass :: get_id => c_mumps_solver_get_id + procedure, pass(sv) :: is_global => c_mumps_solver_is_global + final :: c_mumps_solver_finalize + end type amg_c_mumps_solver_type + + + private :: c_mumps_solver_bld, c_mumps_solver_apply, & + & c_mumps_solver_free, c_mumps_solver_descr, & + & c_mumps_solver_sizeof, c_mumps_solver_apply_vect,& + & c_mumps_solver_cseti, c_mumps_solver_csetr, & + & c_mumps_solver_csetc, c_mumps_solver_clear_data, & + & c_mumps_solver_default, c_mumps_solver_get_fmt, & + & c_mumps_solver_clone_settings, & + & c_mumps_solver_get_id, c_mumps_solver_is_global + private :: c_mumps_solver_finalize + + interface + subroutine c_mumps_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, amg_c_mumps_solver_type, psb_c_vect_type, psb_dpk_, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_mumps_solver_type), intent(inout) :: sv + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + end subroutine c_mumps_solver_apply_vect + end interface + + interface + subroutine c_mumps_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info,init,initu) + import :: psb_desc_type, amg_c_mumps_solver_type, psb_c_vect_type, psb_dpk_, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_mumps_solver_type), intent(inout) :: sv + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + end subroutine c_mumps_solver_apply + end interface + + interface + subroutine c_mumps_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + import :: psb_desc_type, amg_c_mumps_solver_type, psb_c_vect_type, psb_spk_, & + & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + + Implicit None + + ! Arguments + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type), intent(in), target, optional :: b + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine c_mumps_solver_bld + end interface + +contains + + subroutine c_mumps_solver_clone_settings(sv,svout,info) + + use psb_base_mod + Implicit None + ! Arguments + class(amg_c_mumps_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: k,err_act + character(len=20) :: name='c_mumps_solver_clone_settings' + + info = 0 + +#if defined(HAVE_MUMPS_) + + call psb_erractionsave(err_act) + + select type(svout) + class is(amg_c_mumps_solver_type) + svout%ipar(:) = sv%ipar(:) + svout%built = .false. + if (allocated(svout%icntl)) deallocate(svout%icntl,stat=info) + if (info == 0) allocate(svout%icntl(amg_mumps_icntl_size),stat=info) + if (info == 0) then + do k=1,amg_mumps_icntl_size + call psb_safe_ab_cpy(sv%icntl(k)%item,svout%icntl(k)%item,info) + end do + end if + + if (allocated(svout%rcntl)) deallocate(svout%rcntl,stat=info) + if (info == 0) allocate(svout%rcntl(amg_mumps_rcntl_size),stat=info) + if (info == 0) then + do k=1,amg_mumps_rcntl_size + call psb_safe_ab_cpy(sv%rcntl(k)%item,svout%rcntl(k)%item,info) + end do + end if + + class default + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +#endif + end subroutine c_mumps_solver_clone_settings + + subroutine c_mumps_solver_clear_data(sv,info) + use psb_base_mod, only : psb_exit + Implicit None + + ! Arguments + class(amg_c_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + Integer(psb_ipk_) :: err_act + character(len=20) :: name='c_mumps_solver_clear_data' + + info = 0 +#if defined(HAVE_MUMPS_) + call psb_erractionsave(err_act) + if (allocated(sv%id)) then + if (sv%built) then + sv%id%job = -2 + call cmumps(sv%id) + info = sv%id%infog(1) + if (info /= psb_success_) goto 9999 + end if + deallocate(sv%id, stat=info) + if (allocated(sv%local_ictxt)) then + call psb_exit(sv%local_ictxt,close=.false.) + deallocate(sv%local_ictxt,stat=info) + end if + sv%built=.false. + end if + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +#endif + end subroutine c_mumps_solver_clear_data + + subroutine c_mumps_solver_free(sv,info) + use psb_base_mod, only : psb_exit + Implicit None + + ! Arguments + class(amg_c_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + Integer(psb_ipk_) :: err_act + character(len=20) :: name='c_mumps_solver_free' + + info = 0 +#if defined(HAVE_MUMPS_) + call psb_erractionsave(err_act) + call sv%clear_data(info) + if ((info == 0).and.allocated(sv%icntl)) deallocate(sv%icntl,stat=info) + if ((info == 0).and.allocated(sv%rcntl)) deallocate(sv%rcntl,stat=info) + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +#endif + end subroutine c_mumps_solver_free + +subroutine c_mumps_solver_finalize(sv) + + Implicit None + + ! Arguments + type(amg_c_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_) :: info + Integer(psb_ipk_) :: err_act + character(len=20) :: name='c_mumps_solver_finalize' + + call sv%free(info) + + return + +end subroutine c_mumps_solver_finalize + +subroutine c_mumps_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_c_mumps_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt, me, np + character(len=20), parameter :: name='amg_z_mumps_solver_descr' + integer(psb_ipk_) :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' MUMPS Solver. ' + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +end subroutine c_mumps_solver_descr + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! WARNING: OTHER PARAMETERS OF MUMPS COULD BE ADDED. !! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + +subroutine c_mumps_solver_csetc(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_c_mumps_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_mumps_solver_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + + + select case(psb_toupper(trim(what))) +#if defined(HAVE_MUMPS_) + case('MUMPS_LOC_GLOB') + sv%ipar(1) = sv%stringval(psb_toupper(trim(val))) +#endif + case default + call sv%amg_c_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +end subroutine c_mumps_solver_csetc + + +subroutine c_mumps_solver_cseti(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_c_mumps_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_mumps_solver_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) +#if defined(HAVE_MUMPS_) + case('MUMPS_LOC_GLOB') + sv%ipar(1) = val + case('MUMPS_PRINT_ERR') + sv%ipar(2) = val + case('MUMPS_SYM') + sv%ipar(3) = val + case('MUMPS_IPAR_ENTRY') + if(present(idx)) then + ! Note: this will allocate %item + sv%icntl(idx)%item = val + end if +#endif + case default + call sv%amg_c_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +end subroutine c_mumps_solver_cseti + +subroutine c_mumps_solver_csetr(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_c_mumps_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_mumps_solver_csetr' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) +#if defined(HAVE_MUMPS_) + case('MUMPS_RPAR_ENTRY') + if(present(idx)) then + ! Note: this will allocate %item + sv%rcntl(idx)%item = val + end if +#endif + case default + call sv%amg_c_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +end subroutine c_mumps_solver_csetr + +!!NOTE: BY DEFAULT BLR is activated with a dropping parameter to 1d-4 !! +subroutine c_mumps_solver_default(sv) + + Implicit none + + !Argument + class(amg_c_mumps_solver_type),intent(inout) :: sv + integer(psb_ipk_) :: info + integer(psb_ipk_) :: err_act,ictx,icomm + character(len=20) :: name='c_mumps_default' + + info = psb_success_ + call psb_erractionsave(err_act) + +#if defined(HAVE_MUMPS_) + if (.not.allocated(sv%id)) then + allocate(sv%id,stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_dealloc_ + call psb_errpush(info,name,a_err='amg_cmumps_default') + goto 9999 + end if + sv%built=.false. + end if + if (.not.allocated(sv%icntl)) then + allocate(sv%icntl(amg_mumps_icntl_size),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_dealloc_ + call psb_errpush(info,name,a_err='amg_cmumps_default') + goto 9999 + end if + end if + if (.not.allocated(sv%rcntl)) then + allocate(sv%rcntl(amg_mumps_rcntl_size),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_dealloc_ + call psb_errpush(info,name,a_err='amg_cmumps_default') + goto 9999 + end if + end if + ! INSTANTIATION OF sv%id needed to set parmater but mpi communicator needed + ! sv%id%job = -1 + ! sv%id%par=1 + ! call dmumps(sv%id) + sv%ipar = 0 + sv%ipar(1) = amg_global_solver_ + !sv%ipar(10)=6 + !sv%ipar(11)=0 + !sv%ipar(12)=6 + +#endif + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return + +end subroutine c_mumps_solver_default + +function c_mumps_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_c_mumps_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer :: i +#if defined(HAVE_MUMPS_) + val = (sv%id%INFOG(22)+sv%id%INFOG(32))*1d+6 +#else + val = 0 +#endif + ! val = 2*psb_sizeof_ip + psb_sizeof_dp + ! val = val + sv%symbsize + ! val = val + sv%numsize + return +end function c_mumps_solver_sizeof + +function c_mumps_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "MUMPS solver" +end function c_mumps_solver_get_fmt + +function c_mumps_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_mumps_ +end function c_mumps_solver_get_id + + +function c_mumps_solver_is_global(sv) result(val) + implicit none + class(amg_c_mumps_solver_type), intent(in) :: sv + logical :: val + + val = (sv%ipar(1) == amg_global_solver_ ) +end function c_mumps_solver_is_global + +end module amg_c_mumps_solver + diff --git a/mlprec/amg_c_onelev_mod.f90 b/mlprec/amg_c_onelev_mod.f90 new file mode 100644 index 00000000..91365ec0 --- /dev/null +++ b/mlprec/amg_c_onelev_mod.f90 @@ -0,0 +1,824 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_c_onelev_mod.f90 +! +! Module: amg_c_onelev_mod +! +! This module defines: +! - the amg_c_onelev_type data structure containing one level +! of a multilevel preconditioner and related +! data structures; +! +! It contains routines for +! - Building and applying; +! - checking if the preconditioner is correctly defined; +! - printing a description of the preconditioner; +! - deallocating the preconditioner data structure. +! + +module amg_c_onelev_mod + + use amg_base_prec_type + use amg_c_base_smoother_mod + use amg_c_dec_aggregator_mod + use psb_base_mod, only : psb_cspmat_type, psb_c_vect_type, & + & psb_c_base_vect_type, psb_lcspmat_type, psb_clinmap_type, psb_spk_, & + & psb_ipk_, psb_epk_, psb_lpk_, psb_desc_type, psb_i_base_vect_type, & + & psb_erractionsave, psb_error_handler + ! + ! + ! Type: amg_conelev_type. + ! + ! It is the data type containing the necessary items for the current + ! level (essentially, the smoother, the current-level matrix + ! and the restriction and prolongation operators). + ! + ! type amg_conelev_type + ! class(amg_c_base_smoother_type), allocatable :: sm, sm2a + ! class(amg_c_base_smoother_type), pointer :: sm2 => null() + ! class(amg_cmlprec_wrk_type), allocatable :: wrk + ! class(amg_c_base_aggregator_type), allocatable :: aggr + ! type(amg_sml_parms) :: parms + ! type(psb_cspmat_type) :: ac + ! type(psb_cesc_type) :: desc_ac + ! type(psb_cspmat_type), pointer :: base_a => null() + ! type(psb_desc_type), pointer :: base_desc => null() + ! type(psb_clinmap_type) :: map + ! end type amg_conelev_type + ! + ! Note that s denotes the kind of the real data type to be chosen + ! according to single/double precision version of MLD2P4. + ! + ! sm,sm2a - class(amg_c_base_smoother_type), allocatable + ! The current level pre- and post-smooother. + ! sm2 - class(amg_c_base_smoother_type), pointer + ! The current level post-smooother; if sm2a is allocated + ! explicitly, then sm2 => sm2a, otherwise sm2 => sm. + ! wrk - class(amg_cmlprec_wrk_type), allocatable + ! Workspace for application of preconditioner; may be + ! pre-allocated to save time in the application within a + ! Krylov solver. + ! aggr - class(amg_c_base_aggregator_type), allocatable + ! The aggregator object: holds the algorithmic choices and + ! (possibly) additional data for building the aggregation. + ! parms - type(amg_sml_parms) + ! The parameters defining the multilevel strategy. + ! ac - The local part of the current-level matrix, built by + ! coarsening the previous-level matrix. + ! desc_ac - type(psb_desc_type). + ! The communication descriptor associated to the matrix + ! stored in ac. + ! base_a - type(psb_cspmat_type), pointer. + ! Pointer (really a pointer!) to the local part of the current + ! matrix (so we have a unified treatment of residuals). + ! We need this to avoid passing explicitly the current matrix + ! to the routine which applies the preconditioner. + ! base_desc - type(psb_desc_type), pointer. + ! Pointer to the communication descriptor associated to the + ! matrix pointed by base_a. + ! map - Stores the maps (restriction and prolongation) between the + ! vector spaces associated to the index spaces of the previous + ! and current levels. + ! + ! Methods: + ! Most methods follow the encapsulation hierarchy: they take whatever action + ! is appropriate for the current object, then call the corresponding method for + ! the contained object. + ! As an example: the descr() method prints out a description of the + ! level. It starts by invoking the descr() method of the parms object, + ! then calls the descr() method of the smoother object. + ! + ! descr - Prints a description of the object. + ! default - Set default values + ! dump - Dump to file object contents + ! set - Sets various parameters; when a request is unknown + ! it is passed to the smoother object for further processing. + ! check - Sanity checks. + ! sizeof - Total memory occupation in bytes + ! get_nzeros - Number of nonzeros + ! get_wrksz - How many workspace vector does apply_vect need + ! allocate_wrk - Allocate auxiliary workspace + ! free_wrk - Free auxiliary workspace + ! bld_tprol - Invoke the aggr method to build the tentative prolongator + ! mat_asb - Build the final (possibly smoothed) prolongator and coarse matrix. + ! + ! + type amg_cmlprec_wrk_type + complex(psb_spk_), allocatable :: tx(:), ty(:), x2l(:), y2l(:) + type(psb_c_vect_type) :: vtx, vty, vx2l, vy2l + type(psb_c_vect_type), allocatable :: wv(:) + contains + procedure, pass(wk) :: alloc => c_wrk_alloc + procedure, pass(wk) :: free => c_wrk_free + procedure, pass(wk) :: clone => c_wrk_clone + procedure, pass(wk) :: move_alloc => c_wrk_move_alloc + procedure, pass(wk) :: cnv => c_wrk_cnv + procedure, pass(wk) :: sizeof => c_wrk_sizeof + end type amg_cmlprec_wrk_type + private :: c_wrk_alloc, c_wrk_free, & + & c_wrk_clone, c_wrk_move_alloc, c_wrk_cnv, c_wrk_sizeof + + type amg_c_onelev_type + class(amg_c_base_smoother_type), allocatable :: sm, sm2a + class(amg_c_base_smoother_type), pointer :: sm2 => null() + class(amg_cmlprec_wrk_type), allocatable :: wrk + class(amg_c_base_aggregator_type), allocatable :: aggr + type(amg_sml_parms) :: parms + type(psb_cspmat_type) :: ac + integer(psb_ipk_) :: ac_nz_loc + integer(psb_lpk_) :: ac_nz_tot + type(psb_desc_type) :: desc_ac + type(psb_cspmat_type), pointer :: base_a => null() + type(psb_desc_type), pointer :: base_desc => null() + type(psb_lcspmat_type) :: tprol + type(psb_clinmap_type) :: map + real(psb_spk_) :: szratio + contains + procedure, pass(lv) :: bld_tprol => c_base_onelev_bld_tprol + procedure, pass(lv) :: mat_asb => amg_c_base_onelev_mat_asb + procedure, pass(lv) :: update_aggr => c_base_onelev_update_aggr + procedure, pass(lv) :: bld => amg_c_base_onelev_build + procedure, pass(lv) :: clone => c_base_onelev_clone + procedure, pass(lv) :: cnv => amg_c_base_onelev_cnv + procedure, pass(lv) :: descr => amg_c_base_onelev_descr + procedure, pass(lv) :: default => c_base_onelev_default + procedure, pass(lv) :: free => amg_c_base_onelev_free + procedure, pass(lv) :: nullify => c_base_onelev_nullify + procedure, pass(lv) :: check => amg_c_base_onelev_check + procedure, pass(lv) :: dump => amg_c_base_onelev_dump + procedure, pass(lv) :: cseti => amg_c_base_onelev_cseti + procedure, pass(lv) :: csetr => amg_c_base_onelev_csetr + procedure, pass(lv) :: csetc => amg_c_base_onelev_csetc + procedure, pass(lv) :: setsm => amg_c_base_onelev_setsm + procedure, pass(lv) :: setsv => amg_c_base_onelev_setsv + procedure, pass(lv) :: setag => amg_c_base_onelev_setag + generic, public :: set => cseti, csetr, csetc, setsm, setsv, setag + procedure, pass(lv) :: sizeof => c_base_onelev_sizeof + procedure, pass(lv) :: get_nzeros => c_base_onelev_get_nzeros + procedure, pass(lv) :: get_wrksz => c_base_onelev_get_wrksize + procedure, pass(lv) :: allocate_wrk => c_base_onelev_allocate_wrk + procedure, pass(lv) :: free_wrk => c_base_onelev_free_wrk + procedure, nopass :: stringval => amg_stringval + procedure, pass(lv) :: move_alloc => c_base_onelev_move_alloc + + end type amg_c_onelev_type + + type amg_c_onelev_node + type(amg_c_onelev_type) :: item + type(amg_c_onelev_node), pointer :: prev=>null(), next=>null() + end type amg_c_onelev_node + + private :: c_base_onelev_default, c_base_onelev_sizeof, & + & c_base_onelev_nullify, c_base_onelev_get_nzeros, & + & c_base_onelev_clone, c_base_onelev_move_alloc, & + & c_base_onelev_get_wrksize, c_base_onelev_allocate_wrk, & + & c_base_onelev_free_wrk + + interface + subroutine amg_c_base_onelev_mat_asb(lv,a,desc_a,ilaggr,nlaggr,t_prol,info) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, psb_ipk_, psb_lcspmat_type, psb_lpk_ + import :: amg_c_onelev_type + implicit none + class(amg_c_onelev_type), intent(inout), target :: lv + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:),nlaggr(:) + type(psb_lcspmat_type), intent(inout) :: t_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_base_onelev_mat_asb + end interface + + interface + subroutine amg_c_base_onelev_build(lv,info,amold,vmold,imold,ilv) + import :: psb_c_base_sparse_mat, psb_c_base_vect_type, & + & psb_i_base_vect_type, psb_spk_, amg_c_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + implicit none + class(amg_c_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + integer(psb_ipk_), intent(in), optional :: ilv + end subroutine amg_c_base_onelev_build + end interface + + interface + subroutine amg_c_base_onelev_descr(lv,il,nl,ilmin,info,iout) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_clinmap_type, psb_spk_, amg_c_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + ! Arguments + class(amg_c_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: il,nl,ilmin + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + end subroutine amg_c_base_onelev_descr + end interface + + interface + subroutine amg_c_base_onelev_cnv(lv,info,amold,vmold,imold) + import :: amg_c_onelev_type, psb_c_base_vect_type, psb_spk_, & + & psb_c_base_sparse_mat, psb_ipk_, psb_i_base_vect_type + ! Arguments + class(amg_c_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_c_base_onelev_cnv + end interface + +interface + subroutine amg_c_base_onelev_free(lv,info) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_clinmap_type, psb_spk_, amg_c_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + implicit none + + class(amg_c_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_base_onelev_free + end interface + + interface + subroutine amg_c_base_onelev_check(lv,info) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_clinmap_type, psb_spk_, amg_c_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + ! Arguments + class(amg_c_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_base_onelev_check + end interface + + interface + subroutine amg_c_base_onelev_setsm(lv,val,info,pos) + import :: psb_spk_, amg_c_onelev_type, amg_c_base_smoother_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + ! Arguments + class(amg_c_onelev_type), target, intent(inout) :: lv + class(amg_c_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + end subroutine amg_c_base_onelev_setsm + end interface + + interface + subroutine amg_c_base_onelev_setsv(lv,val,info,pos) + import :: psb_spk_, amg_c_onelev_type, amg_c_base_solver_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + ! Arguments + class(amg_c_onelev_type), target, intent(inout) :: lv + class(amg_c_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + end subroutine amg_c_base_onelev_setsv + end interface + + interface + subroutine amg_c_base_onelev_setag(lv,val,info,pos) + import :: psb_spk_, amg_c_onelev_type, amg_c_base_aggregator_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + ! Arguments + class(amg_c_onelev_type), target, intent(inout) :: lv + class(amg_c_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + end subroutine amg_c_base_onelev_setag + end interface + + interface + subroutine amg_c_base_onelev_cseti(lv,what,val,info,pos,idx) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_clinmap_type, psb_spk_, amg_c_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + ! Arguments + class(amg_c_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_c_base_onelev_cseti + end interface + + interface + subroutine amg_c_base_onelev_csetc(lv,what,val,info,pos,idx) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_clinmap_type, psb_spk_, amg_c_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + ! Arguments + class(amg_c_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_c_base_onelev_csetc + end interface + + interface + subroutine amg_c_base_onelev_csetr(lv,what,val,info,pos,idx) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_clinmap_type, psb_spk_, amg_c_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + class(amg_c_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_c_base_onelev_csetr + end interface + + interface + subroutine amg_c_base_onelev_dump(lv,level,info,prefix,head,ac,rp,smoother,& + & solver,tprol,global_num) + import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & + & psb_clinmap_type, psb_spk_, amg_c_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + implicit none + class(amg_c_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: ac, rp, smoother, solver, tprol, global_num + end subroutine amg_c_base_onelev_dump + end interface + +contains + ! + ! Function returning the size of the amg_prec_type data structure + ! in bytes or in number of nonzeros of the operator(s) involved. + ! + + function c_base_onelev_get_nzeros(lv) result(val) + implicit none + class(amg_c_onelev_type), intent(in) :: lv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + if (allocated(lv%sm)) & + & val = lv%sm%get_nzeros() + if (allocated(lv%sm2a)) & + & val = val + lv%sm2a%get_nzeros() + end function c_base_onelev_get_nzeros + + function c_base_onelev_sizeof(lv) result(val) + implicit none + class(amg_c_onelev_type), intent(in) :: lv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = psb_sizeof_ip+psb_sizeof_lp + val = val + lv%desc_ac%sizeof() + val = val + lv%ac%sizeof() + val = val + lv%tprol%sizeof() + val = val + lv%map%sizeof() + if (allocated(lv%sm)) val = val + lv%sm%sizeof() + if (allocated(lv%sm2a)) val = val + lv%sm2a%sizeof() + if (allocated(lv%aggr)) val = val + lv%aggr%sizeof() + if (allocated(lv%wrk)) val = val + lv%wrk%sizeof() + end function c_base_onelev_sizeof + + + subroutine c_base_onelev_nullify(lv) + implicit none + + class(amg_c_onelev_type), intent(inout) :: lv + + nullify(lv%base_a) + nullify(lv%base_desc) + nullify(lv%sm2) + end subroutine c_base_onelev_nullify + + ! + ! Multilevel defaults: + ! multiplicative vs. additive ML framework; + ! Smoothed decoupled aggregation with zero threshold; + ! distributed coarse matrix; + ! damping omega computed with the max-norm estimate of the + ! dominant eigenvalue; + ! two-sided smoothing (i.e. V-cycle) with 1 smoothing sweep; + ! + + subroutine c_base_onelev_default(lv) + + Implicit None + + ! Arguments + class(amg_c_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_) :: info + + lv%parms%sweeps_pre = 1 + lv%parms%sweeps_post = 1 + lv%parms%ml_cycle = amg_vcycle_ml_ + lv%parms%aggr_type = amg_soc1_ + lv%parms%par_aggr_alg = amg_dec_aggr_ + lv%parms%aggr_ord = amg_aggr_ord_nat_ + lv%parms%aggr_prol = amg_smooth_prol_ + lv%parms%coarse_mat = amg_distr_mat_ + lv%parms%aggr_omega_alg = amg_eig_est_ + lv%parms%aggr_eig = amg_max_norm_ + lv%parms%aggr_filter = amg_no_filter_mat_ + lv%parms%aggr_omega_val = szero + lv%parms%aggr_thresh = 0.01_psb_spk_ + + if (allocated(lv%sm)) call lv%sm%default() + if (allocated(lv%sm2a)) then + call lv%sm2a%default() + lv%sm2 => lv%sm2a + else + lv%sm2 => lv%sm + end if + if (.not.allocated(lv%aggr)) allocate(amg_c_dec_aggregator_type :: lv%aggr,stat=info) + if (allocated(lv%aggr)) call lv%aggr%default() + + return + + end subroutine c_base_onelev_default + + subroutine c_base_onelev_bld_tprol(lv,a,desc_a,& + & ilaggr,nlaggr,t_prol,ag_data,info) + implicit none + class(amg_c_onelev_type), intent(inout), target :: lv + type(psb_cspmat_type), intent(inout) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lcspmat_type), intent(out) :: t_prol + type(amg_saggr_data), intent(in) :: ag_data + integer(psb_ipk_), intent(out) :: info + + call lv%aggr%bld_tprol(lv%parms,ag_data,a,desc_a,ilaggr,nlaggr,t_prol,info) + + end subroutine c_base_onelev_bld_tprol + + + subroutine c_base_onelev_update_aggr(lv,lvnext,info) + implicit none + class(amg_c_onelev_type), intent(inout), target :: lv, lvnext + integer(psb_ipk_), intent(out) :: info + + call lv%aggr%update_next(lvnext%aggr,info) + + end subroutine c_base_onelev_update_aggr + + + subroutine c_base_onelev_clone(lv,lvout,info) + + Implicit None + + ! Arguments + class(amg_c_onelev_type), target, intent(inout) :: lv + class(amg_c_onelev_type), target, intent(inout) :: lvout + integer(psb_ipk_), intent(out) :: info + + info = psb_success_ + if (allocated(lv%sm)) then + call lv%sm%clone(lvout%sm,info) + else + if (allocated(lvout%sm)) then + call lvout%sm%free(info) + if (info==psb_success_) deallocate(lvout%sm,stat=info) + end if + end if + if (allocated(lv%sm2a)) then + call lv%sm%clone(lvout%sm2a,info) + lvout%sm2 => lvout%sm2a + else + if (allocated(lvout%sm2a)) then + call lvout%sm2a%free(info) + if (info==psb_success_) deallocate(lvout%sm2a,stat=info) + end if + lvout%sm2 => lvout%sm + end if + if (allocated(lv%aggr)) then + call lv%aggr%clone(lvout%aggr,info) + else + if (allocated(lvout%aggr)) then + call lvout%aggr%free(info) + if (info==psb_success_) deallocate(lvout%aggr,stat=info) + end if + end if + if (info == psb_success_) call lv%parms%clone(lvout%parms,info) + if (info == psb_success_) call lv%ac%clone(lvout%ac,info) + if (info == psb_success_) call lv%tprol%clone(lvout%tprol,info) + if (info == psb_success_) call lv%desc_ac%clone(lvout%desc_ac,info) + if (info == psb_success_) call lv%map%clone(lvout%map,info) + lvout%base_a => lv%base_a + lvout%base_desc => lv%base_desc + + return + + end subroutine c_base_onelev_clone + + subroutine c_base_onelev_move_alloc(lv, b,info) + use psb_base_mod + implicit none + class(amg_c_onelev_type), target, intent(inout) :: lv, b + integer(psb_ipk_), intent(out) :: info + + call b%free(info) + b%parms = lv%parms + b%szratio = lv%szratio + if (associated(lv%sm2,lv%sm2a)) then + call move_alloc(lv%sm,b%sm) + call move_alloc(lv%sm2a,b%sm2a) + b%sm2 =>b%sm2a + else + call move_alloc(lv%sm,b%sm) + call move_alloc(lv%sm2a,b%sm2a) + b%sm2 =>b%sm + end if + + call move_alloc(lv%aggr,b%aggr) + if (info == psb_success_) call psb_move_alloc(lv%ac,b%ac,info) + if (info == psb_success_) call psb_move_alloc(lv%tprol,b%tprol,info) + if (info == psb_success_) call psb_move_alloc(lv%desc_ac,b%desc_ac,info) + if (info == psb_success_) call psb_move_alloc(lv%map,b%map,info) + b%base_a => lv%base_a + b%base_desc => lv%base_desc + + end subroutine c_base_onelev_move_alloc + + + function c_base_onelev_get_wrksize(lv) result(val) + implicit none + class(amg_c_onelev_type), intent(inout) :: lv + integer(psb_ipk_) :: val + + val = 0 + ! SM and SM2A can share work vectors + if (allocated(lv%sm)) val = val + lv%sm%get_wrksz() + if (allocated(lv%sm2a)) val = max(val,lv%sm2a%get_wrksz()) + ! + ! Now for the ML application itself + ! + + ! VTX/VTY/VX2L/VY2L are stored explicitly + ! + + ! + ! additions for specific ML/cycles + ! + select case(lv%parms%ml_cycle) + case(amg_add_ml_,amg_mult_ml_,amg_vcycle_ml_, amg_wcycle_ml_) + ! We're good + + case(amg_kcycle_ml_, amg_kcyclesym_ml_) + ! + ! We need 7 in inneritkcycle. + ! Can we reuse vtx? + ! + val = val + 7 + + case default + ! Need a better error signaling ? + val = -1 + end select + + end function c_base_onelev_get_wrksize + + subroutine c_base_onelev_allocate_wrk(lv,info,vmold) + use psb_base_mod + implicit none + class(amg_c_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_vect_type), intent(in), optional :: vmold + ! + integer(psb_ipk_) :: nwv, i + info = psb_success_ + nwv = lv%get_wrksz() + if (.not.allocated(lv%wrk)) allocate(lv%wrk,stat=info) + if (info == 0) call lv%wrk%alloc(nwv,lv%base_desc,info,vmold=vmold) + + end subroutine c_base_onelev_allocate_wrk + + + subroutine c_base_onelev_free_wrk(lv,info) + use psb_base_mod + implicit none + class(amg_c_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: nwv,i + info = psb_success_ + + if (allocated(lv%wrk)) then + call lv%wrk%free(info) + if (info == 0) deallocate(lv%wrk,stat=info) + end if + end subroutine c_base_onelev_free_wrk + + subroutine c_wrk_alloc(wk,nwv,desc,info,vmold) + use psb_base_mod + + Implicit None + + ! Arguments + class(amg_cmlprec_wrk_type), target, intent(inout) :: wk + integer(psb_ipk_), intent(in) :: nwv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_vect_type), intent(in), optional :: vmold + ! + integer(psb_ipk_) :: i + + info = psb_success_ + call wk%free(info) + call psb_geasb(wk%vx2l,desc,info,& + & scratch=.true.,mold=vmold) + call psb_geasb(wk%vy2l,desc,info,& + & scratch=.true.,mold=vmold) + call psb_geasb(wk%vtx,desc,info,& + & scratch=.true.,mold=vmold) + call psb_geasb(wk%vty,desc,info,& + & scratch=.true.,mold=vmold) + allocate(wk%wv(nwv),stat=info) + do i=1,nwv + call psb_geasb(wk%wv(i),desc,info,& + & scratch=.true.,mold=vmold) + end do + + end subroutine c_wrk_alloc + + subroutine c_wrk_free(wk,info) + + Implicit None + + ! Arguments + class(amg_cmlprec_wrk_type), target, intent(inout) :: wk + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: i + info = psb_success_ + + if (allocated(wk%tx)) deallocate(wk%tx, stat=info) + if (allocated(wk%ty)) deallocate(wk%ty, stat=info) + if (allocated(wk%x2l)) deallocate(wk%x2l, stat=info) + if (allocated(wk%y2l)) deallocate(wk%y2l, stat=info) + call wk%vtx%free(info) + call wk%vty%free(info) + call wk%vx2l%free(info) + call wk%vy2l%free(info) + if (allocated(wk%wv)) then + do i=1,size(wk%wv) + call wk%wv(i)%free(info) + end do + deallocate(wk%wv, stat=info) + end if + + end subroutine c_wrk_free + + subroutine c_wrk_clone(wk,wkout,info) + use psb_base_mod + Implicit None + + ! Arguments + class(amg_cmlprec_wrk_type), target, intent(inout) :: wk + class(amg_cmlprec_wrk_type), target, intent(inout) :: wkout + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: i + info = psb_success_ + + call psb_safe_ab_cpy(wk%tx,wkout%tx,info) + call psb_safe_ab_cpy(wk%ty,wkout%ty,info) + call psb_safe_ab_cpy(wk%x2l,wkout%x2l,info) + call psb_safe_ab_cpy(wk%y2l,wkout%y2l,info) + call wk%vtx%clone(wkout%vtx,info) + call wk%vty%clone(wkout%vty,info) + call wk%vx2l%clone(wkout%vx2l,info) + call wk%vy2l%clone(wkout%vy2l,info) + if (allocated(wkout%wv)) then + do i=1,size(wkout%wv) + call wkout%wv(i)%free(info) + end do + deallocate( wkout%wv) + end if + allocate(wkout%wv(size(wk%wv)),stat=info) + do i=1,size(wk%wv) + call wk%wv(i)%clone(wkout%wv(i),info) + end do + return + + end subroutine c_wrk_clone + + subroutine c_wrk_move_alloc(wk, b,info) + implicit none + class(amg_cmlprec_wrk_type), target, intent(inout) :: wk, b + integer(psb_ipk_), intent(out) :: info + + call b%free(info) + call move_alloc(wk%tx,b%tx) + call move_alloc(wk%ty,b%ty) + call move_alloc(wk%x2l,b%x2l) + call move_alloc(wk%y2l,b%y2l) + ! + ! Should define V%move_alloc.... + call move_alloc(wk%vtx%v,b%vtx%v) + call move_alloc(wk%vty%v,b%vty%v) + call move_alloc(wk%vx2l%v,b%vx2l%v) + call move_alloc(wk%vy2l%v,b%vy2l%v) + call move_alloc(wk%wv,b%wv) + + end subroutine c_wrk_move_alloc + + subroutine c_wrk_cnv(wk,info,vmold) + use psb_base_mod + + Implicit None + + ! Arguments + class(amg_cmlprec_wrk_type), target, intent(inout) :: wk + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_vect_type), intent(in), optional :: vmold + ! + integer(psb_ipk_) :: i + + info = psb_success_ + if (present(vmold)) then + call wk%vtx%cnv(vmold) + call wk%vty%cnv(vmold) + call wk%vx2l%cnv(vmold) + call wk%vy2l%cnv(vmold) + if (allocated(wk%wv)) then + do i=1,size(wk%wv) + call wk%wv(i)%cnv(vmold) + end do + end if + end if + end subroutine c_wrk_cnv + + function c_wrk_sizeof(wk) result(val) + use psb_realloc_mod + implicit none + class(amg_cmlprec_wrk_type), intent(in) :: wk + integer(psb_epk_) :: val + integer :: i + val = 0 + val = val + (1_psb_epk_ * (2*psb_sizeof_sp)) * psb_size(wk%tx) + val = val + (1_psb_epk_ * (2*psb_sizeof_sp)) * psb_size(wk%ty) + val = val + (1_psb_epk_ * (2*psb_sizeof_sp)) * psb_size(wk%x2l) + val = val + (1_psb_epk_ * (2*psb_sizeof_sp)) * psb_size(wk%y2l) + val = val + wk%vtx%sizeof() + val = val + wk%vty%sizeof() + val = val + wk%vx2l%sizeof() + val = val + wk%vy2l%sizeof() + if (allocated(wk%wv)) then + do i=1, size(wk%wv) + val = val + wk%wv(i)%sizeof() + end do + end if + end function c_wrk_sizeof + +end module amg_c_onelev_mod diff --git a/mlprec/amg_c_prec_mod.f90 b/mlprec/amg_c_prec_mod.f90 new file mode 100644 index 00000000..d8fb9cdf --- /dev/null +++ b/mlprec/amg_c_prec_mod.f90 @@ -0,0 +1,139 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_c_prec_mod.f90 +! +! Module: amg_c_prec_mod +! +! This module defines the user interfaces to the real/complex, single/double +! precision versions of the user-level MLD2P4 routines. +! +module amg_c_prec_mod + + use amg_c_prec_type + use amg_c_jac_smoother + use amg_c_as_smoother + use amg_c_id_solver + use amg_c_diag_solver + use amg_c_l1_diag_solver + use amg_c_ilu_solver + use amg_c_gs_solver + + interface amg_precset + module procedure amg_c_iprecsetsm, amg_c_iprecsetsv, & + & amg_c_cprecseti, amg_c_cprecsetc, amg_c_cprecsetr, & + & amg_c_iprecsetag + end interface amg_precset + + interface amg_extprol_bld + subroutine amg_c_extprol_bld(a,desc_a,p,prolv,restrv,info,amold,vmold,imold) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, & + & psb_c_base_sparse_mat, psb_c_base_vect_type, & + & psb_i_base_vect_type, amg_cprec_type, psb_ipk_ + + ! Arguments + type(psb_cspmat_type),intent(in), target :: a + type(psb_cspmat_type),intent(inout), target :: prolv(:) + type(psb_cspmat_type),intent(inout), target :: restrv(:) + type(psb_desc_type), intent(inout), target :: desc_a + type(amg_cprec_type),intent(inout),target :: p + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! !$ character, intent(in), optional :: upd + end subroutine amg_c_extprol_bld + end interface amg_extprol_bld + +contains + + subroutine amg_c_iprecsetsm(p,val,info,pos) + type(amg_cprec_type), intent(inout) :: p + class(amg_c_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + call p%set(val,info,pos=pos) + end subroutine amg_c_iprecsetsm + + subroutine amg_c_iprecsetsv(p,val,info,pos) + type(amg_cprec_type), intent(inout) :: p + class(amg_c_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + call p%set(val,info, pos=pos) + end subroutine amg_c_iprecsetsv + + subroutine amg_c_iprecsetag(p,val,info,pos) + type(amg_cprec_type), intent(inout) :: p + class(amg_c_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + call p%set(val,info, pos=pos) + end subroutine amg_c_iprecsetag + + subroutine amg_c_cprecseti(p,what,val,info,pos) + type(amg_cprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + call p%set(what,val,info,pos=pos) + end subroutine amg_c_cprecseti + + subroutine amg_c_cprecsetr(p,what,val,info,pos) + type(amg_cprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + call p%set(what,val,info,pos=pos) + end subroutine amg_c_cprecsetr + + subroutine amg_c_cprecsetc(p,what,val,info,pos) + type(amg_cprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + call p%set(what,val,info,pos=pos) + end subroutine amg_c_cprecsetc + +end module amg_c_prec_mod diff --git a/mlprec/amg_c_prec_type.f90 b/mlprec/amg_c_prec_type.f90 new file mode 100644 index 00000000..2af5d40a --- /dev/null +++ b/mlprec/amg_c_prec_type.f90 @@ -0,0 +1,964 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_c_prec_type.f90 +! +! Module: amg_c_prec_type +! +! This module defines: +! - the amg_c_prec_type data structure containing the preconditioner and related +! data structures; +! +! It contains routines for +! - Building and applying; +! - checking if the preconditioner is correctly defined; +! - printing a description of the preconditioner; +! - deallocating the preconditioner data structure. +! + +module amg_c_prec_type + + use amg_base_prec_type + use amg_c_base_solver_mod + use amg_c_base_smoother_mod + use amg_c_base_aggregator_mod + use amg_c_onelev_mod + use psb_base_mod, only : psb_erractionsave, psb_erractionrestore, psb_errstatus_fatal + use psb_prec_mod, only : psb_cprec_type + + ! + ! Type: amg_cprec_type. + ! + ! This is the data type containing all the information about the multilevel + ! preconditioner ('d', 's', 'c' and 'z', according to the real/complex, + ! single/double precision version of MLD2P4). + ! It consists of an array of 'one-level' intermediate data structures + ! of type amg_conelev_type, each containing the information needed to apply + ! the smoothing and the coarse-space correction at a generic level. RT is the + ! real data type, i.e. S for both S and C, and D for both D and Z. + ! + ! type amg_cprec_type + ! type(amg_conelev_type), allocatable :: precv(:) + ! end type amg_cprec_type + ! + ! Note that the levels are numbered in increasing order starting from + ! the level 1 as the finest one, and the number of levels is given by + ! size(precv(:)) which is the id of the coarsest level. + ! In the multigrid literature many authors number the levels in the opposite + ! order, with level 0 being the id of the coarsest level. + ! + ! + integer, parameter, private :: wv_size_=4 + + type, extends(psb_cprec_type) :: amg_cprec_type + ! integer(psb_ipk_) :: ictxt ! Now it's in the PSBLAS prec. + type(amg_saggr_data) :: ag_data + ! + ! Number of outer sweeps. Sometimes 2 V-cycles may be better than 1 W-cycle. + ! + integer(psb_ipk_) :: outer_sweeps = 1 + ! + ! Coarse solver requires some tricky checks, and for this we need to + ! record the choice in the format given by the user, + ! to keep track against what is put later in the multilevel array + ! + integer(psb_ipk_) :: coarse_solver = -1 + + ! + ! The multilevel hierarchy + ! + type(amg_c_onelev_type), allocatable :: precv(:) + contains + procedure, pass(prec) :: psb_c_apply2_vect => amg_c_apply2_vect + procedure, pass(prec) :: psb_c_apply1_vect => amg_c_apply1_vect + procedure, pass(prec) :: psb_c_apply2v => amg_c_apply2v + procedure, pass(prec) :: psb_c_apply1v => amg_c_apply1v + procedure, pass(prec) :: dump => amg_c_dump + procedure, pass(prec) :: cnv => amg_c_cnv + procedure, pass(prec) :: clone => amg_c_clone + procedure, pass(prec) :: free => amg_c_prec_free + procedure, pass(prec) :: allocate_wrk => amg_c_allocate_wrk + procedure, pass(prec) :: free_wrk => amg_c_free_wrk + procedure, pass(prec) :: is_allocated_wrk => amg_c_is_allocated_wrk + procedure, pass(prec) :: get_complexity => amg_c_get_compl + procedure, pass(prec) :: cmp_complexity => amg_c_cmp_compl + procedure, pass(prec) :: get_avg_cr => amg_c_get_avg_cr + procedure, pass(prec) :: cmp_avg_cr => amg_c_cmp_avg_cr + procedure, pass(prec) :: get_nlevs => amg_c_get_nlevs + procedure, pass(prec) :: get_nzeros => amg_c_get_nzeros + procedure, pass(prec) :: sizeof => amg_cprec_sizeof + procedure, pass(prec) :: setsm => amg_cprecsetsm + procedure, pass(prec) :: setsv => amg_cprecsetsv + procedure, pass(prec) :: setag => amg_cprecsetag + procedure, pass(prec) :: cseti => amg_ccprecseti + procedure, pass(prec) :: csetc => amg_ccprecsetc + procedure, pass(prec) :: csetr => amg_ccprecsetr + generic, public :: set => cseti, csetc, csetr, setsm, setsv, setag + procedure, pass(prec) :: get_smoother => amg_c_get_smootherp + procedure, pass(prec) :: get_solver => amg_c_get_solverp + procedure, pass(prec) :: move_alloc => c_prec_move_alloc + procedure, pass(prec) :: init => amg_cprecinit + procedure, pass(prec) :: build => amg_cprecbld + procedure, pass(prec) :: hierarchy_build => amg_c_hierarchy_bld + procedure, pass(prec) :: smoothers_build => amg_c_smoothers_bld + procedure, pass(prec) :: descr => amg_cfile_prec_descr + end type amg_cprec_type + + private :: amg_c_dump, amg_c_get_compl, amg_c_cmp_compl,& + & amg_c_get_avg_cr, amg_c_cmp_avg_cr,& + & amg_c_get_nzeros, amg_c_get_nlevs, c_prec_move_alloc + + + ! + ! Interfaces to routines for checking the definition of the preconditioner, + ! for printing its description and for deallocating its data structure + ! + + interface amg_precfree + module procedure amg_cprecfree + end interface + + + interface amg_precdescr + subroutine amg_cfile_prec_descr(prec,iout,root) + import :: amg_cprec_type, psb_ipk_ + implicit none + ! Arguments + class(amg_cprec_type), intent(in) :: prec + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: root + end subroutine amg_cfile_prec_descr + end interface + + interface amg_sizeof + module procedure amg_cprec_sizeof + end interface + + interface amg_precapply + subroutine amg_cprecaply2_vect(prec,x,y,desc_data,info,trans,work) + import :: psb_cspmat_type, psb_desc_type, & + & psb_spk_, psb_c_vect_type, amg_cprec_type, psb_ipk_ + type(psb_desc_type),intent(in) :: desc_data + type(amg_cprec_type), intent(inout) :: prec + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_spk_),intent(inout), optional, target :: work(:) + end subroutine amg_cprecaply2_vect + subroutine amg_cprecaply1_vect(prec,x,desc_data,info,trans,work) + import :: psb_cspmat_type, psb_desc_type, & + & psb_spk_, psb_c_vect_type, amg_cprec_type, psb_ipk_ + type(psb_desc_type),intent(in) :: desc_data + type(amg_cprec_type), intent(inout) :: prec + type(psb_c_vect_type),intent(inout) :: x + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_spk_),intent(inout), optional, target :: work(:) + end subroutine amg_cprecaply1_vect + subroutine amg_cprecaply(prec,x,y,desc_data,info,trans,work) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, amg_cprec_type, psb_ipk_ + type(psb_desc_type),intent(in) :: desc_data + type(amg_cprec_type), intent(inout) :: prec + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_spk_),intent(inout), optional, target :: work(:) + end subroutine amg_cprecaply + subroutine amg_cprecaply1(prec,x,desc_data,info,trans) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, amg_cprec_type, psb_ipk_ + type(psb_desc_type),intent(in) :: desc_data + type(amg_cprec_type), intent(inout) :: prec + complex(psb_spk_),intent(inout) :: x(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + end subroutine amg_cprecaply1 + end interface + + interface + subroutine amg_cprecsetsm(prec,val,info,ilev,ilmax,pos) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, & + & amg_cprec_type, amg_c_base_smoother_type, psb_ipk_ + class(amg_cprec_type), target, intent(inout):: prec + class(amg_c_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + end subroutine amg_cprecsetsm + subroutine amg_cprecsetsv(prec,val,info,ilev,ilmax,pos) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, & + & amg_cprec_type, amg_c_base_solver_type, psb_ipk_ + class(amg_cprec_type), intent(inout) :: prec + class(amg_c_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + end subroutine amg_cprecsetsv + subroutine amg_cprecsetag(prec,val,info,ilev,ilmax,pos) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, & + & amg_cprec_type, amg_c_base_aggregator_type, psb_ipk_ + class(amg_cprec_type), intent(inout) :: prec + class(amg_c_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + end subroutine amg_cprecsetag + subroutine amg_ccprecseti(prec,what,val,info,ilev,ilmax,pos,idx) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, & + & amg_cprec_type, psb_ipk_ + class(amg_cprec_type), intent(inout) :: prec + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx + character(len=*), optional, intent(in) :: pos + end subroutine amg_ccprecseti + subroutine amg_ccprecsetr(prec,what,val,info,ilev,ilmax,pos,idx) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, & + & amg_cprec_type, psb_ipk_ + class(amg_cprec_type), intent(inout) :: prec + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx + character(len=*), optional, intent(in) :: pos + end subroutine amg_ccprecsetr + subroutine amg_ccprecsetc(prec,what,string,info,ilev,ilmax,pos,idx) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, & + & amg_cprec_type, psb_ipk_ + class(amg_cprec_type), intent(inout) :: prec + character(len=*), intent(in) :: what + character(len=*), intent(in) :: string + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx + character(len=*), optional, intent(in) :: pos + end subroutine amg_ccprecsetc + end interface + + interface amg_precinit + subroutine amg_cprecinit(ictxt,prec,ptype,info) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, & + & amg_cprec_type, psb_ipk_ + integer(psb_ipk_), intent(in) :: ictxt + class(amg_cprec_type), intent(inout) :: prec + character(len=*), intent(in) :: ptype + integer(psb_ipk_), intent(out) :: info + end subroutine amg_cprecinit + end interface amg_precinit + + interface amg_precbld + subroutine amg_cprecbld(a,desc_a,prec,info,amold,vmold,imold) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, & + & psb_c_base_sparse_mat, psb_c_base_vect_type, & + & psb_i_base_vect_type, amg_cprec_type, psb_ipk_ + implicit none + type(psb_cspmat_type), intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_cprec_type), intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! character, intent(in),optional :: upd + end subroutine amg_cprecbld + end interface amg_precbld + + interface amg_hierarchy_bld + subroutine amg_c_hierarchy_bld(a,desc_a,prec,info) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, & + & amg_cprec_type, psb_ipk_ + implicit none + type(psb_cspmat_type), intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_cprec_type), intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + ! character, intent(in),optional :: upd + end subroutine amg_c_hierarchy_bld + end interface amg_hierarchy_bld + + interface amg_smoothers_bld + subroutine amg_c_smoothers_bld(a,desc_a,prec,info,amold,vmold,imold) + import :: psb_cspmat_type, psb_desc_type, psb_spk_, & + & psb_c_base_sparse_mat, psb_c_base_vect_type, & + & psb_i_base_vect_type, amg_cprec_type, psb_ipk_ + implicit none + type(psb_cspmat_type), intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_cprec_type), intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! character, intent(in),optional :: upd + end subroutine amg_c_smoothers_bld + end interface amg_smoothers_bld + +contains + ! + ! Function returning a pointer to the smoother + ! + function amg_c_get_smootherp(prec,ilev) result(val) + implicit none + class(amg_cprec_type), target, intent(in) :: prec + integer(psb_ipk_), optional :: ilev + class(amg_c_base_smoother_type), pointer :: val + integer(psb_ipk_) :: ilev_ + + val => null() + if (present(ilev)) then + ilev_ = ilev + else + ! What is a good default? + ilev_ = 1 + end if + if (allocated(prec%precv)) then + if ((1<=ilev_).and.(ilev_<=size(prec%precv))) then + if (allocated(prec%precv(ilev_)%sm)) then + val => prec%precv(ilev_)%sm + end if + end if + end if + end function amg_c_get_smootherp + ! + ! Function returning a pointer to the solver + ! + function amg_c_get_solverp(prec,ilev) result(val) + implicit none + class(amg_cprec_type), target, intent(in) :: prec + integer(psb_ipk_), optional :: ilev + class(amg_c_base_solver_type), pointer :: val + integer(psb_ipk_) :: ilev_ + + val => null() + if (present(ilev)) then + ilev_ = ilev + else + ! What is a good default? + ilev_ = 1 + end if + if (allocated(prec%precv)) then + if ((1<=ilev_).and.(ilev_<=size(prec%precv))) then + if (allocated(prec%precv(ilev_)%sm)) then + if (allocated(prec%precv(ilev_)%sm%sv)) then + val => prec%precv(ilev_)%sm%sv + end if + end if + end if + end if + end function amg_c_get_solverp + ! + ! Function returning the size of the precv(:) array + ! + function amg_c_get_nlevs(prec) result(val) + implicit none + class(amg_cprec_type), intent(in) :: prec + integer(psb_ipk_) :: val + val = 0 + if (allocated(prec%precv)) then + val = size(prec%precv) + end if + end function amg_c_get_nlevs + ! + ! Function returning the size of the amg_prec_type data structure + ! in bytes or in number of nonzeros of the operator(s) involved. + ! + function amg_c_get_nzeros(prec) result(val) + implicit none + class(amg_cprec_type), intent(in) :: prec + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + if (allocated(prec%precv)) then + do i=1, size(prec%precv) + val = val + prec%precv(i)%get_nzeros() + end do + end if + end function amg_c_get_nzeros + + function amg_cprec_sizeof(prec) result(val) + implicit none + class(amg_cprec_type), intent(in) :: prec + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + val = val + psb_sizeof_ip + if (allocated(prec%precv)) then + do i=1, size(prec%precv) + val = val + prec%precv(i)%sizeof() + end do + end if + end function amg_cprec_sizeof + + ! + ! Operator complexity: ratio of total number + ! of nonzeros in the aggregated matrices at the + ! various level to the nonzeroes at the fine level + ! (original matrix) + ! + + function amg_c_get_compl(prec) result(val) + implicit none + class(amg_cprec_type), intent(in) :: prec + complex(psb_spk_) :: val + + val = prec%ag_data%op_complexity + + end function amg_c_get_compl + + subroutine amg_c_cmp_compl(prec) + + implicit none + class(amg_cprec_type), intent(inout) :: prec + + real(psb_spk_) :: num, den, nmin + integer(psb_ipk_) :: ictxt + integer(psb_ipk_) :: il + + num = -sone + den = sone + ictxt = prec%ictxt + if (allocated(prec%precv)) then + il = 1 + num = prec%precv(il)%base_a%get_nzeros() + if (num >= szero) then + den = num + do il=2,size(prec%precv) + num = num + max(0,prec%precv(il)%base_a%get_nzeros()) + end do + end if + end if + nmin = num + call psb_min(ictxt,nmin) + if (nmin < szero) then + num = szero + den = sone + else + call psb_sum(ictxt,num) + call psb_sum(ictxt,den) + end if + prec%ag_data%op_complexity = num/den + end subroutine amg_c_cmp_compl + + ! + ! Average coarsening ratio + ! + + function amg_c_get_avg_cr(prec) result(val) + implicit none + class(amg_cprec_type), intent(in) :: prec + complex(psb_spk_) :: val + + val = prec%ag_data%avg_cr + + end function amg_c_get_avg_cr + + subroutine amg_c_cmp_avg_cr(prec) + + implicit none + class(amg_cprec_type), intent(inout) :: prec + + real(psb_spk_) :: avgcr + integer(psb_ipk_) :: ictxt + integer(psb_ipk_) :: il, nl, iam, np + + + avgcr = szero + ictxt = prec%ictxt + call psb_info(ictxt,iam,np) + if (allocated(prec%precv)) then + nl = size(prec%precv) + do il=2,nl + avgcr = avgcr + max(szero,prec%precv(il)%szratio) + end do + avgcr = avgcr / (nl-1) + end if + call psb_sum(ictxt,avgcr) + prec%ag_data%avg_cr = avgcr/np + end subroutine amg_c_cmp_avg_cr + + ! + ! Subroutines: amg_Tprec_free + ! Version: complex + ! + ! These routines deallocate the amg_Tprec_type data structures. + ! + ! Arguments: + ! p - type(amg_Tprec_type), input. + ! The data structure to be deallocated. + ! info - integer, output. + ! error code. + ! + subroutine amg_cprecfree(p,info) + + implicit none + + ! Arguments + type(amg_cprec_type), intent(inout) :: p + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: me,err_act,i + character(len=20) :: name + + info=psb_success_ + name = 'amg_cprecfree' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; return + end if + + me=-1 + + call p%free(info) + + + return + + end subroutine amg_cprecfree + + subroutine amg_c_prec_free(prec,info) + + implicit none + + ! Arguments + class(amg_cprec_type), intent(inout) :: prec + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: me,err_act,i + character(len=20) :: name + + info=psb_success_ + name = 'amg_cprecfree' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + + me=-1 + if (allocated(prec%precv)) then + do i=1,size(prec%precv) + call prec%precv(i)%free(info) + end do + deallocate(prec%precv,stat=info) + end if + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_c_prec_free + + + + ! + ! Top level methods. + ! + subroutine amg_c_apply2_vect(prec,x,y,desc_data,info,trans,work) + implicit none + type(psb_desc_type),intent(in) :: desc_data + class(amg_cprec_type), intent(inout) :: prec + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_spk_),intent(inout), optional, target :: work(:) + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_prec_apply' + + call psb_erractionsave(err_act) + + select type(prec) + type is (amg_cprec_type) + call amg_precapply(prec,x,y,desc_data,info,trans,work) + class default + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_c_apply2_vect + + subroutine amg_c_apply1_vect(prec,x,desc_data,info,trans,work) + implicit none + type(psb_desc_type),intent(in) :: desc_data + class(amg_cprec_type), intent(inout) :: prec + type(psb_c_vect_type),intent(inout) :: x + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_spk_),intent(inout), optional, target :: work(:) + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_prec_apply' + + call psb_erractionsave(err_act) + + select type(prec) + type is (amg_cprec_type) + call amg_precapply(prec,x,desc_data,info,trans,work) + class default + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_c_apply1_vect + + + subroutine amg_c_apply2v(prec,x,y,desc_data,info,trans,work) + implicit none + type(psb_desc_type),intent(in) :: desc_data + class(amg_cprec_type), intent(inout) :: prec + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_spk_),intent(inout), optional, target :: work(:) + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_prec_apply' + + call psb_erractionsave(err_act) + + select type(prec) + type is (amg_cprec_type) + call amg_precapply(prec,x,y,desc_data,info,trans,work) + class default + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_c_apply2v + + subroutine amg_c_apply1v(prec,x,desc_data,info,trans) + implicit none + type(psb_desc_type),intent(in) :: desc_data + class(amg_cprec_type), intent(inout) :: prec + complex(psb_spk_),intent(inout) :: x(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_prec_apply' + + call psb_erractionsave(err_act) + + select type(prec) + type is (amg_cprec_type) + call amg_precapply(prec,x,desc_data,info,trans) + class default + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_c_apply1v + + + subroutine amg_c_dump(prec,info,istart,iend,iproc,prefix,head,& + & ac,rp,smoother,solver,tprol,& + & global_num) + + implicit none + class(amg_cprec_type), intent(in) :: prec + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: istart, iend, iproc + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver,ac, rp, tprol, global_num + integer(psb_ipk_) :: i, j, il1, iln, lev + integer(psb_ipk_) :: icontxt, iam, np, iproc_ + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + ! len of prefix_ + + info = 0 + icontxt = prec%ictxt + call psb_info(icontxt,iam,np) + + iln = size(prec%precv) + if (present(istart)) then + il1 = max(1,istart) + else + il1 = min(2,iln) + end if + if (present(iend)) then + iln = min(iln, iend) + end if + iproc_ = -1 + if (present(iproc)) then + iproc_ = iproc + end if + + if ((iproc_ == -1).or.(iproc_==iam)) then + do lev=il1, iln + call prec%precv(lev)%dump(lev,info,prefix=prefix,head=head,& + & ac=ac,smoother=smoother,solver=solver,rp=rp,tprol=tprol, & + & global_num=global_num) + end do + end if + end subroutine amg_c_dump + + subroutine amg_c_cnv(prec,info,amold,vmold,imold) + + implicit none + class(amg_cprec_type), intent(inout) :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + integer(psb_ipk_) :: i + + info = psb_success_ + if (allocated(prec%precv)) then + do i=1,size(prec%precv) + if (info == psb_success_ ) & + & call prec%precv(i)%cnv(info,amold=amold,vmold=vmold,imold=imold) + end do + end if + + end subroutine amg_c_cnv + + subroutine amg_c_clone(prec,precout,info) + + implicit none + class(amg_cprec_type), intent(inout) :: prec + class(psb_cprec_type), intent(inout) :: precout + integer(psb_ipk_), intent(out) :: info + + call precout%free(info) + if (info == 0) call amg_c_inner_clone(prec,precout,info) + + end subroutine amg_c_clone + + subroutine amg_c_inner_clone(prec,precout,info) + + implicit none + class(amg_cprec_type), intent(inout) :: prec + class(psb_cprec_type), target, intent(inout) :: precout + integer(psb_ipk_), intent(out) :: info + ! Local vars + integer(psb_ipk_) :: i, j, ln, lev + integer(psb_ipk_) :: icontxt,iam, np + + info = psb_success_ + select type(pout => precout) + class is (amg_cprec_type) + pout%ictxt = prec%ictxt + pout%ag_data = prec%ag_data + pout%outer_sweeps = prec%outer_sweeps + if (allocated(prec%precv)) then + ln = size(prec%precv) + allocate(pout%precv(ln),stat=info) + if (info /= psb_success_) goto 9999 + if (ln >= 1) then + call prec%precv(1)%clone(pout%precv(1),info) + end if + do lev=2, ln + if (info /= psb_success_) exit + call prec%precv(lev)%clone(pout%precv(lev),info) + if (info == psb_success_) then + pout%precv(lev)%base_a => pout%precv(lev)%ac + pout%precv(lev)%base_desc => pout%precv(lev)%desc_ac + pout%precv(lev)%map%p_desc_U => pout%precv(lev-1)%base_desc + pout%precv(lev)%map%p_desc_V => pout%precv(lev)%base_desc + end if + end do + end if + if (allocated(prec%precv(1)%wrk)) & + & call pout%allocate_wrk(info,vmold=prec%precv(1)%wrk%vx2l%v) + + class default + write(0,*) 'Error: wrong out type' + info = psb_err_invalid_input_ + end select +9999 continue + end subroutine amg_c_inner_clone + + subroutine c_prec_move_alloc(prec, b,info) + use psb_base_mod + implicit none + class(amg_cprec_type), intent(inout) :: prec + class(amg_cprec_type), intent(inout), target :: b + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: i + + if (same_type_as(prec,b)) then + if (allocated(b%precv)) then + ! This might not be required if FINAL procedures are available. + call b%free(info) + if (info /= psb_success_) then + !????? +!!$ return + endif + end if + b%ictxt = prec%ictxt + b%ag_data = prec%ag_data + b%outer_sweeps = prec%outer_sweeps + + call move_alloc(prec%precv,b%precv) + ! Fix the pointers except on level 1. + do i=2, size(b%precv) + b%precv(i)%base_a => b%precv(i)%ac + b%precv(i)%base_desc => b%precv(i)%desc_ac + b%precv(i)%map%p_desc_U => b%precv(i-1)%base_desc + b%precv(i)%map%p_desc_V => b%precv(i)%base_desc + end do + + else + write(0,*) 'Warning: PREC%move_alloc onto different type?' + info = psb_err_internal_error_ + end if + end subroutine c_prec_move_alloc + + subroutine amg_c_allocate_wrk(prec,info,vmold,desc) + use psb_base_mod + implicit none + + ! Arguments + class(amg_cprec_type), intent(inout) :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_vect_type), intent(in), optional :: vmold + ! + ! In MLD the DESC optional argument is ignored, since + ! the necessary info is contained in the various entries of the + ! PRECV component. + type(psb_desc_type), intent(in), optional :: desc + + ! Local variables + integer(psb_ipk_) :: me,err_act,i,j,level,nlev, nc2l + character(len=20) :: name + + info=psb_success_ + name = 'amg_c_allocate_wrk' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + nlev = size(prec%precv) + level = 1 + do level = 1, nlev + call prec%precv(level)%allocate_wrk(info,vmold=vmold) + if (psb_errstatus_fatal()) then + nc2l = prec%precv(level)%base_desc%get_local_cols() + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nc2l/), a_err='complex(psb_spk_)') + goto 9999 + end if + end do + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_c_allocate_wrk + + subroutine amg_c_free_wrk(prec,info) + use psb_base_mod + implicit none + + ! Arguments + class(amg_cprec_type), intent(inout) :: prec + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: me,err_act,i,j,level, nlev, nc2l + character(len=20) :: name + + info=psb_success_ + name = 'amg_c_free_wrk' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + + if (allocated(prec%precv)) then + nlev = size(prec%precv) + do level = 1, nlev + call prec%precv(level)%free_wrk(info) + end do + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_c_free_wrk + + function amg_c_is_allocated_wrk(prec) result(res) + use psb_base_mod + implicit none + + ! Arguments + class(amg_cprec_type), intent(in) :: prec + logical :: res + + res = .false. + if (.not.allocated(prec%precv)) return + res = allocated(prec%precv(1)%wrk) + + end function amg_c_is_allocated_wrk + +end module amg_c_prec_type diff --git a/mlprec/amg_c_slu_solver.F90 b/mlprec/amg_c_slu_solver.F90 new file mode 100644 index 00000000..845c0cb9 --- /dev/null +++ b/mlprec/amg_c_slu_solver.F90 @@ -0,0 +1,447 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_c_slu_solver_mod.f90 +! +! Module: amg_c_slu_solver_mod +! +! This module defines: +! - the amg_c_slu_solver_type data structure containing the ingredients +! to interface with the SuperLU package. +! 1. The factorization is restricted to the diagonal block of the +! current image. +! +module amg_c_slu_solver + + use iso_c_binding + use amg_c_base_solver_mod + +#if defined(IPK8) + + type, extends(amg_c_base_solver_type) :: amg_c_slu_solver_type + + end type amg_c_slu_solver_type + +#else + + type, extends(amg_c_base_solver_type) :: amg_c_slu_solver_type + type(c_ptr) :: lufactors=c_null_ptr + integer(c_long_long) :: symbsize=0, numsize=0 + contains + procedure, pass(sv) :: build => c_slu_solver_bld + procedure, pass(sv) :: apply_a => c_slu_solver_apply + procedure, pass(sv) :: apply_v => c_slu_solver_apply_vect + procedure, pass(sv) :: free => c_slu_solver_free + procedure, pass(sv) :: clear_data => c_slu_solver_clear_data + procedure, pass(sv) :: descr => c_slu_solver_descr + procedure, pass(sv) :: sizeof => c_slu_solver_sizeof + procedure, nopass :: get_fmt => c_slu_solver_get_fmt + procedure, nopass :: get_id => c_slu_solver_get_id + final :: c_slu_solver_finalize + end type amg_c_slu_solver_type + + + private :: c_slu_solver_bld, c_slu_solver_apply, & + & c_slu_solver_free, c_slu_solver_descr, & + & c_slu_solver_sizeof, c_slu_solver_apply_vect, & + & c_slu_solver_get_fmt, c_slu_solver_get_id, & + & c_slu_solver_clear_data + private :: c_slu_solver_finalize + + + + interface + function amg_cslu_fact(n,nnz,values,rowptr,colind,& + & lufactors)& + & bind(c,name='amg_cslu_fact') result(info) + use iso_c_binding + integer(c_int), value :: n,nnz + integer(c_int) :: info + integer(c_int) :: rowptr(*),colind(*) + complex(c_float_complex) :: values(*) + type(c_ptr) :: lufactors + end function amg_cslu_fact + end interface + + interface + function amg_cslu_solve(itrans,n,nrhs,b,ldb,lufactors)& + & bind(c,name='amg_cslu_solve') result(info) + use iso_c_binding + integer(c_int) :: info + integer(c_int), value :: itrans,n,nrhs,ldb + complex(c_float_complex) :: b(ldb,*) + type(c_ptr), value :: lufactors + end function amg_cslu_solve + end interface + + interface + function amg_cslu_free(lufactors)& + & bind(c,name='amg_cslu_free') result(info) + use iso_c_binding + integer(c_int) :: info + type(c_ptr), value :: lufactors + end function amg_cslu_free + end interface + +contains + + subroutine c_slu_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + use psb_base_mod + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_slu_solver_type), intent(inout) :: sv + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer, intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + + integer :: n_row,n_col + complex(psb_spk_), pointer :: ww(:) + integer :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='c_slu_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + else + allocate(ww(n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/n_col,0,0,0,0/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + endif + + ww(1:n_row) = x(1:n_row) + select case(trans_) + case('N') + info = amg_cslu_solve(0,n_row,1,ww,n_row,sv%lufactors) + case('T') + info = amg_cslu_solve(1,n_row,1,ww,n_row,sv%lufactors) + case('C') + info = amg_cslu_solve(2,n_row,1,ww,n_row,sv%lufactors) + case default + call psb_errpush(psb_err_internal_error_, & + & name,a_err='Invalid TRANS in ILU subsolve') + goto 9999 + end select + + if (info == psb_success_) & + & call psb_geaxpby(alpha,ww,beta,y,desc_data,info) + + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in subsolve') + goto 9999 + endif + + if (n_col > size(work)) then + deallocate(ww) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine c_slu_solver_apply + + subroutine c_slu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + use psb_base_mod + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_slu_solver_type), intent(inout) :: sv + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer, intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + + integer :: err_act + character(len=20) :: name='c_slu_solver_apply_vect' + + call psb_erractionsave(err_act) + + info = psb_success_ + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call x%v%sync() + call y%v%sync() + call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) + call y%v%set_host() + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine c_slu_solver_apply_vect + + subroutine c_slu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + + Implicit None + + ! Arguments + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_slu_solver_type), intent(inout) :: sv + integer, intent(out) :: info + type(psb_cspmat_type), intent(in), target, optional :: b + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + type(psb_cspmat_type) :: atmp + type(psb_c_csc_sparse_mat) :: acsc + type(psb_c_coo_sparse_mat) :: acoo + integer :: n_row,n_col, nrow_a, nztota + integer :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='c_slu_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + n_col = desc_a%get_local_cols() + + + call a%cscnv(atmp,info,type='coo') + call psb_rwextd(n_row,atmp,info,b=b) + call atmp%cscnv(info,type='coo',dupl=psb_dupl_add_) + nrow_a = atmp%get_nrows() + call atmp%a%csclip(acoo,info,jmax=nrow_a) + call acsc%mv_from_coo(acoo,info) + nztota = acsc%get_nzeros() + ! Fix the entries to call C-base SuperLU + acsc%ia(:) = acsc%ia(:) - 1 + acsc%icp(:) = acsc%icp(:) - 1 + info = amg_cslu_fact(nrow_a,nztota,acsc%val,& + & acsc%icp,acsc%ia,sv%lufactors) + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='amg_cslu_fact' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + call acsc%free() + call atmp%free() + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine c_slu_solver_bld + + subroutine c_slu_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_c_slu_solver_type), intent(inout) :: sv + integer, intent(out) :: info + Integer :: err_act + character(len=20) :: name='c_slu_solver_free' + + call psb_erractionsave(err_act) + + info = psb_success_ + + call sv%clear_data(info) + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine c_slu_solver_free + + subroutine c_slu_solver_clear_data(sv,info) + + Implicit None + + ! Arguments + class(amg_c_slu_solver_type), intent(inout) :: sv + integer, intent(out) :: info + Integer :: err_act + character(len=20) :: name='c_slu_solver_clear_data' + + call psb_erractionsave(err_act) + + info = psb_success_ + if (c_associated(sv%lufactors)) info = amg_cslu_free(sv%lufactors) + sv%lufactors = c_null_ptr + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine c_slu_solver_clear_data + + subroutine c_slu_solver_finalize(sv) + + Implicit None + + ! Arguments + type(amg_c_slu_solver_type), intent(inout) :: sv + integer :: info + Integer :: err_act + character(len=20) :: name='c_slu_solver_finalize' + + call sv%free(info) + + return + + end subroutine c_slu_solver_finalize + + subroutine c_slu_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_c_slu_solver_type), intent(in) :: sv + integer, intent(out) :: info + integer, intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer :: err_act + integer :: ictxt, me, np + character(len=20), parameter :: name='amg_c_slu_solver_descr' + integer :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' SuperLU Sparse Factorization Solver. ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine c_slu_solver_descr + + function c_slu_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_c_slu_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer :: i + + val = 2*psb_sizeof_ip + psb_sizeof_dp + val = val + sv%symbsize + val = val + sv%numsize + return + end function c_slu_solver_sizeof + + function c_slu_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "SuperLU solver" + end function c_slu_solver_get_fmt + + function c_slu_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_slu_ + end function c_slu_solver_get_id +#endif +end module amg_c_slu_solver diff --git a/mlprec/amg_c_symdec_aggregator_mod.f90 b/mlprec/amg_c_symdec_aggregator_mod.f90 new file mode 100644 index 00000000..ab7ca002 --- /dev/null +++ b/mlprec/amg_c_symdec_aggregator_mod.f90 @@ -0,0 +1,105 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! Locally symmetrized (decoupled) aggregation algorithm. +! This version differs from the basic decoupled aggregation algorithm +! only because it works on (the pattern of) A+A^T instead of A. +! +! +module amg_c_symdec_aggregator_mod + + use amg_c_dec_aggregator_mod + !> \namespace amg_c_symdec_aggregator_mod \class amg_c_symdec_aggregator_type + !! \extends amg_c_dec_aggregator_mod::amg_c_dec_aggregator_type + !! + !! This version differs from the basic decoupled aggregation algorithm + !! only because it works on (the pattern of) A+A^T instead of A. + !! + ! + type, extends(amg_c_dec_aggregator_type) :: amg_c_symdec_aggregator_type + + contains + procedure, pass(ag) :: bld_tprol => amg_c_symdec_aggregator_build_tprol + procedure, pass(ag) :: descr => amg_c_symdec_aggregator_descr + procedure, nopass :: fmt => amg_c_symdec_aggregator_fmt + end type amg_c_symdec_aggregator_type + + + interface + subroutine amg_c_symdec_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,t_prol,info) + import :: amg_c_symdec_aggregator_type, psb_desc_type, psb_cspmat_type, psb_spk_, & + & psb_ipk_, psb_lpk_, psb_lcspmat_type, amg_sml_parms, amg_saggr_data + implicit none + class(amg_c_symdec_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(amg_saggr_data), intent(in) :: ag_data + type(psb_cspmat_type), intent(inout) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lcspmat_type), intent(out) :: t_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_c_symdec_aggregator_build_tprol + end interface + + +contains + + function amg_c_symdec_aggregator_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Symmetric Decoupled aggregation" + end function amg_c_symdec_aggregator_fmt + + subroutine amg_c_symdec_aggregator_descr(ag,parms,iout,info) + implicit none + class(amg_c_symdec_aggregator_type), intent(in) :: ag + type(amg_sml_parms), intent(in) :: parms + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + + write(iout,*) 'Decoupled Aggregator locally-symmetrized' + write(iout,*) 'Aggregator object type: ',ag%fmt() + call parms%mldescr(iout,info) + + return + end subroutine amg_c_symdec_aggregator_descr + +end module amg_c_symdec_aggregator_mod diff --git a/mlprec/mld_const.h b/mlprec/amg_const.h similarity index 100% rename from mlprec/mld_const.h rename to mlprec/amg_const.h diff --git a/mlprec/amg_d_as_smoother.f90 b/mlprec/amg_d_as_smoother.f90 new file mode 100644 index 00000000..97645d04 --- /dev/null +++ b/mlprec/amg_d_as_smoother.f90 @@ -0,0 +1,471 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_d_as_smoother_mod.f90 +! +! Module: amg_d_as_smoother_mod +! +! This module defines: +! the amg_d_as_smoother_type data structure containing the +! smoother for an Additive Schwarz smoother. +! +! To begin with, the build procedure constructs the extended +! matrix A and its corresponding descriptor (this has multiple +! halo layers duplicated across different processes); it then +! stores in ND the block off-diagonal matrix, and builds the solver +! on the (extended) block diagonal matrix. +! +! The code allows for the variations of Additive Schwartz, Restricted +! Additive Schwartz and Additive Schwartz with Harmonic Extensions. +! From an implementation point of view, these are handled by +! combining application/non-application of the prolongator/restrictor +! operators. +! +module amg_d_as_smoother + + use amg_d_base_smoother_mod + + type, extends(amg_d_base_smoother_type) :: amg_d_as_smoother_type + ! The local solver component is inherited from the + ! parent type. + ! class(amg_d_base_solver_type), allocatable :: sv + ! + type(psb_dspmat_type) :: nd + type(psb_desc_type) :: desc_data + integer(psb_ipk_) :: novr, restr, prol + integer(psb_lpk_) :: nd_nnz_tot + contains + procedure, pass(sm) :: apply_v => amg_d_as_smoother_apply_vect + procedure, pass(sm) :: apply_a => amg_d_as_smoother_apply + procedure, pass(sm) :: check => amg_d_as_smoother_check + procedure, pass(sm) :: dump => amg_d_as_smoother_dmp + procedure, pass(sm) :: build => amg_d_as_smoother_bld + procedure, pass(sm) :: cnv => amg_d_as_smoother_cnv + procedure, pass(sm) :: clone => amg_d_as_smoother_clone + procedure, pass(sm) :: clone_settings => amg_d_as_smoother_clone_settings + procedure, pass(sm) :: clear_data => amg_d_as_smoother_clear_data + procedure, pass(sm) :: restr_a => amg_d_as_smoother_restr_a + procedure, pass(sm) :: prol_a => amg_d_as_smoother_prol_a + procedure, pass(sm) :: restr_v => amg_d_as_smoother_restr_v + procedure, pass(sm) :: prol_v => amg_d_as_smoother_prol_v + generic, public :: apply_restr => restr_v, restr_a + generic, public :: apply_prol => prol_v, prol_a + procedure, pass(sm) :: free => amg_d_as_smoother_free + procedure, pass(sm) :: cseti => amg_d_as_smoother_cseti + procedure, pass(sm) :: csetc => amg_d_as_smoother_csetc + procedure, pass(sm) :: descr => d_as_smoother_descr + procedure, pass(sm) :: sizeof => d_as_smoother_sizeof + procedure, pass(sm) :: default => d_as_smoother_default + procedure, pass(sm) :: get_nzeros => d_as_smoother_get_nzeros + procedure, pass(sm) :: get_wrksz => d_as_smoother_get_wrksize + procedure, nopass :: get_fmt => d_as_smoother_get_fmt + procedure, nopass :: get_id => d_as_smoother_get_id + end type amg_d_as_smoother_type + + + private :: d_as_smoother_descr, d_as_smoother_sizeof, & + & d_as_smoother_default, d_as_smoother_get_nzeros, & + & d_as_smoother_get_fmt, d_as_smoother_get_id, & + & d_as_smoother_get_wrksize + + character(len=6), parameter, private :: & + & restrict_names(0:4)=(/'none ','halo ',' ',' ',' '/) + character(len=12), parameter, private :: & + & prolong_names(0:3)=(/'none ','sum ','average ','square root'/) + + + interface + subroutine amg_d_as_smoother_check(sm,info) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dpk_, amg_d_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_d_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_as_smoother_check + end interface + + interface + subroutine amg_d_as_smoother_restr_v(sm,x,trans,work,info,data) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dpk_, amg_d_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + class(amg_d_as_smoother_type), intent(inout) :: sm + type(psb_d_vect_type),intent(inout) :: x + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + end subroutine amg_d_as_smoother_restr_v + end interface + + interface + subroutine amg_d_as_smoother_restr_a(sm,x,trans,work,info,data) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dpk_, amg_d_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + class(amg_d_as_smoother_type), intent(inout) :: sm + real(psb_dpk_), intent(inout) :: x(:) + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + end subroutine amg_d_as_smoother_restr_a + end interface + + interface + subroutine amg_d_as_smoother_prol_v(sm,x,trans,work,info,data) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dpk_, amg_d_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + class(amg_d_as_smoother_type), intent(inout) :: sm + type(psb_d_vect_type),intent(inout) :: x + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + end subroutine amg_d_as_smoother_prol_v + end interface + + interface + subroutine amg_d_as_smoother_prol_a(sm,x,trans,work,info,data) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dpk_, amg_d_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + class(amg_d_as_smoother_type), intent(inout) :: sm + real(psb_dpk_), intent(inout) :: x(:) + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + end subroutine amg_d_as_smoother_prol_a + end interface + + + interface + subroutine amg_d_as_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,wv,info,init,initu) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dpk_, amg_d_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_as_smoother_type), intent(inout) :: sm + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + end subroutine amg_d_as_smoother_apply_vect + end interface + + interface + subroutine amg_d_as_smoother_apply(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,info,init,initu) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dpk_, amg_d_as_smoother_type, psb_epk_,& + & psb_desc_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_as_smoother_type), intent(inout) :: sm + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_d_as_smoother_apply + end interface + + interface + subroutine amg_d_as_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dpk_, amg_d_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_d_base_sparse_mat, psb_ipk_,& + & psb_i_base_vect_type + implicit none + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_as_smoother_bld + end interface + + interface + subroutine amg_d_as_smoother_cnv(sm,info,amold,vmold,imold) + import :: psb_d_base_vect_type, & + & psb_dpk_, amg_d_as_smoother_type, psb_epk_, & + & psb_d_base_sparse_mat, psb_ipk_, psb_i_base_vect_type + implicit none + class(amg_d_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_as_smoother_cnv + end interface + + interface + subroutine amg_d_as_smoother_cseti(sm,what,val,info,idx) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dpk_, amg_d_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_d_as_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_d_as_smoother_cseti + end interface + + interface + subroutine amg_d_as_smoother_csetc(sm,what,val,info,idx) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dpk_, amg_d_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_d_as_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_d_as_smoother_csetc + end interface + + interface + subroutine amg_d_as_smoother_free(sm,info) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dpk_, amg_d_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_d_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_as_smoother_free + end interface + + interface + subroutine amg_d_as_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dpk_, amg_d_as_smoother_type, psb_epk_, psb_desc_type, & + & psb_ipk_ + implicit none + class(amg_d_as_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + end subroutine amg_d_as_smoother_dmp + end interface + + interface + subroutine amg_d_as_smoother_clone(sm,smout,info) + import :: amg_d_as_smoother_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_ + class(amg_d_as_smoother_type), intent(inout) :: sm + class(amg_d_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_as_smoother_clone + end interface + + + interface + subroutine amg_d_as_smoother_clone_settings(sm,smout,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_smoother_type, amg_d_as_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_as_smoother_type), intent(inout) :: sm + class(amg_d_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_as_smoother_clone_settings + end interface + + interface + subroutine amg_d_as_smoother_clear_data(sm,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_as_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_as_smoother_clear_data + end interface + + +contains + + function d_as_smoother_sizeof(sm) result(val) + implicit none + ! Arguments + class(amg_d_as_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 3*psb_sizeof_ip + psb_sizeof_lp + if (allocated(sm%sv)) val = val + sm%sv%sizeof() + val = val + sm%nd%sizeof() + + return + end function d_as_smoother_sizeof + + function d_as_smoother_get_nzeros(sm) result(val) + implicit none + class(amg_d_as_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + if (allocated(sm%sv)) & + & val = sm%sv%get_nzeros() + val = val + sm%nd%get_nzeros() + + end function d_as_smoother_get_nzeros + + subroutine d_as_smoother_default(sm) + + use psb_base_mod, only : psb_halo_, psb_none_ + + Implicit None + + ! Arguments + class(amg_d_as_smoother_type), intent(inout) :: sm + + ! + ! Default: AS with 1 overlap layer + ! + sm%restr = psb_halo_ + sm%prol = psb_sum_ + sm%novr = 1 + + if (allocated(sm%sv)) then + call sm%sv%default() + end if + + return + end subroutine d_as_smoother_default + + + subroutine d_as_smoother_descr(sm,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_d_as_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_d_as_smoother_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (.not.coarse_) then + write(iout_,*) ' Additive Schwarz with ',& + & sm%novr, ' overlap layers.' + write(iout_,*) ' Restrictor: ',restrict_names(sm%restr) + write(iout_,*) ' Prolongator: ',prolong_names(sm%prol) + write(iout_,*) ' Local solver:' + endif + if (allocated(sm%sv)) then + call sm%sv%descr(info,iout_,coarse=coarse) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine d_as_smoother_descr + + function d_as_smoother_get_wrksize(sm) result(val) + implicit none + class(amg_d_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_) :: val + + val = 3 + if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() + + end function d_as_smoother_get_wrksize + + function d_as_smoother_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Additive Schwarz" + end function d_as_smoother_get_fmt + + function d_as_smoother_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_as_ + end function d_as_smoother_get_id + +end module amg_d_as_smoother diff --git a/mlprec/amg_d_base_aggregator_mod.f90 b/mlprec/amg_d_base_aggregator_mod.f90 new file mode 100644 index 00000000..4d552f16 --- /dev/null +++ b/mlprec/amg_d_base_aggregator_mod.f90 @@ -0,0 +1,519 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! The aggregator object hosts the aggregation method for building +! the multilevel hierarchy. +! +module amg_d_base_aggregator_mod + + use amg_base_prec_type, only : amg_dml_parms, amg_daggr_data + use psb_base_mod, only : psb_dspmat_type, psb_ldspmat_type, psb_d_vect_type, & + & psb_d_base_vect_type, psb_dlinmap_type, psb_dpk_, & + & psb_ld_csr_sparse_mat, psb_ld_coo_sparse_mat, & + & psb_d_csr_sparse_mat, psb_d_coo_sparse_mat, & + & psb_ipk_, psb_epk_, psb_lpk_, psb_desc_type, psb_i_base_vect_type, & + & psb_erractionsave, psb_error_handler, psb_success_, psb_toupper + ! + ! + ! + !> \class amg_d_base_aggregator_type + !! + !! It is the data type containing the basic interface definition for + !! building a multigrid hierarchy by aggregation. The base object has no attributes, + !! it is intended to be essentially an abstract type. + !! + !! + !! type amg_d_base_aggregator_type + !! end type + !! + !! + !! Methods: + !! + !! bld_tprol - Build a tentative prolongator + !! + !! mat_bld - Build prolongator/restrictor and coarse matrix ac + !! + !! mat_asb - Convert prolongator/restrictor/coarse matrix + !! and fix their descriptor(s) + !! + !! update_next - Transfer information to the next level; default is + !! to do nothing, i.e. aggregators at different + !! levels are independent. + !! + !! default - Apply defaults + !! set_aggr_type - For aggregator that have internal options. + !! fmt - Return a short string description + !! descr - Print a more detailed description + !! + !! cseti, csetr, csetc - Set internal parameters, if any + ! + type amg_d_base_aggregator_type + ! Do we want to purge explicit zeros when aggregating? + logical :: do_clean_zeros + contains + procedure, pass(ag) :: bld_tprol => amg_d_base_aggregator_build_tprol + procedure, pass(ag) :: mat_bld => amg_d_base_aggregator_mat_bld + procedure, pass(ag) :: mat_asb => amg_d_base_aggregator_mat_asb + procedure, pass(ag) :: bld_map => amg_d_base_aggregator_bld_map + procedure, pass(ag) :: update_next => amg_d_base_aggregator_update_next + procedure, pass(ag) :: clone => amg_d_base_aggregator_clone + procedure, pass(ag) :: free => amg_d_base_aggregator_free + procedure, pass(ag) :: default => amg_d_base_aggregator_default + procedure, pass(ag) :: descr => amg_d_base_aggregator_descr + procedure, pass(ag) :: sizeof => amg_d_base_aggregator_sizeof + procedure, pass(ag) :: set_aggr_type => amg_d_base_aggregator_set_aggr_type + procedure, nopass :: fmt => amg_d_base_aggregator_fmt + procedure, pass(ag) :: cseti => amg_d_base_aggregator_cseti + procedure, pass(ag) :: csetr => amg_d_base_aggregator_csetr + procedure, pass(ag) :: csetc => amg_d_base_aggregator_csetc + generic, public :: set => cseti, csetr, csetc + procedure, nopass :: xt_desc => amg_d_base_aggregator_xt_desc + end type amg_d_base_aggregator_type + + abstract interface + subroutine amg_d_soc_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, psb_ipk_, psb_lpk_ + implicit none + integer(psb_ipk_), intent(in) :: iorder + logical, intent(in) :: clean_zeros + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + real(psb_dpk_), intent(in) :: theta + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_soc_map_bld + end interface + + interface amg_ptap + subroutine amg_d_ptap(a_csr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_cprol,coo_restr,info,desc_ax) + import :: psb_d_csr_sparse_mat, psb_dspmat_type, psb_desc_type, & + & psb_d_coo_sparse_mat, amg_dml_parms, psb_dpk_, psb_ipk_, psb_lpk_ + implicit none + type(psb_d_csr_sparse_mat), intent(inout) :: a_csr + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + type(amg_dml_parms), intent(inout) :: parms + type(psb_d_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr + type(psb_desc_type), intent(inout) :: desc_cprol + type(psb_dspmat_type), intent(out) :: ac + integer(psb_ipk_), intent(out) :: info + type(psb_desc_type), intent(inout), optional :: desc_ax + end subroutine amg_d_ptap +!!$ subroutine amg_d_ld_ptap(a_csr,desc_a,nlaggr,parms,ac,& +!!$ & coo_prol,desc_cprol,coo_restr,info,desc_ax) +!!$ import :: psb_d_csr_sparse_mat, psb_ldspmat_type, psb_desc_type, & +!!$ & psb_ld_coo_sparse_mat, amg_dml_parms, psb_dpk_, psb_ipk_, psb_lpk_ +!!$ implicit none +!!$ type(psb_d_csr_sparse_mat), intent(inout) :: a_csr +!!$ type(psb_desc_type), intent(in) :: desc_a +!!$ integer(psb_lpk_), intent(inout) :: nlaggr(:) +!!$ type(amg_dml_parms), intent(inout) :: parms +!!$ type(psb_ld_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr +!!$ type(psb_desc_type), intent(inout) :: desc_cprol +!!$ type(psb_ldspmat_type), intent(out) :: ac +!!$ integer(psb_ipk_), intent(out) :: info +!!$ type(psb_desc_type), intent(inout), optional :: desc_ax +!!$ end subroutine amg_d_ld_ptap +!!$ subroutine amg_ld_ptap(a_csr,desc_a,nlaggr,parms,ac,& +!!$ & coo_prol,desc_cprol,coo_restr,info,desc_ax) +!!$ import :: psb_ld_csr_sparse_mat, psb_ldspmat_type, psb_desc_type, & +!!$ & psb_ld_coo_sparse_mat, amg_dml_parms, psb_dpk_, psb_ipk_, psb_lpk_ +!!$ implicit none +!!$ type(psb_ld_csr_sparse_mat), intent(inout) :: a_csr +!!$ type(psb_desc_type), intent(in) :: desc_a +!!$ integer(psb_lpk_), intent(inout) :: nlaggr(:) +!!$ type(amg_dml_parms), intent(inout) :: parms +!!$ type(psb_ld_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr +!!$ type(psb_desc_type), intent(inout) :: desc_cprol +!!$ type(psb_ldspmat_type), intent(out) :: ac +!!$ integer(psb_ipk_), intent(out) :: info +!!$ type(psb_desc_type), intent(inout), optional :: desc_ax +!!$ end subroutine amg_ld_ptap + end interface amg_ptap + +contains + + subroutine amg_d_base_aggregator_cseti(ag,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_d_base_aggregator_type), intent(inout) :: ag + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + ! Do nothing + info = 0 + end subroutine amg_d_base_aggregator_cseti + + subroutine amg_d_base_aggregator_csetr(ag,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_d_base_aggregator_type), intent(inout) :: ag + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + ! Do nothing + info = 0 + end subroutine amg_d_base_aggregator_csetr + + subroutine amg_d_base_aggregator_csetc(ag,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_d_base_aggregator_type), intent(inout) :: ag + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + ! Set clean zeros, or do nothing. + select case (psb_toupper(trim(what))) + case('AGGR_CLEAN_ZEROS') + select case (psb_toupper(trim(val))) + case('TRUE','T') + ag%do_clean_zeros = .true. + case('FALSE','F') + ag%do_clean_zeros = .false. + end select + end select + info = 0 + end subroutine amg_d_base_aggregator_csetc + + + subroutine amg_d_base_aggregator_update_next(ag,agnext,info) + implicit none + class(amg_d_base_aggregator_type), target, intent(inout) :: ag, agnext + integer(psb_ipk_), intent(out) :: info + + ! + ! Base version does nothing. + ! + info = 0 + end subroutine amg_d_base_aggregator_update_next + + subroutine amg_d_base_aggregator_clone(ag,agnext,info) + implicit none + class(amg_d_base_aggregator_type), intent(inout) :: ag + class(amg_d_base_aggregator_type), allocatable, intent(inout) :: agnext + integer(psb_ipk_), intent(out) :: info + + info = 0 + if (allocated(agnext)) then + call agnext%free(info) + if (info == 0) deallocate(agnext,stat=info) + end if + if (info /= 0) return + allocate(agnext,source=ag,stat=info) + + end subroutine amg_d_base_aggregator_clone + + subroutine amg_d_base_aggregator_free(ag,info) + implicit none + class(amg_d_base_aggregator_type), intent(inout) :: ag + integer(psb_ipk_), intent(out) :: info + + info = psb_success_ + return + end subroutine amg_d_base_aggregator_free + + subroutine amg_d_base_aggregator_default(ag) + implicit none + class(amg_d_base_aggregator_type), intent(inout) :: ag + ! Only one default setting + ag%do_clean_zeros = .true. + + return + end subroutine amg_d_base_aggregator_default + + function amg_d_base_aggregator_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Default aggregator " + end function amg_d_base_aggregator_fmt + + function amg_d_base_aggregator_sizeof(ag) result(val) + implicit none + class(amg_d_base_aggregator_type), intent(in) :: ag + integer(psb_epk_) :: val + + val = 1 + end function amg_d_base_aggregator_sizeof + + function amg_d_base_aggregator_xt_desc() result(val) + implicit none + logical :: val + + val = .false. + end function amg_d_base_aggregator_xt_desc + + subroutine amg_d_base_aggregator_descr(ag,parms,iout,info) + implicit none + class(amg_d_base_aggregator_type), intent(in) :: ag + type(amg_dml_parms), intent(in) :: parms + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + + write(iout,*) 'Aggregator object type: ',ag%fmt() + call parms%mldescr(iout,info) + + return + end subroutine amg_d_base_aggregator_descr + + subroutine amg_d_base_aggregator_set_aggr_type(ag,parms,info) + implicit none + class(amg_d_base_aggregator_type), intent(inout) :: ag + type(amg_dml_parms), intent(in) :: parms + integer(psb_ipk_), intent(out) :: info + + ! Do nothing + + return + end subroutine amg_d_base_aggregator_set_aggr_type + + ! + !> Function bld_tprol: + !! \memberof amg_d_base_aggregator_type + !! \brief Build a tentative prolongator. + !! The routine will map the local matrix entries to aggregates. + !! The mapping is store in ILAGGR; for each local row index I, + !! ILAGGR(I) contains the index of the aggregate to which index I + !! will contribute, in global numbering. + !! Many aggregations produce a binary tentative prolongator, but some + !! do not, hence we also need the OP_PROL output. + !! AG_DATA is passed here just in case some of the + !! aggregators need it internally, most of them will ignore. + !! + !! \param ag The input aggregator object + !! \param parms The auxiliary parameters object + !! \param ag_data Auxiliary global aggregation info + !! \param a The local matrix part + !! \param desc_a The descriptor + !! \param ilaggr Output aggregation map + !! \param nlaggr Sizes of ilaggr on all processes + !! \param op_prol The tentative prolongator operator + !! \param info Return code + !! + ! + subroutine amg_d_base_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,t_prol,info) + use psb_base_mod + implicit none + class(amg_d_base_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(amg_daggr_data), intent(in) :: ag_data + type(psb_dspmat_type), intent(inout) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_ldspmat_type), intent(out) :: t_prol + integer(psb_ipk_), intent(out) :: info + + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_aggregator_build_tprol' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + + end subroutine amg_d_base_aggregator_build_tprol + + ! + !> Function mat_bld + !! \memberof amg_d_base_aggregator_type + !! \brief Build prolongator/restrictor/coarse matrix. + !! + !! + !! \param ag The input aggregator object + !! \param parms The auxiliary parameters object + !! \param a The local matrix part + !! \param desc_a The descriptor + !! \param ilaggr Aggregation map + !! \param nlaggr Sizes of ilaggr on all processes + !! \param ac On output the coarse matrix + !! \param op_prol On input, the tentative prolongator operator, on output + !! the final prolongator + !! \param op_restr On output, the restrictor operator; + !! in many cases it is the transpose of the prolongator. + !! \param info Return code + !! + subroutine amg_d_base_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + use psb_base_mod + implicit none + class(amg_d_base_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(psb_ldspmat_type), intent(inout) :: t_prol + type(psb_dspmat_type), intent(out) :: op_prol, ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_aggregator_mat_bld' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + end subroutine amg_d_base_aggregator_mat_bld + + ! + !> Function mat_asb + !! \memberof amg_d_base_aggregator_type + !! \brief Build prolongator/restrictor/coarse matrix. + !! + !! + !! \param ag The input aggregator object + !! \param parms The auxiliary parameters object + !! \param a The local matrix part + !! \param desc_a The descriptor + !! \param ilaggr Aggregation map + !! \param nlaggr Sizes of ilaggr on all processes + !! \param ac On output the coarse matrix + !! \param op_prol On input, the tentative prolongator operator, on output + !! the final prolongator + !! \param op_restr On output, the restrictor operator; + !! in many cases it is the transpose of the prolongator. + !! \param info Return code + !! + subroutine amg_d_base_aggregator_mat_asb(ag,parms,a,desc_a,& + & ac,desc_ac, op_prol,op_restr,info) + use psb_base_mod + implicit none + class(amg_d_base_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + type(psb_dspmat_type), intent(inout) :: op_prol,ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_aggregator_mat_asb' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + end subroutine amg_d_base_aggregator_mat_asb + + ! + !> Function bld_map + !! \memberof amg_d_base_aggregator_type + !! \brief Build linear map between hierarchy levels + !! + !! + !! \param ag The input aggregator object + !! \param desc_a The fine space descriptor + !! \param desc_ac The coarse space descriptor + !! \param ilaggr Aggregation map vector + !! \param nlaggr Sizes of ilaggr on all processes + !! \param op_prol The prolongator operator + !! \param op_restr The restrictor operator + !! \param map The output map + !! \param info Return code + !! + subroutine amg_d_base_aggregator_bld_map(ag,desc_a,desc_ac,ilaggr,nlaggr,& + & op_restr,op_prol,map,info) + use psb_base_mod + implicit none + class(amg_d_base_aggregator_type), target, intent(inout) :: ag + type(psb_desc_type), intent(in), target :: desc_a, desc_ac + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(psb_dspmat_type), intent(inout) :: op_restr, op_prol + type(psb_dlinmap_type), intent(out) :: map + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_aggregator_bld_map' + + call psb_erractionsave(err_act) + ! + ! Copy the prolongation/restriction matrices into the descriptor map. + ! op_restr => PR^T i.e. restriction operator + ! op_prol => PR i.e. prolongation operator + ! + ! WARNING: need to check whether the copy into IOP_RESTR/IOP_PROL + ! is safe or not. + ! + ! This default implementation reuses desc_a/desc_ac through + ! pointers in the map structure. + ! + map = psb_linmap(psb_map_aggr_,desc_a,& + & desc_ac,op_restr,op_prol,ilaggr,nlaggr) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + end subroutine amg_d_base_aggregator_bld_map + + +end module amg_d_base_aggregator_mod diff --git a/mlprec/amg_d_base_smoother_mod.f90 b/mlprec/amg_d_base_smoother_mod.f90 new file mode 100644 index 00000000..8a53dfeb --- /dev/null +++ b/mlprec/amg_d_base_smoother_mod.f90 @@ -0,0 +1,412 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_d_base_smoother_mod.f90 +! +! Module: amg_d_base_smoother_mod +! +! This module defines: +! - the amg_d_base_smoother_type data structure containing the +! smoother and related data structures; +! +! It contains routines for +! - Building and applying; +! - checking if the smoother is correctly defined; +! - printing a description of the preconditioner; +! - deallocating the preconditioner data structure. +! +! What is the difference between a smoother and a solver? +! In the mathematics literature the two concepts are treated +! essentially as synonymous, but here we are using them in a more +! computer-science oriented fashion. In particular, a SMOOTHER object +! contains a SOLVER object: the SOLVER operates locally within the +! current process, whereas the SMOOTHER object accounts for (possible) +! interactions between processes. +! Some solvers (MUMPS and SuperLU_DIST) can also operate on the entire +! distributed matrix, in which case the smoother object essentially +! becomes transparent. +! +module amg_d_base_smoother_mod + + use amg_d_base_solver_mod + use psb_base_mod, only : psb_desc_type, psb_dspmat_type, psb_epk_,& + & psb_d_vect_type, psb_d_base_vect_type, psb_d_base_sparse_mat, & + & psb_dpk_, psb_i_base_vect_type, psb_erractionsave, psb_error_handler + + ! + ! + ! + ! Type: amg_T_base_smoother_type. + ! + ! It holds the smoother a single level. Its only mandatory component is a solver + ! object which holds a local solver; this decoupling allows to have the same solver + ! e.g ILU to work with Jacobi with multiple sweeps as well as with any AS variant. + ! + ! type amg_T_base_smoother_type + ! class(amg_T_base_solver_type), allocatable :: sv + ! end type amg_T_base_smoother_type + ! + ! Methods: + ! + ! build - Compute the actual contents of the smoother; includes + ! invocation of the build method on the solver component. + ! free - Release memory + ! apply - Apply the smoother to a vector (or to an array); includes + ! invocation of the apply method on the solver component. + ! descr - Prints a description of the object. + ! default - Set default values + ! dump - Dump to file object contents + ! set - Sets various parameters; when a request is unknown + ! it is passed to the solver object for further processing. + ! check - Sanity checks. + ! sizeof - Total memory occupation in bytes + ! get_nzeros - Number of nonzeros + ! stringval - convert string to val for internal parms + ! get_fmt - short string descriptor + ! get_id - numeric id descriptro + ! get_wrksz - How many workspace vector does apply_vect need + ! + ! + ! + + type amg_d_base_smoother_type + class(amg_d_base_solver_type), allocatable :: sv + contains + procedure, pass(sm) :: apply_v => amg_d_base_smoother_apply_vect + procedure, pass(sm) :: apply_a => amg_d_base_smoother_apply + generic, public :: apply => apply_a, apply_v + procedure, pass(sm) :: check => amg_d_base_smoother_check + procedure, pass(sm) :: dump => amg_d_base_smoother_dmp + procedure, pass(sm) :: clone => amg_d_base_smoother_clone + procedure, pass(sm) :: build => amg_d_base_smoother_bld + procedure, pass(sm) :: cnv => amg_d_base_smoother_cnv + procedure, pass(sm) :: free => amg_d_base_smoother_free + procedure, pass(sm) :: clone_settings => amg_d_base_smoother_clone_settings + procedure, pass(sm) :: clear_data => amg_d_base_smoother_clear_data + procedure, pass(sm) :: cseti => amg_d_base_smoother_cseti + procedure, pass(sm) :: csetc => amg_d_base_smoother_csetc + procedure, pass(sm) :: csetr => amg_d_base_smoother_csetr + generic, public :: set => cseti, csetc, csetr + procedure, pass(sm) :: default => d_base_smoother_default + procedure, pass(sm) :: descr => amg_d_base_smoother_descr + procedure, pass(sm) :: sizeof => d_base_smoother_sizeof + procedure, pass(sm) :: get_nzeros => d_base_smoother_get_nzeros + procedure, pass(sm) :: get_wrksz => d_base_smoother_get_wrksize + procedure, nopass :: stringval => amg_stringval + procedure, nopass :: get_fmt => d_base_smoother_get_fmt + procedure, nopass :: get_id => d_base_smoother_get_id + end type amg_d_base_smoother_type + + + private :: d_base_smoother_sizeof, d_base_smoother_get_fmt, & + & d_base_smoother_default, d_base_smoother_get_nzeros, & + & d_base_smoother_get_id, d_base_smoother_get_wrksize + + + + interface + subroutine amg_d_base_smoother_apply(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,info,init,initu) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_base_smoother_type), intent(inout) :: sm + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_d_base_smoother_apply + end interface + + interface + subroutine amg_d_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,wv,info,init,initu) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_base_smoother_type), intent(inout) :: sm + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + end subroutine amg_d_base_smoother_apply_vect + end interface + + interface + subroutine amg_d_base_smoother_check(sm,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_base_smoother_check + end interface + + interface + subroutine amg_d_base_smoother_cseti(sm,what,val,info,idx) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_d_base_smoother_cseti + end interface + + interface + subroutine amg_d_base_smoother_csetc(sm,what,val,info,idx) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_ + class(amg_d_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_d_base_smoother_csetc + end interface + + interface + subroutine amg_d_base_smoother_csetr(sm,what,val,info,idx) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_d_base_smoother_csetr + end interface + + interface + subroutine amg_d_base_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_, psb_i_base_vect_type + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_base_smoother_bld + end interface + + interface + subroutine amg_d_base_smoother_cnv(sm,info,amold,vmold,imold) + import :: psb_d_base_sparse_mat, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_, psb_i_base_vect_type + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_base_smoother_cnv + end interface + + interface + subroutine amg_d_base_smoother_free(sm,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_base_smoother_free + end interface + + interface + subroutine amg_d_base_smoother_descr(sm,info,iout,coarse) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_d_base_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + end subroutine amg_d_base_smoother_descr + end interface + + interface + subroutine amg_d_base_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_ + class(amg_d_base_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + end subroutine amg_d_base_smoother_dmp + end interface + + interface + subroutine amg_d_base_smoother_clone(sm,smout,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + class(amg_d_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_base_smoother_clone + end interface + + interface + subroutine amg_d_base_smoother_clone_settings(sm,smout,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + class(amg_d_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_base_smoother_clone_settings + end interface + + interface + subroutine amg_d_base_smoother_clear_data(sm,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_base_smoother_clear_data + end interface + +contains + ! + ! Function returning the size of the amg_prec_type data structure + ! in bytes or in number of nonzeros of the operator(s) involved. + ! + + function d_base_smoother_get_nzeros(sm) result(val) + implicit none + class(amg_d_base_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + if (allocated(sm%sv)) & + & val = sm%sv%get_nzeros() + end function d_base_smoother_get_nzeros + + function d_base_smoother_sizeof(sm) result(val) + implicit none + ! Arguments + class(amg_d_base_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + if (allocated(sm%sv)) then + val = sm%sv%sizeof() + end if + + return + end function d_base_smoother_sizeof + + ! + ! Set sensible defaults. + ! To be called immediately after allocation + ! + subroutine d_base_smoother_default(sm) + implicit none + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + ! Do nothing for base version + + if (allocated(sm%sv)) call sm%sv%default() + + return + end subroutine d_base_smoother_default + + function d_base_smoother_get_wrksize(sm) result(val) + implicit none + class(amg_d_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_) :: val + + val = 0 + if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() + + end function d_base_smoother_get_wrksize + + function d_base_smoother_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Base smoother" + end function d_base_smoother_get_fmt + + function d_base_smoother_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_base_smooth_ + end function d_base_smoother_get_id + +end module amg_d_base_smoother_mod diff --git a/mlprec/amg_d_base_solver_mod.f90 b/mlprec/amg_d_base_solver_mod.f90 new file mode 100644 index 00000000..e2b33186 --- /dev/null +++ b/mlprec/amg_d_base_solver_mod.f90 @@ -0,0 +1,421 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_d_base_solver_mod.f90 +! +! Module: amg_d_base_solver_mod +! +! This module defines: +! - the amg_d_base_solver_type data structure containing the +! basic solver type acting on a subdomain +! +! It contains routines for +! - Building and applying; +! - checking if the solver is correctly defined; +! - printing a description of the solver; +! - deallocating the data structure. +! + +module amg_d_base_solver_mod + + use amg_base_prec_type + use psb_base_mod, only : psb_dspmat_type, & + & psb_d_vect_type, psb_d_base_vect_type, psb_d_base_sparse_mat, & + & psb_dpk_, psb_i_base_vect_type, psb_erractionsave, psb_error_handler + ! + ! + ! Type: amg_T_base_solver_type. + ! + ! It holds the local solver; it has no mandatory components. + ! + ! type amg_T_base_solver_type + ! end type amg_T_base_solver_type + ! + ! build - Compute the actual contents of the smoother; includes + ! invocation of the build method on the solver component. + ! free - Release memory + ! apply - Apply the smoother to a vector (or to an array); includes + ! invocation of the apply method on the solver component. + ! descr - Prints a description of the object. + ! default - Set default values + ! dump - Dump to file object contents + ! set - Sets various parameters; when a request is unknown + ! it is passed to the smoother object for further processing. + ! check - Sanity checks. + ! sizeof - Total memory occupation in bytes + ! get_nzeros - Number of nonzeros + ! stringval - convert string to val for internal parms + ! get_fmt - short string descriptor + ! get_id - numeric id descriptro + ! get_wrksz - How many workspace vector does apply_vect need + ! + ! + + type amg_d_base_solver_type + contains + procedure, pass(sv) :: apply_v => amg_d_base_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_d_base_solver_apply + generic, public :: apply => apply_a, apply_v + procedure, pass(sv) :: check => amg_d_base_solver_check + procedure, pass(sv) :: dump => amg_d_base_solver_dmp + procedure, pass(sv) :: clone => amg_d_base_solver_clone + procedure, pass(sv) :: clone_settings => amg_d_base_solver_clone_settings + procedure, pass(sv) :: clear_data => amg_d_base_solver_clear_data + procedure, pass(sv) :: build => amg_d_base_solver_bld + procedure, pass(sv) :: cnv => amg_d_base_solver_cnv + procedure, pass(sv) :: free => amg_d_base_solver_free + procedure, pass(sv) :: cseti => amg_d_base_solver_cseti + procedure, pass(sv) :: csetc => amg_d_base_solver_csetc + procedure, pass(sv) :: csetr => amg_d_base_solver_csetr + generic, public :: set => cseti, csetc, csetr + procedure, pass(sv) :: default => d_base_solver_default + procedure, pass(sv) :: descr => amg_d_base_solver_descr + procedure, pass(sv) :: sizeof => d_base_solver_sizeof + procedure, pass(sv) :: get_nzeros => d_base_solver_get_nzeros + procedure, nopass :: get_wrksz => d_base_solver_get_wrksize + procedure, nopass :: stringval => amg_stringval + procedure, nopass :: get_fmt => d_base_solver_get_fmt + procedure, nopass :: get_id => d_base_solver_get_id + procedure, nopass :: is_iterative => d_base_solver_is_iterative + procedure, pass(sv) :: is_global => d_base_solver_is_global + end type amg_d_base_solver_type + + private :: d_base_solver_sizeof, d_base_solver_default,& + & d_base_solver_get_nzeros, d_base_solver_get_fmt, & + & d_base_solver_is_iterative, d_base_solver_get_id, & + & d_base_solver_get_wrksize, d_base_solver_is_global + + + interface + subroutine amg_d_base_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_base_solver_type), intent(inout) :: sv + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_d_base_solver_apply + end interface + + + interface + subroutine amg_d_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_base_solver_type), intent(inout) :: sv + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + end subroutine amg_d_base_solver_apply_vect + end interface + + interface + subroutine amg_d_base_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, psb_ipk_, psb_i_base_vect_type + Implicit None + + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_base_solver_bld + end interface + + interface + subroutine amg_d_base_solver_cnv(sv,info,amold,vmold,imold) + import :: psb_d_base_sparse_mat, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, psb_ipk_, psb_i_base_vect_type + Implicit None + + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_base_solver_cnv + end interface + + interface + subroutine amg_d_base_solver_check(sv,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_base_solver_check + end interface + + interface + subroutine amg_d_base_solver_cseti(sv,what,val,info,idx) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_d_base_solver_cseti + end interface + + interface + subroutine amg_d_base_solver_csetc(sv,what,val,info,idx) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_d_base_solver_csetc + end interface + + interface + subroutine amg_d_base_solver_csetr(sv,what,val,info,idx) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, psb_ipk_ + Implicit None + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_d_base_solver_csetr + end interface + + interface + subroutine amg_d_base_solver_free(sv,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_base_solver_free + end interface + + interface + subroutine amg_d_base_solver_descr(sv,info,iout,coarse) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_base_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + end subroutine amg_d_base_solver_descr + end interface + + interface + subroutine amg_d_base_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, psb_ipk_ + implicit none + class(amg_d_base_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_d_base_solver_dmp + end interface + + interface + subroutine amg_d_base_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_base_solver_clone + end interface + + interface + subroutine amg_d_base_solver_clone_settings(sv,svout,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_base_solver_clone_settings + end interface + + interface + subroutine amg_d_base_solver_clear_data(sv,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_base_solver_clear_data + end interface + +contains + ! + ! Function returning the size of the data structure + ! in bytes or in number of nonzeros of the operator(s) involved. + ! + + function d_base_solver_sizeof(sv) result(val) + implicit none + ! Arguments + class(amg_d_base_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + + return + end function d_base_solver_sizeof + + function d_base_solver_get_nzeros(sv) result(val) + implicit none + class(amg_d_base_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + end function d_base_solver_get_nzeros + + subroutine d_base_solver_default(sv) + implicit none + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + ! Do nothing for base version + + return + end subroutine d_base_solver_default + + function d_base_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Base solver" + end function d_base_solver_get_fmt + + ! + ! If this is true, then the solver needs a starting + ! guess. Currently only handled in JAC smoother. + ! + function d_base_solver_is_iterative() result(val) + implicit none + logical :: val + + val = .false. + end function d_base_solver_is_iterative + ! + ! Is the solver acting globally? In most cases + ! not, SuperLU_Dist does, MUMPS can do either. + ! + function d_base_solver_is_global(sv) result(val) + implicit none + class(amg_d_base_solver_type), intent(in) :: sv + logical :: val + + val = .false. + end function d_base_solver_is_global + + function d_base_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_f_none_ + end function d_base_solver_get_id + + function d_base_solver_get_wrksize() result(val) + implicit none + integer(psb_ipk_) :: val + + val = 0 + end function d_base_solver_get_wrksize + +end module amg_d_base_solver_mod diff --git a/mlprec/amg_d_dec_aggregator_mod.f90 b/mlprec/amg_d_dec_aggregator_mod.f90 new file mode 100644 index 00000000..10c9d7ef --- /dev/null +++ b/mlprec/amg_d_dec_aggregator_mod.f90 @@ -0,0 +1,201 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! Basic (decoupled) aggregation algorithm. Based on the ideas in +! M. Brezina and P. Vanek, A black-box iterative solver based on a +! two-level Schwarz method, Computing, 63 (1999), 233-263. +! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed +! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 +! (1996), 179-196. +! +module amg_d_dec_aggregator_mod + + use amg_d_base_aggregator_mod + !> \namespace amg_d_dec_aggregator_mod \class amg_d_dec_aggregator_type + !! \extends amg_d_base_aggregator_mod::amg_d_base_aggregator_type + !! + !! type, extends(amg_d_base_aggregator_type) :: amg_d_dec_aggregator_type + !! procedure(amg_d_soc_map_bld), nopass, pointer :: soc_map_bld => null() + !! end type + !! + !! This is the simplest aggregation method: starting from the + !! strength-of-connection measure for defining the aggregation + !! presented in + !! + !! M. Brezina and P. Vanek, A black-box iterative solver based on a + !! two-level Schwarz method, Computing, 63 (1999), 233-263. + !! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed + !! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 + !! (1996), 179-196. + !! + !! it achieves parallelization by simply acting on the local matrix, + !! i.e. by "decoupling" the subdomains. + !! The data structure hosts a "map_bld" function pointer which allows to + !! choose other ways to measure "strength-of-connection", of which the + !! Vanek-Brezina-Mandel is the default. More details are available in + !! + !! P. D'Ambra, D. di Serafino and S. Filippone, On the development of + !! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math. + !! 57 (2007), 1181-1196. + !! + !! The soc_map_bld method is used inside the implementation of build_tprol + !! + ! + ! + type, extends(amg_d_base_aggregator_type) :: amg_d_dec_aggregator_type + procedure(amg_d_soc_map_bld), nopass, pointer :: soc_map_bld => null() + + contains + procedure, pass(ag) :: bld_tprol => amg_d_dec_aggregator_build_tprol + procedure, pass(ag) :: mat_bld => amg_d_dec_aggregator_mat_bld + procedure, pass(ag) :: mat_asb => amg_d_dec_aggregator_mat_asb + procedure, pass(ag) :: default => amg_d_dec_aggregator_default + procedure, pass(ag) :: set_aggr_type => amg_d_dec_aggregator_set_aggr_type + procedure, pass(ag) :: descr => amg_d_dec_aggregator_descr + procedure, nopass :: fmt => amg_d_dec_aggregator_fmt + end type amg_d_dec_aggregator_type + + + procedure(amg_d_soc_map_bld) :: amg_d_soc1_map_bld, amg_d_soc2_map_bld + + interface + subroutine amg_d_dec_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,t_prol,info) + import :: amg_d_dec_aggregator_type, psb_desc_type, psb_dspmat_type, psb_dpk_, & + & psb_ipk_, psb_lpk_, psb_ldspmat_type, amg_dml_parms, amg_daggr_data + implicit none + class(amg_d_dec_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(amg_daggr_data), intent(in) :: ag_data + type(psb_dspmat_type), intent(inout) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_ldspmat_type), intent(out) :: t_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_dec_aggregator_build_tprol + end interface + + interface + subroutine amg_d_dec_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + import :: amg_d_dec_aggregator_type, psb_desc_type, psb_dspmat_type, psb_dpk_, & + & psb_ipk_, psb_lpk_, psb_ldspmat_type, amg_dml_parms + implicit none + class(amg_d_dec_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(psb_ldspmat_type), intent(inout) :: t_prol + type(psb_dspmat_type), intent(out) :: op_prol, ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_dec_aggregator_mat_bld + end interface + + interface + subroutine amg_d_dec_aggregator_mat_asb(ag,parms,a,desc_a,& + & ac,desc_ac,op_prol,op_restr,info) + import :: amg_d_dec_aggregator_type, psb_desc_type, psb_dspmat_type, psb_dpk_, & + & psb_ipk_, psb_lpk_, psb_ldspmat_type, amg_dml_parms + implicit none + class(amg_d_dec_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + type(psb_dspmat_type), intent(inout) :: op_prol,ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_dec_aggregator_mat_asb + end interface + +contains + + subroutine amg_d_dec_aggregator_set_aggr_type(ag,parms,info) + use amg_base_prec_type + implicit none + class(amg_d_dec_aggregator_type), intent(inout) :: ag + type(amg_dml_parms), intent(in) :: parms + integer(psb_ipk_), intent(out) :: info + + select case(parms%aggr_type) + case (amg_noalg_) + ag%soc_map_bld => null() + case (amg_soc1_) + ag%soc_map_bld => amg_d_soc1_map_bld + case (amg_soc2_) + ag%soc_map_bld => amg_d_soc2_map_bld + case default + write(0,*) 'Unknown aggregation type, defaulting to SOC1' + ag%soc_map_bld => amg_d_soc1_map_bld + end select + + return + end subroutine amg_d_dec_aggregator_set_aggr_type + + + subroutine amg_d_dec_aggregator_default(ag) + implicit none + class(amg_d_dec_aggregator_type), intent(inout) :: ag + + call ag%amg_d_base_aggregator_type%default() + ag%soc_map_bld => amg_d_soc1_map_bld + + return + end subroutine amg_d_dec_aggregator_default + + function amg_d_dec_aggregator_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Decoupled aggregation" + end function amg_d_dec_aggregator_fmt + + subroutine amg_d_dec_aggregator_descr(ag,parms,iout,info) + implicit none + class(amg_d_dec_aggregator_type), intent(in) :: ag + type(amg_dml_parms), intent(in) :: parms + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + + write(iout,*) 'Decoupled Aggregator' + write(iout,*) 'Aggregator object type: ',ag%fmt() + call parms%mldescr(iout,info) + + return + end subroutine amg_d_dec_aggregator_descr + +end module amg_d_dec_aggregator_mod diff --git a/mlprec/amg_d_diag_solver.f90 b/mlprec/amg_d_diag_solver.f90 new file mode 100644 index 00000000..5724284f --- /dev/null +++ b/mlprec/amg_d_diag_solver.f90 @@ -0,0 +1,398 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_d_diag_solver_mod.f90 +! +! Module: amg_d_diag_solver_mod +! +! This module defines: +! - the amg_d_diag_solver_type data structure containing the +! simple diagonal solver. This extracts the main diagonal of a matrix +! and precomputes its inverse. Combined with a Jacobi "smoother" generates +! what are commonly known as the classic Jacobi iterations +! +module amg_d_diag_solver + + use amg_d_base_solver_mod + + type, extends(amg_d_base_solver_type) :: amg_d_diag_solver_type + type(psb_d_vect_type), allocatable :: dv + real(psb_dpk_), allocatable :: d(:) + contains + procedure, pass(sv) :: dump => amg_d_diag_solver_dmp + procedure, pass(sv) :: build => amg_d_diag_solver_bld + procedure, pass(sv) :: cnv => amg_d_diag_solver_cnv + procedure, pass(sv) :: clone => amg_d_diag_solver_clone + procedure, pass(sv) :: clear_data => amg_d_diag_solver_clear_data + procedure, pass(sv) :: apply_v => amg_d_diag_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_d_diag_solver_apply + procedure, pass(sv) :: free => d_diag_solver_free + procedure, pass(sv) :: descr => d_diag_solver_descr + procedure, pass(sv) :: sizeof => d_diag_solver_sizeof + procedure, pass(sv) :: get_nzeros => d_diag_solver_get_nzeros + procedure, nopass :: get_fmt => d_diag_solver_get_fmt + procedure, nopass :: get_id => d_diag_solver_get_id + end type amg_d_diag_solver_type + + + private :: d_diag_solver_free, d_diag_solver_descr, & + & d_diag_solver_sizeof, d_diag_solver_get_nzeros, & + & d_diag_solver_get_fmt, d_diag_solver_get_id + + + interface + subroutine amg_d_diag_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_diag_solver_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_diag_solver_type), intent(inout) :: sv + type(psb_d_vect_type), intent(inout) :: x + type(psb_d_vect_type), intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + end subroutine amg_d_diag_solver_apply_vect + end interface + + interface + subroutine amg_d_diag_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_diag_solver_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_diag_solver_type), intent(inout) :: sv + real(psb_dpk_), intent(inout) :: x(:) + real(psb_dpk_), intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_d_diag_solver_apply + end interface + + interface + subroutine amg_d_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_diag_solver_type, psb_ipk_, psb_i_base_vect_type + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_diag_solver_bld + end interface + + interface + subroutine amg_d_diag_solver_cnv(sv,info,amold,vmold,imold) + import :: psb_d_base_sparse_mat, psb_d_base_vect_type, psb_dpk_, & + & amg_d_diag_solver_type, psb_ipk_, psb_i_base_vect_type + class(amg_d_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_diag_solver_cnv + end interface + + interface + subroutine amg_d_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, amg_d_diag_solver_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, & + & psb_ipk_ + implicit none + class(amg_d_diag_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_d_diag_solver_dmp + end interface + + interface + subroutine amg_d_diag_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, amg_d_diag_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_diag_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_diag_solver_clone + end interface + + interface + subroutine amg_d_diag_solver_clear_data(sv,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_diag_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_diag_solver_clear_data + end interface + + +contains + + subroutine d_diag_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_d_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_diag_solver_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sv%dv)) call sv%dv%free(info) + + if (allocated(sv%d)) then + deallocate(sv%d,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine d_diag_solver_free + + subroutine d_diag_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_d_diag_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_d_diag_solver_descr' + integer(psb_ipk_) :: iout_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' Diagonal local solver ' + + return + + end subroutine d_diag_solver_descr + + function d_diag_solver_sizeof(sv) result(val) + implicit none + ! Arguments + class(amg_d_diag_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + if (allocated(sv%dv)) val = val + sv%dv%sizeof() + + return + end function d_diag_solver_sizeof + + function d_diag_solver_get_nzeros(sv) result(val) + implicit none + ! Arguments + class(amg_d_diag_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + if (allocated(sv%dv)) val = val + sv%dv%get_nrows() + + return + end function d_diag_solver_get_nzeros + + function d_diag_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Diag solver" + end function d_diag_solver_get_fmt + + function d_diag_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_diag_scale_ + end function d_diag_solver_get_id + +end module amg_d_diag_solver + +! +! Module: amg_d_l1_diag_solver_mod +! +! This module defines: +! - the amg_d_l1_diag_solver_type data structure containing the +! L1 diagonal solver. +! The solver is defined as a diagonal containing in each element the +! inverse of the sum of the absolute values of the matrix entries +! along the corresponding row. +! Combined with a Jacobi "smoother" generates +! what are commonly known as the L1-Jacobi iterations +! + +module amg_d_l1_diag_solver + + use amg_d_diag_solver + + type, extends(amg_d_diag_solver_type) :: amg_d_l1_diag_solver_type + contains + procedure, pass(sv) :: dump => amg_d_l1_diag_solver_dmp + procedure, pass(sv) :: build => amg_d_l1_diag_solver_bld + procedure, pass(sv) :: descr => d_l1_diag_solver_descr + procedure, nopass :: get_fmt => d_l1_diag_solver_get_fmt + procedure, nopass :: get_id => d_l1_diag_solver_get_id + end type amg_d_l1_diag_solver_type + + + private :: d_l1_diag_solver_descr, & + & d_l1_diag_solver_get_fmt, d_l1_diag_solver_get_id + + interface + subroutine amg_d_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_l1_diag_solver_type, psb_ipk_, psb_i_base_vect_type + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_l1_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_l1_diag_solver_bld + end interface + + interface + subroutine amg_d_l1_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, amg_d_l1_diag_solver_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, & + & psb_ipk_ + implicit none + class(amg_d_l1_diag_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_d_l1_diag_solver_dmp + end interface + +contains + + subroutine d_l1_diag_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_d_l1_diag_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_d_l1_diag_solver_descr' + integer(psb_ipk_) :: iout_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' L1 Diagonal solver ' + + return + + end subroutine d_l1_diag_solver_descr + + function d_l1_diag_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "L1 Diag solver" + end function d_l1_diag_solver_get_fmt + + function d_l1_diag_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_l1_diag_scale_ + end function d_l1_diag_solver_get_id + +end module amg_d_l1_diag_solver + diff --git a/mlprec/amg_d_gs_solver.f90 b/mlprec/amg_d_gs_solver.f90 new file mode 100644 index 00000000..24f19574 --- /dev/null +++ b/mlprec/amg_d_gs_solver.f90 @@ -0,0 +1,588 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! File: amg_d_gs_solver_mod.f90 +! +! Module: amg_d_gs_solver_mod +! +! This module defines: +! - the amg_d_gs_solver_type data structure containing the ingredients +! for a local Gauss-Seidel iteration. We provide Forward GS (FWGS) and +! backward GS (BWGS). The iterations are local to a process (they operate +! on the block diagonal). Combined with a Jacobi smoother will generate a +! hybrid-Gauss-Seidel solver, i.e. Gauss-Seidel within each process, Jacobi +! among the processes. +! With two objects as pre- and post-smoothers it is possible to build a +! Forward-Backward smoother, suitable for symmetric iterations. +! +module amg_d_gs_solver + + use amg_d_base_solver_mod + + type, extends(amg_d_base_solver_type) :: amg_d_gs_solver_type + type(psb_dspmat_type) :: l, u + integer(psb_ipk_) :: sweeps + real(psb_dpk_) :: eps + contains + procedure, pass(sv) :: dump => amg_d_gs_solver_dmp + procedure, pass(sv) :: check => d_gs_solver_check + procedure, pass(sv) :: clone => amg_d_gs_solver_clone + procedure, pass(sv) :: clone_settings => amg_d_gs_solver_clone_settings + procedure, pass(sv) :: clear_data => amg_d_gs_solver_clear_data + procedure, pass(sv) :: build => amg_d_gs_solver_bld + procedure, pass(sv) :: cnv => amg_d_gs_solver_cnv + procedure, pass(sv) :: apply_v => amg_d_gs_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_d_gs_solver_apply + procedure, pass(sv) :: free => d_gs_solver_free + procedure, pass(sv) :: cseti => d_gs_solver_cseti + procedure, pass(sv) :: csetc => d_gs_solver_csetc + procedure, pass(sv) :: csetr => d_gs_solver_csetr + procedure, pass(sv) :: descr => d_gs_solver_descr + procedure, pass(sv) :: default => d_gs_solver_default + procedure, pass(sv) :: sizeof => d_gs_solver_sizeof + procedure, pass(sv) :: get_nzeros => d_gs_solver_get_nzeros + procedure, nopass :: get_wrksz => d_gs_solver_get_wrksize + procedure, nopass :: get_fmt => d_gs_solver_get_fmt + procedure, nopass :: get_id => d_gs_solver_get_id + procedure, nopass :: is_iterative => d_gs_solver_is_iterative + end type amg_d_gs_solver_type + + type, extends(amg_d_gs_solver_type) :: amg_d_bwgs_solver_type + contains + procedure, pass(sv) :: build => amg_d_bwgs_solver_bld + procedure, pass(sv) :: apply_v => amg_d_bwgs_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_d_bwgs_solver_apply + procedure, nopass :: get_fmt => d_bwgs_solver_get_fmt + procedure, nopass :: get_id => d_bwgs_solver_get_id + procedure, pass(sv) :: descr => d_bwgs_solver_descr + end type amg_d_bwgs_solver_type + + + private :: d_gs_solver_bld, d_gs_solver_apply, & + & d_gs_solver_free, & + & d_gs_solver_descr, d_gs_solver_sizeof, & + & d_gs_solver_default, d_gs_solver_dmp, & + & d_gs_solver_apply_vect, d_gs_solver_get_nzeros, & + & d_gs_solver_get_fmt, d_gs_solver_check,& + & d_gs_solver_is_iterative, & + & d_bwgs_solver_get_fmt, d_bwgs_solver_descr, & + & d_gs_solver_get_id, d_bwgs_solver_get_id, d_gs_solver_get_wrksize + + interface + subroutine amg_d_gs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, amg_d_gs_solver_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_gs_solver_type), intent(inout) :: sv + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + end subroutine amg_d_gs_solver_apply_vect + subroutine amg_d_bwgs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, amg_d_bwgs_solver_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_bwgs_solver_type), intent(inout) :: sv + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + end subroutine amg_d_bwgs_solver_apply_vect + end interface + + interface + subroutine amg_d_gs_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info,init,initu) + import :: psb_desc_type, amg_d_gs_solver_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_gs_solver_type), intent(inout) :: sv + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_d_gs_solver_apply + subroutine amg_d_bwgs_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, amg_d_bwgs_solver_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_bwgs_solver_type), intent(inout) :: sv + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_d_bwgs_solver_apply + end interface + + interface + subroutine amg_d_gs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, amg_d_gs_solver_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_gs_solver_bld + subroutine amg_d_bwgs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, amg_d_bwgs_solver_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_bwgs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_bwgs_solver_bld + end interface + + interface + subroutine amg_d_gs_solver_cnv(sv,info,amold,vmold,imold) + import :: amg_d_gs_solver_type, psb_dpk_, & + & psb_d_base_sparse_mat, psb_d_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + class(amg_d_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_gs_solver_cnv + end interface + + interface + subroutine amg_d_gs_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, amg_d_gs_solver_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, & + & psb_ipk_ + implicit none + class(amg_d_gs_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_d_gs_solver_dmp + end interface + + interface + subroutine amg_d_gs_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, amg_d_gs_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_gs_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_gs_solver_clone + end interface + + interface + subroutine amg_d_gs_solver_clone_settings(sv,svout,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, amg_d_gs_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_gs_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_gs_solver_clone_settings + end interface + + interface + subroutine amg_d_gs_solver_clear_data(sv,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_gs_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_gs_solver_clear_data + end interface + +contains + + subroutine d_gs_solver_default(sv) + + Implicit None + + ! Arguments + class(amg_d_gs_solver_type), intent(inout) :: sv + + sv%sweeps = ione + sv%eps = dzero + + return + end subroutine d_gs_solver_default + + subroutine d_gs_solver_check(sv,info) + + Implicit None + + ! Arguments + class(amg_d_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_gs_solver_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + call amg_check_def(sv%sweeps,& + & 'GS Sweeps',ione,is_int_positive) + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine d_gs_solver_check + + subroutine d_gs_solver_cseti(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_d_gs_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_gs_solver_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) + case('SOLVER_SWEEPS') + sv%sweeps = val + case default + call sv%amg_d_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_gs_solver_cseti + + subroutine d_gs_solver_csetc(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_d_gs_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='d_gs_solver_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + + + call sv%amg_d_base_solver_type%set(what,val,info,idx=idx) + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info, name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_gs_solver_csetc + + subroutine d_gs_solver_csetr(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_d_gs_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_gs_solver_csetr' + + call psb_erractionsave(err_act) + info = psb_success_ + + select case(psb_toupper(what)) + case('SOLVER_EPS') + sv%eps = val + case default + call sv%amg_d_base_solver_type%set(what,val,info,idx=idx) + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_gs_solver_csetr + + subroutine d_gs_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_d_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_gs_solver_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + call sv%l%free() + call sv%u%free() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_gs_solver_free + + subroutine d_gs_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_d_gs_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_d_gs_solver_descr' + integer(psb_ipk_) :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (sv%eps<=dzero) then + write(iout_,*) ' Forward Gauss-Seidel iterative solver with ',& + & sv%sweeps,' sweeps' + else + write(iout_,*) ' Forward Gauss-Seidel iterative solver with tolerance',& + & sv%eps,' and maxit', sv%sweeps + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_gs_solver_descr + + function d_gs_solver_get_nzeros(sv) result(val) + + implicit none + ! Arguments + class(amg_d_gs_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + val = val + sv%l%get_nzeros() + val = val + sv%u%get_nzeros() + + return + end function d_gs_solver_get_nzeros + + function d_gs_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_d_gs_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = psb_sizeof_ip + val = val + sv%l%sizeof() + val = val + sv%u%sizeof() + + return + end function d_gs_solver_sizeof + + function d_gs_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Forward Gauss-Seidel solver" + end function d_gs_solver_get_fmt + + function d_gs_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_gs_ + end function d_gs_solver_get_id + + ! + ! If this is true, then the solver needs a starting + ! guess. Currently only handled in JAC smoother. + ! + function d_gs_solver_is_iterative() result(val) + implicit none + logical :: val + + val = .true. + end function d_gs_solver_is_iterative + + subroutine d_bwgs_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_d_bwgs_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_d_bwgs_solver_descr' + integer(psb_ipk_) :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (sv%eps<=dzero) then + write(iout_,*) ' Backward Gauss-Seidel iterative solver with ',& + & sv%sweeps,' sweeps' + else + write(iout_,*) ' Backward Gauss-Seidel iterative solver with tolerance',& + & sv%eps,' and maxit', sv%sweeps + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_bwgs_solver_descr + + function d_bwgs_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Backward Gauss-Seidel solver" + end function d_bwgs_solver_get_fmt + + function d_bwgs_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_bwgs_ + end function d_bwgs_solver_get_id + + function d_gs_solver_get_wrksize() result(val) + implicit none + integer(psb_ipk_) :: val + + val = 2 + end function d_gs_solver_get_wrksize + +end module amg_d_gs_solver diff --git a/mlprec/amg_d_hybrid_aggregator_mod.F90 b/mlprec/amg_d_hybrid_aggregator_mod.F90 new file mode 100644 index 00000000..753542da --- /dev/null +++ b/mlprec/amg_d_hybrid_aggregator_mod.F90 @@ -0,0 +1,125 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! The aggregator object hosts the aggregation method for building +! the multilevel hierarchy. This variant is based on the hybrid method +! presented in +! +! S. Gratton, P. Henon, P. Jiranek and X. Vasseur: +! Reducing complexity of algebraic multigrid by aggregation +! Numerical Lin. Algebra with Applications, 2016, 23:501-518 +! +module amg_d_hybrid_aggregator_mod + + use amg_d_dec_aggregator_mod + ! + ! sm - class(amg_T_base_smoother_type), allocatable + ! The current level preconditioner (aka smoother). + ! parms - type(amg_RTml_parms) + ! The parameters defining the multilevel strategy. + ! ac - The local part of the current-level matrix, built by + ! coarsening the previous-level matrix. + ! desc_ac - type(psb_desc_type). + ! The communication descriptor associated to the matrix + ! stored in ac. + ! base_a - type(psb_Tspmat_type), pointer. + ! Pointer (really a pointer!) to the local part of the current + ! matrix (so we have a unified treatment of residuals). + ! We need this to avoid passing explicitly the current matrix + ! to the routine which applies the preconditioner. + ! base_desc - type(psb_desc_type), pointer. + ! Pointer to the communication descriptor associated to the + ! matrix pointed by base_a. + ! map - Stores the maps (restriction and prolongation) between the + ! vector spaces associated to the index spaces of the previous + ! and current levels. + ! + ! Methods: + ! Most methods follow the encapsulation hierarchy: they take whatever action + ! is appropriate for the current object, then call the corresponding method for + ! the contained object. + ! As an example: the descr() method prints out a description of the + ! level. It starts by invoking the descr() method of the parms object, + ! then calls the descr() method of the smoother object. + ! + ! descr - Prints a description of the object. + ! default - Set default values + ! dump - Dump to file object contents + ! set - Sets various parameters; when a request is unknown + ! it is passed to the smoother object for further processing. + ! check - Sanity checks. + ! sizeof - Total memory occupation in bytes + ! get_nzeros - Number of nonzeros + ! + ! + type, extends(amg_d_dec_aggregator_type) :: amg_d_hybrid_aggregator_type + + contains + procedure, pass(ag) :: bld_tprol => amg_d_hybrid_aggregator_build_tprol + procedure, nopass :: fmt => amg_d_hybrid_aggregator_fmt + end type amg_d_hybrid_aggregator_type + + + interface + subroutine amg_d_hybrid_aggregator_build_tprol(ag,parms,a,desc_a,ilaggr,nlaggr,op_prol,info) + import :: amg_d_hybrid_aggregator_type, psb_desc_type, psb_dspmat_type, psb_dpk_, & + & psb_ipk_, psb_long_int_k_, amg_dml_parms + implicit none + class(amg_d_hybrid_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + integer(psb_ipk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_dspmat_type), intent(out) :: op_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_hybrid_aggregator_build_tprol + end interface + +contains + + + function amg_d_hybrid_aggregator_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Hybrid Decoupled aggregation" + end function amg_d_hybrid_aggregator_fmt + + +end module amg_d_hybrid_aggregator_mod diff --git a/mlprec/amg_d_id_solver.f90 b/mlprec/amg_d_id_solver.f90 new file mode 100644 index 00000000..43d3b091 --- /dev/null +++ b/mlprec/amg_d_id_solver.f90 @@ -0,0 +1,202 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! +! Identity solver. Reference for nullprec. +! +! +module amg_d_id_solver + + use amg_d_base_solver_mod + + type, extends(amg_d_base_solver_type) :: amg_d_id_solver_type + contains + procedure, pass(sv) :: build => d_id_solver_bld + procedure, pass(sv) :: clone => amg_d_id_solver_clone + procedure, pass(sv) :: apply_v => amg_d_id_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_d_id_solver_apply + procedure, pass(sv) :: free => d_id_solver_free + procedure, pass(sv) :: descr => d_id_solver_descr + procedure, nopass :: get_fmt => d_id_solver_get_fmt + procedure, nopass :: get_id => d_id_solver_get_id + end type amg_d_id_solver_type + + + private :: d_id_solver_bld, & + & d_id_solver_free, d_id_solver_get_fmt, & + & d_id_solver_descr, d_id_solver_get_id + + interface + subroutine amg_d_id_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_id_solver_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_id_solver_type), intent(inout) :: sv + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + end subroutine amg_d_id_solver_apply_vect + end interface + + interface + subroutine amg_d_id_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_id_solver_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_id_solver_type), intent(inout) :: sv + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_d_id_solver_apply + end interface + + interface + subroutine amg_d_id_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, amg_d_id_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_id_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_id_solver_clone + end interface + +contains + + + subroutine d_id_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + Implicit None + + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_id_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: i, err_act, debug_unit, debug_level + character(len=20) :: name='d_id_solver_bld', ch_err + + info=psb_success_ + + return + end subroutine d_id_solver_bld + + subroutine d_id_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_d_id_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_id_solver_free' + + info = psb_success_ + + return + end subroutine d_id_solver_free + + subroutine d_id_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_d_id_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_d_id_solver_descr' + integer(psb_ipk_) :: iout_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' Identity local solver ' + + return + + end subroutine d_id_solver_descr + + function d_id_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Identity solver" + end function d_id_solver_get_fmt + + function d_id_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_f_none_ + end function d_id_solver_get_id + +end module amg_d_id_solver diff --git a/mlprec/amg_d_ilu_fact_mod.f90 b/mlprec/amg_d_ilu_fact_mod.f90 new file mode 100644 index 00000000..70ed5607 --- /dev/null +++ b/mlprec/amg_d_ilu_fact_mod.f90 @@ -0,0 +1,91 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! File: amg_d_ilu_fact_mod.f90 +! +! Module: amg_d_ilu_fact_mod +! +! This module defines some interfaces used internally by the implementation of +! amg_d_ilu_solver, but not visible to the end user. +! +! +module amg_d_ilu_fact_mod + + use amg_d_base_solver_mod + + interface amg_ilu0_fact + subroutine amg_dilu0_fact(ialg,a,l,u,d,info,blck,upd) + import psb_dspmat_type, psb_dpk_, psb_ipk_ + integer(psb_ipk_), intent(in) :: ialg + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type),intent(in) :: a + type(psb_dspmat_type),intent(inout) :: l,u + type(psb_dspmat_type),intent(in), optional, target :: blck + character, intent(in), optional :: upd + real(psb_dpk_), intent(inout) :: d(:) + end subroutine amg_dilu0_fact + end interface + + interface amg_iluk_fact + subroutine amg_diluk_fact(fill_in,ialg,a,l,u,d,info,blck) + import psb_dspmat_type, psb_dpk_, psb_ipk_ + integer(psb_ipk_), intent(in) :: fill_in,ialg + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type),intent(in) :: a + type(psb_dspmat_type),intent(inout) :: l,u + type(psb_dspmat_type),intent(in), optional, target :: blck + real(psb_dpk_), intent(inout) :: d(:) + end subroutine amg_diluk_fact + end interface + + interface amg_ilut_fact + subroutine amg_dilut_fact(fill_in,thres,a,l,u,d,info,blck,iscale) + import psb_dspmat_type, psb_dpk_, psb_ipk_ + integer(psb_ipk_), intent(in) :: fill_in + real(psb_dpk_), intent(in) :: thres + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type),intent(in) :: a + type(psb_dspmat_type),intent(inout) :: l,u + real(psb_dpk_), intent(inout) :: d(:) + type(psb_dspmat_type),intent(in), optional, target :: blck + integer(psb_ipk_), intent(in), optional :: iscale + end subroutine amg_dilut_fact + end interface + +end module amg_d_ilu_fact_mod diff --git a/mlprec/amg_d_ilu_solver.f90 b/mlprec/amg_d_ilu_solver.f90 new file mode 100644 index 00000000..3a65fd86 --- /dev/null +++ b/mlprec/amg_d_ilu_solver.f90 @@ -0,0 +1,502 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! File: amg_d_ilu_solver_mod.f90 +! +! Module: amg_d_ilu_solver_mod +! +! This module defines: +! - the amg_d_ilu_solver_type data structure containing the ingredients +! for a local Incomplete LU factorization. +! 1. The factorization is always restricted to the diagonal block of the +! current image (coherently with the definition of a SOLVER as a local +! object) +! 2. The code provides support for both pattern-based ILU(K) and +! threshold base ILU(T,L) +! 3. The diagonal is stored separately, so strictly speaking this is +! an incomplete LDU factorization; +! 4. The application phase is shared among all variants; +! +! +module amg_d_ilu_solver + + use amg_base_prec_type, only : amg_fact_names + use amg_d_base_solver_mod + use psb_d_ilu_fact_mod + + type, extends(amg_d_base_solver_type) :: amg_d_ilu_solver_type + type(psb_dspmat_type) :: l, u + real(psb_dpk_), allocatable :: d(:) + type(psb_d_vect_type) :: dv + integer(psb_ipk_) :: fact_type, fill_in + real(psb_dpk_) :: thresh + contains + procedure, pass(sv) :: dump => amg_d_ilu_solver_dmp + procedure, pass(sv) :: check => d_ilu_solver_check + procedure, pass(sv) :: clone => amg_d_ilu_solver_clone + procedure, pass(sv) :: clone_settings => amg_d_ilu_solver_clone_settings + procedure, pass(sv) :: clear_data => amg_d_ilu_solver_clear_data + procedure, pass(sv) :: build => amg_d_ilu_solver_bld + procedure, pass(sv) :: cnv => amg_d_ilu_solver_cnv + procedure, pass(sv) :: apply_v => amg_d_ilu_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_d_ilu_solver_apply + procedure, pass(sv) :: free => d_ilu_solver_free + procedure, pass(sv) :: cseti => d_ilu_solver_cseti + procedure, pass(sv) :: csetc => d_ilu_solver_csetc + procedure, pass(sv) :: csetr => d_ilu_solver_csetr + procedure, pass(sv) :: descr => d_ilu_solver_descr + procedure, pass(sv) :: default => d_ilu_solver_default + procedure, pass(sv) :: sizeof => d_ilu_solver_sizeof + procedure, pass(sv) :: get_nzeros => d_ilu_solver_get_nzeros + procedure, nopass :: get_wrksz => d_ilu_solver_get_wrksize + procedure, nopass :: get_fmt => d_ilu_solver_get_fmt + procedure, nopass :: get_id => d_ilu_solver_get_id + end type amg_d_ilu_solver_type + + + private :: d_ilu_solver_bld, d_ilu_solver_apply, & + & d_ilu_solver_free, & + & d_ilu_solver_descr, d_ilu_solver_sizeof, & + & d_ilu_solver_default, d_ilu_solver_dmp, & + & d_ilu_solver_apply_vect, d_ilu_solver_get_nzeros, & + & d_ilu_solver_get_fmt, d_ilu_solver_check, & + & d_ilu_solver_get_id, d_ilu_solver_get_wrksize + + + interface + subroutine amg_d_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, amg_d_ilu_solver_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_ilu_solver_type), intent(inout) :: sv + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + end subroutine amg_d_ilu_solver_apply_vect + end interface + + interface + subroutine amg_d_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, amg_d_ilu_solver_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_ilu_solver_type), intent(inout) :: sv + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_d_ilu_solver_apply + end interface + + interface + subroutine amg_d_ilu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, amg_d_ilu_solver_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_ilu_solver_bld + end interface + + interface + subroutine amg_d_ilu_solver_cnv(sv,info,amold,vmold,imold) + import :: amg_d_ilu_solver_type, psb_dpk_, & + & psb_d_base_sparse_mat, psb_d_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + class(amg_d_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_ilu_solver_cnv + end interface + + interface + subroutine amg_d_ilu_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, amg_d_ilu_solver_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, & + & psb_ipk_ + implicit none + class(amg_d_ilu_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_d_ilu_solver_dmp + end interface + + interface + subroutine amg_d_ilu_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, amg_d_ilu_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_ilu_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_ilu_solver_clone + end interface + + interface + subroutine amg_d_ilu_solver_clone_settings(sv,svout,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_base_solver_type, amg_d_ilu_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_ilu_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_ilu_solver_clone_settings + end interface + + interface + subroutine amg_d_ilu_solver_clear_data(sv,info) + import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & + & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & + & amg_d_ilu_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_d_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_ilu_solver_clear_data + end interface + +contains + + subroutine d_ilu_solver_default(sv) + + Implicit None + + ! Arguments + class(amg_d_ilu_solver_type), intent(inout) :: sv + + sv%fact_type = psb_ilu_n_ + sv%fill_in = 0 + sv%thresh = dzero + + return + end subroutine d_ilu_solver_default + + subroutine d_ilu_solver_check(sv,info) + + Implicit None + + ! Arguments + class(amg_d_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_ilu_solver_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + call amg_check_def(sv%fact_type,& + & 'Factorization',psb_ilu_n_,is_legal_ilu_fact) + + select case(sv%fact_type) + case(psb_ilu_n_,psb_milu_n_) + call amg_check_def(sv%fill_in,& + & 'Level',izero,is_int_non_negative) + case(psb_ilu_t_) + call amg_check_def(sv%thresh,& + & 'Eps',dzero,is_legal_d_fact_thrs) + end select + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine d_ilu_solver_check + + subroutine d_ilu_solver_cseti(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_d_ilu_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_ilu_solver_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(trim((what)))) + case('SUB_SOLVE') + sv%fact_type = val + case('SUB_FILLIN') + sv%fill_in = val + case default + call sv%amg_d_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_ilu_solver_cseti + + subroutine d_ilu_solver_csetc(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_d_ilu_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='d_ilu_solver_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + ival = amg_stringval(val) + select case(psb_toupper(trim((what)))) + case('SUB_SOLVE') + sv%fact_type = ival + case default + call sv%amg_d_base_solver_type%set(what,val,info,idx=idx) + end select + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info, name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_ilu_solver_csetc + + subroutine d_ilu_solver_csetr(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_d_ilu_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_ilu_solver_csetr' + + call psb_erractionsave(err_act) + info = psb_success_ + + select case(psb_toupper(what)) + case('SUB_ILUTHRS') + sv%thresh = val + case default + call sv%amg_d_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_ilu_solver_csetr + + subroutine d_ilu_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_d_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_ilu_solver_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sv%d)) then + deallocate(sv%d,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + end if + call sv%l%free() + call sv%u%free() + call sv%dv%free(info) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_ilu_solver_free + + subroutine d_ilu_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_d_ilu_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_d_ilu_solver_descr' + integer(psb_ipk_) :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' Incomplete factorization solver: ',& + & amg_fact_names(sv%fact_type) + select case(sv%fact_type) + case(psb_ilu_n_,psb_milu_n_) + write(iout_,*) ' Fill level:',sv%fill_in + case(psb_ilu_t_) + write(iout_,*) ' Fill level:',sv%fill_in + write(iout_,*) ' Fill threshold :',sv%thresh + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_ilu_solver_descr + + function d_ilu_solver_get_nzeros(sv) result(val) + + implicit none + ! Arguments + class(amg_d_ilu_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + val = val + sv%dv%get_nrows() + val = val + sv%l%get_nzeros() + val = val + sv%u%get_nzeros() + + return + end function d_ilu_solver_get_nzeros + + function d_ilu_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_d_ilu_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 2*psb_sizeof_ip + psb_sizeof_dp + val = val + sv%dv%sizeof() + val = val + sv%l%sizeof() + val = val + sv%u%sizeof() + + return + end function d_ilu_solver_sizeof + + function d_ilu_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "ILU solver" + end function d_ilu_solver_get_fmt + + function d_ilu_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = psb_ilu_n_ + end function d_ilu_solver_get_id + + function d_ilu_solver_get_wrksize() result(val) + implicit none + integer(psb_ipk_) :: val + + val = 2 + end function d_ilu_solver_get_wrksize + +end module amg_d_ilu_solver diff --git a/mlprec/amg_d_inner_mod.f90 b/mlprec/amg_d_inner_mod.f90 new file mode 100644 index 00000000..70e6b350 --- /dev/null +++ b/mlprec/amg_d_inner_mod.f90 @@ -0,0 +1,131 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_inner_mod.f90 +! +! Module: amg_inner_mod +! +! This module defines the interfaces to inner MLD2P4 routines. +! The interfaces of the user level routines are defined in amg_prec_mod.f90. +! +module amg_d_inner_mod + + use psb_base_mod, only : psb_dspmat_type, psb_desc_type, psb_i_base_vect_type, & + & psb_dpk_, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_, & + & psb_d_vect_type, psb_lpk_, psb_ldspmat_type + use amg_d_prec_type, only : amg_dprec_type, amg_dml_parms, & + & amg_d_onelev_type, amg_dmlprec_wrk_type + + interface amg_mlprec_bld + subroutine amg_dmlprec_bld(a,desc_a,prec,info, amold, vmold,imold) + import :: psb_dspmat_type, psb_desc_type, psb_i_base_vect_type, & + & psb_dpk_, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ + import :: amg_dprec_type + implicit none + type(psb_dspmat_type), intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + type(amg_dprec_type), intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_dmlprec_bld + end interface amg_mlprec_bld + + interface amg_mlprec_aply + subroutine amg_dmlprec_aply(alpha,p,x,beta,y,desc_data,trans,work,info) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, psb_ipk_ + import :: amg_dprec_type + implicit none + type(psb_desc_type),intent(in) :: desc_data + type(amg_dprec_type), intent(inout) :: p + real(psb_dpk_),intent(in) :: alpha,beta + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + character,intent(in) :: trans + real(psb_dpk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + end subroutine amg_dmlprec_aply + subroutine amg_dmlprec_aply_vect(alpha,p,x,beta,y,desc_data,trans,work,info) + import :: psb_dspmat_type, psb_desc_type, & + & psb_dpk_, psb_d_vect_type, psb_ipk_ + import :: amg_dprec_type + implicit none + type(psb_desc_type),intent(in) :: desc_data + type(amg_dprec_type), intent(inout) :: p + real(psb_dpk_),intent(in) :: alpha,beta + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + character,intent(in) :: trans + real(psb_dpk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + end subroutine amg_dmlprec_aply_vect + end interface amg_mlprec_aply + + interface amg_map_to_tprol + subroutine amg_d_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, psb_ipk_, psb_lpk_, psb_ldspmat_type + import :: amg_d_onelev_type + implicit none + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), allocatable, intent(inout) :: ilaggr(:),nlaggr(:) + type(psb_ldspmat_type), intent(out) :: op_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_map_to_tprol + end interface amg_map_to_tprol + + abstract interface + subroutine amg_daggrmat_var_bld(a,desc_a,ilaggr,nlaggr,parms,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, psb_ipk_, psb_lpk_, psb_ldspmat_type + import :: amg_d_onelev_type, amg_dml_parms + implicit none + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(amg_dml_parms), intent(inout) :: parms + type(psb_dspmat_type), intent(inout) :: op_prol,ac,op_restr + type(psb_ldspmat_type), intent(inout) :: t_prol + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + end subroutine amg_daggrmat_var_bld + end interface + + procedure(amg_daggrmat_var_bld) :: amg_daggrmat_nosmth_bld, & + & amg_daggrmat_smth_bld, amg_daggrmat_minnrg_bld + +end module amg_d_inner_mod diff --git a/mlprec/amg_d_jac_smoother.f90 b/mlprec/amg_d_jac_smoother.f90 new file mode 100644 index 00000000..5d817192 --- /dev/null +++ b/mlprec/amg_d_jac_smoother.f90 @@ -0,0 +1,454 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_d_jac_smoother_mod.f90 +! +! Module: amg_d_jac_smoother_mod +! +! This module defines: +! the amg_d_jac_smoother_type data structure containing the +! smoother for a Jacobi/block Jacobi smoother. +! The smoother stores in ND the block off-diagonal matrix. +! One special case is treated separately, when the solver is DIAG or L1-DIAG +! then the ND is the entire off-diagonal part of the matrix (including the +! main diagonal block), so that it becomes possible to implement +! a pure Jacobi or L1-Jacobi global solver. +! +module amg_d_jac_smoother + + use amg_d_base_smoother_mod + + type, extends(amg_d_base_smoother_type) :: amg_d_jac_smoother_type + ! The local solver component is inherited from the + ! parent type. + ! class(amg_d_base_solver_type), allocatable :: sv + ! + type(psb_dspmat_type), pointer :: pa => null() + type(psb_dspmat_type) :: nd + integer(psb_lpk_) :: nd_nnz_tot + logical :: checkres + logical :: printres + integer(psb_ipk_) :: checkiter + integer(psb_ipk_) :: printiter + real(psb_dpk_) :: tol + contains + procedure, pass(sm) :: apply_v => amg_d_jac_smoother_apply_vect + procedure, pass(sm) :: apply_a => amg_d_jac_smoother_apply + procedure, pass(sm) :: dump => amg_d_jac_smoother_dmp + procedure, pass(sm) :: build => amg_d_jac_smoother_bld + procedure, pass(sm) :: cnv => amg_d_jac_smoother_cnv + procedure, pass(sm) :: clone => amg_d_jac_smoother_clone + procedure, pass(sm) :: clone_settings => amg_d_jac_smoother_clone_settings + procedure, pass(sm) :: clear_data => amg_d_jac_smoother_clear_data + procedure, pass(sm) :: free => d_jac_smoother_free + procedure, pass(sm) :: cseti => amg_d_jac_smoother_cseti + procedure, pass(sm) :: csetc => amg_d_jac_smoother_csetc + procedure, pass(sm) :: csetr => amg_d_jac_smoother_csetr + procedure, pass(sm) :: descr => amg_d_jac_smoother_descr + procedure, pass(sm) :: sizeof => d_jac_smoother_sizeof + procedure, pass(sm) :: default => d_jac_smoother_default + procedure, pass(sm) :: get_nzeros => d_jac_smoother_get_nzeros + procedure, pass(sm) :: get_wrksz => d_jac_smoother_get_wrksize + procedure, nopass :: get_fmt => d_jac_smoother_get_fmt + procedure, nopass :: get_id => d_jac_smoother_get_id + end type amg_d_jac_smoother_type + + type, extends(amg_d_jac_smoother_type) :: amg_d_l1_jac_smoother_type + contains + procedure, pass(sm) :: build => amg_d_l1_jac_smoother_bld + procedure, pass(sm) :: clone => amg_d_l1_jac_smoother_clone + procedure, pass(sm) :: descr => amg_d_l1_jac_smoother_descr + procedure, nopass :: get_fmt => d_l1_jac_smoother_get_fmt + procedure, nopass :: get_id => d_l1_jac_smoother_get_id + end type amg_d_l1_jac_smoother_type + + private :: d_jac_smoother_free, & + & d_jac_smoother_sizeof, d_jac_smoother_get_nzeros, & + & d_jac_smoother_get_fmt, d_jac_smoother_get_id, & + & d_jac_smoother_get_wrksize + private :: d_l1_jac_smoother_get_fmt, d_l1_jac_smoother_get_id + + + interface + subroutine amg_d_jac_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,wv,info,init,initu) + import :: psb_desc_type, amg_d_jac_smoother_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type,& + & psb_ipk_ + + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_jac_smoother_type), intent(inout) :: sm + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + end subroutine amg_d_jac_smoother_apply_vect + end interface + + interface + subroutine amg_d_jac_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,info,init,initu) + import :: psb_desc_type, amg_d_jac_smoother_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, & + & psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_jac_smoother_type), intent(inout) :: sm + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_d_jac_smoother_apply + end interface + + interface + subroutine amg_d_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + import :: psb_desc_type, amg_d_jac_smoother_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_jac_smoother_bld + end interface + + interface + subroutine amg_d_jac_smoother_cnv(sm,info,amold,vmold,imold) + import :: amg_d_jac_smoother_type, psb_dpk_, & + & psb_d_base_sparse_mat, psb_d_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + class(amg_d_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_jac_smoother_cnv + end interface + + interface + subroutine amg_d_jac_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dpk_, amg_d_jac_smoother_type, psb_epk_, psb_desc_type, & + & psb_ipk_ + implicit none + class(amg_d_jac_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + end subroutine amg_d_jac_smoother_dmp + end interface + + interface + subroutine amg_d_jac_smoother_clone(sm,smout,info) + import :: amg_d_jac_smoother_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_ + class(amg_d_jac_smoother_type), intent(inout) :: sm + class(amg_d_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_jac_smoother_clone + end interface + + interface + subroutine amg_d_jac_smoother_clone_settings(sm,smout,info) + import :: amg_d_jac_smoother_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_ + class(amg_d_jac_smoother_type), intent(inout) :: sm + class(amg_d_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_jac_smoother_clone_settings + end interface + + interface + subroutine amg_d_jac_smoother_clear_data(sm,info) + import :: amg_d_jac_smoother_type, psb_dpk_, & + & amg_d_base_smoother_type, psb_ipk_ + class(amg_d_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_jac_smoother_clear_data + end interface + + interface + subroutine amg_d_jac_smoother_descr(sm,info,iout,coarse) + import :: amg_d_jac_smoother_type, psb_ipk_ + class(amg_d_jac_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + end subroutine amg_d_jac_smoother_descr + end interface + + interface + subroutine amg_d_jac_smoother_cseti(sm,what,val,info,idx) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dpk_, amg_d_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_d_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_d_jac_smoother_cseti + end interface + + interface + subroutine amg_d_jac_smoother_csetc(sm,what,val,info,idx) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dpk_, amg_d_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_d_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_d_jac_smoother_csetc + end interface + + interface + subroutine amg_d_jac_smoother_csetr(sm,what,val,info,idx) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dpk_, amg_d_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_d_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_d_jac_smoother_csetr + end interface + + + interface + subroutine amg_d_l1_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + import :: psb_desc_type, amg_d_l1_jac_smoother_type, psb_d_vect_type, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_l1_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_l1_jac_smoother_bld + end interface + + interface + subroutine amg_d_l1_jac_smoother_clone(sm,smout,info) + import :: amg_d_l1_jac_smoother_type, & + & amg_d_base_smoother_type, psb_ipk_ + class(amg_d_l1_jac_smoother_type), intent(inout) :: sm + class(amg_d_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_l1_jac_smoother_clone + end interface + + interface + subroutine amg_d_l1_jac_smoother_clone_settings(sm,smout,info) + import :: amg_d_l1_jac_smoother_type, & + & amg_d_base_smoother_type, psb_ipk_ + class(amg_d_l1_jac_smoother_type), intent(inout) :: sm + class(amg_d_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_l1_jac_smoother_clone_settings + end interface + + interface + subroutine amg_d_l1_jac_smoother_clear_data(sm,info) + import :: amg_d_l1_jac_smoother_type, & + & amg_d_base_smoother_type, psb_ipk_ + class(amg_d_l1_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_l1_jac_smoother_clear_data + end interface + + interface + subroutine amg_d_l1_jac_smoother_descr(sm,info,iout,coarse) + import :: amg_d_l1_jac_smoother_type, psb_ipk_ + class(amg_d_l1_jac_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + end subroutine amg_d_l1_jac_smoother_descr + end interface + +contains + + + subroutine d_jac_smoother_free(sm,info) + + + Implicit None + + ! Arguments + class(amg_d_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_jac_smoother_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + + + if (allocated(sm%sv)) then + call sm%sv%free(info) + if (info == psb_success_) deallocate(sm%sv,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + end if + call sm%nd%free() + sm%pa => null() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_jac_smoother_free + + function d_jac_smoother_sizeof(sm) result(val) + + implicit none + ! Arguments + class(amg_d_jac_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = psb_sizeof_lp + if (allocated(sm%sv)) val = val + sm%sv%sizeof() + val = val + sm%nd%sizeof() + + return + end function d_jac_smoother_sizeof + + subroutine d_jac_smoother_default(sm) + + Implicit None + + ! Arguments + class(amg_d_jac_smoother_type), intent(inout) :: sm + + ! + ! Default: BJAC with no residual check + ! + sm%checkres = .false. + sm%printres = .false. + sm%checkiter = -1 + sm%printiter = -1 + sm%tol = 0 + + if (allocated(sm%sv)) then + call sm%sv%default() + end if + + return + end subroutine d_jac_smoother_default + + function d_jac_smoother_get_nzeros(sm) result(val) + + implicit none + ! Arguments + class(amg_d_jac_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + if (allocated(sm%sv)) val = val + sm%sv%get_nzeros() + val = val + sm%nd%get_nzeros() + + return + end function d_jac_smoother_get_nzeros + + function d_jac_smoother_get_wrksize(sm) result(val) + implicit none + class(amg_d_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_) :: val + + val = 2 + if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() + + end function d_jac_smoother_get_wrksize + + function d_jac_smoother_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Jacobi smoother" + end function d_jac_smoother_get_fmt + + function d_jac_smoother_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_jac_ + end function d_jac_smoother_get_id + + function d_l1_jac_smoother_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "L1-Jacobi smoother" + end function d_l1_jac_smoother_get_fmt + + function d_l1_jac_smoother_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_l1_jac_ + end function d_l1_jac_smoother_get_id + +end module amg_d_jac_smoother diff --git a/mlprec/amg_d_mumps_solver.F90 b/mlprec/amg_d_mumps_solver.F90 new file mode 100644 index 00000000..8abc2fbb --- /dev/null +++ b/mlprec/amg_d_mumps_solver.F90 @@ -0,0 +1,590 @@ + +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +! File: amg_d_mumps_solver_mod.f90 +! +! Module: amg_d_mumps_solver_mod +! +! This module defines: +! - the amg_d_mumps_solver_type data structure containing the ingredients +! to interface with the MUMPS package. +! 1. The factorization can be either restricted to the diagonal block of the +! current image or distributed (and thus exact). +! +module amg_d_mumps_solver + use amg_d_base_solver_mod +#if defined(HAVE_MUMPS_) && defined(HAVE_MUMPS_MODULES_) + use dmumps_struc_def +#endif +#if defined(HAVE_MUMPS_) && defined(HAVE_MUMPS_INCLUDES_) + include 'dmumps_struc.h' +#endif + + + type :: amg_d_mumps_icntl_item + integer(psb_ipk_), allocatable :: item + end type amg_d_mumps_icntl_item + type :: amg_d_mumps_rcntl_item + real(psb_dpk_), allocatable :: item + end type amg_d_mumps_rcntl_item + + type, extends(amg_d_base_solver_type) :: amg_d_mumps_solver_type +#if defined(HAVE_MUMPS_) + type(dmumps_struc), allocatable :: id +#else + integer, allocatable :: id +#endif + type(amg_d_mumps_icntl_item), allocatable :: icntl(:) + type(amg_d_mumps_rcntl_item), allocatable :: rcntl(:) + ! + ! Controls to be set before MUMPS instantiation: + ! + ! IPAR(1) : MUMPS_LOC_GLOB 0==amg_local_solver_: LOCAL 1==amg_global_solver_: GLOBAL + ! IPAR(2) : MUMPS_PRINT_ERR print verbosity (see MUMPS) + ! IPAR(3) : MUMPS_SYM 0: non-symmetric 2: symmetric + integer(psb_ipk_), dimension(3) :: ipar + integer(psb_ipk_), allocatable :: local_ictxt + logical :: built = .false. + contains + procedure, pass(sv) :: build => d_mumps_solver_bld + procedure, pass(sv) :: apply_a => d_mumps_solver_apply + procedure, pass(sv) :: apply_v => d_mumps_solver_apply_vect + procedure, pass(sv) :: clone_settings => d_mumps_solver_clone_settings + procedure, pass(sv) :: clear_data => d_mumps_solver_clear_data + procedure, pass(sv) :: free => d_mumps_solver_free + procedure, pass(sv) :: descr => d_mumps_solver_descr + procedure, pass(sv) :: sizeof => d_mumps_solver_sizeof + procedure, pass(sv) :: csetc => d_mumps_solver_csetc + procedure, pass(sv) :: cseti => d_mumps_solver_cseti + procedure, pass(sv) :: csetr => d_mumps_solver_csetr + procedure, pass(sv) :: default => d_mumps_solver_default + procedure, nopass :: get_fmt => d_mumps_solver_get_fmt + procedure, nopass :: get_id => d_mumps_solver_get_id + procedure, pass(sv) :: is_global => d_mumps_solver_is_global + final :: d_mumps_solver_finalize + end type amg_d_mumps_solver_type + + + private :: d_mumps_solver_bld, d_mumps_solver_apply, & + & d_mumps_solver_free, d_mumps_solver_descr, & + & d_mumps_solver_sizeof, d_mumps_solver_apply_vect,& + & d_mumps_solver_cseti, d_mumps_solver_csetr, & + & d_mumps_solver_csetc, d_mumps_solver_clear_data, & + & d_mumps_solver_default, d_mumps_solver_get_fmt, & + & d_mumps_solver_clone_settings, & + & d_mumps_solver_get_id, d_mumps_solver_is_global + private :: d_mumps_solver_finalize + + interface + subroutine d_mumps_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, amg_d_mumps_solver_type, psb_d_vect_type, psb_dpk_, psb_spk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_mumps_solver_type), intent(inout) :: sv + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + end subroutine d_mumps_solver_apply_vect + end interface + + interface + subroutine d_mumps_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info,init,initu) + import :: psb_desc_type, amg_d_mumps_solver_type, psb_d_vect_type, psb_dpk_, psb_spk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_mumps_solver_type), intent(inout) :: sv + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine d_mumps_solver_apply + end interface + + interface + subroutine d_mumps_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + import :: psb_desc_type, amg_d_mumps_solver_type, psb_d_vect_type, psb_dpk_, & + & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + + Implicit None + + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine d_mumps_solver_bld + end interface + +contains + + subroutine d_mumps_solver_clone_settings(sv,svout,info) + + use psb_base_mod + Implicit None + ! Arguments + class(amg_d_mumps_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: k,err_act + character(len=20) :: name='d_mumps_solver_clone_settings' + + info = 0 + +#if defined(HAVE_MUMPS_) + + call psb_erractionsave(err_act) + + select type(svout) + class is(amg_d_mumps_solver_type) + svout%ipar(:) = sv%ipar(:) + svout%built = .false. + if (allocated(svout%icntl)) deallocate(svout%icntl,stat=info) + if (info == 0) allocate(svout%icntl(amg_mumps_icntl_size),stat=info) + if (info == 0) then + do k=1,amg_mumps_icntl_size + call psb_safe_ab_cpy(sv%icntl(k)%item,svout%icntl(k)%item,info) + end do + end if + + if (allocated(svout%rcntl)) deallocate(svout%rcntl,stat=info) + if (info == 0) allocate(svout%rcntl(amg_mumps_rcntl_size),stat=info) + if (info == 0) then + do k=1,amg_mumps_rcntl_size + call psb_safe_ab_cpy(sv%rcntl(k)%item,svout%rcntl(k)%item,info) + end do + end if + + class default + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +#endif + end subroutine d_mumps_solver_clone_settings + + subroutine d_mumps_solver_clear_data(sv,info) + use psb_base_mod, only : psb_exit + Implicit None + + ! Arguments + class(amg_d_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_mumps_solver_clear_data' + + info = 0 +#if defined(HAVE_MUMPS_) + call psb_erractionsave(err_act) + if (allocated(sv%id)) then + if (sv%built) then + sv%id%job = -2 + call dmumps(sv%id) + info = sv%id%infog(1) + if (info /= psb_success_) goto 9999 + end if + deallocate(sv%id, stat=info) + if (allocated(sv%local_ictxt)) then + call psb_exit(sv%local_ictxt,close=.false.) + deallocate(sv%local_ictxt,stat=info) + end if + sv%built=.false. + end if + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +#endif + end subroutine d_mumps_solver_clear_data + + subroutine d_mumps_solver_free(sv,info) + use psb_base_mod, only : psb_exit + Implicit None + + ! Arguments + class(amg_d_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_mumps_solver_free' + + info = 0 +#if defined(HAVE_MUMPS_) + call psb_erractionsave(err_act) + call sv%clear_data(info) + if ((info == 0).and.allocated(sv%icntl)) deallocate(sv%icntl,stat=info) + if ((info == 0).and.allocated(sv%rcntl)) deallocate(sv%rcntl,stat=info) + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +#endif + end subroutine d_mumps_solver_free + +subroutine d_mumps_solver_finalize(sv) + + Implicit None + + ! Arguments + type(amg_d_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_) :: info + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_mumps_solver_finalize' + + call sv%free(info) + + return + +end subroutine d_mumps_solver_finalize + +subroutine d_mumps_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_d_mumps_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt, me, np + character(len=20), parameter :: name='amg_z_mumps_solver_descr' + integer(psb_ipk_) :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' MUMPS Solver. ' + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +end subroutine d_mumps_solver_descr + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! WARNING: OTHER PARAMETERS OF MUMPS COULD BE ADDED. !! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + +subroutine d_mumps_solver_csetc(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_d_mumps_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_mumps_solver_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + + + select case(psb_toupper(trim(what))) +#if defined(HAVE_MUMPS_) + case('MUMPS_LOC_GLOB') + sv%ipar(1) = sv%stringval(psb_toupper(trim(val))) +#endif + case default + call sv%amg_d_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +end subroutine d_mumps_solver_csetc + + +subroutine d_mumps_solver_cseti(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_d_mumps_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_mumps_solver_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) +#if defined(HAVE_MUMPS_) + case('MUMPS_LOC_GLOB') + sv%ipar(1) = val + case('MUMPS_PRINT_ERR') + sv%ipar(2) = val + case('MUMPS_SYM') + sv%ipar(3) = val + case('MUMPS_IPAR_ENTRY') + if(present(idx)) then + ! Note: this will allocate %item + sv%icntl(idx)%item = val + end if +#endif + case default + call sv%amg_d_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +end subroutine d_mumps_solver_cseti + +subroutine d_mumps_solver_csetr(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_d_mumps_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_mumps_solver_csetr' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) +#if defined(HAVE_MUMPS_) + case('MUMPS_RPAR_ENTRY') + if(present(idx)) then + ! Note: this will allocate %item + sv%rcntl(idx)%item = val + end if +#endif + case default + call sv%amg_d_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +end subroutine d_mumps_solver_csetr + +!!NOTE: BY DEFAULT BLR is activated with a dropping parameter to 1d-4 !! +subroutine d_mumps_solver_default(sv) + + Implicit none + + !Argument + class(amg_d_mumps_solver_type),intent(inout) :: sv + integer(psb_ipk_) :: info + integer(psb_ipk_) :: err_act,ictx,icomm + character(len=20) :: name='d_mumps_default' + + info = psb_success_ + call psb_erractionsave(err_act) + +#if defined(HAVE_MUMPS_) + if (.not.allocated(sv%id)) then + allocate(sv%id,stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_dealloc_ + call psb_errpush(info,name,a_err='amg_dmumps_default') + goto 9999 + end if + sv%built=.false. + end if + if (.not.allocated(sv%icntl)) then + allocate(sv%icntl(amg_mumps_icntl_size),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_dealloc_ + call psb_errpush(info,name,a_err='amg_dmumps_default') + goto 9999 + end if + end if + if (.not.allocated(sv%rcntl)) then + allocate(sv%rcntl(amg_mumps_rcntl_size),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_dealloc_ + call psb_errpush(info,name,a_err='amg_dmumps_default') + goto 9999 + end if + end if + ! INSTANTIATION OF sv%id needed to set parmater but mpi communicator needed + ! sv%id%job = -1 + ! sv%id%par=1 + ! call dmumps(sv%id) + sv%ipar = 0 + sv%ipar(1) = amg_global_solver_ + !sv%ipar(10)=6 + !sv%ipar(11)=0 + !sv%ipar(12)=6 + +#endif + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return + +end subroutine d_mumps_solver_default + +function d_mumps_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_d_mumps_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer :: i +#if defined(HAVE_MUMPS_) + val = (sv%id%INFOG(22)+sv%id%INFOG(32))*1d+6 +#else + val = 0 +#endif + ! val = 2*psb_sizeof_ip + psb_sizeof_dp + ! val = val + sv%symbsize + ! val = val + sv%numsize + return +end function d_mumps_solver_sizeof + +function d_mumps_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "MUMPS solver" +end function d_mumps_solver_get_fmt + +function d_mumps_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_mumps_ +end function d_mumps_solver_get_id + + +function d_mumps_solver_is_global(sv) result(val) + implicit none + class(amg_d_mumps_solver_type), intent(in) :: sv + logical :: val + + val = (sv%ipar(1) == amg_global_solver_ ) +end function d_mumps_solver_is_global + +end module amg_d_mumps_solver + diff --git a/mlprec/amg_d_onelev_mod.f90 b/mlprec/amg_d_onelev_mod.f90 new file mode 100644 index 00000000..9382ba6d --- /dev/null +++ b/mlprec/amg_d_onelev_mod.f90 @@ -0,0 +1,824 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_d_onelev_mod.f90 +! +! Module: amg_d_onelev_mod +! +! This module defines: +! - the amg_d_onelev_type data structure containing one level +! of a multilevel preconditioner and related +! data structures; +! +! It contains routines for +! - Building and applying; +! - checking if the preconditioner is correctly defined; +! - printing a description of the preconditioner; +! - deallocating the preconditioner data structure. +! + +module amg_d_onelev_mod + + use amg_base_prec_type + use amg_d_base_smoother_mod + use amg_d_dec_aggregator_mod + use psb_base_mod, only : psb_dspmat_type, psb_d_vect_type, & + & psb_d_base_vect_type, psb_ldspmat_type, psb_dlinmap_type, psb_dpk_, & + & psb_ipk_, psb_epk_, psb_lpk_, psb_desc_type, psb_i_base_vect_type, & + & psb_erractionsave, psb_error_handler + ! + ! + ! Type: amg_donelev_type. + ! + ! It is the data type containing the necessary items for the current + ! level (essentially, the smoother, the current-level matrix + ! and the restriction and prolongation operators). + ! + ! type amg_donelev_type + ! class(amg_d_base_smoother_type), allocatable :: sm, sm2a + ! class(amg_d_base_smoother_type), pointer :: sm2 => null() + ! class(amg_dmlprec_wrk_type), allocatable :: wrk + ! class(amg_d_base_aggregator_type), allocatable :: aggr + ! type(amg_dml_parms) :: parms + ! type(psb_dspmat_type) :: ac + ! type(psb_desc_type) :: desc_ac + ! type(psb_dspmat_type), pointer :: base_a => null() + ! type(psb_desc_type), pointer :: base_desc => null() + ! type(psb_dlinmap_type) :: map + ! end type amg_donelev_type + ! + ! Note that d denotes the kind of the real data type to be chosen + ! according to single/double precision version of MLD2P4. + ! + ! sm,sm2a - class(amg_d_base_smoother_type), allocatable + ! The current level pre- and post-smooother. + ! sm2 - class(amg_d_base_smoother_type), pointer + ! The current level post-smooother; if sm2a is allocated + ! explicitly, then sm2 => sm2a, otherwise sm2 => sm. + ! wrk - class(amg_dmlprec_wrk_type), allocatable + ! Workspace for application of preconditioner; may be + ! pre-allocated to save time in the application within a + ! Krylov solver. + ! aggr - class(amg_d_base_aggregator_type), allocatable + ! The aggregator object: holds the algorithmic choices and + ! (possibly) additional data for building the aggregation. + ! parms - type(amg_dml_parms) + ! The parameters defining the multilevel strategy. + ! ac - The local part of the current-level matrix, built by + ! coarsening the previous-level matrix. + ! desc_ac - type(psb_desc_type). + ! The communication descriptor associated to the matrix + ! stored in ac. + ! base_a - type(psb_dspmat_type), pointer. + ! Pointer (really a pointer!) to the local part of the current + ! matrix (so we have a unified treatment of residuals). + ! We need this to avoid passing explicitly the current matrix + ! to the routine which applies the preconditioner. + ! base_desc - type(psb_desc_type), pointer. + ! Pointer to the communication descriptor associated to the + ! matrix pointed by base_a. + ! map - Stores the maps (restriction and prolongation) between the + ! vector spaces associated to the index spaces of the previous + ! and current levels. + ! + ! Methods: + ! Most methods follow the encapsulation hierarchy: they take whatever action + ! is appropriate for the current object, then call the corresponding method for + ! the contained object. + ! As an example: the descr() method prints out a description of the + ! level. It starts by invoking the descr() method of the parms object, + ! then calls the descr() method of the smoother object. + ! + ! descr - Prints a description of the object. + ! default - Set default values + ! dump - Dump to file object contents + ! set - Sets various parameters; when a request is unknown + ! it is passed to the smoother object for further processing. + ! check - Sanity checks. + ! sizeof - Total memory occupation in bytes + ! get_nzeros - Number of nonzeros + ! get_wrksz - How many workspace vector does apply_vect need + ! allocate_wrk - Allocate auxiliary workspace + ! free_wrk - Free auxiliary workspace + ! bld_tprol - Invoke the aggr method to build the tentative prolongator + ! mat_asb - Build the final (possibly smoothed) prolongator and coarse matrix. + ! + ! + type amg_dmlprec_wrk_type + real(psb_dpk_), allocatable :: tx(:), ty(:), x2l(:), y2l(:) + type(psb_d_vect_type) :: vtx, vty, vx2l, vy2l + type(psb_d_vect_type), allocatable :: wv(:) + contains + procedure, pass(wk) :: alloc => d_wrk_alloc + procedure, pass(wk) :: free => d_wrk_free + procedure, pass(wk) :: clone => d_wrk_clone + procedure, pass(wk) :: move_alloc => d_wrk_move_alloc + procedure, pass(wk) :: cnv => d_wrk_cnv + procedure, pass(wk) :: sizeof => d_wrk_sizeof + end type amg_dmlprec_wrk_type + private :: d_wrk_alloc, d_wrk_free, & + & d_wrk_clone, d_wrk_move_alloc, d_wrk_cnv, d_wrk_sizeof + + type amg_d_onelev_type + class(amg_d_base_smoother_type), allocatable :: sm, sm2a + class(amg_d_base_smoother_type), pointer :: sm2 => null() + class(amg_dmlprec_wrk_type), allocatable :: wrk + class(amg_d_base_aggregator_type), allocatable :: aggr + type(amg_dml_parms) :: parms + type(psb_dspmat_type) :: ac + integer(psb_ipk_) :: ac_nz_loc + integer(psb_lpk_) :: ac_nz_tot + type(psb_desc_type) :: desc_ac + type(psb_dspmat_type), pointer :: base_a => null() + type(psb_desc_type), pointer :: base_desc => null() + type(psb_ldspmat_type) :: tprol + type(psb_dlinmap_type) :: map + real(psb_dpk_) :: szratio + contains + procedure, pass(lv) :: bld_tprol => d_base_onelev_bld_tprol + procedure, pass(lv) :: mat_asb => amg_d_base_onelev_mat_asb + procedure, pass(lv) :: update_aggr => d_base_onelev_update_aggr + procedure, pass(lv) :: bld => amg_d_base_onelev_build + procedure, pass(lv) :: clone => d_base_onelev_clone + procedure, pass(lv) :: cnv => amg_d_base_onelev_cnv + procedure, pass(lv) :: descr => amg_d_base_onelev_descr + procedure, pass(lv) :: default => d_base_onelev_default + procedure, pass(lv) :: free => amg_d_base_onelev_free + procedure, pass(lv) :: nullify => d_base_onelev_nullify + procedure, pass(lv) :: check => amg_d_base_onelev_check + procedure, pass(lv) :: dump => amg_d_base_onelev_dump + procedure, pass(lv) :: cseti => amg_d_base_onelev_cseti + procedure, pass(lv) :: csetr => amg_d_base_onelev_csetr + procedure, pass(lv) :: csetc => amg_d_base_onelev_csetc + procedure, pass(lv) :: setsm => amg_d_base_onelev_setsm + procedure, pass(lv) :: setsv => amg_d_base_onelev_setsv + procedure, pass(lv) :: setag => amg_d_base_onelev_setag + generic, public :: set => cseti, csetr, csetc, setsm, setsv, setag + procedure, pass(lv) :: sizeof => d_base_onelev_sizeof + procedure, pass(lv) :: get_nzeros => d_base_onelev_get_nzeros + procedure, pass(lv) :: get_wrksz => d_base_onelev_get_wrksize + procedure, pass(lv) :: allocate_wrk => d_base_onelev_allocate_wrk + procedure, pass(lv) :: free_wrk => d_base_onelev_free_wrk + procedure, nopass :: stringval => amg_stringval + procedure, pass(lv) :: move_alloc => d_base_onelev_move_alloc + + end type amg_d_onelev_type + + type amg_d_onelev_node + type(amg_d_onelev_type) :: item + type(amg_d_onelev_node), pointer :: prev=>null(), next=>null() + end type amg_d_onelev_node + + private :: d_base_onelev_default, d_base_onelev_sizeof, & + & d_base_onelev_nullify, d_base_onelev_get_nzeros, & + & d_base_onelev_clone, d_base_onelev_move_alloc, & + & d_base_onelev_get_wrksize, d_base_onelev_allocate_wrk, & + & d_base_onelev_free_wrk + + interface + subroutine amg_d_base_onelev_mat_asb(lv,a,desc_a,ilaggr,nlaggr,t_prol,info) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, psb_ipk_, psb_ldspmat_type, psb_lpk_ + import :: amg_d_onelev_type + implicit none + class(amg_d_onelev_type), intent(inout), target :: lv + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:),nlaggr(:) + type(psb_ldspmat_type), intent(inout) :: t_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_base_onelev_mat_asb + end interface + + interface + subroutine amg_d_base_onelev_build(lv,info,amold,vmold,imold,ilv) + import :: psb_d_base_sparse_mat, psb_d_base_vect_type, & + & psb_i_base_vect_type, psb_dpk_, amg_d_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + implicit none + class(amg_d_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + integer(psb_ipk_), intent(in), optional :: ilv + end subroutine amg_d_base_onelev_build + end interface + + interface + subroutine amg_d_base_onelev_descr(lv,il,nl,ilmin,info,iout) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dlinmap_type, psb_dpk_, amg_d_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + ! Arguments + class(amg_d_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: il,nl,ilmin + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + end subroutine amg_d_base_onelev_descr + end interface + + interface + subroutine amg_d_base_onelev_cnv(lv,info,amold,vmold,imold) + import :: amg_d_onelev_type, psb_d_base_vect_type, psb_dpk_, & + & psb_d_base_sparse_mat, psb_ipk_, psb_i_base_vect_type + ! Arguments + class(amg_d_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_d_base_onelev_cnv + end interface + +interface + subroutine amg_d_base_onelev_free(lv,info) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dlinmap_type, psb_dpk_, amg_d_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + implicit none + + class(amg_d_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_base_onelev_free + end interface + + interface + subroutine amg_d_base_onelev_check(lv,info) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dlinmap_type, psb_dpk_, amg_d_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + ! Arguments + class(amg_d_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_base_onelev_check + end interface + + interface + subroutine amg_d_base_onelev_setsm(lv,val,info,pos) + import :: psb_dpk_, amg_d_onelev_type, amg_d_base_smoother_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + ! Arguments + class(amg_d_onelev_type), target, intent(inout) :: lv + class(amg_d_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + end subroutine amg_d_base_onelev_setsm + end interface + + interface + subroutine amg_d_base_onelev_setsv(lv,val,info,pos) + import :: psb_dpk_, amg_d_onelev_type, amg_d_base_solver_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + ! Arguments + class(amg_d_onelev_type), target, intent(inout) :: lv + class(amg_d_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + end subroutine amg_d_base_onelev_setsv + end interface + + interface + subroutine amg_d_base_onelev_setag(lv,val,info,pos) + import :: psb_dpk_, amg_d_onelev_type, amg_d_base_aggregator_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + ! Arguments + class(amg_d_onelev_type), target, intent(inout) :: lv + class(amg_d_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + end subroutine amg_d_base_onelev_setag + end interface + + interface + subroutine amg_d_base_onelev_cseti(lv,what,val,info,pos,idx) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dlinmap_type, psb_dpk_, amg_d_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + ! Arguments + class(amg_d_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_d_base_onelev_cseti + end interface + + interface + subroutine amg_d_base_onelev_csetc(lv,what,val,info,pos,idx) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dlinmap_type, psb_dpk_, amg_d_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + ! Arguments + class(amg_d_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_d_base_onelev_csetc + end interface + + interface + subroutine amg_d_base_onelev_csetr(lv,what,val,info,pos,idx) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dlinmap_type, psb_dpk_, amg_d_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + class(amg_d_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_d_base_onelev_csetr + end interface + + interface + subroutine amg_d_base_onelev_dump(lv,level,info,prefix,head,ac,rp,smoother,& + & solver,tprol,global_num) + import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & + & psb_dlinmap_type, psb_dpk_, amg_d_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + implicit none + class(amg_d_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: ac, rp, smoother, solver, tprol, global_num + end subroutine amg_d_base_onelev_dump + end interface + +contains + ! + ! Function returning the size of the amg_prec_type data structure + ! in bytes or in number of nonzeros of the operator(s) involved. + ! + + function d_base_onelev_get_nzeros(lv) result(val) + implicit none + class(amg_d_onelev_type), intent(in) :: lv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + if (allocated(lv%sm)) & + & val = lv%sm%get_nzeros() + if (allocated(lv%sm2a)) & + & val = val + lv%sm2a%get_nzeros() + end function d_base_onelev_get_nzeros + + function d_base_onelev_sizeof(lv) result(val) + implicit none + class(amg_d_onelev_type), intent(in) :: lv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = psb_sizeof_ip+psb_sizeof_lp + val = val + lv%desc_ac%sizeof() + val = val + lv%ac%sizeof() + val = val + lv%tprol%sizeof() + val = val + lv%map%sizeof() + if (allocated(lv%sm)) val = val + lv%sm%sizeof() + if (allocated(lv%sm2a)) val = val + lv%sm2a%sizeof() + if (allocated(lv%aggr)) val = val + lv%aggr%sizeof() + if (allocated(lv%wrk)) val = val + lv%wrk%sizeof() + end function d_base_onelev_sizeof + + + subroutine d_base_onelev_nullify(lv) + implicit none + + class(amg_d_onelev_type), intent(inout) :: lv + + nullify(lv%base_a) + nullify(lv%base_desc) + nullify(lv%sm2) + end subroutine d_base_onelev_nullify + + ! + ! Multilevel defaults: + ! multiplicative vs. additive ML framework; + ! Smoothed decoupled aggregation with zero threshold; + ! distributed coarse matrix; + ! damping omega computed with the max-norm estimate of the + ! dominant eigenvalue; + ! two-sided smoothing (i.e. V-cycle) with 1 smoothing sweep; + ! + + subroutine d_base_onelev_default(lv) + + Implicit None + + ! Arguments + class(amg_d_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_) :: info + + lv%parms%sweeps_pre = 1 + lv%parms%sweeps_post = 1 + lv%parms%ml_cycle = amg_vcycle_ml_ + lv%parms%aggr_type = amg_soc1_ + lv%parms%par_aggr_alg = amg_dec_aggr_ + lv%parms%aggr_ord = amg_aggr_ord_nat_ + lv%parms%aggr_prol = amg_smooth_prol_ + lv%parms%coarse_mat = amg_distr_mat_ + lv%parms%aggr_omega_alg = amg_eig_est_ + lv%parms%aggr_eig = amg_max_norm_ + lv%parms%aggr_filter = amg_no_filter_mat_ + lv%parms%aggr_omega_val = dzero + lv%parms%aggr_thresh = 0.01_psb_dpk_ + + if (allocated(lv%sm)) call lv%sm%default() + if (allocated(lv%sm2a)) then + call lv%sm2a%default() + lv%sm2 => lv%sm2a + else + lv%sm2 => lv%sm + end if + if (.not.allocated(lv%aggr)) allocate(amg_d_dec_aggregator_type :: lv%aggr,stat=info) + if (allocated(lv%aggr)) call lv%aggr%default() + + return + + end subroutine d_base_onelev_default + + subroutine d_base_onelev_bld_tprol(lv,a,desc_a,& + & ilaggr,nlaggr,t_prol,ag_data,info) + implicit none + class(amg_d_onelev_type), intent(inout), target :: lv + type(psb_dspmat_type), intent(inout) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_ldspmat_type), intent(out) :: t_prol + type(amg_daggr_data), intent(in) :: ag_data + integer(psb_ipk_), intent(out) :: info + + call lv%aggr%bld_tprol(lv%parms,ag_data,a,desc_a,ilaggr,nlaggr,t_prol,info) + + end subroutine d_base_onelev_bld_tprol + + + subroutine d_base_onelev_update_aggr(lv,lvnext,info) + implicit none + class(amg_d_onelev_type), intent(inout), target :: lv, lvnext + integer(psb_ipk_), intent(out) :: info + + call lv%aggr%update_next(lvnext%aggr,info) + + end subroutine d_base_onelev_update_aggr + + + subroutine d_base_onelev_clone(lv,lvout,info) + + Implicit None + + ! Arguments + class(amg_d_onelev_type), target, intent(inout) :: lv + class(amg_d_onelev_type), target, intent(inout) :: lvout + integer(psb_ipk_), intent(out) :: info + + info = psb_success_ + if (allocated(lv%sm)) then + call lv%sm%clone(lvout%sm,info) + else + if (allocated(lvout%sm)) then + call lvout%sm%free(info) + if (info==psb_success_) deallocate(lvout%sm,stat=info) + end if + end if + if (allocated(lv%sm2a)) then + call lv%sm%clone(lvout%sm2a,info) + lvout%sm2 => lvout%sm2a + else + if (allocated(lvout%sm2a)) then + call lvout%sm2a%free(info) + if (info==psb_success_) deallocate(lvout%sm2a,stat=info) + end if + lvout%sm2 => lvout%sm + end if + if (allocated(lv%aggr)) then + call lv%aggr%clone(lvout%aggr,info) + else + if (allocated(lvout%aggr)) then + call lvout%aggr%free(info) + if (info==psb_success_) deallocate(lvout%aggr,stat=info) + end if + end if + if (info == psb_success_) call lv%parms%clone(lvout%parms,info) + if (info == psb_success_) call lv%ac%clone(lvout%ac,info) + if (info == psb_success_) call lv%tprol%clone(lvout%tprol,info) + if (info == psb_success_) call lv%desc_ac%clone(lvout%desc_ac,info) + if (info == psb_success_) call lv%map%clone(lvout%map,info) + lvout%base_a => lv%base_a + lvout%base_desc => lv%base_desc + + return + + end subroutine d_base_onelev_clone + + subroutine d_base_onelev_move_alloc(lv, b,info) + use psb_base_mod + implicit none + class(amg_d_onelev_type), target, intent(inout) :: lv, b + integer(psb_ipk_), intent(out) :: info + + call b%free(info) + b%parms = lv%parms + b%szratio = lv%szratio + if (associated(lv%sm2,lv%sm2a)) then + call move_alloc(lv%sm,b%sm) + call move_alloc(lv%sm2a,b%sm2a) + b%sm2 =>b%sm2a + else + call move_alloc(lv%sm,b%sm) + call move_alloc(lv%sm2a,b%sm2a) + b%sm2 =>b%sm + end if + + call move_alloc(lv%aggr,b%aggr) + if (info == psb_success_) call psb_move_alloc(lv%ac,b%ac,info) + if (info == psb_success_) call psb_move_alloc(lv%tprol,b%tprol,info) + if (info == psb_success_) call psb_move_alloc(lv%desc_ac,b%desc_ac,info) + if (info == psb_success_) call psb_move_alloc(lv%map,b%map,info) + b%base_a => lv%base_a + b%base_desc => lv%base_desc + + end subroutine d_base_onelev_move_alloc + + + function d_base_onelev_get_wrksize(lv) result(val) + implicit none + class(amg_d_onelev_type), intent(inout) :: lv + integer(psb_ipk_) :: val + + val = 0 + ! SM and SM2A can share work vectors + if (allocated(lv%sm)) val = val + lv%sm%get_wrksz() + if (allocated(lv%sm2a)) val = max(val,lv%sm2a%get_wrksz()) + ! + ! Now for the ML application itself + ! + + ! VTX/VTY/VX2L/VY2L are stored explicitly + ! + + ! + ! additions for specific ML/cycles + ! + select case(lv%parms%ml_cycle) + case(amg_add_ml_,amg_mult_ml_,amg_vcycle_ml_, amg_wcycle_ml_) + ! We're good + + case(amg_kcycle_ml_, amg_kcyclesym_ml_) + ! + ! We need 7 in inneritkcycle. + ! Can we reuse vtx? + ! + val = val + 7 + + case default + ! Need a better error signaling ? + val = -1 + end select + + end function d_base_onelev_get_wrksize + + subroutine d_base_onelev_allocate_wrk(lv,info,vmold) + use psb_base_mod + implicit none + class(amg_d_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_vect_type), intent(in), optional :: vmold + ! + integer(psb_ipk_) :: nwv, i + info = psb_success_ + nwv = lv%get_wrksz() + if (.not.allocated(lv%wrk)) allocate(lv%wrk,stat=info) + if (info == 0) call lv%wrk%alloc(nwv,lv%base_desc,info,vmold=vmold) + + end subroutine d_base_onelev_allocate_wrk + + + subroutine d_base_onelev_free_wrk(lv,info) + use psb_base_mod + implicit none + class(amg_d_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: nwv,i + info = psb_success_ + + if (allocated(lv%wrk)) then + call lv%wrk%free(info) + if (info == 0) deallocate(lv%wrk,stat=info) + end if + end subroutine d_base_onelev_free_wrk + + subroutine d_wrk_alloc(wk,nwv,desc,info,vmold) + use psb_base_mod + + Implicit None + + ! Arguments + class(amg_dmlprec_wrk_type), target, intent(inout) :: wk + integer(psb_ipk_), intent(in) :: nwv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_vect_type), intent(in), optional :: vmold + ! + integer(psb_ipk_) :: i + + info = psb_success_ + call wk%free(info) + call psb_geasb(wk%vx2l,desc,info,& + & scratch=.true.,mold=vmold) + call psb_geasb(wk%vy2l,desc,info,& + & scratch=.true.,mold=vmold) + call psb_geasb(wk%vtx,desc,info,& + & scratch=.true.,mold=vmold) + call psb_geasb(wk%vty,desc,info,& + & scratch=.true.,mold=vmold) + allocate(wk%wv(nwv),stat=info) + do i=1,nwv + call psb_geasb(wk%wv(i),desc,info,& + & scratch=.true.,mold=vmold) + end do + + end subroutine d_wrk_alloc + + subroutine d_wrk_free(wk,info) + + Implicit None + + ! Arguments + class(amg_dmlprec_wrk_type), target, intent(inout) :: wk + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: i + info = psb_success_ + + if (allocated(wk%tx)) deallocate(wk%tx, stat=info) + if (allocated(wk%ty)) deallocate(wk%ty, stat=info) + if (allocated(wk%x2l)) deallocate(wk%x2l, stat=info) + if (allocated(wk%y2l)) deallocate(wk%y2l, stat=info) + call wk%vtx%free(info) + call wk%vty%free(info) + call wk%vx2l%free(info) + call wk%vy2l%free(info) + if (allocated(wk%wv)) then + do i=1,size(wk%wv) + call wk%wv(i)%free(info) + end do + deallocate(wk%wv, stat=info) + end if + + end subroutine d_wrk_free + + subroutine d_wrk_clone(wk,wkout,info) + use psb_base_mod + Implicit None + + ! Arguments + class(amg_dmlprec_wrk_type), target, intent(inout) :: wk + class(amg_dmlprec_wrk_type), target, intent(inout) :: wkout + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: i + info = psb_success_ + + call psb_safe_ab_cpy(wk%tx,wkout%tx,info) + call psb_safe_ab_cpy(wk%ty,wkout%ty,info) + call psb_safe_ab_cpy(wk%x2l,wkout%x2l,info) + call psb_safe_ab_cpy(wk%y2l,wkout%y2l,info) + call wk%vtx%clone(wkout%vtx,info) + call wk%vty%clone(wkout%vty,info) + call wk%vx2l%clone(wkout%vx2l,info) + call wk%vy2l%clone(wkout%vy2l,info) + if (allocated(wkout%wv)) then + do i=1,size(wkout%wv) + call wkout%wv(i)%free(info) + end do + deallocate( wkout%wv) + end if + allocate(wkout%wv(size(wk%wv)),stat=info) + do i=1,size(wk%wv) + call wk%wv(i)%clone(wkout%wv(i),info) + end do + return + + end subroutine d_wrk_clone + + subroutine d_wrk_move_alloc(wk, b,info) + implicit none + class(amg_dmlprec_wrk_type), target, intent(inout) :: wk, b + integer(psb_ipk_), intent(out) :: info + + call b%free(info) + call move_alloc(wk%tx,b%tx) + call move_alloc(wk%ty,b%ty) + call move_alloc(wk%x2l,b%x2l) + call move_alloc(wk%y2l,b%y2l) + ! + ! Should define V%move_alloc.... + call move_alloc(wk%vtx%v,b%vtx%v) + call move_alloc(wk%vty%v,b%vty%v) + call move_alloc(wk%vx2l%v,b%vx2l%v) + call move_alloc(wk%vy2l%v,b%vy2l%v) + call move_alloc(wk%wv,b%wv) + + end subroutine d_wrk_move_alloc + + subroutine d_wrk_cnv(wk,info,vmold) + use psb_base_mod + + Implicit None + + ! Arguments + class(amg_dmlprec_wrk_type), target, intent(inout) :: wk + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_vect_type), intent(in), optional :: vmold + ! + integer(psb_ipk_) :: i + + info = psb_success_ + if (present(vmold)) then + call wk%vtx%cnv(vmold) + call wk%vty%cnv(vmold) + call wk%vx2l%cnv(vmold) + call wk%vy2l%cnv(vmold) + if (allocated(wk%wv)) then + do i=1,size(wk%wv) + call wk%wv(i)%cnv(vmold) + end do + end if + end if + end subroutine d_wrk_cnv + + function d_wrk_sizeof(wk) result(val) + use psb_realloc_mod + implicit none + class(amg_dmlprec_wrk_type), intent(in) :: wk + integer(psb_epk_) :: val + integer :: i + val = 0 + val = val + (1_psb_epk_ * psb_sizeof_dp) * psb_size(wk%tx) + val = val + (1_psb_epk_ * psb_sizeof_dp) * psb_size(wk%ty) + val = val + (1_psb_epk_ * psb_sizeof_dp) * psb_size(wk%x2l) + val = val + (1_psb_epk_ * psb_sizeof_dp) * psb_size(wk%y2l) + val = val + wk%vtx%sizeof() + val = val + wk%vty%sizeof() + val = val + wk%vx2l%sizeof() + val = val + wk%vy2l%sizeof() + if (allocated(wk%wv)) then + do i=1, size(wk%wv) + val = val + wk%wv(i)%sizeof() + end do + end if + end function d_wrk_sizeof + +end module amg_d_onelev_mod diff --git a/mlprec/amg_d_prec_mod.f90 b/mlprec/amg_d_prec_mod.f90 new file mode 100644 index 00000000..9fdb4e7a --- /dev/null +++ b/mlprec/amg_d_prec_mod.f90 @@ -0,0 +1,139 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_d_prec_mod.f90 +! +! Module: amg_d_prec_mod +! +! This module defines the user interfaces to the real/complex, single/double +! precision versions of the user-level MLD2P4 routines. +! +module amg_d_prec_mod + + use amg_d_prec_type + use amg_d_jac_smoother + use amg_d_as_smoother + use amg_d_id_solver + use amg_d_diag_solver + use amg_d_l1_diag_solver + use amg_d_ilu_solver + use amg_d_gs_solver + + interface amg_precset + module procedure amg_d_iprecsetsm, amg_d_iprecsetsv, & + & amg_d_cprecseti, amg_d_cprecsetc, amg_d_cprecsetr, & + & amg_d_iprecsetag + end interface amg_precset + + interface amg_extprol_bld + subroutine amg_d_extprol_bld(a,desc_a,p,prolv,restrv,info,amold,vmold,imold) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & + & psb_d_base_sparse_mat, psb_d_base_vect_type, & + & psb_i_base_vect_type, amg_dprec_type, psb_ipk_ + + ! Arguments + type(psb_dspmat_type),intent(in), target :: a + type(psb_dspmat_type),intent(inout), target :: prolv(:) + type(psb_dspmat_type),intent(inout), target :: restrv(:) + type(psb_desc_type), intent(inout), target :: desc_a + type(amg_dprec_type),intent(inout),target :: p + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! !$ character, intent(in), optional :: upd + end subroutine amg_d_extprol_bld + end interface amg_extprol_bld + +contains + + subroutine amg_d_iprecsetsm(p,val,info,pos) + type(amg_dprec_type), intent(inout) :: p + class(amg_d_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + call p%set(val,info,pos=pos) + end subroutine amg_d_iprecsetsm + + subroutine amg_d_iprecsetsv(p,val,info,pos) + type(amg_dprec_type), intent(inout) :: p + class(amg_d_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + call p%set(val,info, pos=pos) + end subroutine amg_d_iprecsetsv + + subroutine amg_d_iprecsetag(p,val,info,pos) + type(amg_dprec_type), intent(inout) :: p + class(amg_d_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + call p%set(val,info, pos=pos) + end subroutine amg_d_iprecsetag + + subroutine amg_d_cprecseti(p,what,val,info,pos) + type(amg_dprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + call p%set(what,val,info,pos=pos) + end subroutine amg_d_cprecseti + + subroutine amg_d_cprecsetr(p,what,val,info,pos) + type(amg_dprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + call p%set(what,val,info,pos=pos) + end subroutine amg_d_cprecsetr + + subroutine amg_d_cprecsetc(p,what,val,info,pos) + type(amg_dprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + call p%set(what,val,info,pos=pos) + end subroutine amg_d_cprecsetc + +end module amg_d_prec_mod diff --git a/mlprec/amg_d_prec_type.f90 b/mlprec/amg_d_prec_type.f90 new file mode 100644 index 00000000..077f82fd --- /dev/null +++ b/mlprec/amg_d_prec_type.f90 @@ -0,0 +1,964 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_d_prec_type.f90 +! +! Module: amg_d_prec_type +! +! This module defines: +! - the amg_d_prec_type data structure containing the preconditioner and related +! data structures; +! +! It contains routines for +! - Building and applying; +! - checking if the preconditioner is correctly defined; +! - printing a description of the preconditioner; +! - deallocating the preconditioner data structure. +! + +module amg_d_prec_type + + use amg_base_prec_type + use amg_d_base_solver_mod + use amg_d_base_smoother_mod + use amg_d_base_aggregator_mod + use amg_d_onelev_mod + use psb_base_mod, only : psb_erractionsave, psb_erractionrestore, psb_errstatus_fatal + use psb_prec_mod, only : psb_dprec_type + + ! + ! Type: amg_dprec_type. + ! + ! This is the data type containing all the information about the multilevel + ! preconditioner ('d', 's', 'c' and 'z', according to the real/complex, + ! single/double precision version of MLD2P4). + ! It consists of an array of 'one-level' intermediate data structures + ! of type amg_donelev_type, each containing the information needed to apply + ! the smoothing and the coarse-space correction at a generic level. RT is the + ! real data type, i.e. S for both S and C, and D for both D and Z. + ! + ! type amg_dprec_type + ! type(amg_donelev_type), allocatable :: precv(:) + ! end type amg_dprec_type + ! + ! Note that the levels are numbered in increasing order starting from + ! the level 1 as the finest one, and the number of levels is given by + ! size(precv(:)) which is the id of the coarsest level. + ! In the multigrid literature many authors number the levels in the opposite + ! order, with level 0 being the id of the coarsest level. + ! + ! + integer, parameter, private :: wv_size_=4 + + type, extends(psb_dprec_type) :: amg_dprec_type + ! integer(psb_ipk_) :: ictxt ! Now it's in the PSBLAS prec. + type(amg_daggr_data) :: ag_data + ! + ! Number of outer sweeps. Sometimes 2 V-cycles may be better than 1 W-cycle. + ! + integer(psb_ipk_) :: outer_sweeps = 1 + ! + ! Coarse solver requires some tricky checks, and for this we need to + ! record the choice in the format given by the user, + ! to keep track against what is put later in the multilevel array + ! + integer(psb_ipk_) :: coarse_solver = -1 + + ! + ! The multilevel hierarchy + ! + type(amg_d_onelev_type), allocatable :: precv(:) + contains + procedure, pass(prec) :: psb_d_apply2_vect => amg_d_apply2_vect + procedure, pass(prec) :: psb_d_apply1_vect => amg_d_apply1_vect + procedure, pass(prec) :: psb_d_apply2v => amg_d_apply2v + procedure, pass(prec) :: psb_d_apply1v => amg_d_apply1v + procedure, pass(prec) :: dump => amg_d_dump + procedure, pass(prec) :: cnv => amg_d_cnv + procedure, pass(prec) :: clone => amg_d_clone + procedure, pass(prec) :: free => amg_d_prec_free + procedure, pass(prec) :: allocate_wrk => amg_d_allocate_wrk + procedure, pass(prec) :: free_wrk => amg_d_free_wrk + procedure, pass(prec) :: is_allocated_wrk => amg_d_is_allocated_wrk + procedure, pass(prec) :: get_complexity => amg_d_get_compl + procedure, pass(prec) :: cmp_complexity => amg_d_cmp_compl + procedure, pass(prec) :: get_avg_cr => amg_d_get_avg_cr + procedure, pass(prec) :: cmp_avg_cr => amg_d_cmp_avg_cr + procedure, pass(prec) :: get_nlevs => amg_d_get_nlevs + procedure, pass(prec) :: get_nzeros => amg_d_get_nzeros + procedure, pass(prec) :: sizeof => amg_dprec_sizeof + procedure, pass(prec) :: setsm => amg_dprecsetsm + procedure, pass(prec) :: setsv => amg_dprecsetsv + procedure, pass(prec) :: setag => amg_dprecsetag + procedure, pass(prec) :: cseti => amg_dcprecseti + procedure, pass(prec) :: csetc => amg_dcprecsetc + procedure, pass(prec) :: csetr => amg_dcprecsetr + generic, public :: set => cseti, csetc, csetr, setsm, setsv, setag + procedure, pass(prec) :: get_smoother => amg_d_get_smootherp + procedure, pass(prec) :: get_solver => amg_d_get_solverp + procedure, pass(prec) :: move_alloc => d_prec_move_alloc + procedure, pass(prec) :: init => amg_dprecinit + procedure, pass(prec) :: build => amg_dprecbld + procedure, pass(prec) :: hierarchy_build => amg_d_hierarchy_bld + procedure, pass(prec) :: smoothers_build => amg_d_smoothers_bld + procedure, pass(prec) :: descr => amg_dfile_prec_descr + end type amg_dprec_type + + private :: amg_d_dump, amg_d_get_compl, amg_d_cmp_compl,& + & amg_d_get_avg_cr, amg_d_cmp_avg_cr,& + & amg_d_get_nzeros, amg_d_get_nlevs, d_prec_move_alloc + + + ! + ! Interfaces to routines for checking the definition of the preconditioner, + ! for printing its description and for deallocating its data structure + ! + + interface amg_precfree + module procedure amg_dprecfree + end interface + + + interface amg_precdescr + subroutine amg_dfile_prec_descr(prec,iout,root) + import :: amg_dprec_type, psb_ipk_ + implicit none + ! Arguments + class(amg_dprec_type), intent(in) :: prec + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: root + end subroutine amg_dfile_prec_descr + end interface + + interface amg_sizeof + module procedure amg_dprec_sizeof + end interface + + interface amg_precapply + subroutine amg_dprecaply2_vect(prec,x,y,desc_data,info,trans,work) + import :: psb_dspmat_type, psb_desc_type, & + & psb_dpk_, psb_d_vect_type, amg_dprec_type, psb_ipk_ + type(psb_desc_type),intent(in) :: desc_data + type(amg_dprec_type), intent(inout) :: prec + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_dpk_),intent(inout), optional, target :: work(:) + end subroutine amg_dprecaply2_vect + subroutine amg_dprecaply1_vect(prec,x,desc_data,info,trans,work) + import :: psb_dspmat_type, psb_desc_type, & + & psb_dpk_, psb_d_vect_type, amg_dprec_type, psb_ipk_ + type(psb_desc_type),intent(in) :: desc_data + type(amg_dprec_type), intent(inout) :: prec + type(psb_d_vect_type),intent(inout) :: x + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_dpk_),intent(inout), optional, target :: work(:) + end subroutine amg_dprecaply1_vect + subroutine amg_dprecaply(prec,x,y,desc_data,info,trans,work) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, amg_dprec_type, psb_ipk_ + type(psb_desc_type),intent(in) :: desc_data + type(amg_dprec_type), intent(inout) :: prec + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_dpk_),intent(inout), optional, target :: work(:) + end subroutine amg_dprecaply + subroutine amg_dprecaply1(prec,x,desc_data,info,trans) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, amg_dprec_type, psb_ipk_ + type(psb_desc_type),intent(in) :: desc_data + type(amg_dprec_type), intent(inout) :: prec + real(psb_dpk_),intent(inout) :: x(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + end subroutine amg_dprecaply1 + end interface + + interface + subroutine amg_dprecsetsm(prec,val,info,ilev,ilmax,pos) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & + & amg_dprec_type, amg_d_base_smoother_type, psb_ipk_ + class(amg_dprec_type), target, intent(inout):: prec + class(amg_d_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + end subroutine amg_dprecsetsm + subroutine amg_dprecsetsv(prec,val,info,ilev,ilmax,pos) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & + & amg_dprec_type, amg_d_base_solver_type, psb_ipk_ + class(amg_dprec_type), intent(inout) :: prec + class(amg_d_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + end subroutine amg_dprecsetsv + subroutine amg_dprecsetag(prec,val,info,ilev,ilmax,pos) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & + & amg_dprec_type, amg_d_base_aggregator_type, psb_ipk_ + class(amg_dprec_type), intent(inout) :: prec + class(amg_d_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + end subroutine amg_dprecsetag + subroutine amg_dcprecseti(prec,what,val,info,ilev,ilmax,pos,idx) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & + & amg_dprec_type, psb_ipk_ + class(amg_dprec_type), intent(inout) :: prec + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx + character(len=*), optional, intent(in) :: pos + end subroutine amg_dcprecseti + subroutine amg_dcprecsetr(prec,what,val,info,ilev,ilmax,pos,idx) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & + & amg_dprec_type, psb_ipk_ + class(amg_dprec_type), intent(inout) :: prec + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx + character(len=*), optional, intent(in) :: pos + end subroutine amg_dcprecsetr + subroutine amg_dcprecsetc(prec,what,string,info,ilev,ilmax,pos,idx) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & + & amg_dprec_type, psb_ipk_ + class(amg_dprec_type), intent(inout) :: prec + character(len=*), intent(in) :: what + character(len=*), intent(in) :: string + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx + character(len=*), optional, intent(in) :: pos + end subroutine amg_dcprecsetc + end interface + + interface amg_precinit + subroutine amg_dprecinit(ictxt,prec,ptype,info) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & + & amg_dprec_type, psb_ipk_ + integer(psb_ipk_), intent(in) :: ictxt + class(amg_dprec_type), intent(inout) :: prec + character(len=*), intent(in) :: ptype + integer(psb_ipk_), intent(out) :: info + end subroutine amg_dprecinit + end interface amg_precinit + + interface amg_precbld + subroutine amg_dprecbld(a,desc_a,prec,info,amold,vmold,imold) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & + & psb_d_base_sparse_mat, psb_d_base_vect_type, & + & psb_i_base_vect_type, amg_dprec_type, psb_ipk_ + implicit none + type(psb_dspmat_type), intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_dprec_type), intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! character, intent(in),optional :: upd + end subroutine amg_dprecbld + end interface amg_precbld + + interface amg_hierarchy_bld + subroutine amg_d_hierarchy_bld(a,desc_a,prec,info) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & + & amg_dprec_type, psb_ipk_ + implicit none + type(psb_dspmat_type), intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_dprec_type), intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + ! character, intent(in),optional :: upd + end subroutine amg_d_hierarchy_bld + end interface amg_hierarchy_bld + + interface amg_smoothers_bld + subroutine amg_d_smoothers_bld(a,desc_a,prec,info,amold,vmold,imold) + import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & + & psb_d_base_sparse_mat, psb_d_base_vect_type, & + & psb_i_base_vect_type, amg_dprec_type, psb_ipk_ + implicit none + type(psb_dspmat_type), intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_dprec_type), intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! character, intent(in),optional :: upd + end subroutine amg_d_smoothers_bld + end interface amg_smoothers_bld + +contains + ! + ! Function returning a pointer to the smoother + ! + function amg_d_get_smootherp(prec,ilev) result(val) + implicit none + class(amg_dprec_type), target, intent(in) :: prec + integer(psb_ipk_), optional :: ilev + class(amg_d_base_smoother_type), pointer :: val + integer(psb_ipk_) :: ilev_ + + val => null() + if (present(ilev)) then + ilev_ = ilev + else + ! What is a good default? + ilev_ = 1 + end if + if (allocated(prec%precv)) then + if ((1<=ilev_).and.(ilev_<=size(prec%precv))) then + if (allocated(prec%precv(ilev_)%sm)) then + val => prec%precv(ilev_)%sm + end if + end if + end if + end function amg_d_get_smootherp + ! + ! Function returning a pointer to the solver + ! + function amg_d_get_solverp(prec,ilev) result(val) + implicit none + class(amg_dprec_type), target, intent(in) :: prec + integer(psb_ipk_), optional :: ilev + class(amg_d_base_solver_type), pointer :: val + integer(psb_ipk_) :: ilev_ + + val => null() + if (present(ilev)) then + ilev_ = ilev + else + ! What is a good default? + ilev_ = 1 + end if + if (allocated(prec%precv)) then + if ((1<=ilev_).and.(ilev_<=size(prec%precv))) then + if (allocated(prec%precv(ilev_)%sm)) then + if (allocated(prec%precv(ilev_)%sm%sv)) then + val => prec%precv(ilev_)%sm%sv + end if + end if + end if + end if + end function amg_d_get_solverp + ! + ! Function returning the size of the precv(:) array + ! + function amg_d_get_nlevs(prec) result(val) + implicit none + class(amg_dprec_type), intent(in) :: prec + integer(psb_ipk_) :: val + val = 0 + if (allocated(prec%precv)) then + val = size(prec%precv) + end if + end function amg_d_get_nlevs + ! + ! Function returning the size of the amg_prec_type data structure + ! in bytes or in number of nonzeros of the operator(s) involved. + ! + function amg_d_get_nzeros(prec) result(val) + implicit none + class(amg_dprec_type), intent(in) :: prec + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + if (allocated(prec%precv)) then + do i=1, size(prec%precv) + val = val + prec%precv(i)%get_nzeros() + end do + end if + end function amg_d_get_nzeros + + function amg_dprec_sizeof(prec) result(val) + implicit none + class(amg_dprec_type), intent(in) :: prec + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + val = val + psb_sizeof_ip + if (allocated(prec%precv)) then + do i=1, size(prec%precv) + val = val + prec%precv(i)%sizeof() + end do + end if + end function amg_dprec_sizeof + + ! + ! Operator complexity: ratio of total number + ! of nonzeros in the aggregated matrices at the + ! various level to the nonzeroes at the fine level + ! (original matrix) + ! + + function amg_d_get_compl(prec) result(val) + implicit none + class(amg_dprec_type), intent(in) :: prec + real(psb_dpk_) :: val + + val = prec%ag_data%op_complexity + + end function amg_d_get_compl + + subroutine amg_d_cmp_compl(prec) + + implicit none + class(amg_dprec_type), intent(inout) :: prec + + real(psb_dpk_) :: num, den, nmin + integer(psb_ipk_) :: ictxt + integer(psb_ipk_) :: il + + num = -done + den = done + ictxt = prec%ictxt + if (allocated(prec%precv)) then + il = 1 + num = prec%precv(il)%base_a%get_nzeros() + if (num >= dzero) then + den = num + do il=2,size(prec%precv) + num = num + max(0,prec%precv(il)%base_a%get_nzeros()) + end do + end if + end if + nmin = num + call psb_min(ictxt,nmin) + if (nmin < dzero) then + num = dzero + den = done + else + call psb_sum(ictxt,num) + call psb_sum(ictxt,den) + end if + prec%ag_data%op_complexity = num/den + end subroutine amg_d_cmp_compl + + ! + ! Average coarsening ratio + ! + + function amg_d_get_avg_cr(prec) result(val) + implicit none + class(amg_dprec_type), intent(in) :: prec + real(psb_dpk_) :: val + + val = prec%ag_data%avg_cr + + end function amg_d_get_avg_cr + + subroutine amg_d_cmp_avg_cr(prec) + + implicit none + class(amg_dprec_type), intent(inout) :: prec + + real(psb_dpk_) :: avgcr + integer(psb_ipk_) :: ictxt + integer(psb_ipk_) :: il, nl, iam, np + + + avgcr = dzero + ictxt = prec%ictxt + call psb_info(ictxt,iam,np) + if (allocated(prec%precv)) then + nl = size(prec%precv) + do il=2,nl + avgcr = avgcr + max(dzero,prec%precv(il)%szratio) + end do + avgcr = avgcr / (nl-1) + end if + call psb_sum(ictxt,avgcr) + prec%ag_data%avg_cr = avgcr/np + end subroutine amg_d_cmp_avg_cr + + ! + ! Subroutines: amg_Tprec_free + ! Version: real + ! + ! These routines deallocate the amg_Tprec_type data structures. + ! + ! Arguments: + ! p - type(amg_Tprec_type), input. + ! The data structure to be deallocated. + ! info - integer, output. + ! error code. + ! + subroutine amg_dprecfree(p,info) + + implicit none + + ! Arguments + type(amg_dprec_type), intent(inout) :: p + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: me,err_act,i + character(len=20) :: name + + info=psb_success_ + name = 'amg_dprecfree' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; return + end if + + me=-1 + + call p%free(info) + + + return + + end subroutine amg_dprecfree + + subroutine amg_d_prec_free(prec,info) + + implicit none + + ! Arguments + class(amg_dprec_type), intent(inout) :: prec + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: me,err_act,i + character(len=20) :: name + + info=psb_success_ + name = 'amg_dprecfree' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + + me=-1 + if (allocated(prec%precv)) then + do i=1,size(prec%precv) + call prec%precv(i)%free(info) + end do + deallocate(prec%precv,stat=info) + end if + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_d_prec_free + + + + ! + ! Top level methods. + ! + subroutine amg_d_apply2_vect(prec,x,y,desc_data,info,trans,work) + implicit none + type(psb_desc_type),intent(in) :: desc_data + class(amg_dprec_type), intent(inout) :: prec + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_dpk_),intent(inout), optional, target :: work(:) + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_prec_apply' + + call psb_erractionsave(err_act) + + select type(prec) + type is (amg_dprec_type) + call amg_precapply(prec,x,y,desc_data,info,trans,work) + class default + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_d_apply2_vect + + subroutine amg_d_apply1_vect(prec,x,desc_data,info,trans,work) + implicit none + type(psb_desc_type),intent(in) :: desc_data + class(amg_dprec_type), intent(inout) :: prec + type(psb_d_vect_type),intent(inout) :: x + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_dpk_),intent(inout), optional, target :: work(:) + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_prec_apply' + + call psb_erractionsave(err_act) + + select type(prec) + type is (amg_dprec_type) + call amg_precapply(prec,x,desc_data,info,trans,work) + class default + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_d_apply1_vect + + + subroutine amg_d_apply2v(prec,x,y,desc_data,info,trans,work) + implicit none + type(psb_desc_type),intent(in) :: desc_data + class(amg_dprec_type), intent(inout) :: prec + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_dpk_),intent(inout), optional, target :: work(:) + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_prec_apply' + + call psb_erractionsave(err_act) + + select type(prec) + type is (amg_dprec_type) + call amg_precapply(prec,x,y,desc_data,info,trans,work) + class default + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_d_apply2v + + subroutine amg_d_apply1v(prec,x,desc_data,info,trans) + implicit none + type(psb_desc_type),intent(in) :: desc_data + class(amg_dprec_type), intent(inout) :: prec + real(psb_dpk_),intent(inout) :: x(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_prec_apply' + + call psb_erractionsave(err_act) + + select type(prec) + type is (amg_dprec_type) + call amg_precapply(prec,x,desc_data,info,trans) + class default + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_d_apply1v + + + subroutine amg_d_dump(prec,info,istart,iend,iproc,prefix,head,& + & ac,rp,smoother,solver,tprol,& + & global_num) + + implicit none + class(amg_dprec_type), intent(in) :: prec + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: istart, iend, iproc + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver,ac, rp, tprol, global_num + integer(psb_ipk_) :: i, j, il1, iln, lev + integer(psb_ipk_) :: icontxt, iam, np, iproc_ + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + ! len of prefix_ + + info = 0 + icontxt = prec%ictxt + call psb_info(icontxt,iam,np) + + iln = size(prec%precv) + if (present(istart)) then + il1 = max(1,istart) + else + il1 = min(2,iln) + end if + if (present(iend)) then + iln = min(iln, iend) + end if + iproc_ = -1 + if (present(iproc)) then + iproc_ = iproc + end if + + if ((iproc_ == -1).or.(iproc_==iam)) then + do lev=il1, iln + call prec%precv(lev)%dump(lev,info,prefix=prefix,head=head,& + & ac=ac,smoother=smoother,solver=solver,rp=rp,tprol=tprol, & + & global_num=global_num) + end do + end if + end subroutine amg_d_dump + + subroutine amg_d_cnv(prec,info,amold,vmold,imold) + + implicit none + class(amg_dprec_type), intent(inout) :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + integer(psb_ipk_) :: i + + info = psb_success_ + if (allocated(prec%precv)) then + do i=1,size(prec%precv) + if (info == psb_success_ ) & + & call prec%precv(i)%cnv(info,amold=amold,vmold=vmold,imold=imold) + end do + end if + + end subroutine amg_d_cnv + + subroutine amg_d_clone(prec,precout,info) + + implicit none + class(amg_dprec_type), intent(inout) :: prec + class(psb_dprec_type), intent(inout) :: precout + integer(psb_ipk_), intent(out) :: info + + call precout%free(info) + if (info == 0) call amg_d_inner_clone(prec,precout,info) + + end subroutine amg_d_clone + + subroutine amg_d_inner_clone(prec,precout,info) + + implicit none + class(amg_dprec_type), intent(inout) :: prec + class(psb_dprec_type), target, intent(inout) :: precout + integer(psb_ipk_), intent(out) :: info + ! Local vars + integer(psb_ipk_) :: i, j, ln, lev + integer(psb_ipk_) :: icontxt,iam, np + + info = psb_success_ + select type(pout => precout) + class is (amg_dprec_type) + pout%ictxt = prec%ictxt + pout%ag_data = prec%ag_data + pout%outer_sweeps = prec%outer_sweeps + if (allocated(prec%precv)) then + ln = size(prec%precv) + allocate(pout%precv(ln),stat=info) + if (info /= psb_success_) goto 9999 + if (ln >= 1) then + call prec%precv(1)%clone(pout%precv(1),info) + end if + do lev=2, ln + if (info /= psb_success_) exit + call prec%precv(lev)%clone(pout%precv(lev),info) + if (info == psb_success_) then + pout%precv(lev)%base_a => pout%precv(lev)%ac + pout%precv(lev)%base_desc => pout%precv(lev)%desc_ac + pout%precv(lev)%map%p_desc_U => pout%precv(lev-1)%base_desc + pout%precv(lev)%map%p_desc_V => pout%precv(lev)%base_desc + end if + end do + end if + if (allocated(prec%precv(1)%wrk)) & + & call pout%allocate_wrk(info,vmold=prec%precv(1)%wrk%vx2l%v) + + class default + write(0,*) 'Error: wrong out type' + info = psb_err_invalid_input_ + end select +9999 continue + end subroutine amg_d_inner_clone + + subroutine d_prec_move_alloc(prec, b,info) + use psb_base_mod + implicit none + class(amg_dprec_type), intent(inout) :: prec + class(amg_dprec_type), intent(inout), target :: b + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: i + + if (same_type_as(prec,b)) then + if (allocated(b%precv)) then + ! This might not be required if FINAL procedures are available. + call b%free(info) + if (info /= psb_success_) then + !????? +!!$ return + endif + end if + b%ictxt = prec%ictxt + b%ag_data = prec%ag_data + b%outer_sweeps = prec%outer_sweeps + + call move_alloc(prec%precv,b%precv) + ! Fix the pointers except on level 1. + do i=2, size(b%precv) + b%precv(i)%base_a => b%precv(i)%ac + b%precv(i)%base_desc => b%precv(i)%desc_ac + b%precv(i)%map%p_desc_U => b%precv(i-1)%base_desc + b%precv(i)%map%p_desc_V => b%precv(i)%base_desc + end do + + else + write(0,*) 'Warning: PREC%move_alloc onto different type?' + info = psb_err_internal_error_ + end if + end subroutine d_prec_move_alloc + + subroutine amg_d_allocate_wrk(prec,info,vmold,desc) + use psb_base_mod + implicit none + + ! Arguments + class(amg_dprec_type), intent(inout) :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_vect_type), intent(in), optional :: vmold + ! + ! In MLD the DESC optional argument is ignored, since + ! the necessary info is contained in the various entries of the + ! PRECV component. + type(psb_desc_type), intent(in), optional :: desc + + ! Local variables + integer(psb_ipk_) :: me,err_act,i,j,level,nlev, nc2l + character(len=20) :: name + + info=psb_success_ + name = 'amg_d_allocate_wrk' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + nlev = size(prec%precv) + level = 1 + do level = 1, nlev + call prec%precv(level)%allocate_wrk(info,vmold=vmold) + if (psb_errstatus_fatal()) then + nc2l = prec%precv(level)%base_desc%get_local_cols() + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nc2l/), a_err='real(psb_dpk_)') + goto 9999 + end if + end do + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_d_allocate_wrk + + subroutine amg_d_free_wrk(prec,info) + use psb_base_mod + implicit none + + ! Arguments + class(amg_dprec_type), intent(inout) :: prec + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: me,err_act,i,j,level, nlev, nc2l + character(len=20) :: name + + info=psb_success_ + name = 'amg_d_free_wrk' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + + if (allocated(prec%precv)) then + nlev = size(prec%precv) + do level = 1, nlev + call prec%precv(level)%free_wrk(info) + end do + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_d_free_wrk + + function amg_d_is_allocated_wrk(prec) result(res) + use psb_base_mod + implicit none + + ! Arguments + class(amg_dprec_type), intent(in) :: prec + logical :: res + + res = .false. + if (.not.allocated(prec%precv)) return + res = allocated(prec%precv(1)%wrk) + + end function amg_d_is_allocated_wrk + +end module amg_d_prec_type diff --git a/mlprec/amg_d_slu_solver.F90 b/mlprec/amg_d_slu_solver.F90 new file mode 100644 index 00000000..08451626 --- /dev/null +++ b/mlprec/amg_d_slu_solver.F90 @@ -0,0 +1,447 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_d_slu_solver_mod.f90 +! +! Module: amg_d_slu_solver_mod +! +! This module defines: +! - the amg_d_slu_solver_type data structure containing the ingredients +! to interface with the SuperLU package. +! 1. The factorization is restricted to the diagonal block of the +! current image. +! +module amg_d_slu_solver + + use iso_c_binding + use amg_d_base_solver_mod + +#if defined(IPK8) + + type, extends(amg_d_base_solver_type) :: amg_d_slu_solver_type + + end type amg_d_slu_solver_type + +#else + + type, extends(amg_d_base_solver_type) :: amg_d_slu_solver_type + type(c_ptr) :: lufactors=c_null_ptr + integer(c_long_long) :: symbsize=0, numsize=0 + contains + procedure, pass(sv) :: build => d_slu_solver_bld + procedure, pass(sv) :: apply_a => d_slu_solver_apply + procedure, pass(sv) :: apply_v => d_slu_solver_apply_vect + procedure, pass(sv) :: free => d_slu_solver_free + procedure, pass(sv) :: clear_data => d_slu_solver_clear_data + procedure, pass(sv) :: descr => d_slu_solver_descr + procedure, pass(sv) :: sizeof => d_slu_solver_sizeof + procedure, nopass :: get_fmt => d_slu_solver_get_fmt + procedure, nopass :: get_id => d_slu_solver_get_id + final :: d_slu_solver_finalize + end type amg_d_slu_solver_type + + + private :: d_slu_solver_bld, d_slu_solver_apply, & + & d_slu_solver_free, d_slu_solver_descr, & + & d_slu_solver_sizeof, d_slu_solver_apply_vect, & + & d_slu_solver_get_fmt, d_slu_solver_get_id, & + & d_slu_solver_clear_data + private :: d_slu_solver_finalize + + + + interface + function amg_dslu_fact(n,nnz,values,rowptr,colind,& + & lufactors)& + & bind(c,name='amg_dslu_fact') result(info) + use iso_c_binding + integer(c_int), value :: n,nnz + integer(c_int) :: info + integer(c_int) :: rowptr(*),colind(*) + real(c_double) :: values(*) + type(c_ptr) :: lufactors + end function amg_dslu_fact + end interface + + interface + function amg_dslu_solve(itrans,n,nrhs,b,ldb,lufactors)& + & bind(c,name='amg_dslu_solve') result(info) + use iso_c_binding + integer(c_int) :: info + integer(c_int), value :: itrans,n,nrhs,ldb + real(c_double) :: b(ldb,*) + type(c_ptr), value :: lufactors + end function amg_dslu_solve + end interface + + interface + function amg_dslu_free(lufactors)& + & bind(c,name='amg_dslu_free') result(info) + use iso_c_binding + integer(c_int) :: info + type(c_ptr), value :: lufactors + end function amg_dslu_free + end interface + +contains + + subroutine d_slu_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + use psb_base_mod + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_slu_solver_type), intent(inout) :: sv + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer, intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + + integer :: n_row,n_col + real(psb_dpk_), pointer :: ww(:) + integer :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='d_slu_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + else + allocate(ww(n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/n_col,0,0,0,0/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + endif + + ww(1:n_row) = x(1:n_row) + select case(trans_) + case('N') + info = amg_dslu_solve(0,n_row,1,ww,n_row,sv%lufactors) + case('T') + info = amg_dslu_solve(1,n_row,1,ww,n_row,sv%lufactors) + case('C') + info = amg_dslu_solve(2,n_row,1,ww,n_row,sv%lufactors) + case default + call psb_errpush(psb_err_internal_error_, & + & name,a_err='Invalid TRANS in ILU subsolve') + goto 9999 + end select + + if (info == psb_success_) & + & call psb_geaxpby(alpha,ww,beta,y,desc_data,info) + + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in subsolve') + goto 9999 + endif + + if (n_col > size(work)) then + deallocate(ww) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine d_slu_solver_apply + + subroutine d_slu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + use psb_base_mod + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_slu_solver_type), intent(inout) :: sv + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer, intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + + integer :: err_act + character(len=20) :: name='d_slu_solver_apply_vect' + + call psb_erractionsave(err_act) + + info = psb_success_ + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call x%v%sync() + call y%v%sync() + call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) + call y%v%set_host() + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine d_slu_solver_apply_vect + + subroutine d_slu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + + Implicit None + + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_slu_solver_type), intent(inout) :: sv + integer, intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + type(psb_dspmat_type) :: atmp + type(psb_d_csc_sparse_mat) :: acsc + type(psb_d_coo_sparse_mat) :: acoo + integer :: n_row,n_col, nrow_a, nztota + integer :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_slu_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + n_col = desc_a%get_local_cols() + + + call a%cscnv(atmp,info,type='coo') + call psb_rwextd(n_row,atmp,info,b=b) + call atmp%cscnv(info,type='coo',dupl=psb_dupl_add_) + nrow_a = atmp%get_nrows() + call atmp%a%csclip(acoo,info,jmax=nrow_a) + call acsc%mv_from_coo(acoo,info) + nztota = acsc%get_nzeros() + ! Fix the entries to call C-base SuperLU + acsc%ia(:) = acsc%ia(:) - 1 + acsc%icp(:) = acsc%icp(:) - 1 + info = amg_dslu_fact(nrow_a,nztota,acsc%val,& + & acsc%icp,acsc%ia,sv%lufactors) + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='amg_dslu_fact' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + call acsc%free() + call atmp%free() + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_slu_solver_bld + + subroutine d_slu_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_d_slu_solver_type), intent(inout) :: sv + integer, intent(out) :: info + Integer :: err_act + character(len=20) :: name='d_slu_solver_free' + + call psb_erractionsave(err_act) + + info = psb_success_ + + call sv%clear_data(info) + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_slu_solver_free + + subroutine d_slu_solver_clear_data(sv,info) + + Implicit None + + ! Arguments + class(amg_d_slu_solver_type), intent(inout) :: sv + integer, intent(out) :: info + Integer :: err_act + character(len=20) :: name='d_slu_solver_clear_data' + + call psb_erractionsave(err_act) + + info = psb_success_ + if (c_associated(sv%lufactors)) info = amg_dslu_free(sv%lufactors) + sv%lufactors = c_null_ptr + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_slu_solver_clear_data + + subroutine d_slu_solver_finalize(sv) + + Implicit None + + ! Arguments + type(amg_d_slu_solver_type), intent(inout) :: sv + integer :: info + Integer :: err_act + character(len=20) :: name='d_slu_solver_finalize' + + call sv%free(info) + + return + + end subroutine d_slu_solver_finalize + + subroutine d_slu_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_d_slu_solver_type), intent(in) :: sv + integer, intent(out) :: info + integer, intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer :: err_act + integer :: ictxt, me, np + character(len=20), parameter :: name='amg_d_slu_solver_descr' + integer :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' SuperLU Sparse Factorization Solver. ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_slu_solver_descr + + function d_slu_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_d_slu_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer :: i + + val = 2*psb_sizeof_ip + psb_sizeof_dp + val = val + sv%symbsize + val = val + sv%numsize + return + end function d_slu_solver_sizeof + + function d_slu_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "SuperLU solver" + end function d_slu_solver_get_fmt + + function d_slu_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_slu_ + end function d_slu_solver_get_id +#endif +end module amg_d_slu_solver diff --git a/mlprec/amg_d_sludist_solver.F90 b/mlprec/amg_d_sludist_solver.F90 new file mode 100644 index 00000000..b35e2929 --- /dev/null +++ b/mlprec/amg_d_sludist_solver.F90 @@ -0,0 +1,465 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_d_sludist_solver_mod.f90 +! +! Module: amg_d_sludist_solver_mod +! +! This module defines: +! - the amg_d_sludist_solver_type data structure containing the ingredients +! to interface with the SuperLU_Dist package. +! 1. The factorization is distributed (and thus exact) +! +! +! +module amg_d_sludist_solver + + use iso_c_binding + use amg_d_base_solver_mod + +#if defined(LPK8) + + type, extends(amg_d_base_solver_type) :: amg_d_sludist_solver_type + + end type amg_d_sludist_solver_type +#else + type, extends(amg_d_base_solver_type) :: amg_d_sludist_solver_type + type(c_ptr) :: lufactors=c_null_ptr + integer(c_long_long) :: symbsize=0, numsize=0 + contains + procedure, pass(sv) :: build => d_sludist_solver_bld + procedure, pass(sv) :: apply_a => d_sludist_solver_apply + procedure, pass(sv) :: apply_v => d_sludist_solver_apply_vect + procedure, pass(sv) :: free => d_sludist_solver_free + procedure, pass(sv) :: clear_data => d_sludist_solver_clear_data + procedure, pass(sv) :: descr => d_sludist_solver_descr + procedure, pass(sv) :: sizeof => d_sludist_solver_sizeof + procedure, nopass :: get_fmt => d_sludist_solver_get_fmt + procedure, nopass :: get_id => d_sludist_solver_get_id + procedure, pass(sv) :: is_global => d_sludist_solver_is_global + final :: d_sludist_solver_finalize + end type amg_d_sludist_solver_type + + + private :: d_sludist_solver_bld, d_sludist_solver_apply, & + & d_sludist_solver_free, d_sludist_solver_descr, & + & d_sludist_solver_sizeof, d_sludist_solver_apply_vect, & + & d_sludist_solver_get_fmt, d_sludist_solver_get_id, & + & d_sludist_solver_is_global, d_sludist_solver_clear_data + private :: d_sludist_solver_finalize + + + interface + function amg_dsludist_fact(n,nl,nnz,ifrst, & + & values,rowptr,colind,lufactors,npr,npc) & + & bind(c,name='amg_dsludist_fact') result(info) + use iso_c_binding + integer(c_int), value :: n,nl,nnz,ifrst,npr,npc + integer(c_int) :: info + integer(c_int) :: rowptr(*),colind(*) + real(c_double) :: values(*) + type(c_ptr) :: lufactors + end function amg_dsludist_fact + end interface + + interface + function amg_dsludist_solve(itrans,n,nrhs, b, ldb, lufactors)& + & bind(c,name='amg_dsludist_solve') result(info) + use iso_c_binding + integer(c_int) :: info + integer(c_int), value :: itrans,n,nrhs,ldb + real(c_double) :: b(ldb,*) + type(c_ptr), value :: lufactors + end function amg_dsludist_solve + end interface + + interface + function amg_dsludist_free(lufactors)& + & bind(c,name='amg_dsludist_free') result(info) + use iso_c_binding + integer(c_int) :: info + type(c_ptr), value :: lufactors + end function amg_dsludist_free + end interface + +contains + + subroutine d_sludist_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + use psb_base_mod + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_sludist_solver_type), intent(inout) :: sv + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer, intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + + integer :: n_row,n_col + real(psb_dpk_), pointer :: ww(:) + integer :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='d_sludist_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + else + allocate(ww(n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/n_col/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + endif + + if (info == psb_success_)& + & call psb_geaxpby(done,x,dzero,ww,desc_data,info) + + select case(trans_) + case('N') + info = amg_dsludist_solve(0,n_row,1,ww,n_row,sv%lufactors) + case('T') + info = amg_dsludist_solve(1,n_row,1,ww,n_row,sv%lufactors) + case('C') + info = amg_dsludist_solve(2,n_row,1,ww,n_row,sv%lufactors) + case default + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Invalid TRANS in subsolve') + goto 9999 + end select + + if (info == psb_success_)& + & call psb_geaxpby(alpha,ww,beta,y,desc_data,info) + + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in subsolve') + goto 9999 + endif + + if (n_col > size(work)) then + deallocate(ww) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine d_sludist_solver_apply + + subroutine d_sludist_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + use psb_base_mod + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_sludist_solver_type), intent(inout) :: sv + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer, intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + + integer :: err_act + character(len=20) :: name='d_sludist_solver_apply_vect' + + call psb_erractionsave(err_act) + + info = psb_success_ + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + + call x%v%sync() + call y%v%sync() + call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) + call y%v%set_host() + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine d_sludist_solver_apply_vect + + subroutine d_sludist_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + + Implicit None + + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_sludist_solver_type), intent(inout) :: sv + integer, intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + type(psb_dspmat_type) :: atmp + type(psb_d_csr_sparse_mat) :: acsr + integer :: n_row,n_col, nrow_a, nztota, nglob, nzt, npr, npc + integer :: ifrst, ibcheck + integer :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_sludist_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + npr = np + npc = 1 + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + + n_row = desc_a%get_local_rows() + n_col = desc_a%get_local_cols() + nglob = desc_a%get_global_rows() + + call a%cscnv(atmp,info,type='coo') + call psb_rwextd(n_row,atmp,info,b=b) + call atmp%cscnv(info,type='csr',dupl=psb_dupl_add_) + call atmp%mv_to(acsr) + nrow_a = acsr%get_nrows() + nztota = acsr%get_nzeros() + ! Fix the entries to call C-base SuperLU + call psb_loc_to_glob(1,ifrst,desc_a,info) + call psb_loc_to_glob(nrow_a,ibcheck,desc_a,info) + call psb_loc_to_glob(acsr%ja(1:nztota),desc_a,info,iact='I') + acsr%ja(:) = acsr%ja(:) - 1 + acsr%irp(:) = acsr%irp(:) - 1 + ifrst = ifrst - 1 + info = amg_dsludist_fact(nglob,nrow_a,nztota,ifrst,& + & acsr%val,acsr%irp,acsr%ja,sv%lufactors,& + & npr,npc) + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='amg_dsludist_fact' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + call acsr%free() + call atmp%free() + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_sludist_solver_bld + + subroutine d_sludist_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_d_sludist_solver_type), intent(inout) :: sv + integer, intent(out) :: info + Integer :: err_act + character(len=20) :: name='d_sludist_solver_free' + + call psb_erractionsave(err_act) + info = 0 + call sv%clear_data(info) + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_sludist_solver_free + + subroutine d_sludist_solver_clear_data(sv,info) + + Implicit None + + ! Arguments + class(amg_d_sludist_solver_type), intent(inout) :: sv + integer, intent(out) :: info + Integer :: err_act + character(len=20) :: name='d_sludist_solver_clear_data' + + call psb_erractionsave(err_act) + + info = psb_success_ + if (c_associated(sv%lufactors)) info = amg_dsludist_free(sv%lufactors) + sv%lufactors = c_null_ptr + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_sludist_solver_clear_data + + ! + function d_sludist_solver_is_global(sv) result(val) + implicit none + class(amg_d_sludist_solver_type), intent(in) :: sv + logical :: val + + val = .true. + end function d_sludist_solver_is_global + + subroutine d_sludist_solver_finalize(sv) + + Implicit None + + ! Arguments + type(amg_d_sludist_solver_type), intent(inout) :: sv + integer :: info + Integer :: err_act + character(len=20) :: name='d_sludist_solver_finalize' + + call sv%free(info) + + return + + end subroutine d_sludist_solver_finalize + + subroutine d_sludist_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_d_sludist_solver_type), intent(in) :: sv + integer, intent(out) :: info + integer, intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer :: err_act + integer :: ictxt, me, np + character(len=20), parameter :: name='amg_d_sludist_solver_descr' + integer :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' SuperLU_Dist Sparse Factorization Solver. ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_sludist_solver_descr + + function d_sludist_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_d_sludist_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer :: i + + val = 2*psb_sizeof_ip + psb_sizeof_dp + val = val + sv%symbsize + val = val + sv%numsize + return + end function d_sludist_solver_sizeof + + function d_sludist_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "SuperLU_Dist solver" + end function d_sludist_solver_get_fmt + + function d_sludist_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_sludist_ + end function d_sludist_solver_get_id +#endif +end module amg_d_sludist_solver diff --git a/mlprec/amg_d_symdec_aggregator_mod.f90 b/mlprec/amg_d_symdec_aggregator_mod.f90 new file mode 100644 index 00000000..f1652eb8 --- /dev/null +++ b/mlprec/amg_d_symdec_aggregator_mod.f90 @@ -0,0 +1,105 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! Locally symmetrized (decoupled) aggregation algorithm. +! This version differs from the basic decoupled aggregation algorithm +! only because it works on (the pattern of) A+A^T instead of A. +! +! +module amg_d_symdec_aggregator_mod + + use amg_d_dec_aggregator_mod + !> \namespace amg_d_symdec_aggregator_mod \class amg_d_symdec_aggregator_type + !! \extends amg_d_dec_aggregator_mod::amg_d_dec_aggregator_type + !! + !! This version differs from the basic decoupled aggregation algorithm + !! only because it works on (the pattern of) A+A^T instead of A. + !! + ! + type, extends(amg_d_dec_aggregator_type) :: amg_d_symdec_aggregator_type + + contains + procedure, pass(ag) :: bld_tprol => amg_d_symdec_aggregator_build_tprol + procedure, pass(ag) :: descr => amg_d_symdec_aggregator_descr + procedure, nopass :: fmt => amg_d_symdec_aggregator_fmt + end type amg_d_symdec_aggregator_type + + + interface + subroutine amg_d_symdec_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,t_prol,info) + import :: amg_d_symdec_aggregator_type, psb_desc_type, psb_dspmat_type, psb_dpk_, & + & psb_ipk_, psb_lpk_, psb_ldspmat_type, amg_dml_parms, amg_daggr_data + implicit none + class(amg_d_symdec_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(amg_daggr_data), intent(in) :: ag_data + type(psb_dspmat_type), intent(inout) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_ldspmat_type), intent(out) :: t_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_d_symdec_aggregator_build_tprol + end interface + + +contains + + function amg_d_symdec_aggregator_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Symmetric Decoupled aggregation" + end function amg_d_symdec_aggregator_fmt + + subroutine amg_d_symdec_aggregator_descr(ag,parms,iout,info) + implicit none + class(amg_d_symdec_aggregator_type), intent(in) :: ag + type(amg_dml_parms), intent(in) :: parms + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + + write(iout,*) 'Decoupled Aggregator locally-symmetrized' + write(iout,*) 'Aggregator object type: ',ag%fmt() + call parms%mldescr(iout,info) + + return + end subroutine amg_d_symdec_aggregator_descr + +end module amg_d_symdec_aggregator_mod diff --git a/mlprec/amg_d_umf_solver.F90 b/mlprec/amg_d_umf_solver.F90 new file mode 100644 index 00000000..a06beb8c --- /dev/null +++ b/mlprec/amg_d_umf_solver.F90 @@ -0,0 +1,453 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_d_umf_solver_mod.f90 +! +! Module: amg_d_umf_solver_mod +! +! This module defines: +! - the amg_d_umf_solver_type data structure containing the ingredients +! to interface with the UMFPACK package. +! 1. The factorization is restricted to the diagonal block of the +! current image. +! +module amg_d_umf_solver + + use iso_c_binding + use amg_d_base_solver_mod + +#if defined(IPK8) + type, extends(amg_d_base_solver_type) :: amg_d_umf_solver_type + + end type amg_d_umf_solver_type + +#else + + type, extends(amg_d_base_solver_type) :: amg_d_umf_solver_type + type(c_ptr) :: symbolic=c_null_ptr, numeric=c_null_ptr + integer(c_long_long) :: symbsize=0, numsize=0 + contains + procedure, pass(sv) :: build => d_umf_solver_bld + procedure, pass(sv) :: apply_a => d_umf_solver_apply + procedure, pass(sv) :: apply_v => d_umf_solver_apply_vect + procedure, pass(sv) :: free => d_umf_solver_free + procedure, pass(sv) :: clear_data => d_umf_solver_clear_data + procedure, pass(sv) :: descr => d_umf_solver_descr + procedure, pass(sv) :: sizeof => d_umf_solver_sizeof + procedure, nopass :: get_fmt => d_umf_solver_get_fmt + procedure, nopass :: get_id => d_umf_solver_get_id + final :: d_umf_solver_finalize + end type amg_d_umf_solver_type + + + private :: d_umf_solver_bld, d_umf_solver_apply, & + & d_umf_solver_free, d_umf_solver_descr, & + & d_umf_solver_sizeof, d_umf_solver_apply_vect, & + & d_umf_solver_get_fmt, d_umf_solver_get_id, & + & d_umf_solver_clear_data + private :: d_umf_solver_finalize + + + + interface + function amg_dumf_fact(n,nnz,values,rowind,colptr,& + & symptr,numptr,ssize,nsize)& + & bind(c,name='amg_dumf_fact') result(info) + use iso_c_binding + integer(c_int), value :: n,nnz + integer(c_int) :: info + integer(c_long_long) :: ssize, nsize + integer(c_int) :: rowind(*),colptr(*) + real(c_double) :: values(*) + type(c_ptr) :: symptr, numptr + end function amg_dumf_fact + end interface + + interface + function amg_dumf_solve(itrans,n,x, b, ldb, numptr)& + & bind(c,name='amg_dumf_solve') result(info) + use iso_c_binding + integer(c_int) :: info + integer(c_int), value :: itrans,n,ldb + real(c_double) :: x(*), b(ldb,*) + type(c_ptr), value :: numptr + end function amg_dumf_solve + end interface + + interface + function amg_dumf_free(symptr, numptr)& + & bind(c,name='amg_dumf_free') result(info) + use iso_c_binding + integer(c_int) :: info + type(c_ptr), value :: symptr, numptr + end function amg_dumf_free + end interface + +contains + + subroutine d_umf_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + use psb_base_mod + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_umf_solver_type), intent(inout) :: sv + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer, intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + + integer :: n_row,n_col + real(psb_dpk_), pointer :: ww(:) + integer :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='d_umf_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + else + allocate(ww(n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/n_col,0,0,0,0/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + endif + + select case(trans_) + case('N') + info = amg_dumf_solve(0,n_row,ww,x,n_row,sv%numeric) + case('T') + ! + ! Note: with UMF, 1 meand Ctranspose, 2 means transpose + ! even for complex data. + ! + if (psb_d_is_complex_) then + info = amg_dumf_solve(2,n_row,ww,x,n_row,sv%numeric) + else + info = amg_dumf_solve(1,n_row,ww,x,n_row,sv%numeric) + end if + case('C') + info = amg_dumf_solve(1,n_row,ww,x,n_row,sv%numeric) + case default + call psb_errpush(psb_err_internal_error_,name,a_err='Invalid TRANS in ILU subsolve') + goto 9999 + end select + + if (info == psb_success_) call psb_geaxpby(alpha,ww,beta,y,desc_data,info) + + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Error in subsolve') + goto 9999 + endif + + if (n_col > size(work)) then + deallocate(ww) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine d_umf_solver_apply + + subroutine d_umf_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + use psb_base_mod + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_umf_solver_type), intent(inout) :: sv + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer, intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + + integer :: err_act + character(len=20) :: name='d_umf_solver_apply_vect' + + call psb_erractionsave(err_act) + + info = psb_success_ + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call x%v%sync() + call y%v%sync() + call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) + call y%v%set_host() + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine d_umf_solver_apply_vect + + subroutine d_umf_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + + Implicit None + + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_umf_solver_type), intent(inout) :: sv + integer, intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + type(psb_dspmat_type) :: atmp + type(psb_d_csc_sparse_mat) :: acsc + integer :: n_row,n_col, nrow_a, nztota + integer :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_umf_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + n_col = desc_a%get_local_cols() + + call a%cscnv(atmp,info,type='coo') + call psb_rwextd(n_row,atmp,info,b=b) + call atmp%cscnv(info,type='csc',dupl=psb_dupl_add_) + call atmp%mv_to(acsc) + nrow_a = acsc%get_nrows() + nztota = acsc%get_nzeros() + ! Fix the entres to call C-base UMFPACK. + acsc%ia(:) = acsc%ia(:) - 1 + acsc%icp(:) = acsc%icp(:) - 1 + info = amg_dumf_fact(nrow_a,nztota,acsc%val,& + & acsc%ia,acsc%icp,sv%symbolic,sv%numeric,& + & sv%symbsize,sv%numsize) + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='amg_dumf_fact' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + call acsc%free() + call atmp%free() + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_umf_solver_bld + + subroutine d_umf_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_d_umf_solver_type), intent(inout) :: sv + integer, intent(out) :: info + Integer :: err_act + character(len=20) :: name='d_umf_solver_free' + + call psb_erractionsave(err_act) + + call sv%clear_data(info) + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_umf_solver_free + + + subroutine d_umf_solver_clear_data(sv,info) + + Implicit None + + ! Arguments + class(amg_d_umf_solver_type), intent(inout) :: sv + integer, intent(out) :: info + Integer :: err_act + character(len=20) :: name='d_umf_solver_clear_data' + + call psb_erractionsave(err_act) + info = 0 + if (c_associated(sv%symbolic).and.c_associated(sv%numeric)) then + info = amg_dumf_free(sv%symbolic,sv%numeric) + + if (info /= psb_success_) goto 9999 + sv%symbolic = c_null_ptr + sv%numeric = c_null_ptr + sv%symbsize = 0 + sv%numsize = 0 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_umf_solver_clear_data + + subroutine d_umf_solver_finalize(sv) + + Implicit None + + ! Arguments + type(amg_d_umf_solver_type), intent(inout) :: sv + integer :: info + Integer :: err_act + character(len=20) :: name='d_umf_solver_finalize' + + call sv%free(info) + + return + + end subroutine d_umf_solver_finalize + + subroutine d_umf_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_d_umf_solver_type), intent(in) :: sv + integer, intent(out) :: info + integer, intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer :: err_act + integer :: ictxt, me, np + character(len=20), parameter :: name='amg_d_umf_solver_descr' + integer :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' UMFPACK Sparse Factorization Solver. ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine d_umf_solver_descr + + function d_umf_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_d_umf_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer :: i + + val = 2*psb_sizeof_lp + val = val + sv%symbsize + val = val + sv%numsize + return + end function d_umf_solver_sizeof + + function d_umf_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "UMFPACK solver" + end function d_umf_solver_get_fmt + + function d_umf_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_umf_ + end function d_umf_solver_get_id +#endif +end module amg_d_umf_solver diff --git a/mlprec/amg_prec_mod.f90 b/mlprec/amg_prec_mod.f90 new file mode 100644 index 00000000..5c09edd5 --- /dev/null +++ b/mlprec/amg_prec_mod.f90 @@ -0,0 +1,52 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_prec_mod.f90 +! +! Module: amg_prec_mod +! +! This module defines the interfaces to the real/complex, single/double +! precision versions of the user-level MLD2P4 routines. +! +module amg_prec_mod + + use amg_s_prec_mod + use amg_d_prec_mod + use amg_c_prec_mod + use amg_z_prec_mod + +end module amg_prec_mod diff --git a/mlprec/amg_prec_type.f90 b/mlprec/amg_prec_type.f90 new file mode 100644 index 00000000..33a49f70 --- /dev/null +++ b/mlprec/amg_prec_type.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_prec_type.f90 +! +! Module: amg_prec_type +! +! This module defines: +! - the amg_prec_type data structure containing the preconditioner and related +! data structures; +! - integer constants defining the preconditioner; +! - character constants describing the preconditioner (used by the routines +! printing out a preconditioner description); +! - the interfaces to the routines for the management of the preconditioner +! data structure (see below). +! +! It contains routines for +! - converting character constants defining the preconditioner into integer +! constants; +! - checking if the preconditioner is correctly defined; +! - printing a description of the preconditioner; +! - deallocating the preconditioner data structure. +! + +module amg_prec_type + + use amg_base_prec_type + use amg_s_prec_type + use amg_d_prec_type + use amg_c_prec_type + use amg_z_prec_type + +end module amg_prec_type diff --git a/mlprec/amg_s_as_smoother.f90 b/mlprec/amg_s_as_smoother.f90 new file mode 100644 index 00000000..c25c08da --- /dev/null +++ b/mlprec/amg_s_as_smoother.f90 @@ -0,0 +1,471 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_s_as_smoother_mod.f90 +! +! Module: amg_s_as_smoother_mod +! +! This module defines: +! the amg_s_as_smoother_type data structure containing the +! smoother for an Additive Schwarz smoother. +! +! To begin with, the build procedure constructs the extended +! matrix A and its corresponding descriptor (this has multiple +! halo layers duplicated across different processes); it then +! stores in ND the block off-diagonal matrix, and builds the solver +! on the (extended) block diagonal matrix. +! +! The code allows for the variations of Additive Schwartz, Restricted +! Additive Schwartz and Additive Schwartz with Harmonic Extensions. +! From an implementation point of view, these are handled by +! combining application/non-application of the prolongator/restrictor +! operators. +! +module amg_s_as_smoother + + use amg_s_base_smoother_mod + + type, extends(amg_s_base_smoother_type) :: amg_s_as_smoother_type + ! The local solver component is inherited from the + ! parent type. + ! class(amg_s_base_solver_type), allocatable :: sv + ! + type(psb_sspmat_type) :: nd + type(psb_desc_type) :: desc_data + integer(psb_ipk_) :: novr, restr, prol + integer(psb_lpk_) :: nd_nnz_tot + contains + procedure, pass(sm) :: apply_v => amg_s_as_smoother_apply_vect + procedure, pass(sm) :: apply_a => amg_s_as_smoother_apply + procedure, pass(sm) :: check => amg_s_as_smoother_check + procedure, pass(sm) :: dump => amg_s_as_smoother_dmp + procedure, pass(sm) :: build => amg_s_as_smoother_bld + procedure, pass(sm) :: cnv => amg_s_as_smoother_cnv + procedure, pass(sm) :: clone => amg_s_as_smoother_clone + procedure, pass(sm) :: clone_settings => amg_s_as_smoother_clone_settings + procedure, pass(sm) :: clear_data => amg_s_as_smoother_clear_data + procedure, pass(sm) :: restr_a => amg_s_as_smoother_restr_a + procedure, pass(sm) :: prol_a => amg_s_as_smoother_prol_a + procedure, pass(sm) :: restr_v => amg_s_as_smoother_restr_v + procedure, pass(sm) :: prol_v => amg_s_as_smoother_prol_v + generic, public :: apply_restr => restr_v, restr_a + generic, public :: apply_prol => prol_v, prol_a + procedure, pass(sm) :: free => amg_s_as_smoother_free + procedure, pass(sm) :: cseti => amg_s_as_smoother_cseti + procedure, pass(sm) :: csetc => amg_s_as_smoother_csetc + procedure, pass(sm) :: descr => s_as_smoother_descr + procedure, pass(sm) :: sizeof => s_as_smoother_sizeof + procedure, pass(sm) :: default => s_as_smoother_default + procedure, pass(sm) :: get_nzeros => s_as_smoother_get_nzeros + procedure, pass(sm) :: get_wrksz => s_as_smoother_get_wrksize + procedure, nopass :: get_fmt => s_as_smoother_get_fmt + procedure, nopass :: get_id => s_as_smoother_get_id + end type amg_s_as_smoother_type + + + private :: s_as_smoother_descr, s_as_smoother_sizeof, & + & s_as_smoother_default, s_as_smoother_get_nzeros, & + & s_as_smoother_get_fmt, s_as_smoother_get_id, & + & s_as_smoother_get_wrksize + + character(len=6), parameter, private :: & + & restrict_names(0:4)=(/'none ','halo ',' ',' ',' '/) + character(len=12), parameter, private :: & + & prolong_names(0:3)=(/'none ','sum ','average ','square root'/) + + + interface + subroutine amg_s_as_smoother_check(sm,info) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_spk_, amg_s_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_s_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_as_smoother_check + end interface + + interface + subroutine amg_s_as_smoother_restr_v(sm,x,trans,work,info,data) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_spk_, amg_s_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + class(amg_s_as_smoother_type), intent(inout) :: sm + type(psb_s_vect_type),intent(inout) :: x + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + end subroutine amg_s_as_smoother_restr_v + end interface + + interface + subroutine amg_s_as_smoother_restr_a(sm,x,trans,work,info,data) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_spk_, amg_s_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + class(amg_s_as_smoother_type), intent(inout) :: sm + real(psb_spk_), intent(inout) :: x(:) + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + end subroutine amg_s_as_smoother_restr_a + end interface + + interface + subroutine amg_s_as_smoother_prol_v(sm,x,trans,work,info,data) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_spk_, amg_s_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + class(amg_s_as_smoother_type), intent(inout) :: sm + type(psb_s_vect_type),intent(inout) :: x + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + end subroutine amg_s_as_smoother_prol_v + end interface + + interface + subroutine amg_s_as_smoother_prol_a(sm,x,trans,work,info,data) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_spk_, amg_s_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + class(amg_s_as_smoother_type), intent(inout) :: sm + real(psb_spk_), intent(inout) :: x(:) + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + end subroutine amg_s_as_smoother_prol_a + end interface + + + interface + subroutine amg_s_as_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,wv,info,init,initu) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_spk_, amg_s_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_as_smoother_type), intent(inout) :: sm + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + end subroutine amg_s_as_smoother_apply_vect + end interface + + interface + subroutine amg_s_as_smoother_apply(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,info,init,initu) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_spk_, amg_s_as_smoother_type, psb_epk_,& + & psb_desc_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_as_smoother_type), intent(inout) :: sm + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_s_as_smoother_apply + end interface + + interface + subroutine amg_s_as_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_spk_, amg_s_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_s_base_sparse_mat, psb_ipk_,& + & psb_i_base_vect_type + implicit none + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_as_smoother_bld + end interface + + interface + subroutine amg_s_as_smoother_cnv(sm,info,amold,vmold,imold) + import :: psb_s_base_vect_type, & + & psb_spk_, amg_s_as_smoother_type, psb_epk_, & + & psb_s_base_sparse_mat, psb_ipk_, psb_i_base_vect_type + implicit none + class(amg_s_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_as_smoother_cnv + end interface + + interface + subroutine amg_s_as_smoother_cseti(sm,what,val,info,idx) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_spk_, amg_s_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_s_as_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_s_as_smoother_cseti + end interface + + interface + subroutine amg_s_as_smoother_csetc(sm,what,val,info,idx) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_spk_, amg_s_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_s_as_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_s_as_smoother_csetc + end interface + + interface + subroutine amg_s_as_smoother_free(sm,info) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_spk_, amg_s_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_s_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_as_smoother_free + end interface + + interface + subroutine amg_s_as_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_spk_, amg_s_as_smoother_type, psb_epk_, psb_desc_type, & + & psb_ipk_ + implicit none + class(amg_s_as_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + end subroutine amg_s_as_smoother_dmp + end interface + + interface + subroutine amg_s_as_smoother_clone(sm,smout,info) + import :: amg_s_as_smoother_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_ + class(amg_s_as_smoother_type), intent(inout) :: sm + class(amg_s_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_as_smoother_clone + end interface + + + interface + subroutine amg_s_as_smoother_clone_settings(sm,smout,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_smoother_type, amg_s_as_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_as_smoother_type), intent(inout) :: sm + class(amg_s_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_as_smoother_clone_settings + end interface + + interface + subroutine amg_s_as_smoother_clear_data(sm,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_as_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_as_smoother_clear_data + end interface + + +contains + + function s_as_smoother_sizeof(sm) result(val) + implicit none + ! Arguments + class(amg_s_as_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 3*psb_sizeof_ip + psb_sizeof_lp + if (allocated(sm%sv)) val = val + sm%sv%sizeof() + val = val + sm%nd%sizeof() + + return + end function s_as_smoother_sizeof + + function s_as_smoother_get_nzeros(sm) result(val) + implicit none + class(amg_s_as_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + if (allocated(sm%sv)) & + & val = sm%sv%get_nzeros() + val = val + sm%nd%get_nzeros() + + end function s_as_smoother_get_nzeros + + subroutine s_as_smoother_default(sm) + + use psb_base_mod, only : psb_halo_, psb_none_ + + Implicit None + + ! Arguments + class(amg_s_as_smoother_type), intent(inout) :: sm + + ! + ! Default: AS with 1 overlap layer + ! + sm%restr = psb_halo_ + sm%prol = psb_sum_ + sm%novr = 1 + + if (allocated(sm%sv)) then + call sm%sv%default() + end if + + return + end subroutine s_as_smoother_default + + + subroutine s_as_smoother_descr(sm,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_s_as_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_s_as_smoother_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (.not.coarse_) then + write(iout_,*) ' Additive Schwarz with ',& + & sm%novr, ' overlap layers.' + write(iout_,*) ' Restrictor: ',restrict_names(sm%restr) + write(iout_,*) ' Prolongator: ',prolong_names(sm%prol) + write(iout_,*) ' Local solver:' + endif + if (allocated(sm%sv)) then + call sm%sv%descr(info,iout_,coarse=coarse) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine s_as_smoother_descr + + function s_as_smoother_get_wrksize(sm) result(val) + implicit none + class(amg_s_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_) :: val + + val = 3 + if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() + + end function s_as_smoother_get_wrksize + + function s_as_smoother_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Additive Schwarz" + end function s_as_smoother_get_fmt + + function s_as_smoother_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_as_ + end function s_as_smoother_get_id + +end module amg_s_as_smoother diff --git a/mlprec/amg_s_base_aggregator_mod.f90 b/mlprec/amg_s_base_aggregator_mod.f90 new file mode 100644 index 00000000..140e6564 --- /dev/null +++ b/mlprec/amg_s_base_aggregator_mod.f90 @@ -0,0 +1,519 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! The aggregator object hosts the aggregation method for building +! the multilevel hierarchy. +! +module amg_s_base_aggregator_mod + + use amg_base_prec_type, only : amg_sml_parms, amg_saggr_data + use psb_base_mod, only : psb_sspmat_type, psb_lsspmat_type, psb_s_vect_type, & + & psb_s_base_vect_type, psb_slinmap_type, psb_spk_, & + & psb_ls_csr_sparse_mat, psb_ls_coo_sparse_mat, & + & psb_s_csr_sparse_mat, psb_s_coo_sparse_mat, & + & psb_ipk_, psb_epk_, psb_lpk_, psb_desc_type, psb_i_base_vect_type, & + & psb_erractionsave, psb_error_handler, psb_success_, psb_toupper + ! + ! + ! + !> \class amg_s_base_aggregator_type + !! + !! It is the data type containing the basic interface definition for + !! building a multigrid hierarchy by aggregation. The base object has no attributes, + !! it is intended to be essentially an abstract type. + !! + !! + !! type amg_s_base_aggregator_type + !! end type + !! + !! + !! Methods: + !! + !! bld_tprol - Build a tentative prolongator + !! + !! mat_bld - Build prolongator/restrictor and coarse matrix ac + !! + !! mat_asb - Convert prolongator/restrictor/coarse matrix + !! and fix their descriptor(s) + !! + !! update_next - Transfer information to the next level; default is + !! to do nothing, i.e. aggregators at different + !! levels are independent. + !! + !! default - Apply defaults + !! set_aggr_type - For aggregator that have internal options. + !! fmt - Return a short string description + !! descr - Print a more detailed description + !! + !! cseti, csetr, csetc - Set internal parameters, if any + ! + type amg_s_base_aggregator_type + ! Do we want to purge explicit zeros when aggregating? + logical :: do_clean_zeros + contains + procedure, pass(ag) :: bld_tprol => amg_s_base_aggregator_build_tprol + procedure, pass(ag) :: mat_bld => amg_s_base_aggregator_mat_bld + procedure, pass(ag) :: mat_asb => amg_s_base_aggregator_mat_asb + procedure, pass(ag) :: bld_map => amg_s_base_aggregator_bld_map + procedure, pass(ag) :: update_next => amg_s_base_aggregator_update_next + procedure, pass(ag) :: clone => amg_s_base_aggregator_clone + procedure, pass(ag) :: free => amg_s_base_aggregator_free + procedure, pass(ag) :: default => amg_s_base_aggregator_default + procedure, pass(ag) :: descr => amg_s_base_aggregator_descr + procedure, pass(ag) :: sizeof => amg_s_base_aggregator_sizeof + procedure, pass(ag) :: set_aggr_type => amg_s_base_aggregator_set_aggr_type + procedure, nopass :: fmt => amg_s_base_aggregator_fmt + procedure, pass(ag) :: cseti => amg_s_base_aggregator_cseti + procedure, pass(ag) :: csetr => amg_s_base_aggregator_csetr + procedure, pass(ag) :: csetc => amg_s_base_aggregator_csetc + generic, public :: set => cseti, csetr, csetc + procedure, nopass :: xt_desc => amg_s_base_aggregator_xt_desc + end type amg_s_base_aggregator_type + + abstract interface + subroutine amg_s_soc_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, psb_ipk_, psb_lpk_ + implicit none + integer(psb_ipk_), intent(in) :: iorder + logical, intent(in) :: clean_zeros + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + real(psb_spk_), intent(in) :: theta + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_soc_map_bld + end interface + + interface amg_ptap + subroutine amg_s_ptap(a_csr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_cprol,coo_restr,info,desc_ax) + import :: psb_s_csr_sparse_mat, psb_sspmat_type, psb_desc_type, & + & psb_s_coo_sparse_mat, amg_sml_parms, psb_spk_, psb_ipk_, psb_lpk_ + implicit none + type(psb_s_csr_sparse_mat), intent(inout) :: a_csr + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + type(amg_sml_parms), intent(inout) :: parms + type(psb_s_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr + type(psb_desc_type), intent(inout) :: desc_cprol + type(psb_sspmat_type), intent(out) :: ac + integer(psb_ipk_), intent(out) :: info + type(psb_desc_type), intent(inout), optional :: desc_ax + end subroutine amg_s_ptap +!!$ subroutine amg_s_ls_ptap(a_csr,desc_a,nlaggr,parms,ac,& +!!$ & coo_prol,desc_cprol,coo_restr,info,desc_ax) +!!$ import :: psb_s_csr_sparse_mat, psb_lsspmat_type, psb_desc_type, & +!!$ & psb_ls_coo_sparse_mat, amg_sml_parms, psb_spk_, psb_ipk_, psb_lpk_ +!!$ implicit none +!!$ type(psb_s_csr_sparse_mat), intent(inout) :: a_csr +!!$ type(psb_desc_type), intent(in) :: desc_a +!!$ integer(psb_lpk_), intent(inout) :: nlaggr(:) +!!$ type(amg_sml_parms), intent(inout) :: parms +!!$ type(psb_ls_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr +!!$ type(psb_desc_type), intent(inout) :: desc_cprol +!!$ type(psb_lsspmat_type), intent(out) :: ac +!!$ integer(psb_ipk_), intent(out) :: info +!!$ type(psb_desc_type), intent(inout), optional :: desc_ax +!!$ end subroutine amg_s_ls_ptap +!!$ subroutine amg_ls_ptap(a_csr,desc_a,nlaggr,parms,ac,& +!!$ & coo_prol,desc_cprol,coo_restr,info,desc_ax) +!!$ import :: psb_ls_csr_sparse_mat, psb_lsspmat_type, psb_desc_type, & +!!$ & psb_ls_coo_sparse_mat, amg_sml_parms, psb_spk_, psb_ipk_, psb_lpk_ +!!$ implicit none +!!$ type(psb_ls_csr_sparse_mat), intent(inout) :: a_csr +!!$ type(psb_desc_type), intent(in) :: desc_a +!!$ integer(psb_lpk_), intent(inout) :: nlaggr(:) +!!$ type(amg_sml_parms), intent(inout) :: parms +!!$ type(psb_ls_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr +!!$ type(psb_desc_type), intent(inout) :: desc_cprol +!!$ type(psb_lsspmat_type), intent(out) :: ac +!!$ integer(psb_ipk_), intent(out) :: info +!!$ type(psb_desc_type), intent(inout), optional :: desc_ax +!!$ end subroutine amg_ls_ptap + end interface amg_ptap + +contains + + subroutine amg_s_base_aggregator_cseti(ag,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_s_base_aggregator_type), intent(inout) :: ag + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + ! Do nothing + info = 0 + end subroutine amg_s_base_aggregator_cseti + + subroutine amg_s_base_aggregator_csetr(ag,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_s_base_aggregator_type), intent(inout) :: ag + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + ! Do nothing + info = 0 + end subroutine amg_s_base_aggregator_csetr + + subroutine amg_s_base_aggregator_csetc(ag,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_s_base_aggregator_type), intent(inout) :: ag + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + ! Set clean zeros, or do nothing. + select case (psb_toupper(trim(what))) + case('AGGR_CLEAN_ZEROS') + select case (psb_toupper(trim(val))) + case('TRUE','T') + ag%do_clean_zeros = .true. + case('FALSE','F') + ag%do_clean_zeros = .false. + end select + end select + info = 0 + end subroutine amg_s_base_aggregator_csetc + + + subroutine amg_s_base_aggregator_update_next(ag,agnext,info) + implicit none + class(amg_s_base_aggregator_type), target, intent(inout) :: ag, agnext + integer(psb_ipk_), intent(out) :: info + + ! + ! Base version does nothing. + ! + info = 0 + end subroutine amg_s_base_aggregator_update_next + + subroutine amg_s_base_aggregator_clone(ag,agnext,info) + implicit none + class(amg_s_base_aggregator_type), intent(inout) :: ag + class(amg_s_base_aggregator_type), allocatable, intent(inout) :: agnext + integer(psb_ipk_), intent(out) :: info + + info = 0 + if (allocated(agnext)) then + call agnext%free(info) + if (info == 0) deallocate(agnext,stat=info) + end if + if (info /= 0) return + allocate(agnext,source=ag,stat=info) + + end subroutine amg_s_base_aggregator_clone + + subroutine amg_s_base_aggregator_free(ag,info) + implicit none + class(amg_s_base_aggregator_type), intent(inout) :: ag + integer(psb_ipk_), intent(out) :: info + + info = psb_success_ + return + end subroutine amg_s_base_aggregator_free + + subroutine amg_s_base_aggregator_default(ag) + implicit none + class(amg_s_base_aggregator_type), intent(inout) :: ag + ! Only one default setting + ag%do_clean_zeros = .true. + + return + end subroutine amg_s_base_aggregator_default + + function amg_s_base_aggregator_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Default aggregator " + end function amg_s_base_aggregator_fmt + + function amg_s_base_aggregator_sizeof(ag) result(val) + implicit none + class(amg_s_base_aggregator_type), intent(in) :: ag + integer(psb_epk_) :: val + + val = 1 + end function amg_s_base_aggregator_sizeof + + function amg_s_base_aggregator_xt_desc() result(val) + implicit none + logical :: val + + val = .false. + end function amg_s_base_aggregator_xt_desc + + subroutine amg_s_base_aggregator_descr(ag,parms,iout,info) + implicit none + class(amg_s_base_aggregator_type), intent(in) :: ag + type(amg_sml_parms), intent(in) :: parms + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + + write(iout,*) 'Aggregator object type: ',ag%fmt() + call parms%mldescr(iout,info) + + return + end subroutine amg_s_base_aggregator_descr + + subroutine amg_s_base_aggregator_set_aggr_type(ag,parms,info) + implicit none + class(amg_s_base_aggregator_type), intent(inout) :: ag + type(amg_sml_parms), intent(in) :: parms + integer(psb_ipk_), intent(out) :: info + + ! Do nothing + + return + end subroutine amg_s_base_aggregator_set_aggr_type + + ! + !> Function bld_tprol: + !! \memberof amg_s_base_aggregator_type + !! \brief Build a tentative prolongator. + !! The routine will map the local matrix entries to aggregates. + !! The mapping is store in ILAGGR; for each local row index I, + !! ILAGGR(I) contains the index of the aggregate to which index I + !! will contribute, in global numbering. + !! Many aggregations produce a binary tentative prolongator, but some + !! do not, hence we also need the OP_PROL output. + !! AG_DATA is passed here just in case some of the + !! aggregators need it internally, most of them will ignore. + !! + !! \param ag The input aggregator object + !! \param parms The auxiliary parameters object + !! \param ag_data Auxiliary global aggregation info + !! \param a The local matrix part + !! \param desc_a The descriptor + !! \param ilaggr Output aggregation map + !! \param nlaggr Sizes of ilaggr on all processes + !! \param op_prol The tentative prolongator operator + !! \param info Return code + !! + ! + subroutine amg_s_base_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,t_prol,info) + use psb_base_mod + implicit none + class(amg_s_base_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(amg_saggr_data), intent(in) :: ag_data + type(psb_sspmat_type), intent(inout) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lsspmat_type), intent(out) :: t_prol + integer(psb_ipk_), intent(out) :: info + + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_aggregator_build_tprol' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + + end subroutine amg_s_base_aggregator_build_tprol + + ! + !> Function mat_bld + !! \memberof amg_s_base_aggregator_type + !! \brief Build prolongator/restrictor/coarse matrix. + !! + !! + !! \param ag The input aggregator object + !! \param parms The auxiliary parameters object + !! \param a The local matrix part + !! \param desc_a The descriptor + !! \param ilaggr Aggregation map + !! \param nlaggr Sizes of ilaggr on all processes + !! \param ac On output the coarse matrix + !! \param op_prol On input, the tentative prolongator operator, on output + !! the final prolongator + !! \param op_restr On output, the restrictor operator; + !! in many cases it is the transpose of the prolongator. + !! \param info Return code + !! + subroutine amg_s_base_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + use psb_base_mod + implicit none + class(amg_s_base_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(psb_lsspmat_type), intent(inout) :: t_prol + type(psb_sspmat_type), intent(out) :: op_prol, ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_aggregator_mat_bld' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + end subroutine amg_s_base_aggregator_mat_bld + + ! + !> Function mat_asb + !! \memberof amg_s_base_aggregator_type + !! \brief Build prolongator/restrictor/coarse matrix. + !! + !! + !! \param ag The input aggregator object + !! \param parms The auxiliary parameters object + !! \param a The local matrix part + !! \param desc_a The descriptor + !! \param ilaggr Aggregation map + !! \param nlaggr Sizes of ilaggr on all processes + !! \param ac On output the coarse matrix + !! \param op_prol On input, the tentative prolongator operator, on output + !! the final prolongator + !! \param op_restr On output, the restrictor operator; + !! in many cases it is the transpose of the prolongator. + !! \param info Return code + !! + subroutine amg_s_base_aggregator_mat_asb(ag,parms,a,desc_a,& + & ac,desc_ac, op_prol,op_restr,info) + use psb_base_mod + implicit none + class(amg_s_base_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + type(psb_sspmat_type), intent(inout) :: op_prol,ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_aggregator_mat_asb' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + end subroutine amg_s_base_aggregator_mat_asb + + ! + !> Function bld_map + !! \memberof amg_s_base_aggregator_type + !! \brief Build linear map between hierarchy levels + !! + !! + !! \param ag The input aggregator object + !! \param desc_a The fine space descriptor + !! \param desc_ac The coarse space descriptor + !! \param ilaggr Aggregation map vector + !! \param nlaggr Sizes of ilaggr on all processes + !! \param op_prol The prolongator operator + !! \param op_restr The restrictor operator + !! \param map The output map + !! \param info Return code + !! + subroutine amg_s_base_aggregator_bld_map(ag,desc_a,desc_ac,ilaggr,nlaggr,& + & op_restr,op_prol,map,info) + use psb_base_mod + implicit none + class(amg_s_base_aggregator_type), target, intent(inout) :: ag + type(psb_desc_type), intent(in), target :: desc_a, desc_ac + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(psb_sspmat_type), intent(inout) :: op_restr, op_prol + type(psb_slinmap_type), intent(out) :: map + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_aggregator_bld_map' + + call psb_erractionsave(err_act) + ! + ! Copy the prolongation/restriction matrices into the descriptor map. + ! op_restr => PR^T i.e. restriction operator + ! op_prol => PR i.e. prolongation operator + ! + ! WARNING: need to check whether the copy into IOP_RESTR/IOP_PROL + ! is safe or not. + ! + ! This default implementation reuses desc_a/desc_ac through + ! pointers in the map structure. + ! + map = psb_linmap(psb_map_aggr_,desc_a,& + & desc_ac,op_restr,op_prol,ilaggr,nlaggr) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + end subroutine amg_s_base_aggregator_bld_map + + +end module amg_s_base_aggregator_mod diff --git a/mlprec/amg_s_base_smoother_mod.f90 b/mlprec/amg_s_base_smoother_mod.f90 new file mode 100644 index 00000000..b8554248 --- /dev/null +++ b/mlprec/amg_s_base_smoother_mod.f90 @@ -0,0 +1,412 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_s_base_smoother_mod.f90 +! +! Module: amg_s_base_smoother_mod +! +! This module defines: +! - the amg_s_base_smoother_type data structure containing the +! smoother and related data structures; +! +! It contains routines for +! - Building and applying; +! - checking if the smoother is correctly defined; +! - printing a description of the preconditioner; +! - deallocating the preconditioner data structure. +! +! What is the difference between a smoother and a solver? +! In the mathematics literature the two concepts are treated +! essentially as synonymous, but here we are using them in a more +! computer-science oriented fashion. In particular, a SMOOTHER object +! contains a SOLVER object: the SOLVER operates locally within the +! current process, whereas the SMOOTHER object accounts for (possible) +! interactions between processes. +! Some solvers (MUMPS and SuperLU_DIST) can also operate on the entire +! distributed matrix, in which case the smoother object essentially +! becomes transparent. +! +module amg_s_base_smoother_mod + + use amg_s_base_solver_mod + use psb_base_mod, only : psb_desc_type, psb_sspmat_type, psb_epk_,& + & psb_s_vect_type, psb_s_base_vect_type, psb_s_base_sparse_mat, & + & psb_spk_, psb_i_base_vect_type, psb_erractionsave, psb_error_handler + + ! + ! + ! + ! Type: amg_T_base_smoother_type. + ! + ! It holds the smoother a single level. Its only mandatory component is a solver + ! object which holds a local solver; this decoupling allows to have the same solver + ! e.g ILU to work with Jacobi with multiple sweeps as well as with any AS variant. + ! + ! type amg_T_base_smoother_type + ! class(amg_T_base_solver_type), allocatable :: sv + ! end type amg_T_base_smoother_type + ! + ! Methods: + ! + ! build - Compute the actual contents of the smoother; includes + ! invocation of the build method on the solver component. + ! free - Release memory + ! apply - Apply the smoother to a vector (or to an array); includes + ! invocation of the apply method on the solver component. + ! descr - Prints a description of the object. + ! default - Set default values + ! dump - Dump to file object contents + ! set - Sets various parameters; when a request is unknown + ! it is passed to the solver object for further processing. + ! check - Sanity checks. + ! sizeof - Total memory occupation in bytes + ! get_nzeros - Number of nonzeros + ! stringval - convert string to val for internal parms + ! get_fmt - short string descriptor + ! get_id - numeric id descriptro + ! get_wrksz - How many workspace vector does apply_vect need + ! + ! + ! + + type amg_s_base_smoother_type + class(amg_s_base_solver_type), allocatable :: sv + contains + procedure, pass(sm) :: apply_v => amg_s_base_smoother_apply_vect + procedure, pass(sm) :: apply_a => amg_s_base_smoother_apply + generic, public :: apply => apply_a, apply_v + procedure, pass(sm) :: check => amg_s_base_smoother_check + procedure, pass(sm) :: dump => amg_s_base_smoother_dmp + procedure, pass(sm) :: clone => amg_s_base_smoother_clone + procedure, pass(sm) :: build => amg_s_base_smoother_bld + procedure, pass(sm) :: cnv => amg_s_base_smoother_cnv + procedure, pass(sm) :: free => amg_s_base_smoother_free + procedure, pass(sm) :: clone_settings => amg_s_base_smoother_clone_settings + procedure, pass(sm) :: clear_data => amg_s_base_smoother_clear_data + procedure, pass(sm) :: cseti => amg_s_base_smoother_cseti + procedure, pass(sm) :: csetc => amg_s_base_smoother_csetc + procedure, pass(sm) :: csetr => amg_s_base_smoother_csetr + generic, public :: set => cseti, csetc, csetr + procedure, pass(sm) :: default => s_base_smoother_default + procedure, pass(sm) :: descr => amg_s_base_smoother_descr + procedure, pass(sm) :: sizeof => s_base_smoother_sizeof + procedure, pass(sm) :: get_nzeros => s_base_smoother_get_nzeros + procedure, pass(sm) :: get_wrksz => s_base_smoother_get_wrksize + procedure, nopass :: stringval => amg_stringval + procedure, nopass :: get_fmt => s_base_smoother_get_fmt + procedure, nopass :: get_id => s_base_smoother_get_id + end type amg_s_base_smoother_type + + + private :: s_base_smoother_sizeof, s_base_smoother_get_fmt, & + & s_base_smoother_default, s_base_smoother_get_nzeros, & + & s_base_smoother_get_id, s_base_smoother_get_wrksize + + + + interface + subroutine amg_s_base_smoother_apply(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,info,init,initu) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_base_smoother_type), intent(inout) :: sm + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_s_base_smoother_apply + end interface + + interface + subroutine amg_s_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,wv,info,init,initu) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_base_smoother_type), intent(inout) :: sm + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + end subroutine amg_s_base_smoother_apply_vect + end interface + + interface + subroutine amg_s_base_smoother_check(sm,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_base_smoother_check + end interface + + interface + subroutine amg_s_base_smoother_cseti(sm,what,val,info,idx) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_s_base_smoother_cseti + end interface + + interface + subroutine amg_s_base_smoother_csetc(sm,what,val,info,idx) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_ + class(amg_s_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_s_base_smoother_csetc + end interface + + interface + subroutine amg_s_base_smoother_csetr(sm,what,val,info,idx) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_s_base_smoother_csetr + end interface + + interface + subroutine amg_s_base_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_, psb_i_base_vect_type + ! Arguments + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_base_smoother_bld + end interface + + interface + subroutine amg_s_base_smoother_cnv(sm,info,amold,vmold,imold) + import :: psb_s_base_sparse_mat, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_, psb_i_base_vect_type + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_base_smoother_cnv + end interface + + interface + subroutine amg_s_base_smoother_free(sm,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_base_smoother_free + end interface + + interface + subroutine amg_s_base_smoother_descr(sm,info,iout,coarse) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_s_base_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + end subroutine amg_s_base_smoother_descr + end interface + + interface + subroutine amg_s_base_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_ + class(amg_s_base_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + end subroutine amg_s_base_smoother_dmp + end interface + + interface + subroutine amg_s_base_smoother_clone(sm,smout,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + class(amg_s_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_base_smoother_clone + end interface + + interface + subroutine amg_s_base_smoother_clone_settings(sm,smout,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + class(amg_s_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_base_smoother_clone_settings + end interface + + interface + subroutine amg_s_base_smoother_clear_data(sm,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_base_smoother_clear_data + end interface + +contains + ! + ! Function returning the size of the amg_prec_type data structure + ! in bytes or in number of nonzeros of the operator(s) involved. + ! + + function s_base_smoother_get_nzeros(sm) result(val) + implicit none + class(amg_s_base_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + if (allocated(sm%sv)) & + & val = sm%sv%get_nzeros() + end function s_base_smoother_get_nzeros + + function s_base_smoother_sizeof(sm) result(val) + implicit none + ! Arguments + class(amg_s_base_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + if (allocated(sm%sv)) then + val = sm%sv%sizeof() + end if + + return + end function s_base_smoother_sizeof + + ! + ! Set sensible defaults. + ! To be called immediately after allocation + ! + subroutine s_base_smoother_default(sm) + implicit none + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + ! Do nothing for base version + + if (allocated(sm%sv)) call sm%sv%default() + + return + end subroutine s_base_smoother_default + + function s_base_smoother_get_wrksize(sm) result(val) + implicit none + class(amg_s_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_) :: val + + val = 0 + if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() + + end function s_base_smoother_get_wrksize + + function s_base_smoother_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Base smoother" + end function s_base_smoother_get_fmt + + function s_base_smoother_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_base_smooth_ + end function s_base_smoother_get_id + +end module amg_s_base_smoother_mod diff --git a/mlprec/amg_s_base_solver_mod.f90 b/mlprec/amg_s_base_solver_mod.f90 new file mode 100644 index 00000000..187f058d --- /dev/null +++ b/mlprec/amg_s_base_solver_mod.f90 @@ -0,0 +1,421 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_s_base_solver_mod.f90 +! +! Module: amg_s_base_solver_mod +! +! This module defines: +! - the amg_s_base_solver_type data structure containing the +! basic solver type acting on a subdomain +! +! It contains routines for +! - Building and applying; +! - checking if the solver is correctly defined; +! - printing a description of the solver; +! - deallocating the data structure. +! + +module amg_s_base_solver_mod + + use amg_base_prec_type + use psb_base_mod, only : psb_sspmat_type, & + & psb_s_vect_type, psb_s_base_vect_type, psb_s_base_sparse_mat, & + & psb_spk_, psb_i_base_vect_type, psb_erractionsave, psb_error_handler + ! + ! + ! Type: amg_T_base_solver_type. + ! + ! It holds the local solver; it has no mandatory components. + ! + ! type amg_T_base_solver_type + ! end type amg_T_base_solver_type + ! + ! build - Compute the actual contents of the smoother; includes + ! invocation of the build method on the solver component. + ! free - Release memory + ! apply - Apply the smoother to a vector (or to an array); includes + ! invocation of the apply method on the solver component. + ! descr - Prints a description of the object. + ! default - Set default values + ! dump - Dump to file object contents + ! set - Sets various parameters; when a request is unknown + ! it is passed to the smoother object for further processing. + ! check - Sanity checks. + ! sizeof - Total memory occupation in bytes + ! get_nzeros - Number of nonzeros + ! stringval - convert string to val for internal parms + ! get_fmt - short string descriptor + ! get_id - numeric id descriptro + ! get_wrksz - How many workspace vector does apply_vect need + ! + ! + + type amg_s_base_solver_type + contains + procedure, pass(sv) :: apply_v => amg_s_base_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_s_base_solver_apply + generic, public :: apply => apply_a, apply_v + procedure, pass(sv) :: check => amg_s_base_solver_check + procedure, pass(sv) :: dump => amg_s_base_solver_dmp + procedure, pass(sv) :: clone => amg_s_base_solver_clone + procedure, pass(sv) :: clone_settings => amg_s_base_solver_clone_settings + procedure, pass(sv) :: clear_data => amg_s_base_solver_clear_data + procedure, pass(sv) :: build => amg_s_base_solver_bld + procedure, pass(sv) :: cnv => amg_s_base_solver_cnv + procedure, pass(sv) :: free => amg_s_base_solver_free + procedure, pass(sv) :: cseti => amg_s_base_solver_cseti + procedure, pass(sv) :: csetc => amg_s_base_solver_csetc + procedure, pass(sv) :: csetr => amg_s_base_solver_csetr + generic, public :: set => cseti, csetc, csetr + procedure, pass(sv) :: default => s_base_solver_default + procedure, pass(sv) :: descr => amg_s_base_solver_descr + procedure, pass(sv) :: sizeof => s_base_solver_sizeof + procedure, pass(sv) :: get_nzeros => s_base_solver_get_nzeros + procedure, nopass :: get_wrksz => s_base_solver_get_wrksize + procedure, nopass :: stringval => amg_stringval + procedure, nopass :: get_fmt => s_base_solver_get_fmt + procedure, nopass :: get_id => s_base_solver_get_id + procedure, nopass :: is_iterative => s_base_solver_is_iterative + procedure, pass(sv) :: is_global => s_base_solver_is_global + end type amg_s_base_solver_type + + private :: s_base_solver_sizeof, s_base_solver_default,& + & s_base_solver_get_nzeros, s_base_solver_get_fmt, & + & s_base_solver_is_iterative, s_base_solver_get_id, & + & s_base_solver_get_wrksize, s_base_solver_is_global + + + interface + subroutine amg_s_base_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_base_solver_type), intent(inout) :: sv + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_s_base_solver_apply + end interface + + + interface + subroutine amg_s_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_base_solver_type), intent(inout) :: sv + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + end subroutine amg_s_base_solver_apply_vect + end interface + + interface + subroutine amg_s_base_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, psb_ipk_, psb_i_base_vect_type + Implicit None + + ! Arguments + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type), intent(in), target, optional :: b + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_base_solver_bld + end interface + + interface + subroutine amg_s_base_solver_cnv(sv,info,amold,vmold,imold) + import :: psb_s_base_sparse_mat, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, psb_ipk_, psb_i_base_vect_type + Implicit None + + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_base_solver_cnv + end interface + + interface + subroutine amg_s_base_solver_check(sv,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_base_solver_check + end interface + + interface + subroutine amg_s_base_solver_cseti(sv,what,val,info,idx) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_s_base_solver_cseti + end interface + + interface + subroutine amg_s_base_solver_csetc(sv,what,val,info,idx) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_s_base_solver_csetc + end interface + + interface + subroutine amg_s_base_solver_csetr(sv,what,val,info,idx) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, psb_ipk_ + Implicit None + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_s_base_solver_csetr + end interface + + interface + subroutine amg_s_base_solver_free(sv,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_base_solver_free + end interface + + interface + subroutine amg_s_base_solver_descr(sv,info,iout,coarse) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_base_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + end subroutine amg_s_base_solver_descr + end interface + + interface + subroutine amg_s_base_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, psb_ipk_ + implicit none + class(amg_s_base_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_s_base_solver_dmp + end interface + + interface + subroutine amg_s_base_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_base_solver_clone + end interface + + interface + subroutine amg_s_base_solver_clone_settings(sv,svout,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_base_solver_clone_settings + end interface + + interface + subroutine amg_s_base_solver_clear_data(sv,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_base_solver_clear_data + end interface + +contains + ! + ! Function returning the size of the data structure + ! in bytes or in number of nonzeros of the operator(s) involved. + ! + + function s_base_solver_sizeof(sv) result(val) + implicit none + ! Arguments + class(amg_s_base_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + + return + end function s_base_solver_sizeof + + function s_base_solver_get_nzeros(sv) result(val) + implicit none + class(amg_s_base_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + end function s_base_solver_get_nzeros + + subroutine s_base_solver_default(sv) + implicit none + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + ! Do nothing for base version + + return + end subroutine s_base_solver_default + + function s_base_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Base solver" + end function s_base_solver_get_fmt + + ! + ! If this is true, then the solver needs a starting + ! guess. Currently only handled in JAC smoother. + ! + function s_base_solver_is_iterative() result(val) + implicit none + logical :: val + + val = .false. + end function s_base_solver_is_iterative + ! + ! Is the solver acting globally? In most cases + ! not, SuperLU_Dist does, MUMPS can do either. + ! + function s_base_solver_is_global(sv) result(val) + implicit none + class(amg_s_base_solver_type), intent(in) :: sv + logical :: val + + val = .false. + end function s_base_solver_is_global + + function s_base_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_f_none_ + end function s_base_solver_get_id + + function s_base_solver_get_wrksize() result(val) + implicit none + integer(psb_ipk_) :: val + + val = 0 + end function s_base_solver_get_wrksize + +end module amg_s_base_solver_mod diff --git a/mlprec/amg_s_dec_aggregator_mod.f90 b/mlprec/amg_s_dec_aggregator_mod.f90 new file mode 100644 index 00000000..6064a97e --- /dev/null +++ b/mlprec/amg_s_dec_aggregator_mod.f90 @@ -0,0 +1,201 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! Basic (decoupled) aggregation algorithm. Based on the ideas in +! M. Brezina and P. Vanek, A black-box iterative solver based on a +! two-level Schwarz method, Computing, 63 (1999), 233-263. +! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed +! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 +! (1996), 179-196. +! +module amg_s_dec_aggregator_mod + + use amg_s_base_aggregator_mod + !> \namespace amg_s_dec_aggregator_mod \class amg_s_dec_aggregator_type + !! \extends amg_s_base_aggregator_mod::amg_s_base_aggregator_type + !! + !! type, extends(amg_s_base_aggregator_type) :: amg_s_dec_aggregator_type + !! procedure(amg_s_soc_map_bld), nopass, pointer :: soc_map_bld => null() + !! end type + !! + !! This is the simplest aggregation method: starting from the + !! strength-of-connection measure for defining the aggregation + !! presented in + !! + !! M. Brezina and P. Vanek, A black-box iterative solver based on a + !! two-level Schwarz method, Computing, 63 (1999), 233-263. + !! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed + !! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 + !! (1996), 179-196. + !! + !! it achieves parallelization by simply acting on the local matrix, + !! i.e. by "decoupling" the subdomains. + !! The data structure hosts a "map_bld" function pointer which allows to + !! choose other ways to measure "strength-of-connection", of which the + !! Vanek-Brezina-Mandel is the default. More details are available in + !! + !! P. D'Ambra, D. di Serafino and S. Filippone, On the development of + !! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math. + !! 57 (2007), 1181-1196. + !! + !! The soc_map_bld method is used inside the implementation of build_tprol + !! + ! + ! + type, extends(amg_s_base_aggregator_type) :: amg_s_dec_aggregator_type + procedure(amg_s_soc_map_bld), nopass, pointer :: soc_map_bld => null() + + contains + procedure, pass(ag) :: bld_tprol => amg_s_dec_aggregator_build_tprol + procedure, pass(ag) :: mat_bld => amg_s_dec_aggregator_mat_bld + procedure, pass(ag) :: mat_asb => amg_s_dec_aggregator_mat_asb + procedure, pass(ag) :: default => amg_s_dec_aggregator_default + procedure, pass(ag) :: set_aggr_type => amg_s_dec_aggregator_set_aggr_type + procedure, pass(ag) :: descr => amg_s_dec_aggregator_descr + procedure, nopass :: fmt => amg_s_dec_aggregator_fmt + end type amg_s_dec_aggregator_type + + + procedure(amg_s_soc_map_bld) :: amg_s_soc1_map_bld, amg_s_soc2_map_bld + + interface + subroutine amg_s_dec_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,t_prol,info) + import :: amg_s_dec_aggregator_type, psb_desc_type, psb_sspmat_type, psb_spk_, & + & psb_ipk_, psb_lpk_, psb_lsspmat_type, amg_sml_parms, amg_saggr_data + implicit none + class(amg_s_dec_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(amg_saggr_data), intent(in) :: ag_data + type(psb_sspmat_type), intent(inout) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lsspmat_type), intent(out) :: t_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_dec_aggregator_build_tprol + end interface + + interface + subroutine amg_s_dec_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + import :: amg_s_dec_aggregator_type, psb_desc_type, psb_sspmat_type, psb_spk_, & + & psb_ipk_, psb_lpk_, psb_lsspmat_type, amg_sml_parms + implicit none + class(amg_s_dec_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(psb_lsspmat_type), intent(inout) :: t_prol + type(psb_sspmat_type), intent(out) :: op_prol, ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_dec_aggregator_mat_bld + end interface + + interface + subroutine amg_s_dec_aggregator_mat_asb(ag,parms,a,desc_a,& + & ac,desc_ac,op_prol,op_restr,info) + import :: amg_s_dec_aggregator_type, psb_desc_type, psb_sspmat_type, psb_spk_, & + & psb_ipk_, psb_lpk_, psb_lsspmat_type, amg_sml_parms + implicit none + class(amg_s_dec_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + type(psb_sspmat_type), intent(inout) :: op_prol,ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_dec_aggregator_mat_asb + end interface + +contains + + subroutine amg_s_dec_aggregator_set_aggr_type(ag,parms,info) + use amg_base_prec_type + implicit none + class(amg_s_dec_aggregator_type), intent(inout) :: ag + type(amg_sml_parms), intent(in) :: parms + integer(psb_ipk_), intent(out) :: info + + select case(parms%aggr_type) + case (amg_noalg_) + ag%soc_map_bld => null() + case (amg_soc1_) + ag%soc_map_bld => amg_s_soc1_map_bld + case (amg_soc2_) + ag%soc_map_bld => amg_s_soc2_map_bld + case default + write(0,*) 'Unknown aggregation type, defaulting to SOC1' + ag%soc_map_bld => amg_s_soc1_map_bld + end select + + return + end subroutine amg_s_dec_aggregator_set_aggr_type + + + subroutine amg_s_dec_aggregator_default(ag) + implicit none + class(amg_s_dec_aggregator_type), intent(inout) :: ag + + call ag%amg_s_base_aggregator_type%default() + ag%soc_map_bld => amg_s_soc1_map_bld + + return + end subroutine amg_s_dec_aggregator_default + + function amg_s_dec_aggregator_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Decoupled aggregation" + end function amg_s_dec_aggregator_fmt + + subroutine amg_s_dec_aggregator_descr(ag,parms,iout,info) + implicit none + class(amg_s_dec_aggregator_type), intent(in) :: ag + type(amg_sml_parms), intent(in) :: parms + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + + write(iout,*) 'Decoupled Aggregator' + write(iout,*) 'Aggregator object type: ',ag%fmt() + call parms%mldescr(iout,info) + + return + end subroutine amg_s_dec_aggregator_descr + +end module amg_s_dec_aggregator_mod diff --git a/mlprec/amg_s_diag_solver.f90 b/mlprec/amg_s_diag_solver.f90 new file mode 100644 index 00000000..76530925 --- /dev/null +++ b/mlprec/amg_s_diag_solver.f90 @@ -0,0 +1,398 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_s_diag_solver_mod.f90 +! +! Module: amg_s_diag_solver_mod +! +! This module defines: +! - the amg_s_diag_solver_type data structure containing the +! simple diagonal solver. This extracts the main diagonal of a matrix +! and precomputes its inverse. Combined with a Jacobi "smoother" generates +! what are commonly known as the classic Jacobi iterations +! +module amg_s_diag_solver + + use amg_s_base_solver_mod + + type, extends(amg_s_base_solver_type) :: amg_s_diag_solver_type + type(psb_s_vect_type), allocatable :: dv + real(psb_spk_), allocatable :: d(:) + contains + procedure, pass(sv) :: dump => amg_s_diag_solver_dmp + procedure, pass(sv) :: build => amg_s_diag_solver_bld + procedure, pass(sv) :: cnv => amg_s_diag_solver_cnv + procedure, pass(sv) :: clone => amg_s_diag_solver_clone + procedure, pass(sv) :: clear_data => amg_s_diag_solver_clear_data + procedure, pass(sv) :: apply_v => amg_s_diag_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_s_diag_solver_apply + procedure, pass(sv) :: free => s_diag_solver_free + procedure, pass(sv) :: descr => s_diag_solver_descr + procedure, pass(sv) :: sizeof => s_diag_solver_sizeof + procedure, pass(sv) :: get_nzeros => s_diag_solver_get_nzeros + procedure, nopass :: get_fmt => s_diag_solver_get_fmt + procedure, nopass :: get_id => s_diag_solver_get_id + end type amg_s_diag_solver_type + + + private :: s_diag_solver_free, s_diag_solver_descr, & + & s_diag_solver_sizeof, s_diag_solver_get_nzeros, & + & s_diag_solver_get_fmt, s_diag_solver_get_id + + + interface + subroutine amg_s_diag_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_diag_solver_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_diag_solver_type), intent(inout) :: sv + type(psb_s_vect_type), intent(inout) :: x + type(psb_s_vect_type), intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + end subroutine amg_s_diag_solver_apply_vect + end interface + + interface + subroutine amg_s_diag_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_diag_solver_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_diag_solver_type), intent(inout) :: sv + real(psb_spk_), intent(inout) :: x(:) + real(psb_spk_), intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_s_diag_solver_apply + end interface + + interface + subroutine amg_s_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_diag_solver_type, psb_ipk_, psb_i_base_vect_type + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type), intent(in), target, optional :: b + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_diag_solver_bld + end interface + + interface + subroutine amg_s_diag_solver_cnv(sv,info,amold,vmold,imold) + import :: psb_s_base_sparse_mat, psb_s_base_vect_type, psb_spk_, & + & amg_s_diag_solver_type, psb_ipk_, psb_i_base_vect_type + class(amg_s_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_diag_solver_cnv + end interface + + interface + subroutine amg_s_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, amg_s_diag_solver_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, & + & psb_ipk_ + implicit none + class(amg_s_diag_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_s_diag_solver_dmp + end interface + + interface + subroutine amg_s_diag_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, amg_s_diag_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_diag_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_diag_solver_clone + end interface + + interface + subroutine amg_s_diag_solver_clear_data(sv,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_diag_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_diag_solver_clear_data + end interface + + +contains + + subroutine s_diag_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_s_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_diag_solver_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sv%dv)) call sv%dv%free(info) + + if (allocated(sv%d)) then + deallocate(sv%d,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine s_diag_solver_free + + subroutine s_diag_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_s_diag_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_s_diag_solver_descr' + integer(psb_ipk_) :: iout_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' Diagonal local solver ' + + return + + end subroutine s_diag_solver_descr + + function s_diag_solver_sizeof(sv) result(val) + implicit none + ! Arguments + class(amg_s_diag_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + if (allocated(sv%dv)) val = val + sv%dv%sizeof() + + return + end function s_diag_solver_sizeof + + function s_diag_solver_get_nzeros(sv) result(val) + implicit none + ! Arguments + class(amg_s_diag_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + if (allocated(sv%dv)) val = val + sv%dv%get_nrows() + + return + end function s_diag_solver_get_nzeros + + function s_diag_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Diag solver" + end function s_diag_solver_get_fmt + + function s_diag_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_diag_scale_ + end function s_diag_solver_get_id + +end module amg_s_diag_solver + +! +! Module: amg_s_l1_diag_solver_mod +! +! This module defines: +! - the amg_s_l1_diag_solver_type data structure containing the +! L1 diagonal solver. +! The solver is defined as a diagonal containing in each element the +! inverse of the sum of the absolute values of the matrix entries +! along the corresponding row. +! Combined with a Jacobi "smoother" generates +! what are commonly known as the L1-Jacobi iterations +! + +module amg_s_l1_diag_solver + + use amg_s_diag_solver + + type, extends(amg_s_diag_solver_type) :: amg_s_l1_diag_solver_type + contains + procedure, pass(sv) :: dump => amg_s_l1_diag_solver_dmp + procedure, pass(sv) :: build => amg_s_l1_diag_solver_bld + procedure, pass(sv) :: descr => s_l1_diag_solver_descr + procedure, nopass :: get_fmt => s_l1_diag_solver_get_fmt + procedure, nopass :: get_id => s_l1_diag_solver_get_id + end type amg_s_l1_diag_solver_type + + + private :: s_l1_diag_solver_descr, & + & s_l1_diag_solver_get_fmt, s_l1_diag_solver_get_id + + interface + subroutine amg_s_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_l1_diag_solver_type, psb_ipk_, psb_i_base_vect_type + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_l1_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type), intent(in), target, optional :: b + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_l1_diag_solver_bld + end interface + + interface + subroutine amg_s_l1_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, amg_s_l1_diag_solver_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, & + & psb_ipk_ + implicit none + class(amg_s_l1_diag_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_s_l1_diag_solver_dmp + end interface + +contains + + subroutine s_l1_diag_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_s_l1_diag_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_s_l1_diag_solver_descr' + integer(psb_ipk_) :: iout_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' L1 Diagonal solver ' + + return + + end subroutine s_l1_diag_solver_descr + + function s_l1_diag_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "L1 Diag solver" + end function s_l1_diag_solver_get_fmt + + function s_l1_diag_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_l1_diag_scale_ + end function s_l1_diag_solver_get_id + +end module amg_s_l1_diag_solver + diff --git a/mlprec/amg_s_gs_solver.f90 b/mlprec/amg_s_gs_solver.f90 new file mode 100644 index 00000000..5a386993 --- /dev/null +++ b/mlprec/amg_s_gs_solver.f90 @@ -0,0 +1,588 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! File: amg_s_gs_solver_mod.f90 +! +! Module: amg_s_gs_solver_mod +! +! This module defines: +! - the amg_s_gs_solver_type data structure containing the ingredients +! for a local Gauss-Seidel iteration. We provide Forward GS (FWGS) and +! backward GS (BWGS). The iterations are local to a process (they operate +! on the block diagonal). Combined with a Jacobi smoother will generate a +! hybrid-Gauss-Seidel solver, i.e. Gauss-Seidel within each process, Jacobi +! among the processes. +! With two objects as pre- and post-smoothers it is possible to build a +! Forward-Backward smoother, suitable for symmetric iterations. +! +module amg_s_gs_solver + + use amg_s_base_solver_mod + + type, extends(amg_s_base_solver_type) :: amg_s_gs_solver_type + type(psb_sspmat_type) :: l, u + integer(psb_ipk_) :: sweeps + real(psb_spk_) :: eps + contains + procedure, pass(sv) :: dump => amg_s_gs_solver_dmp + procedure, pass(sv) :: check => s_gs_solver_check + procedure, pass(sv) :: clone => amg_s_gs_solver_clone + procedure, pass(sv) :: clone_settings => amg_s_gs_solver_clone_settings + procedure, pass(sv) :: clear_data => amg_s_gs_solver_clear_data + procedure, pass(sv) :: build => amg_s_gs_solver_bld + procedure, pass(sv) :: cnv => amg_s_gs_solver_cnv + procedure, pass(sv) :: apply_v => amg_s_gs_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_s_gs_solver_apply + procedure, pass(sv) :: free => s_gs_solver_free + procedure, pass(sv) :: cseti => s_gs_solver_cseti + procedure, pass(sv) :: csetc => s_gs_solver_csetc + procedure, pass(sv) :: csetr => s_gs_solver_csetr + procedure, pass(sv) :: descr => s_gs_solver_descr + procedure, pass(sv) :: default => s_gs_solver_default + procedure, pass(sv) :: sizeof => s_gs_solver_sizeof + procedure, pass(sv) :: get_nzeros => s_gs_solver_get_nzeros + procedure, nopass :: get_wrksz => s_gs_solver_get_wrksize + procedure, nopass :: get_fmt => s_gs_solver_get_fmt + procedure, nopass :: get_id => s_gs_solver_get_id + procedure, nopass :: is_iterative => s_gs_solver_is_iterative + end type amg_s_gs_solver_type + + type, extends(amg_s_gs_solver_type) :: amg_s_bwgs_solver_type + contains + procedure, pass(sv) :: build => amg_s_bwgs_solver_bld + procedure, pass(sv) :: apply_v => amg_s_bwgs_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_s_bwgs_solver_apply + procedure, nopass :: get_fmt => s_bwgs_solver_get_fmt + procedure, nopass :: get_id => s_bwgs_solver_get_id + procedure, pass(sv) :: descr => s_bwgs_solver_descr + end type amg_s_bwgs_solver_type + + + private :: s_gs_solver_bld, s_gs_solver_apply, & + & s_gs_solver_free, & + & s_gs_solver_descr, s_gs_solver_sizeof, & + & s_gs_solver_default, s_gs_solver_dmp, & + & s_gs_solver_apply_vect, s_gs_solver_get_nzeros, & + & s_gs_solver_get_fmt, s_gs_solver_check,& + & s_gs_solver_is_iterative, & + & s_bwgs_solver_get_fmt, s_bwgs_solver_descr, & + & s_gs_solver_get_id, s_bwgs_solver_get_id, s_gs_solver_get_wrksize + + interface + subroutine amg_s_gs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, amg_s_gs_solver_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_gs_solver_type), intent(inout) :: sv + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + end subroutine amg_s_gs_solver_apply_vect + subroutine amg_s_bwgs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, amg_s_bwgs_solver_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_bwgs_solver_type), intent(inout) :: sv + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + end subroutine amg_s_bwgs_solver_apply_vect + end interface + + interface + subroutine amg_s_gs_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info,init,initu) + import :: psb_desc_type, amg_s_gs_solver_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_gs_solver_type), intent(inout) :: sv + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_s_gs_solver_apply + subroutine amg_s_bwgs_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, amg_s_bwgs_solver_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_bwgs_solver_type), intent(inout) :: sv + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_s_bwgs_solver_apply + end interface + + interface + subroutine amg_s_gs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, amg_s_gs_solver_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type), intent(in), target, optional :: b + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_gs_solver_bld + subroutine amg_s_bwgs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, amg_s_bwgs_solver_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_bwgs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type), intent(in), target, optional :: b + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_bwgs_solver_bld + end interface + + interface + subroutine amg_s_gs_solver_cnv(sv,info,amold,vmold,imold) + import :: amg_s_gs_solver_type, psb_spk_, & + & psb_s_base_sparse_mat, psb_s_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + class(amg_s_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_gs_solver_cnv + end interface + + interface + subroutine amg_s_gs_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, amg_s_gs_solver_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, & + & psb_ipk_ + implicit none + class(amg_s_gs_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_s_gs_solver_dmp + end interface + + interface + subroutine amg_s_gs_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, amg_s_gs_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_gs_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_gs_solver_clone + end interface + + interface + subroutine amg_s_gs_solver_clone_settings(sv,svout,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, amg_s_gs_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_gs_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_gs_solver_clone_settings + end interface + + interface + subroutine amg_s_gs_solver_clear_data(sv,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_gs_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_gs_solver_clear_data + end interface + +contains + + subroutine s_gs_solver_default(sv) + + Implicit None + + ! Arguments + class(amg_s_gs_solver_type), intent(inout) :: sv + + sv%sweeps = ione + sv%eps = dzero + + return + end subroutine s_gs_solver_default + + subroutine s_gs_solver_check(sv,info) + + Implicit None + + ! Arguments + class(amg_s_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_gs_solver_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + call amg_check_def(sv%sweeps,& + & 'GS Sweeps',ione,is_int_positive) + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine s_gs_solver_check + + subroutine s_gs_solver_cseti(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_s_gs_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_gs_solver_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) + case('SOLVER_SWEEPS') + sv%sweeps = val + case default + call sv%amg_s_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine s_gs_solver_cseti + + subroutine s_gs_solver_csetc(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_s_gs_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='s_gs_solver_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + + + call sv%amg_s_base_solver_type%set(what,val,info,idx=idx) + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info, name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine s_gs_solver_csetc + + subroutine s_gs_solver_csetr(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_s_gs_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_gs_solver_csetr' + + call psb_erractionsave(err_act) + info = psb_success_ + + select case(psb_toupper(what)) + case('SOLVER_EPS') + sv%eps = val + case default + call sv%amg_s_base_solver_type%set(what,val,info,idx=idx) + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine s_gs_solver_csetr + + subroutine s_gs_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_s_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_gs_solver_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + call sv%l%free() + call sv%u%free() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine s_gs_solver_free + + subroutine s_gs_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_s_gs_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_s_gs_solver_descr' + integer(psb_ipk_) :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (sv%eps<=dzero) then + write(iout_,*) ' Forward Gauss-Seidel iterative solver with ',& + & sv%sweeps,' sweeps' + else + write(iout_,*) ' Forward Gauss-Seidel iterative solver with tolerance',& + & sv%eps,' and maxit', sv%sweeps + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine s_gs_solver_descr + + function s_gs_solver_get_nzeros(sv) result(val) + + implicit none + ! Arguments + class(amg_s_gs_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + val = val + sv%l%get_nzeros() + val = val + sv%u%get_nzeros() + + return + end function s_gs_solver_get_nzeros + + function s_gs_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_s_gs_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = psb_sizeof_ip + val = val + sv%l%sizeof() + val = val + sv%u%sizeof() + + return + end function s_gs_solver_sizeof + + function s_gs_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Forward Gauss-Seidel solver" + end function s_gs_solver_get_fmt + + function s_gs_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_gs_ + end function s_gs_solver_get_id + + ! + ! If this is true, then the solver needs a starting + ! guess. Currently only handled in JAC smoother. + ! + function s_gs_solver_is_iterative() result(val) + implicit none + logical :: val + + val = .true. + end function s_gs_solver_is_iterative + + subroutine s_bwgs_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_s_bwgs_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_s_bwgs_solver_descr' + integer(psb_ipk_) :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (sv%eps<=dzero) then + write(iout_,*) ' Backward Gauss-Seidel iterative solver with ',& + & sv%sweeps,' sweeps' + else + write(iout_,*) ' Backward Gauss-Seidel iterative solver with tolerance',& + & sv%eps,' and maxit', sv%sweeps + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine s_bwgs_solver_descr + + function s_bwgs_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Backward Gauss-Seidel solver" + end function s_bwgs_solver_get_fmt + + function s_bwgs_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_bwgs_ + end function s_bwgs_solver_get_id + + function s_gs_solver_get_wrksize() result(val) + implicit none + integer(psb_ipk_) :: val + + val = 2 + end function s_gs_solver_get_wrksize + +end module amg_s_gs_solver diff --git a/mlprec/amg_s_hybrid_aggregator_mod.F90 b/mlprec/amg_s_hybrid_aggregator_mod.F90 new file mode 100644 index 00000000..2a6edd5a --- /dev/null +++ b/mlprec/amg_s_hybrid_aggregator_mod.F90 @@ -0,0 +1,125 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! The aggregator object hosts the aggregation method for building +! the multilevel hierarchy. This variant is based on the hybrid method +! presented in +! +! S. Gratton, P. Henon, P. Jiranek and X. Vasseur: +! Reducing complexity of algebraic multigrid by aggregation +! Numerical Lin. Algebra with Applications, 2016, 23:501-518 +! +module amg_s_hybrid_aggregator_mod + + use amg_s_dec_aggregator_mod + ! + ! sm - class(amg_T_base_smoother_type), allocatable + ! The current level preconditioner (aka smoother). + ! parms - type(amg_RTml_parms) + ! The parameters defining the multilevel strategy. + ! ac - The local part of the current-level matrix, built by + ! coarsening the previous-level matrix. + ! desc_ac - type(psb_desc_type). + ! The communication descriptor associated to the matrix + ! stored in ac. + ! base_a - type(psb_Tspmat_type), pointer. + ! Pointer (really a pointer!) to the local part of the current + ! matrix (so we have a unified treatment of residuals). + ! We need this to avoid passing explicitly the current matrix + ! to the routine which applies the preconditioner. + ! base_desc - type(psb_desc_type), pointer. + ! Pointer to the communication descriptor associated to the + ! matrix pointed by base_a. + ! map - Stores the maps (restriction and prolongation) between the + ! vector spaces associated to the index spaces of the previous + ! and current levels. + ! + ! Methods: + ! Most methods follow the encapsulation hierarchy: they take whatever action + ! is appropriate for the current object, then call the corresponding method for + ! the contained object. + ! As an example: the descr() method prints out a description of the + ! level. It starts by invoking the descr() method of the parms object, + ! then calls the descr() method of the smoother object. + ! + ! descr - Prints a description of the object. + ! default - Set default values + ! dump - Dump to file object contents + ! set - Sets various parameters; when a request is unknown + ! it is passed to the smoother object for further processing. + ! check - Sanity checks. + ! sizeof - Total memory occupation in bytes + ! get_nzeros - Number of nonzeros + ! + ! + type, extends(amg_s_dec_aggregator_type) :: amg_s_hybrid_aggregator_type + + contains + procedure, pass(ag) :: bld_tprol => amg_s_hybrid_aggregator_build_tprol + procedure, nopass :: fmt => amg_s_hybrid_aggregator_fmt + end type amg_s_hybrid_aggregator_type + + + interface + subroutine amg_s_hybrid_aggregator_build_tprol(ag,parms,a,desc_a,ilaggr,nlaggr,op_prol,info) + import :: amg_s_hybrid_aggregator_type, psb_desc_type, psb_sspmat_type, psb_spk_, & + & psb_ipk_, psb_long_int_k_, amg_sml_parms + implicit none + class(amg_s_hybrid_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + integer(psb_ipk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_sspmat_type), intent(out) :: op_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_hybrid_aggregator_build_tprol + end interface + +contains + + + function amg_s_hybrid_aggregator_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Hybrid Decoupled aggregation" + end function amg_s_hybrid_aggregator_fmt + + +end module amg_s_hybrid_aggregator_mod diff --git a/mlprec/amg_s_id_solver.f90 b/mlprec/amg_s_id_solver.f90 new file mode 100644 index 00000000..eac4eac7 --- /dev/null +++ b/mlprec/amg_s_id_solver.f90 @@ -0,0 +1,202 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! +! Identity solver. Reference for nullprec. +! +! +module amg_s_id_solver + + use amg_s_base_solver_mod + + type, extends(amg_s_base_solver_type) :: amg_s_id_solver_type + contains + procedure, pass(sv) :: build => s_id_solver_bld + procedure, pass(sv) :: clone => amg_s_id_solver_clone + procedure, pass(sv) :: apply_v => amg_s_id_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_s_id_solver_apply + procedure, pass(sv) :: free => s_id_solver_free + procedure, pass(sv) :: descr => s_id_solver_descr + procedure, nopass :: get_fmt => s_id_solver_get_fmt + procedure, nopass :: get_id => s_id_solver_get_id + end type amg_s_id_solver_type + + + private :: s_id_solver_bld, & + & s_id_solver_free, s_id_solver_get_fmt, & + & s_id_solver_descr, s_id_solver_get_id + + interface + subroutine amg_s_id_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_id_solver_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_id_solver_type), intent(inout) :: sv + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + end subroutine amg_s_id_solver_apply_vect + end interface + + interface + subroutine amg_s_id_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_id_solver_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_id_solver_type), intent(inout) :: sv + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_s_id_solver_apply + end interface + + interface + subroutine amg_s_id_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, amg_s_id_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_id_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_id_solver_clone + end interface + +contains + + + subroutine s_id_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + Implicit None + + ! Arguments + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_id_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type), intent(in), target, optional :: b + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: i, err_act, debug_unit, debug_level + character(len=20) :: name='s_id_solver_bld', ch_err + + info=psb_success_ + + return + end subroutine s_id_solver_bld + + subroutine s_id_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_s_id_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_id_solver_free' + + info = psb_success_ + + return + end subroutine s_id_solver_free + + subroutine s_id_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_s_id_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_s_id_solver_descr' + integer(psb_ipk_) :: iout_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' Identity local solver ' + + return + + end subroutine s_id_solver_descr + + function s_id_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Identity solver" + end function s_id_solver_get_fmt + + function s_id_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_f_none_ + end function s_id_solver_get_id + +end module amg_s_id_solver diff --git a/mlprec/amg_s_ilu_fact_mod.f90 b/mlprec/amg_s_ilu_fact_mod.f90 new file mode 100644 index 00000000..5b8b3f84 --- /dev/null +++ b/mlprec/amg_s_ilu_fact_mod.f90 @@ -0,0 +1,91 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! File: amg_s_ilu_fact_mod.f90 +! +! Module: amg_s_ilu_fact_mod +! +! This module defines some interfaces used internally by the implementation of +! amg_s_ilu_solver, but not visible to the end user. +! +! +module amg_s_ilu_fact_mod + + use amg_s_base_solver_mod + + interface amg_ilu0_fact + subroutine amg_silu0_fact(ialg,a,l,u,d,info,blck,upd) + import psb_sspmat_type, psb_spk_, psb_ipk_ + integer(psb_ipk_), intent(in) :: ialg + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type),intent(in) :: a + type(psb_sspmat_type),intent(inout) :: l,u + type(psb_sspmat_type),intent(in), optional, target :: blck + character, intent(in), optional :: upd + real(psb_spk_), intent(inout) :: d(:) + end subroutine amg_silu0_fact + end interface + + interface amg_iluk_fact + subroutine amg_siluk_fact(fill_in,ialg,a,l,u,d,info,blck) + import psb_sspmat_type, psb_spk_, psb_ipk_ + integer(psb_ipk_), intent(in) :: fill_in,ialg + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type),intent(in) :: a + type(psb_sspmat_type),intent(inout) :: l,u + type(psb_sspmat_type),intent(in), optional, target :: blck + real(psb_spk_), intent(inout) :: d(:) + end subroutine amg_siluk_fact + end interface + + interface amg_ilut_fact + subroutine amg_silut_fact(fill_in,thres,a,l,u,d,info,blck,iscale) + import psb_sspmat_type, psb_spk_, psb_ipk_ + integer(psb_ipk_), intent(in) :: fill_in + real(psb_spk_), intent(in) :: thres + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type),intent(in) :: a + type(psb_sspmat_type),intent(inout) :: l,u + real(psb_spk_), intent(inout) :: d(:) + type(psb_sspmat_type),intent(in), optional, target :: blck + integer(psb_ipk_), intent(in), optional :: iscale + end subroutine amg_silut_fact + end interface + +end module amg_s_ilu_fact_mod diff --git a/mlprec/amg_s_ilu_solver.f90 b/mlprec/amg_s_ilu_solver.f90 new file mode 100644 index 00000000..13469e7f --- /dev/null +++ b/mlprec/amg_s_ilu_solver.f90 @@ -0,0 +1,502 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! File: amg_s_ilu_solver_mod.f90 +! +! Module: amg_s_ilu_solver_mod +! +! This module defines: +! - the amg_s_ilu_solver_type data structure containing the ingredients +! for a local Incomplete LU factorization. +! 1. The factorization is always restricted to the diagonal block of the +! current image (coherently with the definition of a SOLVER as a local +! object) +! 2. The code provides support for both pattern-based ILU(K) and +! threshold base ILU(T,L) +! 3. The diagonal is stored separately, so strictly speaking this is +! an incomplete LDU factorization; +! 4. The application phase is shared among all variants; +! +! +module amg_s_ilu_solver + + use amg_base_prec_type, only : amg_fact_names + use amg_s_base_solver_mod + use psb_s_ilu_fact_mod + + type, extends(amg_s_base_solver_type) :: amg_s_ilu_solver_type + type(psb_sspmat_type) :: l, u + real(psb_spk_), allocatable :: d(:) + type(psb_s_vect_type) :: dv + integer(psb_ipk_) :: fact_type, fill_in + real(psb_spk_) :: thresh + contains + procedure, pass(sv) :: dump => amg_s_ilu_solver_dmp + procedure, pass(sv) :: check => s_ilu_solver_check + procedure, pass(sv) :: clone => amg_s_ilu_solver_clone + procedure, pass(sv) :: clone_settings => amg_s_ilu_solver_clone_settings + procedure, pass(sv) :: clear_data => amg_s_ilu_solver_clear_data + procedure, pass(sv) :: build => amg_s_ilu_solver_bld + procedure, pass(sv) :: cnv => amg_s_ilu_solver_cnv + procedure, pass(sv) :: apply_v => amg_s_ilu_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_s_ilu_solver_apply + procedure, pass(sv) :: free => s_ilu_solver_free + procedure, pass(sv) :: cseti => s_ilu_solver_cseti + procedure, pass(sv) :: csetc => s_ilu_solver_csetc + procedure, pass(sv) :: csetr => s_ilu_solver_csetr + procedure, pass(sv) :: descr => s_ilu_solver_descr + procedure, pass(sv) :: default => s_ilu_solver_default + procedure, pass(sv) :: sizeof => s_ilu_solver_sizeof + procedure, pass(sv) :: get_nzeros => s_ilu_solver_get_nzeros + procedure, nopass :: get_wrksz => s_ilu_solver_get_wrksize + procedure, nopass :: get_fmt => s_ilu_solver_get_fmt + procedure, nopass :: get_id => s_ilu_solver_get_id + end type amg_s_ilu_solver_type + + + private :: s_ilu_solver_bld, s_ilu_solver_apply, & + & s_ilu_solver_free, & + & s_ilu_solver_descr, s_ilu_solver_sizeof, & + & s_ilu_solver_default, s_ilu_solver_dmp, & + & s_ilu_solver_apply_vect, s_ilu_solver_get_nzeros, & + & s_ilu_solver_get_fmt, s_ilu_solver_check, & + & s_ilu_solver_get_id, s_ilu_solver_get_wrksize + + + interface + subroutine amg_s_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, amg_s_ilu_solver_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_ilu_solver_type), intent(inout) :: sv + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + end subroutine amg_s_ilu_solver_apply_vect + end interface + + interface + subroutine amg_s_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, amg_s_ilu_solver_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_ilu_solver_type), intent(inout) :: sv + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_s_ilu_solver_apply + end interface + + interface + subroutine amg_s_ilu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, amg_s_ilu_solver_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type), intent(in), target, optional :: b + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_ilu_solver_bld + end interface + + interface + subroutine amg_s_ilu_solver_cnv(sv,info,amold,vmold,imold) + import :: amg_s_ilu_solver_type, psb_spk_, & + & psb_s_base_sparse_mat, psb_s_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + class(amg_s_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_ilu_solver_cnv + end interface + + interface + subroutine amg_s_ilu_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, amg_s_ilu_solver_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, & + & psb_ipk_ + implicit none + class(amg_s_ilu_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_s_ilu_solver_dmp + end interface + + interface + subroutine amg_s_ilu_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, amg_s_ilu_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_ilu_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_ilu_solver_clone + end interface + + interface + subroutine amg_s_ilu_solver_clone_settings(sv,svout,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_base_solver_type, amg_s_ilu_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_ilu_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_ilu_solver_clone_settings + end interface + + interface + subroutine amg_s_ilu_solver_clear_data(sv,info) + import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & + & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & + & amg_s_ilu_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_s_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_ilu_solver_clear_data + end interface + +contains + + subroutine s_ilu_solver_default(sv) + + Implicit None + + ! Arguments + class(amg_s_ilu_solver_type), intent(inout) :: sv + + sv%fact_type = psb_ilu_n_ + sv%fill_in = 0 + sv%thresh = szero + + return + end subroutine s_ilu_solver_default + + subroutine s_ilu_solver_check(sv,info) + + Implicit None + + ! Arguments + class(amg_s_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_ilu_solver_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + call amg_check_def(sv%fact_type,& + & 'Factorization',psb_ilu_n_,is_legal_ilu_fact) + + select case(sv%fact_type) + case(psb_ilu_n_,psb_milu_n_) + call amg_check_def(sv%fill_in,& + & 'Level',izero,is_int_non_negative) + case(psb_ilu_t_) + call amg_check_def(sv%thresh,& + & 'Eps',szero,is_legal_s_fact_thrs) + end select + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine s_ilu_solver_check + + subroutine s_ilu_solver_cseti(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_s_ilu_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_ilu_solver_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(trim((what)))) + case('SUB_SOLVE') + sv%fact_type = val + case('SUB_FILLIN') + sv%fill_in = val + case default + call sv%amg_s_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine s_ilu_solver_cseti + + subroutine s_ilu_solver_csetc(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_s_ilu_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='s_ilu_solver_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + ival = amg_stringval(val) + select case(psb_toupper(trim((what)))) + case('SUB_SOLVE') + sv%fact_type = ival + case default + call sv%amg_s_base_solver_type%set(what,val,info,idx=idx) + end select + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info, name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine s_ilu_solver_csetc + + subroutine s_ilu_solver_csetr(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_s_ilu_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_ilu_solver_csetr' + + call psb_erractionsave(err_act) + info = psb_success_ + + select case(psb_toupper(what)) + case('SUB_ILUTHRS') + sv%thresh = val + case default + call sv%amg_s_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine s_ilu_solver_csetr + + subroutine s_ilu_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_s_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_ilu_solver_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sv%d)) then + deallocate(sv%d,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + end if + call sv%l%free() + call sv%u%free() + call sv%dv%free(info) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine s_ilu_solver_free + + subroutine s_ilu_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_s_ilu_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_s_ilu_solver_descr' + integer(psb_ipk_) :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' Incomplete factorization solver: ',& + & amg_fact_names(sv%fact_type) + select case(sv%fact_type) + case(psb_ilu_n_,psb_milu_n_) + write(iout_,*) ' Fill level:',sv%fill_in + case(psb_ilu_t_) + write(iout_,*) ' Fill level:',sv%fill_in + write(iout_,*) ' Fill threshold :',sv%thresh + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine s_ilu_solver_descr + + function s_ilu_solver_get_nzeros(sv) result(val) + + implicit none + ! Arguments + class(amg_s_ilu_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + val = val + sv%dv%get_nrows() + val = val + sv%l%get_nzeros() + val = val + sv%u%get_nzeros() + + return + end function s_ilu_solver_get_nzeros + + function s_ilu_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_s_ilu_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 2*psb_sizeof_ip + psb_sizeof_sp + val = val + sv%dv%sizeof() + val = val + sv%l%sizeof() + val = val + sv%u%sizeof() + + return + end function s_ilu_solver_sizeof + + function s_ilu_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "ILU solver" + end function s_ilu_solver_get_fmt + + function s_ilu_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = psb_ilu_n_ + end function s_ilu_solver_get_id + + function s_ilu_solver_get_wrksize() result(val) + implicit none + integer(psb_ipk_) :: val + + val = 2 + end function s_ilu_solver_get_wrksize + +end module amg_s_ilu_solver diff --git a/mlprec/amg_s_inner_mod.f90 b/mlprec/amg_s_inner_mod.f90 new file mode 100644 index 00000000..308503ce --- /dev/null +++ b/mlprec/amg_s_inner_mod.f90 @@ -0,0 +1,131 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_inner_mod.f90 +! +! Module: amg_inner_mod +! +! This module defines the interfaces to inner MLD2P4 routines. +! The interfaces of the user level routines are defined in amg_prec_mod.f90. +! +module amg_s_inner_mod + + use psb_base_mod, only : psb_sspmat_type, psb_desc_type, psb_i_base_vect_type, & + & psb_spk_, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_, & + & psb_s_vect_type, psb_lpk_, psb_lsspmat_type + use amg_s_prec_type, only : amg_sprec_type, amg_sml_parms, & + & amg_s_onelev_type, amg_smlprec_wrk_type + + interface amg_mlprec_bld + subroutine amg_smlprec_bld(a,desc_a,prec,info, amold, vmold,imold) + import :: psb_sspmat_type, psb_desc_type, psb_i_base_vect_type, & + & psb_spk_, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ + import :: amg_sprec_type + implicit none + type(psb_sspmat_type), intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + type(amg_sprec_type), intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_smlprec_bld + end interface amg_mlprec_bld + + interface amg_mlprec_aply + subroutine amg_smlprec_aply(alpha,p,x,beta,y,desc_data,trans,work,info) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, psb_ipk_ + import :: amg_sprec_type + implicit none + type(psb_desc_type),intent(in) :: desc_data + type(amg_sprec_type), intent(inout) :: p + real(psb_spk_),intent(in) :: alpha,beta + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + character,intent(in) :: trans + real(psb_spk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + end subroutine amg_smlprec_aply + subroutine amg_smlprec_aply_vect(alpha,p,x,beta,y,desc_data,trans,work,info) + import :: psb_sspmat_type, psb_desc_type, & + & psb_spk_, psb_s_vect_type, psb_ipk_ + import :: amg_sprec_type + implicit none + type(psb_desc_type),intent(in) :: desc_data + type(amg_sprec_type), intent(inout) :: p + real(psb_spk_),intent(in) :: alpha,beta + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + character,intent(in) :: trans + real(psb_spk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + end subroutine amg_smlprec_aply_vect + end interface amg_mlprec_aply + + interface amg_map_to_tprol + subroutine amg_s_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, psb_ipk_, psb_lpk_, psb_lsspmat_type + import :: amg_s_onelev_type + implicit none + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), allocatable, intent(inout) :: ilaggr(:),nlaggr(:) + type(psb_lsspmat_type), intent(out) :: op_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_map_to_tprol + end interface amg_map_to_tprol + + abstract interface + subroutine amg_saggrmat_var_bld(a,desc_a,ilaggr,nlaggr,parms,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, psb_ipk_, psb_lpk_, psb_lsspmat_type + import :: amg_s_onelev_type, amg_sml_parms + implicit none + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(amg_sml_parms), intent(inout) :: parms + type(psb_sspmat_type), intent(inout) :: op_prol,ac,op_restr + type(psb_lsspmat_type), intent(inout) :: t_prol + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + end subroutine amg_saggrmat_var_bld + end interface + + procedure(amg_saggrmat_var_bld) :: amg_saggrmat_nosmth_bld, & + & amg_saggrmat_smth_bld, amg_saggrmat_minnrg_bld + +end module amg_s_inner_mod diff --git a/mlprec/amg_s_jac_smoother.f90 b/mlprec/amg_s_jac_smoother.f90 new file mode 100644 index 00000000..c6085f6f --- /dev/null +++ b/mlprec/amg_s_jac_smoother.f90 @@ -0,0 +1,454 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_s_jac_smoother_mod.f90 +! +! Module: amg_s_jac_smoother_mod +! +! This module defines: +! the amg_s_jac_smoother_type data structure containing the +! smoother for a Jacobi/block Jacobi smoother. +! The smoother stores in ND the block off-diagonal matrix. +! One special case is treated separately, when the solver is DIAG or L1-DIAG +! then the ND is the entire off-diagonal part of the matrix (including the +! main diagonal block), so that it becomes possible to implement +! a pure Jacobi or L1-Jacobi global solver. +! +module amg_s_jac_smoother + + use amg_s_base_smoother_mod + + type, extends(amg_s_base_smoother_type) :: amg_s_jac_smoother_type + ! The local solver component is inherited from the + ! parent type. + ! class(amg_s_base_solver_type), allocatable :: sv + ! + type(psb_sspmat_type), pointer :: pa => null() + type(psb_sspmat_type) :: nd + integer(psb_lpk_) :: nd_nnz_tot + logical :: checkres + logical :: printres + integer(psb_ipk_) :: checkiter + integer(psb_ipk_) :: printiter + real(psb_dpk_) :: tol + contains + procedure, pass(sm) :: apply_v => amg_s_jac_smoother_apply_vect + procedure, pass(sm) :: apply_a => amg_s_jac_smoother_apply + procedure, pass(sm) :: dump => amg_s_jac_smoother_dmp + procedure, pass(sm) :: build => amg_s_jac_smoother_bld + procedure, pass(sm) :: cnv => amg_s_jac_smoother_cnv + procedure, pass(sm) :: clone => amg_s_jac_smoother_clone + procedure, pass(sm) :: clone_settings => amg_s_jac_smoother_clone_settings + procedure, pass(sm) :: clear_data => amg_s_jac_smoother_clear_data + procedure, pass(sm) :: free => s_jac_smoother_free + procedure, pass(sm) :: cseti => amg_s_jac_smoother_cseti + procedure, pass(sm) :: csetc => amg_s_jac_smoother_csetc + procedure, pass(sm) :: csetr => amg_s_jac_smoother_csetr + procedure, pass(sm) :: descr => amg_s_jac_smoother_descr + procedure, pass(sm) :: sizeof => s_jac_smoother_sizeof + procedure, pass(sm) :: default => s_jac_smoother_default + procedure, pass(sm) :: get_nzeros => s_jac_smoother_get_nzeros + procedure, pass(sm) :: get_wrksz => s_jac_smoother_get_wrksize + procedure, nopass :: get_fmt => s_jac_smoother_get_fmt + procedure, nopass :: get_id => s_jac_smoother_get_id + end type amg_s_jac_smoother_type + + type, extends(amg_s_jac_smoother_type) :: amg_s_l1_jac_smoother_type + contains + procedure, pass(sm) :: build => amg_s_l1_jac_smoother_bld + procedure, pass(sm) :: clone => amg_s_l1_jac_smoother_clone + procedure, pass(sm) :: descr => amg_s_l1_jac_smoother_descr + procedure, nopass :: get_fmt => s_l1_jac_smoother_get_fmt + procedure, nopass :: get_id => s_l1_jac_smoother_get_id + end type amg_s_l1_jac_smoother_type + + private :: s_jac_smoother_free, & + & s_jac_smoother_sizeof, s_jac_smoother_get_nzeros, & + & s_jac_smoother_get_fmt, s_jac_smoother_get_id, & + & s_jac_smoother_get_wrksize + private :: s_l1_jac_smoother_get_fmt, s_l1_jac_smoother_get_id + + + interface + subroutine amg_s_jac_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,wv,info,init,initu) + import :: psb_desc_type, amg_s_jac_smoother_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type,& + & psb_ipk_ + + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_jac_smoother_type), intent(inout) :: sm + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + end subroutine amg_s_jac_smoother_apply_vect + end interface + + interface + subroutine amg_s_jac_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,info,init,initu) + import :: psb_desc_type, amg_s_jac_smoother_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, & + & psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_jac_smoother_type), intent(inout) :: sm + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + end subroutine amg_s_jac_smoother_apply + end interface + + interface + subroutine amg_s_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + import :: psb_desc_type, amg_s_jac_smoother_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_jac_smoother_bld + end interface + + interface + subroutine amg_s_jac_smoother_cnv(sm,info,amold,vmold,imold) + import :: amg_s_jac_smoother_type, psb_spk_, & + & psb_s_base_sparse_mat, psb_s_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + class(amg_s_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_jac_smoother_cnv + end interface + + interface + subroutine amg_s_jac_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_spk_, amg_s_jac_smoother_type, psb_epk_, psb_desc_type, & + & psb_ipk_ + implicit none + class(amg_s_jac_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + end subroutine amg_s_jac_smoother_dmp + end interface + + interface + subroutine amg_s_jac_smoother_clone(sm,smout,info) + import :: amg_s_jac_smoother_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_ + class(amg_s_jac_smoother_type), intent(inout) :: sm + class(amg_s_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_jac_smoother_clone + end interface + + interface + subroutine amg_s_jac_smoother_clone_settings(sm,smout,info) + import :: amg_s_jac_smoother_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_ + class(amg_s_jac_smoother_type), intent(inout) :: sm + class(amg_s_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_jac_smoother_clone_settings + end interface + + interface + subroutine amg_s_jac_smoother_clear_data(sm,info) + import :: amg_s_jac_smoother_type, psb_spk_, & + & amg_s_base_smoother_type, psb_ipk_ + class(amg_s_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_jac_smoother_clear_data + end interface + + interface + subroutine amg_s_jac_smoother_descr(sm,info,iout,coarse) + import :: amg_s_jac_smoother_type, psb_ipk_ + class(amg_s_jac_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + end subroutine amg_s_jac_smoother_descr + end interface + + interface + subroutine amg_s_jac_smoother_cseti(sm,what,val,info,idx) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_spk_, amg_s_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_s_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_s_jac_smoother_cseti + end interface + + interface + subroutine amg_s_jac_smoother_csetc(sm,what,val,info,idx) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_spk_, amg_s_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_s_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_s_jac_smoother_csetc + end interface + + interface + subroutine amg_s_jac_smoother_csetr(sm,what,val,info,idx) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_spk_, amg_s_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_s_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_s_jac_smoother_csetr + end interface + + + interface + subroutine amg_s_l1_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + import :: psb_desc_type, amg_s_l1_jac_smoother_type, psb_s_vect_type, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_l1_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_l1_jac_smoother_bld + end interface + + interface + subroutine amg_s_l1_jac_smoother_clone(sm,smout,info) + import :: amg_s_l1_jac_smoother_type, & + & amg_s_base_smoother_type, psb_ipk_ + class(amg_s_l1_jac_smoother_type), intent(inout) :: sm + class(amg_s_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_l1_jac_smoother_clone + end interface + + interface + subroutine amg_s_l1_jac_smoother_clone_settings(sm,smout,info) + import :: amg_s_l1_jac_smoother_type, & + & amg_s_base_smoother_type, psb_ipk_ + class(amg_s_l1_jac_smoother_type), intent(inout) :: sm + class(amg_s_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_l1_jac_smoother_clone_settings + end interface + + interface + subroutine amg_s_l1_jac_smoother_clear_data(sm,info) + import :: amg_s_l1_jac_smoother_type, & + & amg_s_base_smoother_type, psb_ipk_ + class(amg_s_l1_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_l1_jac_smoother_clear_data + end interface + + interface + subroutine amg_s_l1_jac_smoother_descr(sm,info,iout,coarse) + import :: amg_s_l1_jac_smoother_type, psb_ipk_ + class(amg_s_l1_jac_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + end subroutine amg_s_l1_jac_smoother_descr + end interface + +contains + + + subroutine s_jac_smoother_free(sm,info) + + + Implicit None + + ! Arguments + class(amg_s_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_jac_smoother_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + + + if (allocated(sm%sv)) then + call sm%sv%free(info) + if (info == psb_success_) deallocate(sm%sv,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + end if + call sm%nd%free() + sm%pa => null() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine s_jac_smoother_free + + function s_jac_smoother_sizeof(sm) result(val) + + implicit none + ! Arguments + class(amg_s_jac_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = psb_sizeof_lp + if (allocated(sm%sv)) val = val + sm%sv%sizeof() + val = val + sm%nd%sizeof() + + return + end function s_jac_smoother_sizeof + + subroutine s_jac_smoother_default(sm) + + Implicit None + + ! Arguments + class(amg_s_jac_smoother_type), intent(inout) :: sm + + ! + ! Default: BJAC with no residual check + ! + sm%checkres = .false. + sm%printres = .false. + sm%checkiter = -1 + sm%printiter = -1 + sm%tol = 0 + + if (allocated(sm%sv)) then + call sm%sv%default() + end if + + return + end subroutine s_jac_smoother_default + + function s_jac_smoother_get_nzeros(sm) result(val) + + implicit none + ! Arguments + class(amg_s_jac_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + if (allocated(sm%sv)) val = val + sm%sv%get_nzeros() + val = val + sm%nd%get_nzeros() + + return + end function s_jac_smoother_get_nzeros + + function s_jac_smoother_get_wrksize(sm) result(val) + implicit none + class(amg_s_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_) :: val + + val = 2 + if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() + + end function s_jac_smoother_get_wrksize + + function s_jac_smoother_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Jacobi smoother" + end function s_jac_smoother_get_fmt + + function s_jac_smoother_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_jac_ + end function s_jac_smoother_get_id + + function s_l1_jac_smoother_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "L1-Jacobi smoother" + end function s_l1_jac_smoother_get_fmt + + function s_l1_jac_smoother_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_l1_jac_ + end function s_l1_jac_smoother_get_id + +end module amg_s_jac_smoother diff --git a/mlprec/amg_s_mumps_solver.F90 b/mlprec/amg_s_mumps_solver.F90 new file mode 100644 index 00000000..f8822452 --- /dev/null +++ b/mlprec/amg_s_mumps_solver.F90 @@ -0,0 +1,590 @@ + +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +! File: amg_s_mumps_solver_mod.f90 +! +! Module: amg_s_mumps_solver_mod +! +! This module defines: +! - the amg_s_mumps_solver_type data structure containing the ingredients +! to interface with the MUMPS package. +! 1. The factorization can be either restricted to the diagonal block of the +! current image or distributed (and thus exact). +! +module amg_s_mumps_solver + use amg_s_base_solver_mod +#if defined(HAVE_MUMPS_) && defined(HAVE_MUMPS_MODULES_) + use smumps_struc_def +#endif +#if defined(HAVE_MUMPS_) && defined(HAVE_MUMPS_INCLUDES_) + include 'smumps_struc.h' +#endif + + + type :: amg_s_mumps_icntl_item + integer(psb_ipk_), allocatable :: item + end type amg_s_mumps_icntl_item + type :: amg_s_mumps_rcntl_item + real(psb_spk_), allocatable :: item + end type amg_s_mumps_rcntl_item + + type, extends(amg_s_base_solver_type) :: amg_s_mumps_solver_type +#if defined(HAVE_MUMPS_) + type(smumps_struc), allocatable :: id +#else + integer, allocatable :: id +#endif + type(amg_s_mumps_icntl_item), allocatable :: icntl(:) + type(amg_s_mumps_rcntl_item), allocatable :: rcntl(:) + ! + ! Controls to be set before MUMPS instantiation: + ! + ! IPAR(1) : MUMPS_LOC_GLOB 0==amg_local_solver_: LOCAL 1==amg_global_solver_: GLOBAL + ! IPAR(2) : MUMPS_PRINT_ERR print verbosity (see MUMPS) + ! IPAR(3) : MUMPS_SYM 0: non-symmetric 2: symmetric + integer(psb_ipk_), dimension(3) :: ipar + integer(psb_ipk_), allocatable :: local_ictxt + logical :: built = .false. + contains + procedure, pass(sv) :: build => s_mumps_solver_bld + procedure, pass(sv) :: apply_a => s_mumps_solver_apply + procedure, pass(sv) :: apply_v => s_mumps_solver_apply_vect + procedure, pass(sv) :: clone_settings => s_mumps_solver_clone_settings + procedure, pass(sv) :: clear_data => s_mumps_solver_clear_data + procedure, pass(sv) :: free => s_mumps_solver_free + procedure, pass(sv) :: descr => s_mumps_solver_descr + procedure, pass(sv) :: sizeof => s_mumps_solver_sizeof + procedure, pass(sv) :: csetc => s_mumps_solver_csetc + procedure, pass(sv) :: cseti => s_mumps_solver_cseti + procedure, pass(sv) :: csetr => s_mumps_solver_csetr + procedure, pass(sv) :: default => s_mumps_solver_default + procedure, nopass :: get_fmt => s_mumps_solver_get_fmt + procedure, nopass :: get_id => s_mumps_solver_get_id + procedure, pass(sv) :: is_global => s_mumps_solver_is_global + final :: s_mumps_solver_finalize + end type amg_s_mumps_solver_type + + + private :: s_mumps_solver_bld, s_mumps_solver_apply, & + & s_mumps_solver_free, s_mumps_solver_descr, & + & s_mumps_solver_sizeof, s_mumps_solver_apply_vect,& + & s_mumps_solver_cseti, s_mumps_solver_csetr, & + & s_mumps_solver_csetc, s_mumps_solver_clear_data, & + & s_mumps_solver_default, s_mumps_solver_get_fmt, & + & s_mumps_solver_clone_settings, & + & s_mumps_solver_get_id, s_mumps_solver_is_global + private :: s_mumps_solver_finalize + + interface + subroutine s_mumps_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, amg_s_mumps_solver_type, psb_s_vect_type, psb_dpk_, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_mumps_solver_type), intent(inout) :: sv + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + end subroutine s_mumps_solver_apply_vect + end interface + + interface + subroutine s_mumps_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info,init,initu) + import :: psb_desc_type, amg_s_mumps_solver_type, psb_s_vect_type, psb_dpk_, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_mumps_solver_type), intent(inout) :: sv + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + end subroutine s_mumps_solver_apply + end interface + + interface + subroutine s_mumps_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + import :: psb_desc_type, amg_s_mumps_solver_type, psb_s_vect_type, psb_spk_, & + & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + + Implicit None + + ! Arguments + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type), intent(in), target, optional :: b + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine s_mumps_solver_bld + end interface + +contains + + subroutine s_mumps_solver_clone_settings(sv,svout,info) + + use psb_base_mod + Implicit None + ! Arguments + class(amg_s_mumps_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: k,err_act + character(len=20) :: name='s_mumps_solver_clone_settings' + + info = 0 + +#if defined(HAVE_MUMPS_) + + call psb_erractionsave(err_act) + + select type(svout) + class is(amg_s_mumps_solver_type) + svout%ipar(:) = sv%ipar(:) + svout%built = .false. + if (allocated(svout%icntl)) deallocate(svout%icntl,stat=info) + if (info == 0) allocate(svout%icntl(amg_mumps_icntl_size),stat=info) + if (info == 0) then + do k=1,amg_mumps_icntl_size + call psb_safe_ab_cpy(sv%icntl(k)%item,svout%icntl(k)%item,info) + end do + end if + + if (allocated(svout%rcntl)) deallocate(svout%rcntl,stat=info) + if (info == 0) allocate(svout%rcntl(amg_mumps_rcntl_size),stat=info) + if (info == 0) then + do k=1,amg_mumps_rcntl_size + call psb_safe_ab_cpy(sv%rcntl(k)%item,svout%rcntl(k)%item,info) + end do + end if + + class default + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +#endif + end subroutine s_mumps_solver_clone_settings + + subroutine s_mumps_solver_clear_data(sv,info) + use psb_base_mod, only : psb_exit + Implicit None + + ! Arguments + class(amg_s_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + Integer(psb_ipk_) :: err_act + character(len=20) :: name='s_mumps_solver_clear_data' + + info = 0 +#if defined(HAVE_MUMPS_) + call psb_erractionsave(err_act) + if (allocated(sv%id)) then + if (sv%built) then + sv%id%job = -2 + call smumps(sv%id) + info = sv%id%infog(1) + if (info /= psb_success_) goto 9999 + end if + deallocate(sv%id, stat=info) + if (allocated(sv%local_ictxt)) then + call psb_exit(sv%local_ictxt,close=.false.) + deallocate(sv%local_ictxt,stat=info) + end if + sv%built=.false. + end if + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +#endif + end subroutine s_mumps_solver_clear_data + + subroutine s_mumps_solver_free(sv,info) + use psb_base_mod, only : psb_exit + Implicit None + + ! Arguments + class(amg_s_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + Integer(psb_ipk_) :: err_act + character(len=20) :: name='s_mumps_solver_free' + + info = 0 +#if defined(HAVE_MUMPS_) + call psb_erractionsave(err_act) + call sv%clear_data(info) + if ((info == 0).and.allocated(sv%icntl)) deallocate(sv%icntl,stat=info) + if ((info == 0).and.allocated(sv%rcntl)) deallocate(sv%rcntl,stat=info) + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +#endif + end subroutine s_mumps_solver_free + +subroutine s_mumps_solver_finalize(sv) + + Implicit None + + ! Arguments + type(amg_s_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_) :: info + Integer(psb_ipk_) :: err_act + character(len=20) :: name='s_mumps_solver_finalize' + + call sv%free(info) + + return + +end subroutine s_mumps_solver_finalize + +subroutine s_mumps_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_s_mumps_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt, me, np + character(len=20), parameter :: name='amg_z_mumps_solver_descr' + integer(psb_ipk_) :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' MUMPS Solver. ' + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +end subroutine s_mumps_solver_descr + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! WARNING: OTHER PARAMETERS OF MUMPS COULD BE ADDED. !! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + +subroutine s_mumps_solver_csetc(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_s_mumps_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_mumps_solver_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + + + select case(psb_toupper(trim(what))) +#if defined(HAVE_MUMPS_) + case('MUMPS_LOC_GLOB') + sv%ipar(1) = sv%stringval(psb_toupper(trim(val))) +#endif + case default + call sv%amg_s_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +end subroutine s_mumps_solver_csetc + + +subroutine s_mumps_solver_cseti(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_s_mumps_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_mumps_solver_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) +#if defined(HAVE_MUMPS_) + case('MUMPS_LOC_GLOB') + sv%ipar(1) = val + case('MUMPS_PRINT_ERR') + sv%ipar(2) = val + case('MUMPS_SYM') + sv%ipar(3) = val + case('MUMPS_IPAR_ENTRY') + if(present(idx)) then + ! Note: this will allocate %item + sv%icntl(idx)%item = val + end if +#endif + case default + call sv%amg_s_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +end subroutine s_mumps_solver_cseti + +subroutine s_mumps_solver_csetr(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_s_mumps_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_mumps_solver_csetr' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) +#if defined(HAVE_MUMPS_) + case('MUMPS_RPAR_ENTRY') + if(present(idx)) then + ! Note: this will allocate %item + sv%rcntl(idx)%item = val + end if +#endif + case default + call sv%amg_s_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +end subroutine s_mumps_solver_csetr + +!!NOTE: BY DEFAULT BLR is activated with a dropping parameter to 1d-4 !! +subroutine s_mumps_solver_default(sv) + + Implicit none + + !Argument + class(amg_s_mumps_solver_type),intent(inout) :: sv + integer(psb_ipk_) :: info + integer(psb_ipk_) :: err_act,ictx,icomm + character(len=20) :: name='s_mumps_default' + + info = psb_success_ + call psb_erractionsave(err_act) + +#if defined(HAVE_MUMPS_) + if (.not.allocated(sv%id)) then + allocate(sv%id,stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_dealloc_ + call psb_errpush(info,name,a_err='amg_smumps_default') + goto 9999 + end if + sv%built=.false. + end if + if (.not.allocated(sv%icntl)) then + allocate(sv%icntl(amg_mumps_icntl_size),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_dealloc_ + call psb_errpush(info,name,a_err='amg_smumps_default') + goto 9999 + end if + end if + if (.not.allocated(sv%rcntl)) then + allocate(sv%rcntl(amg_mumps_rcntl_size),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_dealloc_ + call psb_errpush(info,name,a_err='amg_smumps_default') + goto 9999 + end if + end if + ! INSTANTIATION OF sv%id needed to set parmater but mpi communicator needed + ! sv%id%job = -1 + ! sv%id%par=1 + ! call dmumps(sv%id) + sv%ipar = 0 + sv%ipar(1) = amg_global_solver_ + !sv%ipar(10)=6 + !sv%ipar(11)=0 + !sv%ipar(12)=6 + +#endif + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return + +end subroutine s_mumps_solver_default + +function s_mumps_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_s_mumps_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer :: i +#if defined(HAVE_MUMPS_) + val = (sv%id%INFOG(22)+sv%id%INFOG(32))*1d+6 +#else + val = 0 +#endif + ! val = 2*psb_sizeof_ip + psb_sizeof_dp + ! val = val + sv%symbsize + ! val = val + sv%numsize + return +end function s_mumps_solver_sizeof + +function s_mumps_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "MUMPS solver" +end function s_mumps_solver_get_fmt + +function s_mumps_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_mumps_ +end function s_mumps_solver_get_id + + +function s_mumps_solver_is_global(sv) result(val) + implicit none + class(amg_s_mumps_solver_type), intent(in) :: sv + logical :: val + + val = (sv%ipar(1) == amg_global_solver_ ) +end function s_mumps_solver_is_global + +end module amg_s_mumps_solver + diff --git a/mlprec/amg_s_onelev_mod.f90 b/mlprec/amg_s_onelev_mod.f90 new file mode 100644 index 00000000..bfea3ab6 --- /dev/null +++ b/mlprec/amg_s_onelev_mod.f90 @@ -0,0 +1,824 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_s_onelev_mod.f90 +! +! Module: amg_s_onelev_mod +! +! This module defines: +! - the amg_s_onelev_type data structure containing one level +! of a multilevel preconditioner and related +! data structures; +! +! It contains routines for +! - Building and applying; +! - checking if the preconditioner is correctly defined; +! - printing a description of the preconditioner; +! - deallocating the preconditioner data structure. +! + +module amg_s_onelev_mod + + use amg_base_prec_type + use amg_s_base_smoother_mod + use amg_s_dec_aggregator_mod + use psb_base_mod, only : psb_sspmat_type, psb_s_vect_type, & + & psb_s_base_vect_type, psb_lsspmat_type, psb_slinmap_type, psb_spk_, & + & psb_ipk_, psb_epk_, psb_lpk_, psb_desc_type, psb_i_base_vect_type, & + & psb_erractionsave, psb_error_handler + ! + ! + ! Type: amg_sonelev_type. + ! + ! It is the data type containing the necessary items for the current + ! level (essentially, the smoother, the current-level matrix + ! and the restriction and prolongation operators). + ! + ! type amg_sonelev_type + ! class(amg_s_base_smoother_type), allocatable :: sm, sm2a + ! class(amg_s_base_smoother_type), pointer :: sm2 => null() + ! class(amg_smlprec_wrk_type), allocatable :: wrk + ! class(amg_s_base_aggregator_type), allocatable :: aggr + ! type(amg_sml_parms) :: parms + ! type(psb_sspmat_type) :: ac + ! type(psb_sesc_type) :: desc_ac + ! type(psb_sspmat_type), pointer :: base_a => null() + ! type(psb_desc_type), pointer :: base_desc => null() + ! type(psb_slinmap_type) :: map + ! end type amg_sonelev_type + ! + ! Note that s denotes the kind of the real data type to be chosen + ! according to single/double precision version of MLD2P4. + ! + ! sm,sm2a - class(amg_s_base_smoother_type), allocatable + ! The current level pre- and post-smooother. + ! sm2 - class(amg_s_base_smoother_type), pointer + ! The current level post-smooother; if sm2a is allocated + ! explicitly, then sm2 => sm2a, otherwise sm2 => sm. + ! wrk - class(amg_smlprec_wrk_type), allocatable + ! Workspace for application of preconditioner; may be + ! pre-allocated to save time in the application within a + ! Krylov solver. + ! aggr - class(amg_s_base_aggregator_type), allocatable + ! The aggregator object: holds the algorithmic choices and + ! (possibly) additional data for building the aggregation. + ! parms - type(amg_sml_parms) + ! The parameters defining the multilevel strategy. + ! ac - The local part of the current-level matrix, built by + ! coarsening the previous-level matrix. + ! desc_ac - type(psb_desc_type). + ! The communication descriptor associated to the matrix + ! stored in ac. + ! base_a - type(psb_sspmat_type), pointer. + ! Pointer (really a pointer!) to the local part of the current + ! matrix (so we have a unified treatment of residuals). + ! We need this to avoid passing explicitly the current matrix + ! to the routine which applies the preconditioner. + ! base_desc - type(psb_desc_type), pointer. + ! Pointer to the communication descriptor associated to the + ! matrix pointed by base_a. + ! map - Stores the maps (restriction and prolongation) between the + ! vector spaces associated to the index spaces of the previous + ! and current levels. + ! + ! Methods: + ! Most methods follow the encapsulation hierarchy: they take whatever action + ! is appropriate for the current object, then call the corresponding method for + ! the contained object. + ! As an example: the descr() method prints out a description of the + ! level. It starts by invoking the descr() method of the parms object, + ! then calls the descr() method of the smoother object. + ! + ! descr - Prints a description of the object. + ! default - Set default values + ! dump - Dump to file object contents + ! set - Sets various parameters; when a request is unknown + ! it is passed to the smoother object for further processing. + ! check - Sanity checks. + ! sizeof - Total memory occupation in bytes + ! get_nzeros - Number of nonzeros + ! get_wrksz - How many workspace vector does apply_vect need + ! allocate_wrk - Allocate auxiliary workspace + ! free_wrk - Free auxiliary workspace + ! bld_tprol - Invoke the aggr method to build the tentative prolongator + ! mat_asb - Build the final (possibly smoothed) prolongator and coarse matrix. + ! + ! + type amg_smlprec_wrk_type + real(psb_spk_), allocatable :: tx(:), ty(:), x2l(:), y2l(:) + type(psb_s_vect_type) :: vtx, vty, vx2l, vy2l + type(psb_s_vect_type), allocatable :: wv(:) + contains + procedure, pass(wk) :: alloc => s_wrk_alloc + procedure, pass(wk) :: free => s_wrk_free + procedure, pass(wk) :: clone => s_wrk_clone + procedure, pass(wk) :: move_alloc => s_wrk_move_alloc + procedure, pass(wk) :: cnv => s_wrk_cnv + procedure, pass(wk) :: sizeof => s_wrk_sizeof + end type amg_smlprec_wrk_type + private :: s_wrk_alloc, s_wrk_free, & + & s_wrk_clone, s_wrk_move_alloc, s_wrk_cnv, s_wrk_sizeof + + type amg_s_onelev_type + class(amg_s_base_smoother_type), allocatable :: sm, sm2a + class(amg_s_base_smoother_type), pointer :: sm2 => null() + class(amg_smlprec_wrk_type), allocatable :: wrk + class(amg_s_base_aggregator_type), allocatable :: aggr + type(amg_sml_parms) :: parms + type(psb_sspmat_type) :: ac + integer(psb_ipk_) :: ac_nz_loc + integer(psb_lpk_) :: ac_nz_tot + type(psb_desc_type) :: desc_ac + type(psb_sspmat_type), pointer :: base_a => null() + type(psb_desc_type), pointer :: base_desc => null() + type(psb_lsspmat_type) :: tprol + type(psb_slinmap_type) :: map + real(psb_spk_) :: szratio + contains + procedure, pass(lv) :: bld_tprol => s_base_onelev_bld_tprol + procedure, pass(lv) :: mat_asb => amg_s_base_onelev_mat_asb + procedure, pass(lv) :: update_aggr => s_base_onelev_update_aggr + procedure, pass(lv) :: bld => amg_s_base_onelev_build + procedure, pass(lv) :: clone => s_base_onelev_clone + procedure, pass(lv) :: cnv => amg_s_base_onelev_cnv + procedure, pass(lv) :: descr => amg_s_base_onelev_descr + procedure, pass(lv) :: default => s_base_onelev_default + procedure, pass(lv) :: free => amg_s_base_onelev_free + procedure, pass(lv) :: nullify => s_base_onelev_nullify + procedure, pass(lv) :: check => amg_s_base_onelev_check + procedure, pass(lv) :: dump => amg_s_base_onelev_dump + procedure, pass(lv) :: cseti => amg_s_base_onelev_cseti + procedure, pass(lv) :: csetr => amg_s_base_onelev_csetr + procedure, pass(lv) :: csetc => amg_s_base_onelev_csetc + procedure, pass(lv) :: setsm => amg_s_base_onelev_setsm + procedure, pass(lv) :: setsv => amg_s_base_onelev_setsv + procedure, pass(lv) :: setag => amg_s_base_onelev_setag + generic, public :: set => cseti, csetr, csetc, setsm, setsv, setag + procedure, pass(lv) :: sizeof => s_base_onelev_sizeof + procedure, pass(lv) :: get_nzeros => s_base_onelev_get_nzeros + procedure, pass(lv) :: get_wrksz => s_base_onelev_get_wrksize + procedure, pass(lv) :: allocate_wrk => s_base_onelev_allocate_wrk + procedure, pass(lv) :: free_wrk => s_base_onelev_free_wrk + procedure, nopass :: stringval => amg_stringval + procedure, pass(lv) :: move_alloc => s_base_onelev_move_alloc + + end type amg_s_onelev_type + + type amg_s_onelev_node + type(amg_s_onelev_type) :: item + type(amg_s_onelev_node), pointer :: prev=>null(), next=>null() + end type amg_s_onelev_node + + private :: s_base_onelev_default, s_base_onelev_sizeof, & + & s_base_onelev_nullify, s_base_onelev_get_nzeros, & + & s_base_onelev_clone, s_base_onelev_move_alloc, & + & s_base_onelev_get_wrksize, s_base_onelev_allocate_wrk, & + & s_base_onelev_free_wrk + + interface + subroutine amg_s_base_onelev_mat_asb(lv,a,desc_a,ilaggr,nlaggr,t_prol,info) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, psb_ipk_, psb_lsspmat_type, psb_lpk_ + import :: amg_s_onelev_type + implicit none + class(amg_s_onelev_type), intent(inout), target :: lv + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:),nlaggr(:) + type(psb_lsspmat_type), intent(inout) :: t_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_base_onelev_mat_asb + end interface + + interface + subroutine amg_s_base_onelev_build(lv,info,amold,vmold,imold,ilv) + import :: psb_s_base_sparse_mat, psb_s_base_vect_type, & + & psb_i_base_vect_type, psb_spk_, amg_s_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + implicit none + class(amg_s_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + integer(psb_ipk_), intent(in), optional :: ilv + end subroutine amg_s_base_onelev_build + end interface + + interface + subroutine amg_s_base_onelev_descr(lv,il,nl,ilmin,info,iout) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_slinmap_type, psb_spk_, amg_s_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + ! Arguments + class(amg_s_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: il,nl,ilmin + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + end subroutine amg_s_base_onelev_descr + end interface + + interface + subroutine amg_s_base_onelev_cnv(lv,info,amold,vmold,imold) + import :: amg_s_onelev_type, psb_s_base_vect_type, psb_spk_, & + & psb_s_base_sparse_mat, psb_ipk_, psb_i_base_vect_type + ! Arguments + class(amg_s_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_s_base_onelev_cnv + end interface + +interface + subroutine amg_s_base_onelev_free(lv,info) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_slinmap_type, psb_spk_, amg_s_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + implicit none + + class(amg_s_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_base_onelev_free + end interface + + interface + subroutine amg_s_base_onelev_check(lv,info) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_slinmap_type, psb_spk_, amg_s_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + ! Arguments + class(amg_s_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_base_onelev_check + end interface + + interface + subroutine amg_s_base_onelev_setsm(lv,val,info,pos) + import :: psb_spk_, amg_s_onelev_type, amg_s_base_smoother_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + ! Arguments + class(amg_s_onelev_type), target, intent(inout) :: lv + class(amg_s_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + end subroutine amg_s_base_onelev_setsm + end interface + + interface + subroutine amg_s_base_onelev_setsv(lv,val,info,pos) + import :: psb_spk_, amg_s_onelev_type, amg_s_base_solver_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + ! Arguments + class(amg_s_onelev_type), target, intent(inout) :: lv + class(amg_s_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + end subroutine amg_s_base_onelev_setsv + end interface + + interface + subroutine amg_s_base_onelev_setag(lv,val,info,pos) + import :: psb_spk_, amg_s_onelev_type, amg_s_base_aggregator_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + ! Arguments + class(amg_s_onelev_type), target, intent(inout) :: lv + class(amg_s_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + end subroutine amg_s_base_onelev_setag + end interface + + interface + subroutine amg_s_base_onelev_cseti(lv,what,val,info,pos,idx) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_slinmap_type, psb_spk_, amg_s_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + ! Arguments + class(amg_s_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_s_base_onelev_cseti + end interface + + interface + subroutine amg_s_base_onelev_csetc(lv,what,val,info,pos,idx) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_slinmap_type, psb_spk_, amg_s_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + ! Arguments + class(amg_s_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_s_base_onelev_csetc + end interface + + interface + subroutine amg_s_base_onelev_csetr(lv,what,val,info,pos,idx) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_slinmap_type, psb_spk_, amg_s_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + class(amg_s_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_s_base_onelev_csetr + end interface + + interface + subroutine amg_s_base_onelev_dump(lv,level,info,prefix,head,ac,rp,smoother,& + & solver,tprol,global_num) + import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & + & psb_slinmap_type, psb_spk_, amg_s_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + implicit none + class(amg_s_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: ac, rp, smoother, solver, tprol, global_num + end subroutine amg_s_base_onelev_dump + end interface + +contains + ! + ! Function returning the size of the amg_prec_type data structure + ! in bytes or in number of nonzeros of the operator(s) involved. + ! + + function s_base_onelev_get_nzeros(lv) result(val) + implicit none + class(amg_s_onelev_type), intent(in) :: lv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + if (allocated(lv%sm)) & + & val = lv%sm%get_nzeros() + if (allocated(lv%sm2a)) & + & val = val + lv%sm2a%get_nzeros() + end function s_base_onelev_get_nzeros + + function s_base_onelev_sizeof(lv) result(val) + implicit none + class(amg_s_onelev_type), intent(in) :: lv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = psb_sizeof_ip+psb_sizeof_lp + val = val + lv%desc_ac%sizeof() + val = val + lv%ac%sizeof() + val = val + lv%tprol%sizeof() + val = val + lv%map%sizeof() + if (allocated(lv%sm)) val = val + lv%sm%sizeof() + if (allocated(lv%sm2a)) val = val + lv%sm2a%sizeof() + if (allocated(lv%aggr)) val = val + lv%aggr%sizeof() + if (allocated(lv%wrk)) val = val + lv%wrk%sizeof() + end function s_base_onelev_sizeof + + + subroutine s_base_onelev_nullify(lv) + implicit none + + class(amg_s_onelev_type), intent(inout) :: lv + + nullify(lv%base_a) + nullify(lv%base_desc) + nullify(lv%sm2) + end subroutine s_base_onelev_nullify + + ! + ! Multilevel defaults: + ! multiplicative vs. additive ML framework; + ! Smoothed decoupled aggregation with zero threshold; + ! distributed coarse matrix; + ! damping omega computed with the max-norm estimate of the + ! dominant eigenvalue; + ! two-sided smoothing (i.e. V-cycle) with 1 smoothing sweep; + ! + + subroutine s_base_onelev_default(lv) + + Implicit None + + ! Arguments + class(amg_s_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_) :: info + + lv%parms%sweeps_pre = 1 + lv%parms%sweeps_post = 1 + lv%parms%ml_cycle = amg_vcycle_ml_ + lv%parms%aggr_type = amg_soc1_ + lv%parms%par_aggr_alg = amg_dec_aggr_ + lv%parms%aggr_ord = amg_aggr_ord_nat_ + lv%parms%aggr_prol = amg_smooth_prol_ + lv%parms%coarse_mat = amg_distr_mat_ + lv%parms%aggr_omega_alg = amg_eig_est_ + lv%parms%aggr_eig = amg_max_norm_ + lv%parms%aggr_filter = amg_no_filter_mat_ + lv%parms%aggr_omega_val = szero + lv%parms%aggr_thresh = 0.01_psb_spk_ + + if (allocated(lv%sm)) call lv%sm%default() + if (allocated(lv%sm2a)) then + call lv%sm2a%default() + lv%sm2 => lv%sm2a + else + lv%sm2 => lv%sm + end if + if (.not.allocated(lv%aggr)) allocate(amg_s_dec_aggregator_type :: lv%aggr,stat=info) + if (allocated(lv%aggr)) call lv%aggr%default() + + return + + end subroutine s_base_onelev_default + + subroutine s_base_onelev_bld_tprol(lv,a,desc_a,& + & ilaggr,nlaggr,t_prol,ag_data,info) + implicit none + class(amg_s_onelev_type), intent(inout), target :: lv + type(psb_sspmat_type), intent(inout) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lsspmat_type), intent(out) :: t_prol + type(amg_saggr_data), intent(in) :: ag_data + integer(psb_ipk_), intent(out) :: info + + call lv%aggr%bld_tprol(lv%parms,ag_data,a,desc_a,ilaggr,nlaggr,t_prol,info) + + end subroutine s_base_onelev_bld_tprol + + + subroutine s_base_onelev_update_aggr(lv,lvnext,info) + implicit none + class(amg_s_onelev_type), intent(inout), target :: lv, lvnext + integer(psb_ipk_), intent(out) :: info + + call lv%aggr%update_next(lvnext%aggr,info) + + end subroutine s_base_onelev_update_aggr + + + subroutine s_base_onelev_clone(lv,lvout,info) + + Implicit None + + ! Arguments + class(amg_s_onelev_type), target, intent(inout) :: lv + class(amg_s_onelev_type), target, intent(inout) :: lvout + integer(psb_ipk_), intent(out) :: info + + info = psb_success_ + if (allocated(lv%sm)) then + call lv%sm%clone(lvout%sm,info) + else + if (allocated(lvout%sm)) then + call lvout%sm%free(info) + if (info==psb_success_) deallocate(lvout%sm,stat=info) + end if + end if + if (allocated(lv%sm2a)) then + call lv%sm%clone(lvout%sm2a,info) + lvout%sm2 => lvout%sm2a + else + if (allocated(lvout%sm2a)) then + call lvout%sm2a%free(info) + if (info==psb_success_) deallocate(lvout%sm2a,stat=info) + end if + lvout%sm2 => lvout%sm + end if + if (allocated(lv%aggr)) then + call lv%aggr%clone(lvout%aggr,info) + else + if (allocated(lvout%aggr)) then + call lvout%aggr%free(info) + if (info==psb_success_) deallocate(lvout%aggr,stat=info) + end if + end if + if (info == psb_success_) call lv%parms%clone(lvout%parms,info) + if (info == psb_success_) call lv%ac%clone(lvout%ac,info) + if (info == psb_success_) call lv%tprol%clone(lvout%tprol,info) + if (info == psb_success_) call lv%desc_ac%clone(lvout%desc_ac,info) + if (info == psb_success_) call lv%map%clone(lvout%map,info) + lvout%base_a => lv%base_a + lvout%base_desc => lv%base_desc + + return + + end subroutine s_base_onelev_clone + + subroutine s_base_onelev_move_alloc(lv, b,info) + use psb_base_mod + implicit none + class(amg_s_onelev_type), target, intent(inout) :: lv, b + integer(psb_ipk_), intent(out) :: info + + call b%free(info) + b%parms = lv%parms + b%szratio = lv%szratio + if (associated(lv%sm2,lv%sm2a)) then + call move_alloc(lv%sm,b%sm) + call move_alloc(lv%sm2a,b%sm2a) + b%sm2 =>b%sm2a + else + call move_alloc(lv%sm,b%sm) + call move_alloc(lv%sm2a,b%sm2a) + b%sm2 =>b%sm + end if + + call move_alloc(lv%aggr,b%aggr) + if (info == psb_success_) call psb_move_alloc(lv%ac,b%ac,info) + if (info == psb_success_) call psb_move_alloc(lv%tprol,b%tprol,info) + if (info == psb_success_) call psb_move_alloc(lv%desc_ac,b%desc_ac,info) + if (info == psb_success_) call psb_move_alloc(lv%map,b%map,info) + b%base_a => lv%base_a + b%base_desc => lv%base_desc + + end subroutine s_base_onelev_move_alloc + + + function s_base_onelev_get_wrksize(lv) result(val) + implicit none + class(amg_s_onelev_type), intent(inout) :: lv + integer(psb_ipk_) :: val + + val = 0 + ! SM and SM2A can share work vectors + if (allocated(lv%sm)) val = val + lv%sm%get_wrksz() + if (allocated(lv%sm2a)) val = max(val,lv%sm2a%get_wrksz()) + ! + ! Now for the ML application itself + ! + + ! VTX/VTY/VX2L/VY2L are stored explicitly + ! + + ! + ! additions for specific ML/cycles + ! + select case(lv%parms%ml_cycle) + case(amg_add_ml_,amg_mult_ml_,amg_vcycle_ml_, amg_wcycle_ml_) + ! We're good + + case(amg_kcycle_ml_, amg_kcyclesym_ml_) + ! + ! We need 7 in inneritkcycle. + ! Can we reuse vtx? + ! + val = val + 7 + + case default + ! Need a better error signaling ? + val = -1 + end select + + end function s_base_onelev_get_wrksize + + subroutine s_base_onelev_allocate_wrk(lv,info,vmold) + use psb_base_mod + implicit none + class(amg_s_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_vect_type), intent(in), optional :: vmold + ! + integer(psb_ipk_) :: nwv, i + info = psb_success_ + nwv = lv%get_wrksz() + if (.not.allocated(lv%wrk)) allocate(lv%wrk,stat=info) + if (info == 0) call lv%wrk%alloc(nwv,lv%base_desc,info,vmold=vmold) + + end subroutine s_base_onelev_allocate_wrk + + + subroutine s_base_onelev_free_wrk(lv,info) + use psb_base_mod + implicit none + class(amg_s_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: nwv,i + info = psb_success_ + + if (allocated(lv%wrk)) then + call lv%wrk%free(info) + if (info == 0) deallocate(lv%wrk,stat=info) + end if + end subroutine s_base_onelev_free_wrk + + subroutine s_wrk_alloc(wk,nwv,desc,info,vmold) + use psb_base_mod + + Implicit None + + ! Arguments + class(amg_smlprec_wrk_type), target, intent(inout) :: wk + integer(psb_ipk_), intent(in) :: nwv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_vect_type), intent(in), optional :: vmold + ! + integer(psb_ipk_) :: i + + info = psb_success_ + call wk%free(info) + call psb_geasb(wk%vx2l,desc,info,& + & scratch=.true.,mold=vmold) + call psb_geasb(wk%vy2l,desc,info,& + & scratch=.true.,mold=vmold) + call psb_geasb(wk%vtx,desc,info,& + & scratch=.true.,mold=vmold) + call psb_geasb(wk%vty,desc,info,& + & scratch=.true.,mold=vmold) + allocate(wk%wv(nwv),stat=info) + do i=1,nwv + call psb_geasb(wk%wv(i),desc,info,& + & scratch=.true.,mold=vmold) + end do + + end subroutine s_wrk_alloc + + subroutine s_wrk_free(wk,info) + + Implicit None + + ! Arguments + class(amg_smlprec_wrk_type), target, intent(inout) :: wk + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: i + info = psb_success_ + + if (allocated(wk%tx)) deallocate(wk%tx, stat=info) + if (allocated(wk%ty)) deallocate(wk%ty, stat=info) + if (allocated(wk%x2l)) deallocate(wk%x2l, stat=info) + if (allocated(wk%y2l)) deallocate(wk%y2l, stat=info) + call wk%vtx%free(info) + call wk%vty%free(info) + call wk%vx2l%free(info) + call wk%vy2l%free(info) + if (allocated(wk%wv)) then + do i=1,size(wk%wv) + call wk%wv(i)%free(info) + end do + deallocate(wk%wv, stat=info) + end if + + end subroutine s_wrk_free + + subroutine s_wrk_clone(wk,wkout,info) + use psb_base_mod + Implicit None + + ! Arguments + class(amg_smlprec_wrk_type), target, intent(inout) :: wk + class(amg_smlprec_wrk_type), target, intent(inout) :: wkout + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: i + info = psb_success_ + + call psb_safe_ab_cpy(wk%tx,wkout%tx,info) + call psb_safe_ab_cpy(wk%ty,wkout%ty,info) + call psb_safe_ab_cpy(wk%x2l,wkout%x2l,info) + call psb_safe_ab_cpy(wk%y2l,wkout%y2l,info) + call wk%vtx%clone(wkout%vtx,info) + call wk%vty%clone(wkout%vty,info) + call wk%vx2l%clone(wkout%vx2l,info) + call wk%vy2l%clone(wkout%vy2l,info) + if (allocated(wkout%wv)) then + do i=1,size(wkout%wv) + call wkout%wv(i)%free(info) + end do + deallocate( wkout%wv) + end if + allocate(wkout%wv(size(wk%wv)),stat=info) + do i=1,size(wk%wv) + call wk%wv(i)%clone(wkout%wv(i),info) + end do + return + + end subroutine s_wrk_clone + + subroutine s_wrk_move_alloc(wk, b,info) + implicit none + class(amg_smlprec_wrk_type), target, intent(inout) :: wk, b + integer(psb_ipk_), intent(out) :: info + + call b%free(info) + call move_alloc(wk%tx,b%tx) + call move_alloc(wk%ty,b%ty) + call move_alloc(wk%x2l,b%x2l) + call move_alloc(wk%y2l,b%y2l) + ! + ! Should define V%move_alloc.... + call move_alloc(wk%vtx%v,b%vtx%v) + call move_alloc(wk%vty%v,b%vty%v) + call move_alloc(wk%vx2l%v,b%vx2l%v) + call move_alloc(wk%vy2l%v,b%vy2l%v) + call move_alloc(wk%wv,b%wv) + + end subroutine s_wrk_move_alloc + + subroutine s_wrk_cnv(wk,info,vmold) + use psb_base_mod + + Implicit None + + ! Arguments + class(amg_smlprec_wrk_type), target, intent(inout) :: wk + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_vect_type), intent(in), optional :: vmold + ! + integer(psb_ipk_) :: i + + info = psb_success_ + if (present(vmold)) then + call wk%vtx%cnv(vmold) + call wk%vty%cnv(vmold) + call wk%vx2l%cnv(vmold) + call wk%vy2l%cnv(vmold) + if (allocated(wk%wv)) then + do i=1,size(wk%wv) + call wk%wv(i)%cnv(vmold) + end do + end if + end if + end subroutine s_wrk_cnv + + function s_wrk_sizeof(wk) result(val) + use psb_realloc_mod + implicit none + class(amg_smlprec_wrk_type), intent(in) :: wk + integer(psb_epk_) :: val + integer :: i + val = 0 + val = val + (1_psb_epk_ * psb_sizeof_sp) * psb_size(wk%tx) + val = val + (1_psb_epk_ * psb_sizeof_sp) * psb_size(wk%ty) + val = val + (1_psb_epk_ * psb_sizeof_sp) * psb_size(wk%x2l) + val = val + (1_psb_epk_ * psb_sizeof_sp) * psb_size(wk%y2l) + val = val + wk%vtx%sizeof() + val = val + wk%vty%sizeof() + val = val + wk%vx2l%sizeof() + val = val + wk%vy2l%sizeof() + if (allocated(wk%wv)) then + do i=1, size(wk%wv) + val = val + wk%wv(i)%sizeof() + end do + end if + end function s_wrk_sizeof + +end module amg_s_onelev_mod diff --git a/mlprec/amg_s_prec_mod.f90 b/mlprec/amg_s_prec_mod.f90 new file mode 100644 index 00000000..639fd71d --- /dev/null +++ b/mlprec/amg_s_prec_mod.f90 @@ -0,0 +1,139 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_s_prec_mod.f90 +! +! Module: amg_s_prec_mod +! +! This module defines the user interfaces to the real/complex, single/double +! precision versions of the user-level MLD2P4 routines. +! +module amg_s_prec_mod + + use amg_s_prec_type + use amg_s_jac_smoother + use amg_s_as_smoother + use amg_s_id_solver + use amg_s_diag_solver + use amg_s_l1_diag_solver + use amg_s_ilu_solver + use amg_s_gs_solver + + interface amg_precset + module procedure amg_s_iprecsetsm, amg_s_iprecsetsv, & + & amg_s_cprecseti, amg_s_cprecsetc, amg_s_cprecsetr, & + & amg_s_iprecsetag + end interface amg_precset + + interface amg_extprol_bld + subroutine amg_s_extprol_bld(a,desc_a,p,prolv,restrv,info,amold,vmold,imold) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, & + & psb_s_base_sparse_mat, psb_s_base_vect_type, & + & psb_i_base_vect_type, amg_sprec_type, psb_ipk_ + + ! Arguments + type(psb_sspmat_type),intent(in), target :: a + type(psb_sspmat_type),intent(inout), target :: prolv(:) + type(psb_sspmat_type),intent(inout), target :: restrv(:) + type(psb_desc_type), intent(inout), target :: desc_a + type(amg_sprec_type),intent(inout),target :: p + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! !$ character, intent(in), optional :: upd + end subroutine amg_s_extprol_bld + end interface amg_extprol_bld + +contains + + subroutine amg_s_iprecsetsm(p,val,info,pos) + type(amg_sprec_type), intent(inout) :: p + class(amg_s_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + call p%set(val,info,pos=pos) + end subroutine amg_s_iprecsetsm + + subroutine amg_s_iprecsetsv(p,val,info,pos) + type(amg_sprec_type), intent(inout) :: p + class(amg_s_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + call p%set(val,info, pos=pos) + end subroutine amg_s_iprecsetsv + + subroutine amg_s_iprecsetag(p,val,info,pos) + type(amg_sprec_type), intent(inout) :: p + class(amg_s_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + call p%set(val,info, pos=pos) + end subroutine amg_s_iprecsetag + + subroutine amg_s_cprecseti(p,what,val,info,pos) + type(amg_sprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + call p%set(what,val,info,pos=pos) + end subroutine amg_s_cprecseti + + subroutine amg_s_cprecsetr(p,what,val,info,pos) + type(amg_sprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + call p%set(what,val,info,pos=pos) + end subroutine amg_s_cprecsetr + + subroutine amg_s_cprecsetc(p,what,val,info,pos) + type(amg_sprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + call p%set(what,val,info,pos=pos) + end subroutine amg_s_cprecsetc + +end module amg_s_prec_mod diff --git a/mlprec/amg_s_prec_type.f90 b/mlprec/amg_s_prec_type.f90 new file mode 100644 index 00000000..1b90e973 --- /dev/null +++ b/mlprec/amg_s_prec_type.f90 @@ -0,0 +1,964 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_s_prec_type.f90 +! +! Module: amg_s_prec_type +! +! This module defines: +! - the amg_s_prec_type data structure containing the preconditioner and related +! data structures; +! +! It contains routines for +! - Building and applying; +! - checking if the preconditioner is correctly defined; +! - printing a description of the preconditioner; +! - deallocating the preconditioner data structure. +! + +module amg_s_prec_type + + use amg_base_prec_type + use amg_s_base_solver_mod + use amg_s_base_smoother_mod + use amg_s_base_aggregator_mod + use amg_s_onelev_mod + use psb_base_mod, only : psb_erractionsave, psb_erractionrestore, psb_errstatus_fatal + use psb_prec_mod, only : psb_sprec_type + + ! + ! Type: amg_sprec_type. + ! + ! This is the data type containing all the information about the multilevel + ! preconditioner ('d', 's', 'c' and 'z', according to the real/complex, + ! single/double precision version of MLD2P4). + ! It consists of an array of 'one-level' intermediate data structures + ! of type amg_sonelev_type, each containing the information needed to apply + ! the smoothing and the coarse-space correction at a generic level. RT is the + ! real data type, i.e. S for both S and C, and D for both D and Z. + ! + ! type amg_sprec_type + ! type(amg_sonelev_type), allocatable :: precv(:) + ! end type amg_sprec_type + ! + ! Note that the levels are numbered in increasing order starting from + ! the level 1 as the finest one, and the number of levels is given by + ! size(precv(:)) which is the id of the coarsest level. + ! In the multigrid literature many authors number the levels in the opposite + ! order, with level 0 being the id of the coarsest level. + ! + ! + integer, parameter, private :: wv_size_=4 + + type, extends(psb_sprec_type) :: amg_sprec_type + ! integer(psb_ipk_) :: ictxt ! Now it's in the PSBLAS prec. + type(amg_saggr_data) :: ag_data + ! + ! Number of outer sweeps. Sometimes 2 V-cycles may be better than 1 W-cycle. + ! + integer(psb_ipk_) :: outer_sweeps = 1 + ! + ! Coarse solver requires some tricky checks, and for this we need to + ! record the choice in the format given by the user, + ! to keep track against what is put later in the multilevel array + ! + integer(psb_ipk_) :: coarse_solver = -1 + + ! + ! The multilevel hierarchy + ! + type(amg_s_onelev_type), allocatable :: precv(:) + contains + procedure, pass(prec) :: psb_s_apply2_vect => amg_s_apply2_vect + procedure, pass(prec) :: psb_s_apply1_vect => amg_s_apply1_vect + procedure, pass(prec) :: psb_s_apply2v => amg_s_apply2v + procedure, pass(prec) :: psb_s_apply1v => amg_s_apply1v + procedure, pass(prec) :: dump => amg_s_dump + procedure, pass(prec) :: cnv => amg_s_cnv + procedure, pass(prec) :: clone => amg_s_clone + procedure, pass(prec) :: free => amg_s_prec_free + procedure, pass(prec) :: allocate_wrk => amg_s_allocate_wrk + procedure, pass(prec) :: free_wrk => amg_s_free_wrk + procedure, pass(prec) :: is_allocated_wrk => amg_s_is_allocated_wrk + procedure, pass(prec) :: get_complexity => amg_s_get_compl + procedure, pass(prec) :: cmp_complexity => amg_s_cmp_compl + procedure, pass(prec) :: get_avg_cr => amg_s_get_avg_cr + procedure, pass(prec) :: cmp_avg_cr => amg_s_cmp_avg_cr + procedure, pass(prec) :: get_nlevs => amg_s_get_nlevs + procedure, pass(prec) :: get_nzeros => amg_s_get_nzeros + procedure, pass(prec) :: sizeof => amg_sprec_sizeof + procedure, pass(prec) :: setsm => amg_sprecsetsm + procedure, pass(prec) :: setsv => amg_sprecsetsv + procedure, pass(prec) :: setag => amg_sprecsetag + procedure, pass(prec) :: cseti => amg_scprecseti + procedure, pass(prec) :: csetc => amg_scprecsetc + procedure, pass(prec) :: csetr => amg_scprecsetr + generic, public :: set => cseti, csetc, csetr, setsm, setsv, setag + procedure, pass(prec) :: get_smoother => amg_s_get_smootherp + procedure, pass(prec) :: get_solver => amg_s_get_solverp + procedure, pass(prec) :: move_alloc => s_prec_move_alloc + procedure, pass(prec) :: init => amg_sprecinit + procedure, pass(prec) :: build => amg_sprecbld + procedure, pass(prec) :: hierarchy_build => amg_s_hierarchy_bld + procedure, pass(prec) :: smoothers_build => amg_s_smoothers_bld + procedure, pass(prec) :: descr => amg_sfile_prec_descr + end type amg_sprec_type + + private :: amg_s_dump, amg_s_get_compl, amg_s_cmp_compl,& + & amg_s_get_avg_cr, amg_s_cmp_avg_cr,& + & amg_s_get_nzeros, amg_s_get_nlevs, s_prec_move_alloc + + + ! + ! Interfaces to routines for checking the definition of the preconditioner, + ! for printing its description and for deallocating its data structure + ! + + interface amg_precfree + module procedure amg_sprecfree + end interface + + + interface amg_precdescr + subroutine amg_sfile_prec_descr(prec,iout,root) + import :: amg_sprec_type, psb_ipk_ + implicit none + ! Arguments + class(amg_sprec_type), intent(in) :: prec + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: root + end subroutine amg_sfile_prec_descr + end interface + + interface amg_sizeof + module procedure amg_sprec_sizeof + end interface + + interface amg_precapply + subroutine amg_sprecaply2_vect(prec,x,y,desc_data,info,trans,work) + import :: psb_sspmat_type, psb_desc_type, & + & psb_spk_, psb_s_vect_type, amg_sprec_type, psb_ipk_ + type(psb_desc_type),intent(in) :: desc_data + type(amg_sprec_type), intent(inout) :: prec + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_spk_),intent(inout), optional, target :: work(:) + end subroutine amg_sprecaply2_vect + subroutine amg_sprecaply1_vect(prec,x,desc_data,info,trans,work) + import :: psb_sspmat_type, psb_desc_type, & + & psb_spk_, psb_s_vect_type, amg_sprec_type, psb_ipk_ + type(psb_desc_type),intent(in) :: desc_data + type(amg_sprec_type), intent(inout) :: prec + type(psb_s_vect_type),intent(inout) :: x + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_spk_),intent(inout), optional, target :: work(:) + end subroutine amg_sprecaply1_vect + subroutine amg_sprecaply(prec,x,y,desc_data,info,trans,work) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, amg_sprec_type, psb_ipk_ + type(psb_desc_type),intent(in) :: desc_data + type(amg_sprec_type), intent(inout) :: prec + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_spk_),intent(inout), optional, target :: work(:) + end subroutine amg_sprecaply + subroutine amg_sprecaply1(prec,x,desc_data,info,trans) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, amg_sprec_type, psb_ipk_ + type(psb_desc_type),intent(in) :: desc_data + type(amg_sprec_type), intent(inout) :: prec + real(psb_spk_),intent(inout) :: x(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + end subroutine amg_sprecaply1 + end interface + + interface + subroutine amg_sprecsetsm(prec,val,info,ilev,ilmax,pos) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, & + & amg_sprec_type, amg_s_base_smoother_type, psb_ipk_ + class(amg_sprec_type), target, intent(inout):: prec + class(amg_s_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + end subroutine amg_sprecsetsm + subroutine amg_sprecsetsv(prec,val,info,ilev,ilmax,pos) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, & + & amg_sprec_type, amg_s_base_solver_type, psb_ipk_ + class(amg_sprec_type), intent(inout) :: prec + class(amg_s_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + end subroutine amg_sprecsetsv + subroutine amg_sprecsetag(prec,val,info,ilev,ilmax,pos) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, & + & amg_sprec_type, amg_s_base_aggregator_type, psb_ipk_ + class(amg_sprec_type), intent(inout) :: prec + class(amg_s_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + end subroutine amg_sprecsetag + subroutine amg_scprecseti(prec,what,val,info,ilev,ilmax,pos,idx) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, & + & amg_sprec_type, psb_ipk_ + class(amg_sprec_type), intent(inout) :: prec + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx + character(len=*), optional, intent(in) :: pos + end subroutine amg_scprecseti + subroutine amg_scprecsetr(prec,what,val,info,ilev,ilmax,pos,idx) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, & + & amg_sprec_type, psb_ipk_ + class(amg_sprec_type), intent(inout) :: prec + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx + character(len=*), optional, intent(in) :: pos + end subroutine amg_scprecsetr + subroutine amg_scprecsetc(prec,what,string,info,ilev,ilmax,pos,idx) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, & + & amg_sprec_type, psb_ipk_ + class(amg_sprec_type), intent(inout) :: prec + character(len=*), intent(in) :: what + character(len=*), intent(in) :: string + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx + character(len=*), optional, intent(in) :: pos + end subroutine amg_scprecsetc + end interface + + interface amg_precinit + subroutine amg_sprecinit(ictxt,prec,ptype,info) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, & + & amg_sprec_type, psb_ipk_ + integer(psb_ipk_), intent(in) :: ictxt + class(amg_sprec_type), intent(inout) :: prec + character(len=*), intent(in) :: ptype + integer(psb_ipk_), intent(out) :: info + end subroutine amg_sprecinit + end interface amg_precinit + + interface amg_precbld + subroutine amg_sprecbld(a,desc_a,prec,info,amold,vmold,imold) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, & + & psb_s_base_sparse_mat, psb_s_base_vect_type, & + & psb_i_base_vect_type, amg_sprec_type, psb_ipk_ + implicit none + type(psb_sspmat_type), intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_sprec_type), intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! character, intent(in),optional :: upd + end subroutine amg_sprecbld + end interface amg_precbld + + interface amg_hierarchy_bld + subroutine amg_s_hierarchy_bld(a,desc_a,prec,info) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, & + & amg_sprec_type, psb_ipk_ + implicit none + type(psb_sspmat_type), intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_sprec_type), intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + ! character, intent(in),optional :: upd + end subroutine amg_s_hierarchy_bld + end interface amg_hierarchy_bld + + interface amg_smoothers_bld + subroutine amg_s_smoothers_bld(a,desc_a,prec,info,amold,vmold,imold) + import :: psb_sspmat_type, psb_desc_type, psb_spk_, & + & psb_s_base_sparse_mat, psb_s_base_vect_type, & + & psb_i_base_vect_type, amg_sprec_type, psb_ipk_ + implicit none + type(psb_sspmat_type), intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_sprec_type), intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! character, intent(in),optional :: upd + end subroutine amg_s_smoothers_bld + end interface amg_smoothers_bld + +contains + ! + ! Function returning a pointer to the smoother + ! + function amg_s_get_smootherp(prec,ilev) result(val) + implicit none + class(amg_sprec_type), target, intent(in) :: prec + integer(psb_ipk_), optional :: ilev + class(amg_s_base_smoother_type), pointer :: val + integer(psb_ipk_) :: ilev_ + + val => null() + if (present(ilev)) then + ilev_ = ilev + else + ! What is a good default? + ilev_ = 1 + end if + if (allocated(prec%precv)) then + if ((1<=ilev_).and.(ilev_<=size(prec%precv))) then + if (allocated(prec%precv(ilev_)%sm)) then + val => prec%precv(ilev_)%sm + end if + end if + end if + end function amg_s_get_smootherp + ! + ! Function returning a pointer to the solver + ! + function amg_s_get_solverp(prec,ilev) result(val) + implicit none + class(amg_sprec_type), target, intent(in) :: prec + integer(psb_ipk_), optional :: ilev + class(amg_s_base_solver_type), pointer :: val + integer(psb_ipk_) :: ilev_ + + val => null() + if (present(ilev)) then + ilev_ = ilev + else + ! What is a good default? + ilev_ = 1 + end if + if (allocated(prec%precv)) then + if ((1<=ilev_).and.(ilev_<=size(prec%precv))) then + if (allocated(prec%precv(ilev_)%sm)) then + if (allocated(prec%precv(ilev_)%sm%sv)) then + val => prec%precv(ilev_)%sm%sv + end if + end if + end if + end if + end function amg_s_get_solverp + ! + ! Function returning the size of the precv(:) array + ! + function amg_s_get_nlevs(prec) result(val) + implicit none + class(amg_sprec_type), intent(in) :: prec + integer(psb_ipk_) :: val + val = 0 + if (allocated(prec%precv)) then + val = size(prec%precv) + end if + end function amg_s_get_nlevs + ! + ! Function returning the size of the amg_prec_type data structure + ! in bytes or in number of nonzeros of the operator(s) involved. + ! + function amg_s_get_nzeros(prec) result(val) + implicit none + class(amg_sprec_type), intent(in) :: prec + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + if (allocated(prec%precv)) then + do i=1, size(prec%precv) + val = val + prec%precv(i)%get_nzeros() + end do + end if + end function amg_s_get_nzeros + + function amg_sprec_sizeof(prec) result(val) + implicit none + class(amg_sprec_type), intent(in) :: prec + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + val = val + psb_sizeof_ip + if (allocated(prec%precv)) then + do i=1, size(prec%precv) + val = val + prec%precv(i)%sizeof() + end do + end if + end function amg_sprec_sizeof + + ! + ! Operator complexity: ratio of total number + ! of nonzeros in the aggregated matrices at the + ! various level to the nonzeroes at the fine level + ! (original matrix) + ! + + function amg_s_get_compl(prec) result(val) + implicit none + class(amg_sprec_type), intent(in) :: prec + real(psb_spk_) :: val + + val = prec%ag_data%op_complexity + + end function amg_s_get_compl + + subroutine amg_s_cmp_compl(prec) + + implicit none + class(amg_sprec_type), intent(inout) :: prec + + real(psb_spk_) :: num, den, nmin + integer(psb_ipk_) :: ictxt + integer(psb_ipk_) :: il + + num = -sone + den = sone + ictxt = prec%ictxt + if (allocated(prec%precv)) then + il = 1 + num = prec%precv(il)%base_a%get_nzeros() + if (num >= szero) then + den = num + do il=2,size(prec%precv) + num = num + max(0,prec%precv(il)%base_a%get_nzeros()) + end do + end if + end if + nmin = num + call psb_min(ictxt,nmin) + if (nmin < szero) then + num = szero + den = sone + else + call psb_sum(ictxt,num) + call psb_sum(ictxt,den) + end if + prec%ag_data%op_complexity = num/den + end subroutine amg_s_cmp_compl + + ! + ! Average coarsening ratio + ! + + function amg_s_get_avg_cr(prec) result(val) + implicit none + class(amg_sprec_type), intent(in) :: prec + real(psb_spk_) :: val + + val = prec%ag_data%avg_cr + + end function amg_s_get_avg_cr + + subroutine amg_s_cmp_avg_cr(prec) + + implicit none + class(amg_sprec_type), intent(inout) :: prec + + real(psb_spk_) :: avgcr + integer(psb_ipk_) :: ictxt + integer(psb_ipk_) :: il, nl, iam, np + + + avgcr = szero + ictxt = prec%ictxt + call psb_info(ictxt,iam,np) + if (allocated(prec%precv)) then + nl = size(prec%precv) + do il=2,nl + avgcr = avgcr + max(szero,prec%precv(il)%szratio) + end do + avgcr = avgcr / (nl-1) + end if + call psb_sum(ictxt,avgcr) + prec%ag_data%avg_cr = avgcr/np + end subroutine amg_s_cmp_avg_cr + + ! + ! Subroutines: amg_Tprec_free + ! Version: real + ! + ! These routines deallocate the amg_Tprec_type data structures. + ! + ! Arguments: + ! p - type(amg_Tprec_type), input. + ! The data structure to be deallocated. + ! info - integer, output. + ! error code. + ! + subroutine amg_sprecfree(p,info) + + implicit none + + ! Arguments + type(amg_sprec_type), intent(inout) :: p + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: me,err_act,i + character(len=20) :: name + + info=psb_success_ + name = 'amg_sprecfree' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; return + end if + + me=-1 + + call p%free(info) + + + return + + end subroutine amg_sprecfree + + subroutine amg_s_prec_free(prec,info) + + implicit none + + ! Arguments + class(amg_sprec_type), intent(inout) :: prec + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: me,err_act,i + character(len=20) :: name + + info=psb_success_ + name = 'amg_sprecfree' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + + me=-1 + if (allocated(prec%precv)) then + do i=1,size(prec%precv) + call prec%precv(i)%free(info) + end do + deallocate(prec%precv,stat=info) + end if + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_s_prec_free + + + + ! + ! Top level methods. + ! + subroutine amg_s_apply2_vect(prec,x,y,desc_data,info,trans,work) + implicit none + type(psb_desc_type),intent(in) :: desc_data + class(amg_sprec_type), intent(inout) :: prec + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_spk_),intent(inout), optional, target :: work(:) + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_prec_apply' + + call psb_erractionsave(err_act) + + select type(prec) + type is (amg_sprec_type) + call amg_precapply(prec,x,y,desc_data,info,trans,work) + class default + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_s_apply2_vect + + subroutine amg_s_apply1_vect(prec,x,desc_data,info,trans,work) + implicit none + type(psb_desc_type),intent(in) :: desc_data + class(amg_sprec_type), intent(inout) :: prec + type(psb_s_vect_type),intent(inout) :: x + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_spk_),intent(inout), optional, target :: work(:) + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_prec_apply' + + call psb_erractionsave(err_act) + + select type(prec) + type is (amg_sprec_type) + call amg_precapply(prec,x,desc_data,info,trans,work) + class default + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_s_apply1_vect + + + subroutine amg_s_apply2v(prec,x,y,desc_data,info,trans,work) + implicit none + type(psb_desc_type),intent(in) :: desc_data + class(amg_sprec_type), intent(inout) :: prec + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_spk_),intent(inout), optional, target :: work(:) + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_prec_apply' + + call psb_erractionsave(err_act) + + select type(prec) + type is (amg_sprec_type) + call amg_precapply(prec,x,y,desc_data,info,trans,work) + class default + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_s_apply2v + + subroutine amg_s_apply1v(prec,x,desc_data,info,trans) + implicit none + type(psb_desc_type),intent(in) :: desc_data + class(amg_sprec_type), intent(inout) :: prec + real(psb_spk_),intent(inout) :: x(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_prec_apply' + + call psb_erractionsave(err_act) + + select type(prec) + type is (amg_sprec_type) + call amg_precapply(prec,x,desc_data,info,trans) + class default + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_s_apply1v + + + subroutine amg_s_dump(prec,info,istart,iend,iproc,prefix,head,& + & ac,rp,smoother,solver,tprol,& + & global_num) + + implicit none + class(amg_sprec_type), intent(in) :: prec + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: istart, iend, iproc + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver,ac, rp, tprol, global_num + integer(psb_ipk_) :: i, j, il1, iln, lev + integer(psb_ipk_) :: icontxt, iam, np, iproc_ + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + ! len of prefix_ + + info = 0 + icontxt = prec%ictxt + call psb_info(icontxt,iam,np) + + iln = size(prec%precv) + if (present(istart)) then + il1 = max(1,istart) + else + il1 = min(2,iln) + end if + if (present(iend)) then + iln = min(iln, iend) + end if + iproc_ = -1 + if (present(iproc)) then + iproc_ = iproc + end if + + if ((iproc_ == -1).or.(iproc_==iam)) then + do lev=il1, iln + call prec%precv(lev)%dump(lev,info,prefix=prefix,head=head,& + & ac=ac,smoother=smoother,solver=solver,rp=rp,tprol=tprol, & + & global_num=global_num) + end do + end if + end subroutine amg_s_dump + + subroutine amg_s_cnv(prec,info,amold,vmold,imold) + + implicit none + class(amg_sprec_type), intent(inout) :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + integer(psb_ipk_) :: i + + info = psb_success_ + if (allocated(prec%precv)) then + do i=1,size(prec%precv) + if (info == psb_success_ ) & + & call prec%precv(i)%cnv(info,amold=amold,vmold=vmold,imold=imold) + end do + end if + + end subroutine amg_s_cnv + + subroutine amg_s_clone(prec,precout,info) + + implicit none + class(amg_sprec_type), intent(inout) :: prec + class(psb_sprec_type), intent(inout) :: precout + integer(psb_ipk_), intent(out) :: info + + call precout%free(info) + if (info == 0) call amg_s_inner_clone(prec,precout,info) + + end subroutine amg_s_clone + + subroutine amg_s_inner_clone(prec,precout,info) + + implicit none + class(amg_sprec_type), intent(inout) :: prec + class(psb_sprec_type), target, intent(inout) :: precout + integer(psb_ipk_), intent(out) :: info + ! Local vars + integer(psb_ipk_) :: i, j, ln, lev + integer(psb_ipk_) :: icontxt,iam, np + + info = psb_success_ + select type(pout => precout) + class is (amg_sprec_type) + pout%ictxt = prec%ictxt + pout%ag_data = prec%ag_data + pout%outer_sweeps = prec%outer_sweeps + if (allocated(prec%precv)) then + ln = size(prec%precv) + allocate(pout%precv(ln),stat=info) + if (info /= psb_success_) goto 9999 + if (ln >= 1) then + call prec%precv(1)%clone(pout%precv(1),info) + end if + do lev=2, ln + if (info /= psb_success_) exit + call prec%precv(lev)%clone(pout%precv(lev),info) + if (info == psb_success_) then + pout%precv(lev)%base_a => pout%precv(lev)%ac + pout%precv(lev)%base_desc => pout%precv(lev)%desc_ac + pout%precv(lev)%map%p_desc_U => pout%precv(lev-1)%base_desc + pout%precv(lev)%map%p_desc_V => pout%precv(lev)%base_desc + end if + end do + end if + if (allocated(prec%precv(1)%wrk)) & + & call pout%allocate_wrk(info,vmold=prec%precv(1)%wrk%vx2l%v) + + class default + write(0,*) 'Error: wrong out type' + info = psb_err_invalid_input_ + end select +9999 continue + end subroutine amg_s_inner_clone + + subroutine s_prec_move_alloc(prec, b,info) + use psb_base_mod + implicit none + class(amg_sprec_type), intent(inout) :: prec + class(amg_sprec_type), intent(inout), target :: b + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: i + + if (same_type_as(prec,b)) then + if (allocated(b%precv)) then + ! This might not be required if FINAL procedures are available. + call b%free(info) + if (info /= psb_success_) then + !????? +!!$ return + endif + end if + b%ictxt = prec%ictxt + b%ag_data = prec%ag_data + b%outer_sweeps = prec%outer_sweeps + + call move_alloc(prec%precv,b%precv) + ! Fix the pointers except on level 1. + do i=2, size(b%precv) + b%precv(i)%base_a => b%precv(i)%ac + b%precv(i)%base_desc => b%precv(i)%desc_ac + b%precv(i)%map%p_desc_U => b%precv(i-1)%base_desc + b%precv(i)%map%p_desc_V => b%precv(i)%base_desc + end do + + else + write(0,*) 'Warning: PREC%move_alloc onto different type?' + info = psb_err_internal_error_ + end if + end subroutine s_prec_move_alloc + + subroutine amg_s_allocate_wrk(prec,info,vmold,desc) + use psb_base_mod + implicit none + + ! Arguments + class(amg_sprec_type), intent(inout) :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_vect_type), intent(in), optional :: vmold + ! + ! In MLD the DESC optional argument is ignored, since + ! the necessary info is contained in the various entries of the + ! PRECV component. + type(psb_desc_type), intent(in), optional :: desc + + ! Local variables + integer(psb_ipk_) :: me,err_act,i,j,level,nlev, nc2l + character(len=20) :: name + + info=psb_success_ + name = 'amg_s_allocate_wrk' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + nlev = size(prec%precv) + level = 1 + do level = 1, nlev + call prec%precv(level)%allocate_wrk(info,vmold=vmold) + if (psb_errstatus_fatal()) then + nc2l = prec%precv(level)%base_desc%get_local_cols() + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nc2l/), a_err='real(psb_spk_)') + goto 9999 + end if + end do + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_s_allocate_wrk + + subroutine amg_s_free_wrk(prec,info) + use psb_base_mod + implicit none + + ! Arguments + class(amg_sprec_type), intent(inout) :: prec + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: me,err_act,i,j,level, nlev, nc2l + character(len=20) :: name + + info=psb_success_ + name = 'amg_s_free_wrk' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + + if (allocated(prec%precv)) then + nlev = size(prec%precv) + do level = 1, nlev + call prec%precv(level)%free_wrk(info) + end do + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_s_free_wrk + + function amg_s_is_allocated_wrk(prec) result(res) + use psb_base_mod + implicit none + + ! Arguments + class(amg_sprec_type), intent(in) :: prec + logical :: res + + res = .false. + if (.not.allocated(prec%precv)) return + res = allocated(prec%precv(1)%wrk) + + end function amg_s_is_allocated_wrk + +end module amg_s_prec_type diff --git a/mlprec/amg_s_slu_solver.F90 b/mlprec/amg_s_slu_solver.F90 new file mode 100644 index 00000000..9bc8d5f8 --- /dev/null +++ b/mlprec/amg_s_slu_solver.F90 @@ -0,0 +1,447 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_s_slu_solver_mod.f90 +! +! Module: amg_s_slu_solver_mod +! +! This module defines: +! - the amg_s_slu_solver_type data structure containing the ingredients +! to interface with the SuperLU package. +! 1. The factorization is restricted to the diagonal block of the +! current image. +! +module amg_s_slu_solver + + use iso_c_binding + use amg_s_base_solver_mod + +#if defined(IPK8) + + type, extends(amg_s_base_solver_type) :: amg_s_slu_solver_type + + end type amg_s_slu_solver_type + +#else + + type, extends(amg_s_base_solver_type) :: amg_s_slu_solver_type + type(c_ptr) :: lufactors=c_null_ptr + integer(c_long_long) :: symbsize=0, numsize=0 + contains + procedure, pass(sv) :: build => s_slu_solver_bld + procedure, pass(sv) :: apply_a => s_slu_solver_apply + procedure, pass(sv) :: apply_v => s_slu_solver_apply_vect + procedure, pass(sv) :: free => s_slu_solver_free + procedure, pass(sv) :: clear_data => s_slu_solver_clear_data + procedure, pass(sv) :: descr => s_slu_solver_descr + procedure, pass(sv) :: sizeof => s_slu_solver_sizeof + procedure, nopass :: get_fmt => s_slu_solver_get_fmt + procedure, nopass :: get_id => s_slu_solver_get_id + final :: s_slu_solver_finalize + end type amg_s_slu_solver_type + + + private :: s_slu_solver_bld, s_slu_solver_apply, & + & s_slu_solver_free, s_slu_solver_descr, & + & s_slu_solver_sizeof, s_slu_solver_apply_vect, & + & s_slu_solver_get_fmt, s_slu_solver_get_id, & + & s_slu_solver_clear_data + private :: s_slu_solver_finalize + + + + interface + function amg_sslu_fact(n,nnz,values,rowptr,colind,& + & lufactors)& + & bind(c,name='amg_sslu_fact') result(info) + use iso_c_binding + integer(c_int), value :: n,nnz + integer(c_int) :: info + integer(c_int) :: rowptr(*),colind(*) + real(c_float) :: values(*) + type(c_ptr) :: lufactors + end function amg_sslu_fact + end interface + + interface + function amg_sslu_solve(itrans,n,nrhs,b,ldb,lufactors)& + & bind(c,name='amg_sslu_solve') result(info) + use iso_c_binding + integer(c_int) :: info + integer(c_int), value :: itrans,n,nrhs,ldb + real(c_float) :: b(ldb,*) + type(c_ptr), value :: lufactors + end function amg_sslu_solve + end interface + + interface + function amg_sslu_free(lufactors)& + & bind(c,name='amg_sslu_free') result(info) + use iso_c_binding + integer(c_int) :: info + type(c_ptr), value :: lufactors + end function amg_sslu_free + end interface + +contains + + subroutine s_slu_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + use psb_base_mod + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_slu_solver_type), intent(inout) :: sv + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer, intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + + integer :: n_row,n_col + real(psb_spk_), pointer :: ww(:) + integer :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='s_slu_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + else + allocate(ww(n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/n_col,0,0,0,0/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + endif + + ww(1:n_row) = x(1:n_row) + select case(trans_) + case('N') + info = amg_sslu_solve(0,n_row,1,ww,n_row,sv%lufactors) + case('T') + info = amg_sslu_solve(1,n_row,1,ww,n_row,sv%lufactors) + case('C') + info = amg_sslu_solve(2,n_row,1,ww,n_row,sv%lufactors) + case default + call psb_errpush(psb_err_internal_error_, & + & name,a_err='Invalid TRANS in ILU subsolve') + goto 9999 + end select + + if (info == psb_success_) & + & call psb_geaxpby(alpha,ww,beta,y,desc_data,info) + + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in subsolve') + goto 9999 + endif + + if (n_col > size(work)) then + deallocate(ww) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine s_slu_solver_apply + + subroutine s_slu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + use psb_base_mod + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_slu_solver_type), intent(inout) :: sv + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer, intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + + integer :: err_act + character(len=20) :: name='s_slu_solver_apply_vect' + + call psb_erractionsave(err_act) + + info = psb_success_ + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call x%v%sync() + call y%v%sync() + call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) + call y%v%set_host() + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine s_slu_solver_apply_vect + + subroutine s_slu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + + Implicit None + + ! Arguments + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_slu_solver_type), intent(inout) :: sv + integer, intent(out) :: info + type(psb_sspmat_type), intent(in), target, optional :: b + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + type(psb_sspmat_type) :: atmp + type(psb_s_csc_sparse_mat) :: acsc + type(psb_s_coo_sparse_mat) :: acoo + integer :: n_row,n_col, nrow_a, nztota + integer :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='s_slu_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + n_col = desc_a%get_local_cols() + + + call a%cscnv(atmp,info,type='coo') + call psb_rwextd(n_row,atmp,info,b=b) + call atmp%cscnv(info,type='coo',dupl=psb_dupl_add_) + nrow_a = atmp%get_nrows() + call atmp%a%csclip(acoo,info,jmax=nrow_a) + call acsc%mv_from_coo(acoo,info) + nztota = acsc%get_nzeros() + ! Fix the entries to call C-base SuperLU + acsc%ia(:) = acsc%ia(:) - 1 + acsc%icp(:) = acsc%icp(:) - 1 + info = amg_sslu_fact(nrow_a,nztota,acsc%val,& + & acsc%icp,acsc%ia,sv%lufactors) + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='amg_sslu_fact' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + call acsc%free() + call atmp%free() + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine s_slu_solver_bld + + subroutine s_slu_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_s_slu_solver_type), intent(inout) :: sv + integer, intent(out) :: info + Integer :: err_act + character(len=20) :: name='s_slu_solver_free' + + call psb_erractionsave(err_act) + + info = psb_success_ + + call sv%clear_data(info) + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine s_slu_solver_free + + subroutine s_slu_solver_clear_data(sv,info) + + Implicit None + + ! Arguments + class(amg_s_slu_solver_type), intent(inout) :: sv + integer, intent(out) :: info + Integer :: err_act + character(len=20) :: name='s_slu_solver_clear_data' + + call psb_erractionsave(err_act) + + info = psb_success_ + if (c_associated(sv%lufactors)) info = amg_sslu_free(sv%lufactors) + sv%lufactors = c_null_ptr + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine s_slu_solver_clear_data + + subroutine s_slu_solver_finalize(sv) + + Implicit None + + ! Arguments + type(amg_s_slu_solver_type), intent(inout) :: sv + integer :: info + Integer :: err_act + character(len=20) :: name='s_slu_solver_finalize' + + call sv%free(info) + + return + + end subroutine s_slu_solver_finalize + + subroutine s_slu_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_s_slu_solver_type), intent(in) :: sv + integer, intent(out) :: info + integer, intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer :: err_act + integer :: ictxt, me, np + character(len=20), parameter :: name='amg_s_slu_solver_descr' + integer :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' SuperLU Sparse Factorization Solver. ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine s_slu_solver_descr + + function s_slu_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_s_slu_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer :: i + + val = 2*psb_sizeof_ip + psb_sizeof_dp + val = val + sv%symbsize + val = val + sv%numsize + return + end function s_slu_solver_sizeof + + function s_slu_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "SuperLU solver" + end function s_slu_solver_get_fmt + + function s_slu_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_slu_ + end function s_slu_solver_get_id +#endif +end module amg_s_slu_solver diff --git a/mlprec/amg_s_symdec_aggregator_mod.f90 b/mlprec/amg_s_symdec_aggregator_mod.f90 new file mode 100644 index 00000000..1344a68a --- /dev/null +++ b/mlprec/amg_s_symdec_aggregator_mod.f90 @@ -0,0 +1,105 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! Locally symmetrized (decoupled) aggregation algorithm. +! This version differs from the basic decoupled aggregation algorithm +! only because it works on (the pattern of) A+A^T instead of A. +! +! +module amg_s_symdec_aggregator_mod + + use amg_s_dec_aggregator_mod + !> \namespace amg_s_symdec_aggregator_mod \class amg_s_symdec_aggregator_type + !! \extends amg_s_dec_aggregator_mod::amg_s_dec_aggregator_type + !! + !! This version differs from the basic decoupled aggregation algorithm + !! only because it works on (the pattern of) A+A^T instead of A. + !! + ! + type, extends(amg_s_dec_aggregator_type) :: amg_s_symdec_aggregator_type + + contains + procedure, pass(ag) :: bld_tprol => amg_s_symdec_aggregator_build_tprol + procedure, pass(ag) :: descr => amg_s_symdec_aggregator_descr + procedure, nopass :: fmt => amg_s_symdec_aggregator_fmt + end type amg_s_symdec_aggregator_type + + + interface + subroutine amg_s_symdec_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,t_prol,info) + import :: amg_s_symdec_aggregator_type, psb_desc_type, psb_sspmat_type, psb_spk_, & + & psb_ipk_, psb_lpk_, psb_lsspmat_type, amg_sml_parms, amg_saggr_data + implicit none + class(amg_s_symdec_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(amg_saggr_data), intent(in) :: ag_data + type(psb_sspmat_type), intent(inout) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lsspmat_type), intent(out) :: t_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_s_symdec_aggregator_build_tprol + end interface + + +contains + + function amg_s_symdec_aggregator_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Symmetric Decoupled aggregation" + end function amg_s_symdec_aggregator_fmt + + subroutine amg_s_symdec_aggregator_descr(ag,parms,iout,info) + implicit none + class(amg_s_symdec_aggregator_type), intent(in) :: ag + type(amg_sml_parms), intent(in) :: parms + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + + write(iout,*) 'Decoupled Aggregator locally-symmetrized' + write(iout,*) 'Aggregator object type: ',ag%fmt() + call parms%mldescr(iout,info) + + return + end subroutine amg_s_symdec_aggregator_descr + +end module amg_s_symdec_aggregator_mod diff --git a/mlprec/amg_z_as_smoother.f90 b/mlprec/amg_z_as_smoother.f90 new file mode 100644 index 00000000..507d50e9 --- /dev/null +++ b/mlprec/amg_z_as_smoother.f90 @@ -0,0 +1,471 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_z_as_smoother_mod.f90 +! +! Module: amg_z_as_smoother_mod +! +! This module defines: +! the amg_z_as_smoother_type data structure containing the +! smoother for an Additive Schwarz smoother. +! +! To begin with, the build procedure constructs the extended +! matrix A and its corresponding descriptor (this has multiple +! halo layers duplicated across different processes); it then +! stores in ND the block off-diagonal matrix, and builds the solver +! on the (extended) block diagonal matrix. +! +! The code allows for the variations of Additive Schwartz, Restricted +! Additive Schwartz and Additive Schwartz with Harmonic Extensions. +! From an implementation point of view, these are handled by +! combining application/non-application of the prolongator/restrictor +! operators. +! +module amg_z_as_smoother + + use amg_z_base_smoother_mod + + type, extends(amg_z_base_smoother_type) :: amg_z_as_smoother_type + ! The local solver component is inherited from the + ! parent type. + ! class(amg_z_base_solver_type), allocatable :: sv + ! + type(psb_zspmat_type) :: nd + type(psb_desc_type) :: desc_data + integer(psb_ipk_) :: novr, restr, prol + integer(psb_lpk_) :: nd_nnz_tot + contains + procedure, pass(sm) :: apply_v => amg_z_as_smoother_apply_vect + procedure, pass(sm) :: apply_a => amg_z_as_smoother_apply + procedure, pass(sm) :: check => amg_z_as_smoother_check + procedure, pass(sm) :: dump => amg_z_as_smoother_dmp + procedure, pass(sm) :: build => amg_z_as_smoother_bld + procedure, pass(sm) :: cnv => amg_z_as_smoother_cnv + procedure, pass(sm) :: clone => amg_z_as_smoother_clone + procedure, pass(sm) :: clone_settings => amg_z_as_smoother_clone_settings + procedure, pass(sm) :: clear_data => amg_z_as_smoother_clear_data + procedure, pass(sm) :: restr_a => amg_z_as_smoother_restr_a + procedure, pass(sm) :: prol_a => amg_z_as_smoother_prol_a + procedure, pass(sm) :: restr_v => amg_z_as_smoother_restr_v + procedure, pass(sm) :: prol_v => amg_z_as_smoother_prol_v + generic, public :: apply_restr => restr_v, restr_a + generic, public :: apply_prol => prol_v, prol_a + procedure, pass(sm) :: free => amg_z_as_smoother_free + procedure, pass(sm) :: cseti => amg_z_as_smoother_cseti + procedure, pass(sm) :: csetc => amg_z_as_smoother_csetc + procedure, pass(sm) :: descr => z_as_smoother_descr + procedure, pass(sm) :: sizeof => z_as_smoother_sizeof + procedure, pass(sm) :: default => z_as_smoother_default + procedure, pass(sm) :: get_nzeros => z_as_smoother_get_nzeros + procedure, pass(sm) :: get_wrksz => z_as_smoother_get_wrksize + procedure, nopass :: get_fmt => z_as_smoother_get_fmt + procedure, nopass :: get_id => z_as_smoother_get_id + end type amg_z_as_smoother_type + + + private :: z_as_smoother_descr, z_as_smoother_sizeof, & + & z_as_smoother_default, z_as_smoother_get_nzeros, & + & z_as_smoother_get_fmt, z_as_smoother_get_id, & + & z_as_smoother_get_wrksize + + character(len=6), parameter, private :: & + & restrict_names(0:4)=(/'none ','halo ',' ',' ',' '/) + character(len=12), parameter, private :: & + & prolong_names(0:3)=(/'none ','sum ','average ','square root'/) + + + interface + subroutine amg_z_as_smoother_check(sm,info) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_dpk_, amg_z_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_z_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_as_smoother_check + end interface + + interface + subroutine amg_z_as_smoother_restr_v(sm,x,trans,work,info,data) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_dpk_, amg_z_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + class(amg_z_as_smoother_type), intent(inout) :: sm + type(psb_z_vect_type),intent(inout) :: x + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + end subroutine amg_z_as_smoother_restr_v + end interface + + interface + subroutine amg_z_as_smoother_restr_a(sm,x,trans,work,info,data) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_dpk_, amg_z_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + class(amg_z_as_smoother_type), intent(inout) :: sm + complex(psb_dpk_), intent(inout) :: x(:) + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + end subroutine amg_z_as_smoother_restr_a + end interface + + interface + subroutine amg_z_as_smoother_prol_v(sm,x,trans,work,info,data) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_dpk_, amg_z_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + class(amg_z_as_smoother_type), intent(inout) :: sm + type(psb_z_vect_type),intent(inout) :: x + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + end subroutine amg_z_as_smoother_prol_v + end interface + + interface + subroutine amg_z_as_smoother_prol_a(sm,x,trans,work,info,data) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_dpk_, amg_z_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + class(amg_z_as_smoother_type), intent(inout) :: sm + complex(psb_dpk_), intent(inout) :: x(:) + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + end subroutine amg_z_as_smoother_prol_a + end interface + + + interface + subroutine amg_z_as_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,wv,info,init,initu) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_dpk_, amg_z_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_as_smoother_type), intent(inout) :: sm + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + end subroutine amg_z_as_smoother_apply_vect + end interface + + interface + subroutine amg_z_as_smoother_apply(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,info,init,initu) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_dpk_, amg_z_as_smoother_type, psb_epk_,& + & psb_desc_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_as_smoother_type), intent(inout) :: sm + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_z_as_smoother_apply + end interface + + interface + subroutine amg_z_as_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_dpk_, amg_z_as_smoother_type, psb_epk_, & + & psb_desc_type, psb_z_base_sparse_mat, psb_ipk_,& + & psb_i_base_vect_type + implicit none + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_as_smoother_bld + end interface + + interface + subroutine amg_z_as_smoother_cnv(sm,info,amold,vmold,imold) + import :: psb_z_base_vect_type, & + & psb_dpk_, amg_z_as_smoother_type, psb_epk_, & + & psb_z_base_sparse_mat, psb_ipk_, psb_i_base_vect_type + implicit none + class(amg_z_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_as_smoother_cnv + end interface + + interface + subroutine amg_z_as_smoother_cseti(sm,what,val,info,idx) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_dpk_, amg_z_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_z_as_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_z_as_smoother_cseti + end interface + + interface + subroutine amg_z_as_smoother_csetc(sm,what,val,info,idx) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_dpk_, amg_z_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_z_as_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_z_as_smoother_csetc + end interface + + interface + subroutine amg_z_as_smoother_free(sm,info) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_dpk_, amg_z_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_z_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_as_smoother_free + end interface + + interface + subroutine amg_z_as_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_dpk_, amg_z_as_smoother_type, psb_epk_, psb_desc_type, & + & psb_ipk_ + implicit none + class(amg_z_as_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + end subroutine amg_z_as_smoother_dmp + end interface + + interface + subroutine amg_z_as_smoother_clone(sm,smout,info) + import :: amg_z_as_smoother_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_ + class(amg_z_as_smoother_type), intent(inout) :: sm + class(amg_z_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_as_smoother_clone + end interface + + + interface + subroutine amg_z_as_smoother_clone_settings(sm,smout,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_smoother_type, amg_z_as_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_as_smoother_type), intent(inout) :: sm + class(amg_z_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_as_smoother_clone_settings + end interface + + interface + subroutine amg_z_as_smoother_clear_data(sm,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_as_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_as_smoother_clear_data + end interface + + +contains + + function z_as_smoother_sizeof(sm) result(val) + implicit none + ! Arguments + class(amg_z_as_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 3*psb_sizeof_ip + psb_sizeof_lp + if (allocated(sm%sv)) val = val + sm%sv%sizeof() + val = val + sm%nd%sizeof() + + return + end function z_as_smoother_sizeof + + function z_as_smoother_get_nzeros(sm) result(val) + implicit none + class(amg_z_as_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + if (allocated(sm%sv)) & + & val = sm%sv%get_nzeros() + val = val + sm%nd%get_nzeros() + + end function z_as_smoother_get_nzeros + + subroutine z_as_smoother_default(sm) + + use psb_base_mod, only : psb_halo_, psb_none_ + + Implicit None + + ! Arguments + class(amg_z_as_smoother_type), intent(inout) :: sm + + ! + ! Default: AS with 1 overlap layer + ! + sm%restr = psb_halo_ + sm%prol = psb_sum_ + sm%novr = 1 + + if (allocated(sm%sv)) then + call sm%sv%default() + end if + + return + end subroutine z_as_smoother_default + + + subroutine z_as_smoother_descr(sm,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_z_as_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_z_as_smoother_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (.not.coarse_) then + write(iout_,*) ' Additive Schwarz with ',& + & sm%novr, ' overlap layers.' + write(iout_,*) ' Restrictor: ',restrict_names(sm%restr) + write(iout_,*) ' Prolongator: ',prolong_names(sm%prol) + write(iout_,*) ' Local solver:' + endif + if (allocated(sm%sv)) then + call sm%sv%descr(info,iout_,coarse=coarse) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine z_as_smoother_descr + + function z_as_smoother_get_wrksize(sm) result(val) + implicit none + class(amg_z_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_) :: val + + val = 3 + if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() + + end function z_as_smoother_get_wrksize + + function z_as_smoother_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Additive Schwarz" + end function z_as_smoother_get_fmt + + function z_as_smoother_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_as_ + end function z_as_smoother_get_id + +end module amg_z_as_smoother diff --git a/mlprec/amg_z_base_aggregator_mod.f90 b/mlprec/amg_z_base_aggregator_mod.f90 new file mode 100644 index 00000000..bc84abef --- /dev/null +++ b/mlprec/amg_z_base_aggregator_mod.f90 @@ -0,0 +1,519 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! The aggregator object hosts the aggregation method for building +! the multilevel hierarchy. +! +module amg_z_base_aggregator_mod + + use amg_base_prec_type, only : amg_dml_parms, amg_daggr_data + use psb_base_mod, only : psb_zspmat_type, psb_lzspmat_type, psb_z_vect_type, & + & psb_z_base_vect_type, psb_zlinmap_type, psb_dpk_, & + & psb_lz_csr_sparse_mat, psb_lz_coo_sparse_mat, & + & psb_z_csr_sparse_mat, psb_z_coo_sparse_mat, & + & psb_ipk_, psb_epk_, psb_lpk_, psb_desc_type, psb_i_base_vect_type, & + & psb_erractionsave, psb_error_handler, psb_success_, psb_toupper + ! + ! + ! + !> \class amg_z_base_aggregator_type + !! + !! It is the data type containing the basic interface definition for + !! building a multigrid hierarchy by aggregation. The base object has no attributes, + !! it is intended to be essentially an abstract type. + !! + !! + !! type amg_z_base_aggregator_type + !! end type + !! + !! + !! Methods: + !! + !! bld_tprol - Build a tentative prolongator + !! + !! mat_bld - Build prolongator/restrictor and coarse matrix ac + !! + !! mat_asb - Convert prolongator/restrictor/coarse matrix + !! and fix their descriptor(s) + !! + !! update_next - Transfer information to the next level; default is + !! to do nothing, i.e. aggregators at different + !! levels are independent. + !! + !! default - Apply defaults + !! set_aggr_type - For aggregator that have internal options. + !! fmt - Return a short string description + !! descr - Print a more detailed description + !! + !! cseti, csetr, csetc - Set internal parameters, if any + ! + type amg_z_base_aggregator_type + ! Do we want to purge explicit zeros when aggregating? + logical :: do_clean_zeros + contains + procedure, pass(ag) :: bld_tprol => amg_z_base_aggregator_build_tprol + procedure, pass(ag) :: mat_bld => amg_z_base_aggregator_mat_bld + procedure, pass(ag) :: mat_asb => amg_z_base_aggregator_mat_asb + procedure, pass(ag) :: bld_map => amg_z_base_aggregator_bld_map + procedure, pass(ag) :: update_next => amg_z_base_aggregator_update_next + procedure, pass(ag) :: clone => amg_z_base_aggregator_clone + procedure, pass(ag) :: free => amg_z_base_aggregator_free + procedure, pass(ag) :: default => amg_z_base_aggregator_default + procedure, pass(ag) :: descr => amg_z_base_aggregator_descr + procedure, pass(ag) :: sizeof => amg_z_base_aggregator_sizeof + procedure, pass(ag) :: set_aggr_type => amg_z_base_aggregator_set_aggr_type + procedure, nopass :: fmt => amg_z_base_aggregator_fmt + procedure, pass(ag) :: cseti => amg_z_base_aggregator_cseti + procedure, pass(ag) :: csetr => amg_z_base_aggregator_csetr + procedure, pass(ag) :: csetc => amg_z_base_aggregator_csetc + generic, public :: set => cseti, csetr, csetc + procedure, nopass :: xt_desc => amg_z_base_aggregator_xt_desc + end type amg_z_base_aggregator_type + + abstract interface + subroutine amg_z_soc_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, psb_ipk_, psb_lpk_ + implicit none + integer(psb_ipk_), intent(in) :: iorder + logical, intent(in) :: clean_zeros + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + real(psb_dpk_), intent(in) :: theta + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_soc_map_bld + end interface + + interface amg_ptap + subroutine amg_z_ptap(a_csr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_cprol,coo_restr,info,desc_ax) + import :: psb_z_csr_sparse_mat, psb_zspmat_type, psb_desc_type, & + & psb_z_coo_sparse_mat, amg_dml_parms, psb_dpk_, psb_ipk_, psb_lpk_ + implicit none + type(psb_z_csr_sparse_mat), intent(inout) :: a_csr + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + type(amg_dml_parms), intent(inout) :: parms + type(psb_z_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr + type(psb_desc_type), intent(inout) :: desc_cprol + type(psb_zspmat_type), intent(out) :: ac + integer(psb_ipk_), intent(out) :: info + type(psb_desc_type), intent(inout), optional :: desc_ax + end subroutine amg_z_ptap +!!$ subroutine amg_z_lz_ptap(a_csr,desc_a,nlaggr,parms,ac,& +!!$ & coo_prol,desc_cprol,coo_restr,info,desc_ax) +!!$ import :: psb_z_csr_sparse_mat, psb_lzspmat_type, psb_desc_type, & +!!$ & psb_lz_coo_sparse_mat, amg_dml_parms, psb_dpk_, psb_ipk_, psb_lpk_ +!!$ implicit none +!!$ type(psb_z_csr_sparse_mat), intent(inout) :: a_csr +!!$ type(psb_desc_type), intent(in) :: desc_a +!!$ integer(psb_lpk_), intent(inout) :: nlaggr(:) +!!$ type(amg_dml_parms), intent(inout) :: parms +!!$ type(psb_lz_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr +!!$ type(psb_desc_type), intent(inout) :: desc_cprol +!!$ type(psb_lzspmat_type), intent(out) :: ac +!!$ integer(psb_ipk_), intent(out) :: info +!!$ type(psb_desc_type), intent(inout), optional :: desc_ax +!!$ end subroutine amg_z_lz_ptap +!!$ subroutine amg_lz_ptap(a_csr,desc_a,nlaggr,parms,ac,& +!!$ & coo_prol,desc_cprol,coo_restr,info,desc_ax) +!!$ import :: psb_lz_csr_sparse_mat, psb_lzspmat_type, psb_desc_type, & +!!$ & psb_lz_coo_sparse_mat, amg_dml_parms, psb_dpk_, psb_ipk_, psb_lpk_ +!!$ implicit none +!!$ type(psb_lz_csr_sparse_mat), intent(inout) :: a_csr +!!$ type(psb_desc_type), intent(in) :: desc_a +!!$ integer(psb_lpk_), intent(inout) :: nlaggr(:) +!!$ type(amg_dml_parms), intent(inout) :: parms +!!$ type(psb_lz_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr +!!$ type(psb_desc_type), intent(inout) :: desc_cprol +!!$ type(psb_lzspmat_type), intent(out) :: ac +!!$ integer(psb_ipk_), intent(out) :: info +!!$ type(psb_desc_type), intent(inout), optional :: desc_ax +!!$ end subroutine amg_lz_ptap + end interface amg_ptap + +contains + + subroutine amg_z_base_aggregator_cseti(ag,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_z_base_aggregator_type), intent(inout) :: ag + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + ! Do nothing + info = 0 + end subroutine amg_z_base_aggregator_cseti + + subroutine amg_z_base_aggregator_csetr(ag,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_z_base_aggregator_type), intent(inout) :: ag + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + ! Do nothing + info = 0 + end subroutine amg_z_base_aggregator_csetr + + subroutine amg_z_base_aggregator_csetc(ag,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_z_base_aggregator_type), intent(inout) :: ag + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + ! Set clean zeros, or do nothing. + select case (psb_toupper(trim(what))) + case('AGGR_CLEAN_ZEROS') + select case (psb_toupper(trim(val))) + case('TRUE','T') + ag%do_clean_zeros = .true. + case('FALSE','F') + ag%do_clean_zeros = .false. + end select + end select + info = 0 + end subroutine amg_z_base_aggregator_csetc + + + subroutine amg_z_base_aggregator_update_next(ag,agnext,info) + implicit none + class(amg_z_base_aggregator_type), target, intent(inout) :: ag, agnext + integer(psb_ipk_), intent(out) :: info + + ! + ! Base version does nothing. + ! + info = 0 + end subroutine amg_z_base_aggregator_update_next + + subroutine amg_z_base_aggregator_clone(ag,agnext,info) + implicit none + class(amg_z_base_aggregator_type), intent(inout) :: ag + class(amg_z_base_aggregator_type), allocatable, intent(inout) :: agnext + integer(psb_ipk_), intent(out) :: info + + info = 0 + if (allocated(agnext)) then + call agnext%free(info) + if (info == 0) deallocate(agnext,stat=info) + end if + if (info /= 0) return + allocate(agnext,source=ag,stat=info) + + end subroutine amg_z_base_aggregator_clone + + subroutine amg_z_base_aggregator_free(ag,info) + implicit none + class(amg_z_base_aggregator_type), intent(inout) :: ag + integer(psb_ipk_), intent(out) :: info + + info = psb_success_ + return + end subroutine amg_z_base_aggregator_free + + subroutine amg_z_base_aggregator_default(ag) + implicit none + class(amg_z_base_aggregator_type), intent(inout) :: ag + ! Only one default setting + ag%do_clean_zeros = .true. + + return + end subroutine amg_z_base_aggregator_default + + function amg_z_base_aggregator_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Default aggregator " + end function amg_z_base_aggregator_fmt + + function amg_z_base_aggregator_sizeof(ag) result(val) + implicit none + class(amg_z_base_aggregator_type), intent(in) :: ag + integer(psb_epk_) :: val + + val = 1 + end function amg_z_base_aggregator_sizeof + + function amg_z_base_aggregator_xt_desc() result(val) + implicit none + logical :: val + + val = .false. + end function amg_z_base_aggregator_xt_desc + + subroutine amg_z_base_aggregator_descr(ag,parms,iout,info) + implicit none + class(amg_z_base_aggregator_type), intent(in) :: ag + type(amg_dml_parms), intent(in) :: parms + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + + write(iout,*) 'Aggregator object type: ',ag%fmt() + call parms%mldescr(iout,info) + + return + end subroutine amg_z_base_aggregator_descr + + subroutine amg_z_base_aggregator_set_aggr_type(ag,parms,info) + implicit none + class(amg_z_base_aggregator_type), intent(inout) :: ag + type(amg_dml_parms), intent(in) :: parms + integer(psb_ipk_), intent(out) :: info + + ! Do nothing + + return + end subroutine amg_z_base_aggregator_set_aggr_type + + ! + !> Function bld_tprol: + !! \memberof amg_z_base_aggregator_type + !! \brief Build a tentative prolongator. + !! The routine will map the local matrix entries to aggregates. + !! The mapping is store in ILAGGR; for each local row index I, + !! ILAGGR(I) contains the index of the aggregate to which index I + !! will contribute, in global numbering. + !! Many aggregations produce a binary tentative prolongator, but some + !! do not, hence we also need the OP_PROL output. + !! AG_DATA is passed here just in case some of the + !! aggregators need it internally, most of them will ignore. + !! + !! \param ag The input aggregator object + !! \param parms The auxiliary parameters object + !! \param ag_data Auxiliary global aggregation info + !! \param a The local matrix part + !! \param desc_a The descriptor + !! \param ilaggr Output aggregation map + !! \param nlaggr Sizes of ilaggr on all processes + !! \param op_prol The tentative prolongator operator + !! \param info Return code + !! + ! + subroutine amg_z_base_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,t_prol,info) + use psb_base_mod + implicit none + class(amg_z_base_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(amg_daggr_data), intent(in) :: ag_data + type(psb_zspmat_type), intent(inout) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lzspmat_type), intent(out) :: t_prol + integer(psb_ipk_), intent(out) :: info + + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_aggregator_build_tprol' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + + end subroutine amg_z_base_aggregator_build_tprol + + ! + !> Function mat_bld + !! \memberof amg_z_base_aggregator_type + !! \brief Build prolongator/restrictor/coarse matrix. + !! + !! + !! \param ag The input aggregator object + !! \param parms The auxiliary parameters object + !! \param a The local matrix part + !! \param desc_a The descriptor + !! \param ilaggr Aggregation map + !! \param nlaggr Sizes of ilaggr on all processes + !! \param ac On output the coarse matrix + !! \param op_prol On input, the tentative prolongator operator, on output + !! the final prolongator + !! \param op_restr On output, the restrictor operator; + !! in many cases it is the transpose of the prolongator. + !! \param info Return code + !! + subroutine amg_z_base_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + use psb_base_mod + implicit none + class(amg_z_base_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(psb_lzspmat_type), intent(inout) :: t_prol + type(psb_zspmat_type), intent(out) :: op_prol, ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_aggregator_mat_bld' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + end subroutine amg_z_base_aggregator_mat_bld + + ! + !> Function mat_asb + !! \memberof amg_z_base_aggregator_type + !! \brief Build prolongator/restrictor/coarse matrix. + !! + !! + !! \param ag The input aggregator object + !! \param parms The auxiliary parameters object + !! \param a The local matrix part + !! \param desc_a The descriptor + !! \param ilaggr Aggregation map + !! \param nlaggr Sizes of ilaggr on all processes + !! \param ac On output the coarse matrix + !! \param op_prol On input, the tentative prolongator operator, on output + !! the final prolongator + !! \param op_restr On output, the restrictor operator; + !! in many cases it is the transpose of the prolongator. + !! \param info Return code + !! + subroutine amg_z_base_aggregator_mat_asb(ag,parms,a,desc_a,& + & ac,desc_ac, op_prol,op_restr,info) + use psb_base_mod + implicit none + class(amg_z_base_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + type(psb_zspmat_type), intent(inout) :: op_prol,ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_aggregator_mat_asb' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + end subroutine amg_z_base_aggregator_mat_asb + + ! + !> Function bld_map + !! \memberof amg_z_base_aggregator_type + !! \brief Build linear map between hierarchy levels + !! + !! + !! \param ag The input aggregator object + !! \param desc_a The fine space descriptor + !! \param desc_ac The coarse space descriptor + !! \param ilaggr Aggregation map vector + !! \param nlaggr Sizes of ilaggr on all processes + !! \param op_prol The prolongator operator + !! \param op_restr The restrictor operator + !! \param map The output map + !! \param info Return code + !! + subroutine amg_z_base_aggregator_bld_map(ag,desc_a,desc_ac,ilaggr,nlaggr,& + & op_restr,op_prol,map,info) + use psb_base_mod + implicit none + class(amg_z_base_aggregator_type), target, intent(inout) :: ag + type(psb_desc_type), intent(in), target :: desc_a, desc_ac + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(psb_zspmat_type), intent(inout) :: op_restr, op_prol + type(psb_zlinmap_type), intent(out) :: map + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_aggregator_bld_map' + + call psb_erractionsave(err_act) + ! + ! Copy the prolongation/restriction matrices into the descriptor map. + ! op_restr => PR^T i.e. restriction operator + ! op_prol => PR i.e. prolongation operator + ! + ! WARNING: need to check whether the copy into IOP_RESTR/IOP_PROL + ! is safe or not. + ! + ! This default implementation reuses desc_a/desc_ac through + ! pointers in the map structure. + ! + map = psb_linmap(psb_map_aggr_,desc_a,& + & desc_ac,op_restr,op_prol,ilaggr,nlaggr) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + end subroutine amg_z_base_aggregator_bld_map + + +end module amg_z_base_aggregator_mod diff --git a/mlprec/amg_z_base_smoother_mod.f90 b/mlprec/amg_z_base_smoother_mod.f90 new file mode 100644 index 00000000..d306b2eb --- /dev/null +++ b/mlprec/amg_z_base_smoother_mod.f90 @@ -0,0 +1,412 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_z_base_smoother_mod.f90 +! +! Module: amg_z_base_smoother_mod +! +! This module defines: +! - the amg_z_base_smoother_type data structure containing the +! smoother and related data structures; +! +! It contains routines for +! - Building and applying; +! - checking if the smoother is correctly defined; +! - printing a description of the preconditioner; +! - deallocating the preconditioner data structure. +! +! What is the difference between a smoother and a solver? +! In the mathematics literature the two concepts are treated +! essentially as synonymous, but here we are using them in a more +! computer-science oriented fashion. In particular, a SMOOTHER object +! contains a SOLVER object: the SOLVER operates locally within the +! current process, whereas the SMOOTHER object accounts for (possible) +! interactions between processes. +! Some solvers (MUMPS and SuperLU_DIST) can also operate on the entire +! distributed matrix, in which case the smoother object essentially +! becomes transparent. +! +module amg_z_base_smoother_mod + + use amg_z_base_solver_mod + use psb_base_mod, only : psb_desc_type, psb_zspmat_type, psb_epk_,& + & psb_z_vect_type, psb_z_base_vect_type, psb_z_base_sparse_mat, & + & psb_dpk_, psb_i_base_vect_type, psb_erractionsave, psb_error_handler + + ! + ! + ! + ! Type: amg_T_base_smoother_type. + ! + ! It holds the smoother a single level. Its only mandatory component is a solver + ! object which holds a local solver; this decoupling allows to have the same solver + ! e.g ILU to work with Jacobi with multiple sweeps as well as with any AS variant. + ! + ! type amg_T_base_smoother_type + ! class(amg_T_base_solver_type), allocatable :: sv + ! end type amg_T_base_smoother_type + ! + ! Methods: + ! + ! build - Compute the actual contents of the smoother; includes + ! invocation of the build method on the solver component. + ! free - Release memory + ! apply - Apply the smoother to a vector (or to an array); includes + ! invocation of the apply method on the solver component. + ! descr - Prints a description of the object. + ! default - Set default values + ! dump - Dump to file object contents + ! set - Sets various parameters; when a request is unknown + ! it is passed to the solver object for further processing. + ! check - Sanity checks. + ! sizeof - Total memory occupation in bytes + ! get_nzeros - Number of nonzeros + ! stringval - convert string to val for internal parms + ! get_fmt - short string descriptor + ! get_id - numeric id descriptro + ! get_wrksz - How many workspace vector does apply_vect need + ! + ! + ! + + type amg_z_base_smoother_type + class(amg_z_base_solver_type), allocatable :: sv + contains + procedure, pass(sm) :: apply_v => amg_z_base_smoother_apply_vect + procedure, pass(sm) :: apply_a => amg_z_base_smoother_apply + generic, public :: apply => apply_a, apply_v + procedure, pass(sm) :: check => amg_z_base_smoother_check + procedure, pass(sm) :: dump => amg_z_base_smoother_dmp + procedure, pass(sm) :: clone => amg_z_base_smoother_clone + procedure, pass(sm) :: build => amg_z_base_smoother_bld + procedure, pass(sm) :: cnv => amg_z_base_smoother_cnv + procedure, pass(sm) :: free => amg_z_base_smoother_free + procedure, pass(sm) :: clone_settings => amg_z_base_smoother_clone_settings + procedure, pass(sm) :: clear_data => amg_z_base_smoother_clear_data + procedure, pass(sm) :: cseti => amg_z_base_smoother_cseti + procedure, pass(sm) :: csetc => amg_z_base_smoother_csetc + procedure, pass(sm) :: csetr => amg_z_base_smoother_csetr + generic, public :: set => cseti, csetc, csetr + procedure, pass(sm) :: default => z_base_smoother_default + procedure, pass(sm) :: descr => amg_z_base_smoother_descr + procedure, pass(sm) :: sizeof => z_base_smoother_sizeof + procedure, pass(sm) :: get_nzeros => z_base_smoother_get_nzeros + procedure, pass(sm) :: get_wrksz => z_base_smoother_get_wrksize + procedure, nopass :: stringval => amg_stringval + procedure, nopass :: get_fmt => z_base_smoother_get_fmt + procedure, nopass :: get_id => z_base_smoother_get_id + end type amg_z_base_smoother_type + + + private :: z_base_smoother_sizeof, z_base_smoother_get_fmt, & + & z_base_smoother_default, z_base_smoother_get_nzeros, & + & z_base_smoother_get_id, z_base_smoother_get_wrksize + + + + interface + subroutine amg_z_base_smoother_apply(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,info,init,initu) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_base_smoother_type), intent(inout) :: sm + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_z_base_smoother_apply + end interface + + interface + subroutine amg_z_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,wv,info,init,initu) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_base_smoother_type), intent(inout) :: sm + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + end subroutine amg_z_base_smoother_apply_vect + end interface + + interface + subroutine amg_z_base_smoother_check(sm,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_base_smoother_check + end interface + + interface + subroutine amg_z_base_smoother_cseti(sm,what,val,info,idx) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_z_base_smoother_cseti + end interface + + interface + subroutine amg_z_base_smoother_csetc(sm,what,val,info,idx) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_ + class(amg_z_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_z_base_smoother_csetc + end interface + + interface + subroutine amg_z_base_smoother_csetr(sm,what,val,info,idx) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_z_base_smoother_csetr + end interface + + interface + subroutine amg_z_base_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_, psb_i_base_vect_type + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_base_smoother_bld + end interface + + interface + subroutine amg_z_base_smoother_cnv(sm,info,amold,vmold,imold) + import :: psb_z_base_sparse_mat, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_, psb_i_base_vect_type + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_base_smoother_cnv + end interface + + interface + subroutine amg_z_base_smoother_free(sm,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_base_smoother_free + end interface + + interface + subroutine amg_z_base_smoother_descr(sm,info,iout,coarse) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_ + ! Arguments + class(amg_z_base_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + end subroutine amg_z_base_smoother_descr + end interface + + interface + subroutine amg_z_base_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_ + class(amg_z_base_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + end subroutine amg_z_base_smoother_dmp + end interface + + interface + subroutine amg_z_base_smoother_clone(sm,smout,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + class(amg_z_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_base_smoother_clone + end interface + + interface + subroutine amg_z_base_smoother_clone_settings(sm,smout,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + class(amg_z_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_base_smoother_clone_settings + end interface + + interface + subroutine amg_z_base_smoother_clear_data(sm,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_base_smoother_clear_data + end interface + +contains + ! + ! Function returning the size of the amg_prec_type data structure + ! in bytes or in number of nonzeros of the operator(s) involved. + ! + + function z_base_smoother_get_nzeros(sm) result(val) + implicit none + class(amg_z_base_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + if (allocated(sm%sv)) & + & val = sm%sv%get_nzeros() + end function z_base_smoother_get_nzeros + + function z_base_smoother_sizeof(sm) result(val) + implicit none + ! Arguments + class(amg_z_base_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + if (allocated(sm%sv)) then + val = sm%sv%sizeof() + end if + + return + end function z_base_smoother_sizeof + + ! + ! Set sensible defaults. + ! To be called immediately after allocation + ! + subroutine z_base_smoother_default(sm) + implicit none + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + ! Do nothing for base version + + if (allocated(sm%sv)) call sm%sv%default() + + return + end subroutine z_base_smoother_default + + function z_base_smoother_get_wrksize(sm) result(val) + implicit none + class(amg_z_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_) :: val + + val = 0 + if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() + + end function z_base_smoother_get_wrksize + + function z_base_smoother_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Base smoother" + end function z_base_smoother_get_fmt + + function z_base_smoother_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_base_smooth_ + end function z_base_smoother_get_id + +end module amg_z_base_smoother_mod diff --git a/mlprec/amg_z_base_solver_mod.f90 b/mlprec/amg_z_base_solver_mod.f90 new file mode 100644 index 00000000..54b6e519 --- /dev/null +++ b/mlprec/amg_z_base_solver_mod.f90 @@ -0,0 +1,421 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_z_base_solver_mod.f90 +! +! Module: amg_z_base_solver_mod +! +! This module defines: +! - the amg_z_base_solver_type data structure containing the +! basic solver type acting on a subdomain +! +! It contains routines for +! - Building and applying; +! - checking if the solver is correctly defined; +! - printing a description of the solver; +! - deallocating the data structure. +! + +module amg_z_base_solver_mod + + use amg_base_prec_type + use psb_base_mod, only : psb_zspmat_type, & + & psb_z_vect_type, psb_z_base_vect_type, psb_z_base_sparse_mat, & + & psb_dpk_, psb_i_base_vect_type, psb_erractionsave, psb_error_handler + ! + ! + ! Type: amg_T_base_solver_type. + ! + ! It holds the local solver; it has no mandatory components. + ! + ! type amg_T_base_solver_type + ! end type amg_T_base_solver_type + ! + ! build - Compute the actual contents of the smoother; includes + ! invocation of the build method on the solver component. + ! free - Release memory + ! apply - Apply the smoother to a vector (or to an array); includes + ! invocation of the apply method on the solver component. + ! descr - Prints a description of the object. + ! default - Set default values + ! dump - Dump to file object contents + ! set - Sets various parameters; when a request is unknown + ! it is passed to the smoother object for further processing. + ! check - Sanity checks. + ! sizeof - Total memory occupation in bytes + ! get_nzeros - Number of nonzeros + ! stringval - convert string to val for internal parms + ! get_fmt - short string descriptor + ! get_id - numeric id descriptro + ! get_wrksz - How many workspace vector does apply_vect need + ! + ! + + type amg_z_base_solver_type + contains + procedure, pass(sv) :: apply_v => amg_z_base_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_z_base_solver_apply + generic, public :: apply => apply_a, apply_v + procedure, pass(sv) :: check => amg_z_base_solver_check + procedure, pass(sv) :: dump => amg_z_base_solver_dmp + procedure, pass(sv) :: clone => amg_z_base_solver_clone + procedure, pass(sv) :: clone_settings => amg_z_base_solver_clone_settings + procedure, pass(sv) :: clear_data => amg_z_base_solver_clear_data + procedure, pass(sv) :: build => amg_z_base_solver_bld + procedure, pass(sv) :: cnv => amg_z_base_solver_cnv + procedure, pass(sv) :: free => amg_z_base_solver_free + procedure, pass(sv) :: cseti => amg_z_base_solver_cseti + procedure, pass(sv) :: csetc => amg_z_base_solver_csetc + procedure, pass(sv) :: csetr => amg_z_base_solver_csetr + generic, public :: set => cseti, csetc, csetr + procedure, pass(sv) :: default => z_base_solver_default + procedure, pass(sv) :: descr => amg_z_base_solver_descr + procedure, pass(sv) :: sizeof => z_base_solver_sizeof + procedure, pass(sv) :: get_nzeros => z_base_solver_get_nzeros + procedure, nopass :: get_wrksz => z_base_solver_get_wrksize + procedure, nopass :: stringval => amg_stringval + procedure, nopass :: get_fmt => z_base_solver_get_fmt + procedure, nopass :: get_id => z_base_solver_get_id + procedure, nopass :: is_iterative => z_base_solver_is_iterative + procedure, pass(sv) :: is_global => z_base_solver_is_global + end type amg_z_base_solver_type + + private :: z_base_solver_sizeof, z_base_solver_default,& + & z_base_solver_get_nzeros, z_base_solver_get_fmt, & + & z_base_solver_is_iterative, z_base_solver_get_id, & + & z_base_solver_get_wrksize, z_base_solver_is_global + + + interface + subroutine amg_z_base_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_base_solver_type), intent(inout) :: sv + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_z_base_solver_apply + end interface + + + interface + subroutine amg_z_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_base_solver_type), intent(inout) :: sv + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + end subroutine amg_z_base_solver_apply_vect + end interface + + interface + subroutine amg_z_base_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, psb_ipk_, psb_i_base_vect_type + Implicit None + + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_base_solver_bld + end interface + + interface + subroutine amg_z_base_solver_cnv(sv,info,amold,vmold,imold) + import :: psb_z_base_sparse_mat, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, psb_ipk_, psb_i_base_vect_type + Implicit None + + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_base_solver_cnv + end interface + + interface + subroutine amg_z_base_solver_check(sv,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_base_solver_check + end interface + + interface + subroutine amg_z_base_solver_cseti(sv,what,val,info,idx) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_z_base_solver_cseti + end interface + + interface + subroutine amg_z_base_solver_csetc(sv,what,val,info,idx) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_z_base_solver_csetc + end interface + + interface + subroutine amg_z_base_solver_csetr(sv,what,val,info,idx) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, psb_ipk_ + Implicit None + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_z_base_solver_csetr + end interface + + interface + subroutine amg_z_base_solver_free(sv,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_base_solver_free + end interface + + interface + subroutine amg_z_base_solver_descr(sv,info,iout,coarse) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_base_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + end subroutine amg_z_base_solver_descr + end interface + + interface + subroutine amg_z_base_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, psb_ipk_ + implicit none + class(amg_z_base_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_z_base_solver_dmp + end interface + + interface + subroutine amg_z_base_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_base_solver_clone + end interface + + interface + subroutine amg_z_base_solver_clone_settings(sv,svout,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_base_solver_clone_settings + end interface + + interface + subroutine amg_z_base_solver_clear_data(sv,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_base_solver_clear_data + end interface + +contains + ! + ! Function returning the size of the data structure + ! in bytes or in number of nonzeros of the operator(s) involved. + ! + + function z_base_solver_sizeof(sv) result(val) + implicit none + ! Arguments + class(amg_z_base_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + + return + end function z_base_solver_sizeof + + function z_base_solver_get_nzeros(sv) result(val) + implicit none + class(amg_z_base_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + end function z_base_solver_get_nzeros + + subroutine z_base_solver_default(sv) + implicit none + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + ! Do nothing for base version + + return + end subroutine z_base_solver_default + + function z_base_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Base solver" + end function z_base_solver_get_fmt + + ! + ! If this is true, then the solver needs a starting + ! guess. Currently only handled in JAC smoother. + ! + function z_base_solver_is_iterative() result(val) + implicit none + logical :: val + + val = .false. + end function z_base_solver_is_iterative + ! + ! Is the solver acting globally? In most cases + ! not, SuperLU_Dist does, MUMPS can do either. + ! + function z_base_solver_is_global(sv) result(val) + implicit none + class(amg_z_base_solver_type), intent(in) :: sv + logical :: val + + val = .false. + end function z_base_solver_is_global + + function z_base_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_f_none_ + end function z_base_solver_get_id + + function z_base_solver_get_wrksize() result(val) + implicit none + integer(psb_ipk_) :: val + + val = 0 + end function z_base_solver_get_wrksize + +end module amg_z_base_solver_mod diff --git a/mlprec/amg_z_dec_aggregator_mod.f90 b/mlprec/amg_z_dec_aggregator_mod.f90 new file mode 100644 index 00000000..f2912e17 --- /dev/null +++ b/mlprec/amg_z_dec_aggregator_mod.f90 @@ -0,0 +1,201 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! Basic (decoupled) aggregation algorithm. Based on the ideas in +! M. Brezina and P. Vanek, A black-box iterative solver based on a +! two-level Schwarz method, Computing, 63 (1999), 233-263. +! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed +! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 +! (1996), 179-196. +! +module amg_z_dec_aggregator_mod + + use amg_z_base_aggregator_mod + !> \namespace amg_z_dec_aggregator_mod \class amg_z_dec_aggregator_type + !! \extends amg_z_base_aggregator_mod::amg_z_base_aggregator_type + !! + !! type, extends(amg_z_base_aggregator_type) :: amg_z_dec_aggregator_type + !! procedure(amg_z_soc_map_bld), nopass, pointer :: soc_map_bld => null() + !! end type + !! + !! This is the simplest aggregation method: starting from the + !! strength-of-connection measure for defining the aggregation + !! presented in + !! + !! M. Brezina and P. Vanek, A black-box iterative solver based on a + !! two-level Schwarz method, Computing, 63 (1999), 233-263. + !! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed + !! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 + !! (1996), 179-196. + !! + !! it achieves parallelization by simply acting on the local matrix, + !! i.e. by "decoupling" the subdomains. + !! The data structure hosts a "map_bld" function pointer which allows to + !! choose other ways to measure "strength-of-connection", of which the + !! Vanek-Brezina-Mandel is the default. More details are available in + !! + !! P. D'Ambra, D. di Serafino and S. Filippone, On the development of + !! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math. + !! 57 (2007), 1181-1196. + !! + !! The soc_map_bld method is used inside the implementation of build_tprol + !! + ! + ! + type, extends(amg_z_base_aggregator_type) :: amg_z_dec_aggregator_type + procedure(amg_z_soc_map_bld), nopass, pointer :: soc_map_bld => null() + + contains + procedure, pass(ag) :: bld_tprol => amg_z_dec_aggregator_build_tprol + procedure, pass(ag) :: mat_bld => amg_z_dec_aggregator_mat_bld + procedure, pass(ag) :: mat_asb => amg_z_dec_aggregator_mat_asb + procedure, pass(ag) :: default => amg_z_dec_aggregator_default + procedure, pass(ag) :: set_aggr_type => amg_z_dec_aggregator_set_aggr_type + procedure, pass(ag) :: descr => amg_z_dec_aggregator_descr + procedure, nopass :: fmt => amg_z_dec_aggregator_fmt + end type amg_z_dec_aggregator_type + + + procedure(amg_z_soc_map_bld) :: amg_z_soc1_map_bld, amg_z_soc2_map_bld + + interface + subroutine amg_z_dec_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,t_prol,info) + import :: amg_z_dec_aggregator_type, psb_desc_type, psb_zspmat_type, psb_dpk_, & + & psb_ipk_, psb_lpk_, psb_lzspmat_type, amg_dml_parms, amg_daggr_data + implicit none + class(amg_z_dec_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(amg_daggr_data), intent(in) :: ag_data + type(psb_zspmat_type), intent(inout) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lzspmat_type), intent(out) :: t_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_dec_aggregator_build_tprol + end interface + + interface + subroutine amg_z_dec_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + import :: amg_z_dec_aggregator_type, psb_desc_type, psb_zspmat_type, psb_dpk_, & + & psb_ipk_, psb_lpk_, psb_lzspmat_type, amg_dml_parms + implicit none + class(amg_z_dec_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(psb_lzspmat_type), intent(inout) :: t_prol + type(psb_zspmat_type), intent(out) :: op_prol, ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_dec_aggregator_mat_bld + end interface + + interface + subroutine amg_z_dec_aggregator_mat_asb(ag,parms,a,desc_a,& + & ac,desc_ac,op_prol,op_restr,info) + import :: amg_z_dec_aggregator_type, psb_desc_type, psb_zspmat_type, psb_dpk_, & + & psb_ipk_, psb_lpk_, psb_lzspmat_type, amg_dml_parms + implicit none + class(amg_z_dec_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + type(psb_zspmat_type), intent(inout) :: op_prol,ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_dec_aggregator_mat_asb + end interface + +contains + + subroutine amg_z_dec_aggregator_set_aggr_type(ag,parms,info) + use amg_base_prec_type + implicit none + class(amg_z_dec_aggregator_type), intent(inout) :: ag + type(amg_dml_parms), intent(in) :: parms + integer(psb_ipk_), intent(out) :: info + + select case(parms%aggr_type) + case (amg_noalg_) + ag%soc_map_bld => null() + case (amg_soc1_) + ag%soc_map_bld => amg_z_soc1_map_bld + case (amg_soc2_) + ag%soc_map_bld => amg_z_soc2_map_bld + case default + write(0,*) 'Unknown aggregation type, defaulting to SOC1' + ag%soc_map_bld => amg_z_soc1_map_bld + end select + + return + end subroutine amg_z_dec_aggregator_set_aggr_type + + + subroutine amg_z_dec_aggregator_default(ag) + implicit none + class(amg_z_dec_aggregator_type), intent(inout) :: ag + + call ag%amg_z_base_aggregator_type%default() + ag%soc_map_bld => amg_z_soc1_map_bld + + return + end subroutine amg_z_dec_aggregator_default + + function amg_z_dec_aggregator_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Decoupled aggregation" + end function amg_z_dec_aggregator_fmt + + subroutine amg_z_dec_aggregator_descr(ag,parms,iout,info) + implicit none + class(amg_z_dec_aggregator_type), intent(in) :: ag + type(amg_dml_parms), intent(in) :: parms + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + + write(iout,*) 'Decoupled Aggregator' + write(iout,*) 'Aggregator object type: ',ag%fmt() + call parms%mldescr(iout,info) + + return + end subroutine amg_z_dec_aggregator_descr + +end module amg_z_dec_aggregator_mod diff --git a/mlprec/amg_z_diag_solver.f90 b/mlprec/amg_z_diag_solver.f90 new file mode 100644 index 00000000..5e00805c --- /dev/null +++ b/mlprec/amg_z_diag_solver.f90 @@ -0,0 +1,398 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_z_diag_solver_mod.f90 +! +! Module: amg_z_diag_solver_mod +! +! This module defines: +! - the amg_z_diag_solver_type data structure containing the +! simple diagonal solver. This extracts the main diagonal of a matrix +! and precomputes its inverse. Combined with a Jacobi "smoother" generates +! what are commonly known as the classic Jacobi iterations +! +module amg_z_diag_solver + + use amg_z_base_solver_mod + + type, extends(amg_z_base_solver_type) :: amg_z_diag_solver_type + type(psb_z_vect_type), allocatable :: dv + complex(psb_dpk_), allocatable :: d(:) + contains + procedure, pass(sv) :: dump => amg_z_diag_solver_dmp + procedure, pass(sv) :: build => amg_z_diag_solver_bld + procedure, pass(sv) :: cnv => amg_z_diag_solver_cnv + procedure, pass(sv) :: clone => amg_z_diag_solver_clone + procedure, pass(sv) :: clear_data => amg_z_diag_solver_clear_data + procedure, pass(sv) :: apply_v => amg_z_diag_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_z_diag_solver_apply + procedure, pass(sv) :: free => z_diag_solver_free + procedure, pass(sv) :: descr => z_diag_solver_descr + procedure, pass(sv) :: sizeof => z_diag_solver_sizeof + procedure, pass(sv) :: get_nzeros => z_diag_solver_get_nzeros + procedure, nopass :: get_fmt => z_diag_solver_get_fmt + procedure, nopass :: get_id => z_diag_solver_get_id + end type amg_z_diag_solver_type + + + private :: z_diag_solver_free, z_diag_solver_descr, & + & z_diag_solver_sizeof, z_diag_solver_get_nzeros, & + & z_diag_solver_get_fmt, z_diag_solver_get_id + + + interface + subroutine amg_z_diag_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_diag_solver_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_diag_solver_type), intent(inout) :: sv + type(psb_z_vect_type), intent(inout) :: x + type(psb_z_vect_type), intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + end subroutine amg_z_diag_solver_apply_vect + end interface + + interface + subroutine amg_z_diag_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_diag_solver_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_diag_solver_type), intent(inout) :: sv + complex(psb_dpk_), intent(inout) :: x(:) + complex(psb_dpk_), intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_z_diag_solver_apply + end interface + + interface + subroutine amg_z_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_diag_solver_type, psb_ipk_, psb_i_base_vect_type + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_diag_solver_bld + end interface + + interface + subroutine amg_z_diag_solver_cnv(sv,info,amold,vmold,imold) + import :: psb_z_base_sparse_mat, psb_z_base_vect_type, psb_dpk_, & + & amg_z_diag_solver_type, psb_ipk_, psb_i_base_vect_type + class(amg_z_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_diag_solver_cnv + end interface + + interface + subroutine amg_z_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, amg_z_diag_solver_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, & + & psb_ipk_ + implicit none + class(amg_z_diag_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_z_diag_solver_dmp + end interface + + interface + subroutine amg_z_diag_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, amg_z_diag_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_diag_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_diag_solver_clone + end interface + + interface + subroutine amg_z_diag_solver_clear_data(sv,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_diag_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_diag_solver_clear_data + end interface + + +contains + + subroutine z_diag_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_z_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_diag_solver_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sv%dv)) call sv%dv%free(info) + + if (allocated(sv%d)) then + deallocate(sv%d,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine z_diag_solver_free + + subroutine z_diag_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_z_diag_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_z_diag_solver_descr' + integer(psb_ipk_) :: iout_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' Diagonal local solver ' + + return + + end subroutine z_diag_solver_descr + + function z_diag_solver_sizeof(sv) result(val) + implicit none + ! Arguments + class(amg_z_diag_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + if (allocated(sv%dv)) val = val + sv%dv%sizeof() + + return + end function z_diag_solver_sizeof + + function z_diag_solver_get_nzeros(sv) result(val) + implicit none + ! Arguments + class(amg_z_diag_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + if (allocated(sv%dv)) val = val + sv%dv%get_nrows() + + return + end function z_diag_solver_get_nzeros + + function z_diag_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Diag solver" + end function z_diag_solver_get_fmt + + function z_diag_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_diag_scale_ + end function z_diag_solver_get_id + +end module amg_z_diag_solver + +! +! Module: amg_z_l1_diag_solver_mod +! +! This module defines: +! - the amg_z_l1_diag_solver_type data structure containing the +! L1 diagonal solver. +! The solver is defined as a diagonal containing in each element the +! inverse of the sum of the absolute values of the matrix entries +! along the corresponding row. +! Combined with a Jacobi "smoother" generates +! what are commonly known as the L1-Jacobi iterations +! + +module amg_z_l1_diag_solver + + use amg_z_diag_solver + + type, extends(amg_z_diag_solver_type) :: amg_z_l1_diag_solver_type + contains + procedure, pass(sv) :: dump => amg_z_l1_diag_solver_dmp + procedure, pass(sv) :: build => amg_z_l1_diag_solver_bld + procedure, pass(sv) :: descr => z_l1_diag_solver_descr + procedure, nopass :: get_fmt => z_l1_diag_solver_get_fmt + procedure, nopass :: get_id => z_l1_diag_solver_get_id + end type amg_z_l1_diag_solver_type + + + private :: z_l1_diag_solver_descr, & + & z_l1_diag_solver_get_fmt, z_l1_diag_solver_get_id + + interface + subroutine amg_z_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_l1_diag_solver_type, psb_ipk_, psb_i_base_vect_type + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_l1_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_l1_diag_solver_bld + end interface + + interface + subroutine amg_z_l1_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, amg_z_l1_diag_solver_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, & + & psb_ipk_ + implicit none + class(amg_z_l1_diag_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_z_l1_diag_solver_dmp + end interface + +contains + + subroutine z_l1_diag_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_z_l1_diag_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_z_l1_diag_solver_descr' + integer(psb_ipk_) :: iout_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' L1 Diagonal solver ' + + return + + end subroutine z_l1_diag_solver_descr + + function z_l1_diag_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "L1 Diag solver" + end function z_l1_diag_solver_get_fmt + + function z_l1_diag_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_l1_diag_scale_ + end function z_l1_diag_solver_get_id + +end module amg_z_l1_diag_solver + diff --git a/mlprec/amg_z_gs_solver.f90 b/mlprec/amg_z_gs_solver.f90 new file mode 100644 index 00000000..d812b9bb --- /dev/null +++ b/mlprec/amg_z_gs_solver.f90 @@ -0,0 +1,588 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! File: amg_z_gs_solver_mod.f90 +! +! Module: amg_z_gs_solver_mod +! +! This module defines: +! - the amg_z_gs_solver_type data structure containing the ingredients +! for a local Gauss-Seidel iteration. We provide Forward GS (FWGS) and +! backward GS (BWGS). The iterations are local to a process (they operate +! on the block diagonal). Combined with a Jacobi smoother will generate a +! hybrid-Gauss-Seidel solver, i.e. Gauss-Seidel within each process, Jacobi +! among the processes. +! With two objects as pre- and post-smoothers it is possible to build a +! Forward-Backward smoother, suitable for symmetric iterations. +! +module amg_z_gs_solver + + use amg_z_base_solver_mod + + type, extends(amg_z_base_solver_type) :: amg_z_gs_solver_type + type(psb_zspmat_type) :: l, u + integer(psb_ipk_) :: sweeps + real(psb_dpk_) :: eps + contains + procedure, pass(sv) :: dump => amg_z_gs_solver_dmp + procedure, pass(sv) :: check => z_gs_solver_check + procedure, pass(sv) :: clone => amg_z_gs_solver_clone + procedure, pass(sv) :: clone_settings => amg_z_gs_solver_clone_settings + procedure, pass(sv) :: clear_data => amg_z_gs_solver_clear_data + procedure, pass(sv) :: build => amg_z_gs_solver_bld + procedure, pass(sv) :: cnv => amg_z_gs_solver_cnv + procedure, pass(sv) :: apply_v => amg_z_gs_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_z_gs_solver_apply + procedure, pass(sv) :: free => z_gs_solver_free + procedure, pass(sv) :: cseti => z_gs_solver_cseti + procedure, pass(sv) :: csetc => z_gs_solver_csetc + procedure, pass(sv) :: csetr => z_gs_solver_csetr + procedure, pass(sv) :: descr => z_gs_solver_descr + procedure, pass(sv) :: default => z_gs_solver_default + procedure, pass(sv) :: sizeof => z_gs_solver_sizeof + procedure, pass(sv) :: get_nzeros => z_gs_solver_get_nzeros + procedure, nopass :: get_wrksz => z_gs_solver_get_wrksize + procedure, nopass :: get_fmt => z_gs_solver_get_fmt + procedure, nopass :: get_id => z_gs_solver_get_id + procedure, nopass :: is_iterative => z_gs_solver_is_iterative + end type amg_z_gs_solver_type + + type, extends(amg_z_gs_solver_type) :: amg_z_bwgs_solver_type + contains + procedure, pass(sv) :: build => amg_z_bwgs_solver_bld + procedure, pass(sv) :: apply_v => amg_z_bwgs_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_z_bwgs_solver_apply + procedure, nopass :: get_fmt => z_bwgs_solver_get_fmt + procedure, nopass :: get_id => z_bwgs_solver_get_id + procedure, pass(sv) :: descr => z_bwgs_solver_descr + end type amg_z_bwgs_solver_type + + + private :: z_gs_solver_bld, z_gs_solver_apply, & + & z_gs_solver_free, & + & z_gs_solver_descr, z_gs_solver_sizeof, & + & z_gs_solver_default, z_gs_solver_dmp, & + & z_gs_solver_apply_vect, z_gs_solver_get_nzeros, & + & z_gs_solver_get_fmt, z_gs_solver_check,& + & z_gs_solver_is_iterative, & + & z_bwgs_solver_get_fmt, z_bwgs_solver_descr, & + & z_gs_solver_get_id, z_bwgs_solver_get_id, z_gs_solver_get_wrksize + + interface + subroutine amg_z_gs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, amg_z_gs_solver_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_gs_solver_type), intent(inout) :: sv + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + end subroutine amg_z_gs_solver_apply_vect + subroutine amg_z_bwgs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, amg_z_bwgs_solver_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_bwgs_solver_type), intent(inout) :: sv + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + end subroutine amg_z_bwgs_solver_apply_vect + end interface + + interface + subroutine amg_z_gs_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info,init,initu) + import :: psb_desc_type, amg_z_gs_solver_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_gs_solver_type), intent(inout) :: sv + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_z_gs_solver_apply + subroutine amg_z_bwgs_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, amg_z_bwgs_solver_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_bwgs_solver_type), intent(inout) :: sv + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_z_bwgs_solver_apply + end interface + + interface + subroutine amg_z_gs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, amg_z_gs_solver_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_gs_solver_bld + subroutine amg_z_bwgs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, amg_z_bwgs_solver_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_bwgs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_bwgs_solver_bld + end interface + + interface + subroutine amg_z_gs_solver_cnv(sv,info,amold,vmold,imold) + import :: amg_z_gs_solver_type, psb_dpk_, & + & psb_z_base_sparse_mat, psb_z_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + class(amg_z_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_gs_solver_cnv + end interface + + interface + subroutine amg_z_gs_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, amg_z_gs_solver_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, & + & psb_ipk_ + implicit none + class(amg_z_gs_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_z_gs_solver_dmp + end interface + + interface + subroutine amg_z_gs_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, amg_z_gs_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_gs_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_gs_solver_clone + end interface + + interface + subroutine amg_z_gs_solver_clone_settings(sv,svout,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, amg_z_gs_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_gs_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_gs_solver_clone_settings + end interface + + interface + subroutine amg_z_gs_solver_clear_data(sv,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_gs_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_gs_solver_clear_data + end interface + +contains + + subroutine z_gs_solver_default(sv) + + Implicit None + + ! Arguments + class(amg_z_gs_solver_type), intent(inout) :: sv + + sv%sweeps = ione + sv%eps = dzero + + return + end subroutine z_gs_solver_default + + subroutine z_gs_solver_check(sv,info) + + Implicit None + + ! Arguments + class(amg_z_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_gs_solver_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + call amg_check_def(sv%sweeps,& + & 'GS Sweeps',ione,is_int_positive) + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine z_gs_solver_check + + subroutine z_gs_solver_cseti(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_z_gs_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_gs_solver_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) + case('SOLVER_SWEEPS') + sv%sweeps = val + case default + call sv%amg_z_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_gs_solver_cseti + + subroutine z_gs_solver_csetc(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_z_gs_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='z_gs_solver_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + + + call sv%amg_z_base_solver_type%set(what,val,info,idx=idx) + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info, name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_gs_solver_csetc + + subroutine z_gs_solver_csetr(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_z_gs_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_gs_solver_csetr' + + call psb_erractionsave(err_act) + info = psb_success_ + + select case(psb_toupper(what)) + case('SOLVER_EPS') + sv%eps = val + case default + call sv%amg_z_base_solver_type%set(what,val,info,idx=idx) + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_gs_solver_csetr + + subroutine z_gs_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_z_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_gs_solver_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + call sv%l%free() + call sv%u%free() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_gs_solver_free + + subroutine z_gs_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_z_gs_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_z_gs_solver_descr' + integer(psb_ipk_) :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (sv%eps<=dzero) then + write(iout_,*) ' Forward Gauss-Seidel iterative solver with ',& + & sv%sweeps,' sweeps' + else + write(iout_,*) ' Forward Gauss-Seidel iterative solver with tolerance',& + & sv%eps,' and maxit', sv%sweeps + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_gs_solver_descr + + function z_gs_solver_get_nzeros(sv) result(val) + + implicit none + ! Arguments + class(amg_z_gs_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + val = val + sv%l%get_nzeros() + val = val + sv%u%get_nzeros() + + return + end function z_gs_solver_get_nzeros + + function z_gs_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_z_gs_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = psb_sizeof_ip + val = val + sv%l%sizeof() + val = val + sv%u%sizeof() + + return + end function z_gs_solver_sizeof + + function z_gs_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Forward Gauss-Seidel solver" + end function z_gs_solver_get_fmt + + function z_gs_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_gs_ + end function z_gs_solver_get_id + + ! + ! If this is true, then the solver needs a starting + ! guess. Currently only handled in JAC smoother. + ! + function z_gs_solver_is_iterative() result(val) + implicit none + logical :: val + + val = .true. + end function z_gs_solver_is_iterative + + subroutine z_bwgs_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_z_bwgs_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_z_bwgs_solver_descr' + integer(psb_ipk_) :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (sv%eps<=dzero) then + write(iout_,*) ' Backward Gauss-Seidel iterative solver with ',& + & sv%sweeps,' sweeps' + else + write(iout_,*) ' Backward Gauss-Seidel iterative solver with tolerance',& + & sv%eps,' and maxit', sv%sweeps + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_bwgs_solver_descr + + function z_bwgs_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Backward Gauss-Seidel solver" + end function z_bwgs_solver_get_fmt + + function z_bwgs_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_bwgs_ + end function z_bwgs_solver_get_id + + function z_gs_solver_get_wrksize() result(val) + implicit none + integer(psb_ipk_) :: val + + val = 2 + end function z_gs_solver_get_wrksize + +end module amg_z_gs_solver diff --git a/mlprec/amg_z_hybrid_aggregator_mod.F90 b/mlprec/amg_z_hybrid_aggregator_mod.F90 new file mode 100644 index 00000000..176cf6f3 --- /dev/null +++ b/mlprec/amg_z_hybrid_aggregator_mod.F90 @@ -0,0 +1,125 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! The aggregator object hosts the aggregation method for building +! the multilevel hierarchy. This variant is based on the hybrid method +! presented in +! +! S. Gratton, P. Henon, P. Jiranek and X. Vasseur: +! Reducing complexity of algebraic multigrid by aggregation +! Numerical Lin. Algebra with Applications, 2016, 23:501-518 +! +module amg_z_hybrid_aggregator_mod + + use amg_z_dec_aggregator_mod + ! + ! sm - class(amg_T_base_smoother_type), allocatable + ! The current level preconditioner (aka smoother). + ! parms - type(amg_RTml_parms) + ! The parameters defining the multilevel strategy. + ! ac - The local part of the current-level matrix, built by + ! coarsening the previous-level matrix. + ! desc_ac - type(psb_desc_type). + ! The communication descriptor associated to the matrix + ! stored in ac. + ! base_a - type(psb_Tspmat_type), pointer. + ! Pointer (really a pointer!) to the local part of the current + ! matrix (so we have a unified treatment of residuals). + ! We need this to avoid passing explicitly the current matrix + ! to the routine which applies the preconditioner. + ! base_desc - type(psb_desc_type), pointer. + ! Pointer to the communication descriptor associated to the + ! matrix pointed by base_a. + ! map - Stores the maps (restriction and prolongation) between the + ! vector spaces associated to the index spaces of the previous + ! and current levels. + ! + ! Methods: + ! Most methods follow the encapsulation hierarchy: they take whatever action + ! is appropriate for the current object, then call the corresponding method for + ! the contained object. + ! As an example: the descr() method prints out a description of the + ! level. It starts by invoking the descr() method of the parms object, + ! then calls the descr() method of the smoother object. + ! + ! descr - Prints a description of the object. + ! default - Set default values + ! dump - Dump to file object contents + ! set - Sets various parameters; when a request is unknown + ! it is passed to the smoother object for further processing. + ! check - Sanity checks. + ! sizeof - Total memory occupation in bytes + ! get_nzeros - Number of nonzeros + ! + ! + type, extends(amg_z_dec_aggregator_type) :: amg_z_hybrid_aggregator_type + + contains + procedure, pass(ag) :: bld_tprol => amg_z_hybrid_aggregator_build_tprol + procedure, nopass :: fmt => amg_z_hybrid_aggregator_fmt + end type amg_z_hybrid_aggregator_type + + + interface + subroutine amg_z_hybrid_aggregator_build_tprol(ag,parms,a,desc_a,ilaggr,nlaggr,op_prol,info) + import :: amg_z_hybrid_aggregator_type, psb_desc_type, psb_zspmat_type, psb_dpk_, & + & psb_ipk_, psb_long_int_k_, amg_dml_parms + implicit none + class(amg_z_hybrid_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + integer(psb_ipk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_zspmat_type), intent(out) :: op_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_hybrid_aggregator_build_tprol + end interface + +contains + + + function amg_z_hybrid_aggregator_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Hybrid Decoupled aggregation" + end function amg_z_hybrid_aggregator_fmt + + +end module amg_z_hybrid_aggregator_mod diff --git a/mlprec/amg_z_id_solver.f90 b/mlprec/amg_z_id_solver.f90 new file mode 100644 index 00000000..c72d7bc7 --- /dev/null +++ b/mlprec/amg_z_id_solver.f90 @@ -0,0 +1,202 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! +! Identity solver. Reference for nullprec. +! +! +module amg_z_id_solver + + use amg_z_base_solver_mod + + type, extends(amg_z_base_solver_type) :: amg_z_id_solver_type + contains + procedure, pass(sv) :: build => z_id_solver_bld + procedure, pass(sv) :: clone => amg_z_id_solver_clone + procedure, pass(sv) :: apply_v => amg_z_id_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_z_id_solver_apply + procedure, pass(sv) :: free => z_id_solver_free + procedure, pass(sv) :: descr => z_id_solver_descr + procedure, nopass :: get_fmt => z_id_solver_get_fmt + procedure, nopass :: get_id => z_id_solver_get_id + end type amg_z_id_solver_type + + + private :: z_id_solver_bld, & + & z_id_solver_free, z_id_solver_get_fmt, & + & z_id_solver_descr, z_id_solver_get_id + + interface + subroutine amg_z_id_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_id_solver_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_id_solver_type), intent(inout) :: sv + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + end subroutine amg_z_id_solver_apply_vect + end interface + + interface + subroutine amg_z_id_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_id_solver_type, psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_id_solver_type), intent(inout) :: sv + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_z_id_solver_apply + end interface + + interface + subroutine amg_z_id_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, amg_z_id_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_id_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_id_solver_clone + end interface + +contains + + + subroutine z_id_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + Implicit None + + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_id_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: i, err_act, debug_unit, debug_level + character(len=20) :: name='z_id_solver_bld', ch_err + + info=psb_success_ + + return + end subroutine z_id_solver_bld + + subroutine z_id_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_z_id_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_id_solver_free' + + info = psb_success_ + + return + end subroutine z_id_solver_free + + subroutine z_id_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_z_id_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_z_id_solver_descr' + integer(psb_ipk_) :: iout_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' Identity local solver ' + + return + + end subroutine z_id_solver_descr + + function z_id_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Identity solver" + end function z_id_solver_get_fmt + + function z_id_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_f_none_ + end function z_id_solver_get_id + +end module amg_z_id_solver diff --git a/mlprec/amg_z_ilu_fact_mod.f90 b/mlprec/amg_z_ilu_fact_mod.f90 new file mode 100644 index 00000000..51932b2c --- /dev/null +++ b/mlprec/amg_z_ilu_fact_mod.f90 @@ -0,0 +1,91 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! File: amg_z_ilu_fact_mod.f90 +! +! Module: amg_z_ilu_fact_mod +! +! This module defines some interfaces used internally by the implementation of +! amg_z_ilu_solver, but not visible to the end user. +! +! +module amg_z_ilu_fact_mod + + use amg_z_base_solver_mod + + interface amg_ilu0_fact + subroutine amg_zilu0_fact(ialg,a,l,u,d,info,blck,upd) + import psb_zspmat_type, psb_dpk_, psb_ipk_ + integer(psb_ipk_), intent(in) :: ialg + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type),intent(in) :: a + type(psb_zspmat_type),intent(inout) :: l,u + type(psb_zspmat_type),intent(in), optional, target :: blck + character, intent(in), optional :: upd + complex(psb_dpk_), intent(inout) :: d(:) + end subroutine amg_zilu0_fact + end interface + + interface amg_iluk_fact + subroutine amg_ziluk_fact(fill_in,ialg,a,l,u,d,info,blck) + import psb_zspmat_type, psb_dpk_, psb_ipk_ + integer(psb_ipk_), intent(in) :: fill_in,ialg + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type),intent(in) :: a + type(psb_zspmat_type),intent(inout) :: l,u + type(psb_zspmat_type),intent(in), optional, target :: blck + complex(psb_dpk_), intent(inout) :: d(:) + end subroutine amg_ziluk_fact + end interface + + interface amg_ilut_fact + subroutine amg_zilut_fact(fill_in,thres,a,l,u,d,info,blck,iscale) + import psb_zspmat_type, psb_dpk_, psb_ipk_ + integer(psb_ipk_), intent(in) :: fill_in + real(psb_dpk_), intent(in) :: thres + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type),intent(in) :: a + type(psb_zspmat_type),intent(inout) :: l,u + complex(psb_dpk_), intent(inout) :: d(:) + type(psb_zspmat_type),intent(in), optional, target :: blck + integer(psb_ipk_), intent(in), optional :: iscale + end subroutine amg_zilut_fact + end interface + +end module amg_z_ilu_fact_mod diff --git a/mlprec/amg_z_ilu_solver.f90 b/mlprec/amg_z_ilu_solver.f90 new file mode 100644 index 00000000..0c5a83bc --- /dev/null +++ b/mlprec/amg_z_ilu_solver.f90 @@ -0,0 +1,502 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! File: amg_z_ilu_solver_mod.f90 +! +! Module: amg_z_ilu_solver_mod +! +! This module defines: +! - the amg_z_ilu_solver_type data structure containing the ingredients +! for a local Incomplete LU factorization. +! 1. The factorization is always restricted to the diagonal block of the +! current image (coherently with the definition of a SOLVER as a local +! object) +! 2. The code provides support for both pattern-based ILU(K) and +! threshold base ILU(T,L) +! 3. The diagonal is stored separately, so strictly speaking this is +! an incomplete LDU factorization; +! 4. The application phase is shared among all variants; +! +! +module amg_z_ilu_solver + + use amg_base_prec_type, only : amg_fact_names + use amg_z_base_solver_mod + use psb_z_ilu_fact_mod + + type, extends(amg_z_base_solver_type) :: amg_z_ilu_solver_type + type(psb_zspmat_type) :: l, u + complex(psb_dpk_), allocatable :: d(:) + type(psb_z_vect_type) :: dv + integer(psb_ipk_) :: fact_type, fill_in + real(psb_dpk_) :: thresh + contains + procedure, pass(sv) :: dump => amg_z_ilu_solver_dmp + procedure, pass(sv) :: check => z_ilu_solver_check + procedure, pass(sv) :: clone => amg_z_ilu_solver_clone + procedure, pass(sv) :: clone_settings => amg_z_ilu_solver_clone_settings + procedure, pass(sv) :: clear_data => amg_z_ilu_solver_clear_data + procedure, pass(sv) :: build => amg_z_ilu_solver_bld + procedure, pass(sv) :: cnv => amg_z_ilu_solver_cnv + procedure, pass(sv) :: apply_v => amg_z_ilu_solver_apply_vect + procedure, pass(sv) :: apply_a => amg_z_ilu_solver_apply + procedure, pass(sv) :: free => z_ilu_solver_free + procedure, pass(sv) :: cseti => z_ilu_solver_cseti + procedure, pass(sv) :: csetc => z_ilu_solver_csetc + procedure, pass(sv) :: csetr => z_ilu_solver_csetr + procedure, pass(sv) :: descr => z_ilu_solver_descr + procedure, pass(sv) :: default => z_ilu_solver_default + procedure, pass(sv) :: sizeof => z_ilu_solver_sizeof + procedure, pass(sv) :: get_nzeros => z_ilu_solver_get_nzeros + procedure, nopass :: get_wrksz => z_ilu_solver_get_wrksize + procedure, nopass :: get_fmt => z_ilu_solver_get_fmt + procedure, nopass :: get_id => z_ilu_solver_get_id + end type amg_z_ilu_solver_type + + + private :: z_ilu_solver_bld, z_ilu_solver_apply, & + & z_ilu_solver_free, & + & z_ilu_solver_descr, z_ilu_solver_sizeof, & + & z_ilu_solver_default, z_ilu_solver_dmp, & + & z_ilu_solver_apply_vect, z_ilu_solver_get_nzeros, & + & z_ilu_solver_get_fmt, z_ilu_solver_check, & + & z_ilu_solver_get_id, z_ilu_solver_get_wrksize + + + interface + subroutine amg_z_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, amg_z_ilu_solver_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_ilu_solver_type), intent(inout) :: sv + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + end subroutine amg_z_ilu_solver_apply_vect + end interface + + interface + subroutine amg_z_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + import :: psb_desc_type, amg_z_ilu_solver_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_ilu_solver_type), intent(inout) :: sv + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_z_ilu_solver_apply + end interface + + interface + subroutine amg_z_ilu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + import :: psb_desc_type, amg_z_ilu_solver_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_ilu_solver_bld + end interface + + interface + subroutine amg_z_ilu_solver_cnv(sv,info,amold,vmold,imold) + import :: amg_z_ilu_solver_type, psb_dpk_, & + & psb_z_base_sparse_mat, psb_z_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + implicit none + class(amg_z_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_ilu_solver_cnv + end interface + + interface + subroutine amg_z_ilu_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + import :: psb_desc_type, amg_z_ilu_solver_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, & + & psb_ipk_ + implicit none + class(amg_z_ilu_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + end subroutine amg_z_ilu_solver_dmp + end interface + + interface + subroutine amg_z_ilu_solver_clone(sv,svout,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, amg_z_ilu_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_ilu_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_ilu_solver_clone + end interface + + interface + subroutine amg_z_ilu_solver_clone_settings(sv,svout,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_base_solver_type, amg_z_ilu_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_ilu_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_ilu_solver_clone_settings + end interface + + interface + subroutine amg_z_ilu_solver_clear_data(sv,info) + import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & + & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & + & amg_z_ilu_solver_type, psb_ipk_ + Implicit None + + ! Arguments + class(amg_z_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_ilu_solver_clear_data + end interface + +contains + + subroutine z_ilu_solver_default(sv) + + Implicit None + + ! Arguments + class(amg_z_ilu_solver_type), intent(inout) :: sv + + sv%fact_type = psb_ilu_n_ + sv%fill_in = 0 + sv%thresh = dzero + + return + end subroutine z_ilu_solver_default + + subroutine z_ilu_solver_check(sv,info) + + Implicit None + + ! Arguments + class(amg_z_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_ilu_solver_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + call amg_check_def(sv%fact_type,& + & 'Factorization',psb_ilu_n_,is_legal_ilu_fact) + + select case(sv%fact_type) + case(psb_ilu_n_,psb_milu_n_) + call amg_check_def(sv%fill_in,& + & 'Level',izero,is_int_non_negative) + case(psb_ilu_t_) + call amg_check_def(sv%thresh,& + & 'Eps',dzero,is_legal_d_fact_thrs) + end select + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine z_ilu_solver_check + + subroutine z_ilu_solver_cseti(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_z_ilu_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_ilu_solver_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(trim((what)))) + case('SUB_SOLVE') + sv%fact_type = val + case('SUB_FILLIN') + sv%fill_in = val + case default + call sv%amg_z_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_ilu_solver_cseti + + subroutine z_ilu_solver_csetc(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_z_ilu_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='z_ilu_solver_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + ival = amg_stringval(val) + select case(psb_toupper(trim((what)))) + case('SUB_SOLVE') + sv%fact_type = ival + case default + call sv%amg_z_base_solver_type%set(what,val,info,idx=idx) + end select + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info, name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_ilu_solver_csetc + + subroutine z_ilu_solver_csetr(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_z_ilu_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_ilu_solver_csetr' + + call psb_erractionsave(err_act) + info = psb_success_ + + select case(psb_toupper(what)) + case('SUB_ILUTHRS') + sv%thresh = val + case default + call sv%amg_z_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_ilu_solver_csetr + + subroutine z_ilu_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_z_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_ilu_solver_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sv%d)) then + deallocate(sv%d,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + end if + call sv%l%free() + call sv%u%free() + call sv%dv%free(info) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_ilu_solver_free + + subroutine z_ilu_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_z_ilu_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_z_ilu_solver_descr' + integer(psb_ipk_) :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' Incomplete factorization solver: ',& + & amg_fact_names(sv%fact_type) + select case(sv%fact_type) + case(psb_ilu_n_,psb_milu_n_) + write(iout_,*) ' Fill level:',sv%fill_in + case(psb_ilu_t_) + write(iout_,*) ' Fill level:',sv%fill_in + write(iout_,*) ' Fill threshold :',sv%thresh + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_ilu_solver_descr + + function z_ilu_solver_get_nzeros(sv) result(val) + + implicit none + ! Arguments + class(amg_z_ilu_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + val = val + sv%dv%get_nrows() + val = val + sv%l%get_nzeros() + val = val + sv%u%get_nzeros() + + return + end function z_ilu_solver_get_nzeros + + function z_ilu_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_z_ilu_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 2*psb_sizeof_ip + (2*psb_sizeof_dp) + val = val + sv%dv%sizeof() + val = val + sv%l%sizeof() + val = val + sv%u%sizeof() + + return + end function z_ilu_solver_sizeof + + function z_ilu_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "ILU solver" + end function z_ilu_solver_get_fmt + + function z_ilu_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = psb_ilu_n_ + end function z_ilu_solver_get_id + + function z_ilu_solver_get_wrksize() result(val) + implicit none + integer(psb_ipk_) :: val + + val = 2 + end function z_ilu_solver_get_wrksize + +end module amg_z_ilu_solver diff --git a/mlprec/amg_z_inner_mod.f90 b/mlprec/amg_z_inner_mod.f90 new file mode 100644 index 00000000..156ae5e4 --- /dev/null +++ b/mlprec/amg_z_inner_mod.f90 @@ -0,0 +1,131 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_inner_mod.f90 +! +! Module: amg_inner_mod +! +! This module defines the interfaces to inner MLD2P4 routines. +! The interfaces of the user level routines are defined in amg_prec_mod.f90. +! +module amg_z_inner_mod + + use psb_base_mod, only : psb_zspmat_type, psb_desc_type, psb_i_base_vect_type, & + & psb_dpk_, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_, & + & psb_z_vect_type, psb_lpk_, psb_lzspmat_type + use amg_z_prec_type, only : amg_zprec_type, amg_dml_parms, & + & amg_z_onelev_type, amg_zmlprec_wrk_type + + interface amg_mlprec_bld + subroutine amg_zmlprec_bld(a,desc_a,prec,info, amold, vmold,imold) + import :: psb_zspmat_type, psb_desc_type, psb_i_base_vect_type, & + & psb_dpk_, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ + import :: amg_zprec_type + implicit none + type(psb_zspmat_type), intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + type(amg_zprec_type), intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_zmlprec_bld + end interface amg_mlprec_bld + + interface amg_mlprec_aply + subroutine amg_zmlprec_aply(alpha,p,x,beta,y,desc_data,trans,work,info) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, psb_ipk_ + import :: amg_zprec_type + implicit none + type(psb_desc_type),intent(in) :: desc_data + type(amg_zprec_type), intent(inout) :: p + complex(psb_dpk_),intent(in) :: alpha,beta + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + character,intent(in) :: trans + complex(psb_dpk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + end subroutine amg_zmlprec_aply + subroutine amg_zmlprec_aply_vect(alpha,p,x,beta,y,desc_data,trans,work,info) + import :: psb_zspmat_type, psb_desc_type, & + & psb_dpk_, psb_z_vect_type, psb_ipk_ + import :: amg_zprec_type + implicit none + type(psb_desc_type),intent(in) :: desc_data + type(amg_zprec_type), intent(inout) :: p + complex(psb_dpk_),intent(in) :: alpha,beta + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + character,intent(in) :: trans + complex(psb_dpk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + end subroutine amg_zmlprec_aply_vect + end interface amg_mlprec_aply + + interface amg_map_to_tprol + subroutine amg_z_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, psb_ipk_, psb_lpk_, psb_lzspmat_type + import :: amg_z_onelev_type + implicit none + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), allocatable, intent(inout) :: ilaggr(:),nlaggr(:) + type(psb_lzspmat_type), intent(out) :: op_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_map_to_tprol + end interface amg_map_to_tprol + + abstract interface + subroutine amg_zaggrmat_var_bld(a,desc_a,ilaggr,nlaggr,parms,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, psb_ipk_, psb_lpk_, psb_lzspmat_type + import :: amg_z_onelev_type, amg_dml_parms + implicit none + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(amg_dml_parms), intent(inout) :: parms + type(psb_zspmat_type), intent(inout) :: op_prol,ac,op_restr + type(psb_lzspmat_type), intent(inout) :: t_prol + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + end subroutine amg_zaggrmat_var_bld + end interface + + procedure(amg_zaggrmat_var_bld) :: amg_zaggrmat_nosmth_bld, & + & amg_zaggrmat_smth_bld, amg_zaggrmat_minnrg_bld + +end module amg_z_inner_mod diff --git a/mlprec/amg_z_jac_smoother.f90 b/mlprec/amg_z_jac_smoother.f90 new file mode 100644 index 00000000..26aa81a9 --- /dev/null +++ b/mlprec/amg_z_jac_smoother.f90 @@ -0,0 +1,454 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_z_jac_smoother_mod.f90 +! +! Module: amg_z_jac_smoother_mod +! +! This module defines: +! the amg_z_jac_smoother_type data structure containing the +! smoother for a Jacobi/block Jacobi smoother. +! The smoother stores in ND the block off-diagonal matrix. +! One special case is treated separately, when the solver is DIAG or L1-DIAG +! then the ND is the entire off-diagonal part of the matrix (including the +! main diagonal block), so that it becomes possible to implement +! a pure Jacobi or L1-Jacobi global solver. +! +module amg_z_jac_smoother + + use amg_z_base_smoother_mod + + type, extends(amg_z_base_smoother_type) :: amg_z_jac_smoother_type + ! The local solver component is inherited from the + ! parent type. + ! class(amg_z_base_solver_type), allocatable :: sv + ! + type(psb_zspmat_type), pointer :: pa => null() + type(psb_zspmat_type) :: nd + integer(psb_lpk_) :: nd_nnz_tot + logical :: checkres + logical :: printres + integer(psb_ipk_) :: checkiter + integer(psb_ipk_) :: printiter + real(psb_dpk_) :: tol + contains + procedure, pass(sm) :: apply_v => amg_z_jac_smoother_apply_vect + procedure, pass(sm) :: apply_a => amg_z_jac_smoother_apply + procedure, pass(sm) :: dump => amg_z_jac_smoother_dmp + procedure, pass(sm) :: build => amg_z_jac_smoother_bld + procedure, pass(sm) :: cnv => amg_z_jac_smoother_cnv + procedure, pass(sm) :: clone => amg_z_jac_smoother_clone + procedure, pass(sm) :: clone_settings => amg_z_jac_smoother_clone_settings + procedure, pass(sm) :: clear_data => amg_z_jac_smoother_clear_data + procedure, pass(sm) :: free => z_jac_smoother_free + procedure, pass(sm) :: cseti => amg_z_jac_smoother_cseti + procedure, pass(sm) :: csetc => amg_z_jac_smoother_csetc + procedure, pass(sm) :: csetr => amg_z_jac_smoother_csetr + procedure, pass(sm) :: descr => amg_z_jac_smoother_descr + procedure, pass(sm) :: sizeof => z_jac_smoother_sizeof + procedure, pass(sm) :: default => z_jac_smoother_default + procedure, pass(sm) :: get_nzeros => z_jac_smoother_get_nzeros + procedure, pass(sm) :: get_wrksz => z_jac_smoother_get_wrksize + procedure, nopass :: get_fmt => z_jac_smoother_get_fmt + procedure, nopass :: get_id => z_jac_smoother_get_id + end type amg_z_jac_smoother_type + + type, extends(amg_z_jac_smoother_type) :: amg_z_l1_jac_smoother_type + contains + procedure, pass(sm) :: build => amg_z_l1_jac_smoother_bld + procedure, pass(sm) :: clone => amg_z_l1_jac_smoother_clone + procedure, pass(sm) :: descr => amg_z_l1_jac_smoother_descr + procedure, nopass :: get_fmt => z_l1_jac_smoother_get_fmt + procedure, nopass :: get_id => z_l1_jac_smoother_get_id + end type amg_z_l1_jac_smoother_type + + private :: z_jac_smoother_free, & + & z_jac_smoother_sizeof, z_jac_smoother_get_nzeros, & + & z_jac_smoother_get_fmt, z_jac_smoother_get_id, & + & z_jac_smoother_get_wrksize + private :: z_l1_jac_smoother_get_fmt, z_l1_jac_smoother_get_id + + + interface + subroutine amg_z_jac_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,wv,info,init,initu) + import :: psb_desc_type, amg_z_jac_smoother_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type,& + & psb_ipk_ + + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_jac_smoother_type), intent(inout) :: sm + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + end subroutine amg_z_jac_smoother_apply_vect + end interface + + interface + subroutine amg_z_jac_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,info,init,initu) + import :: psb_desc_type, amg_z_jac_smoother_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, & + & psb_ipk_ + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_jac_smoother_type), intent(inout) :: sm + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine amg_z_jac_smoother_apply + end interface + + interface + subroutine amg_z_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + import :: psb_desc_type, amg_z_jac_smoother_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_jac_smoother_bld + end interface + + interface + subroutine amg_z_jac_smoother_cnv(sm,info,amold,vmold,imold) + import :: amg_z_jac_smoother_type, psb_dpk_, & + & psb_z_base_sparse_mat, psb_z_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + class(amg_z_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_jac_smoother_cnv + end interface + + interface + subroutine amg_z_jac_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_dpk_, amg_z_jac_smoother_type, psb_epk_, psb_desc_type, & + & psb_ipk_ + implicit none + class(amg_z_jac_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + end subroutine amg_z_jac_smoother_dmp + end interface + + interface + subroutine amg_z_jac_smoother_clone(sm,smout,info) + import :: amg_z_jac_smoother_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_ + class(amg_z_jac_smoother_type), intent(inout) :: sm + class(amg_z_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_jac_smoother_clone + end interface + + interface + subroutine amg_z_jac_smoother_clone_settings(sm,smout,info) + import :: amg_z_jac_smoother_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_ + class(amg_z_jac_smoother_type), intent(inout) :: sm + class(amg_z_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_jac_smoother_clone_settings + end interface + + interface + subroutine amg_z_jac_smoother_clear_data(sm,info) + import :: amg_z_jac_smoother_type, psb_dpk_, & + & amg_z_base_smoother_type, psb_ipk_ + class(amg_z_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_jac_smoother_clear_data + end interface + + interface + subroutine amg_z_jac_smoother_descr(sm,info,iout,coarse) + import :: amg_z_jac_smoother_type, psb_ipk_ + class(amg_z_jac_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + end subroutine amg_z_jac_smoother_descr + end interface + + interface + subroutine amg_z_jac_smoother_cseti(sm,what,val,info,idx) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_dpk_, amg_z_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_z_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_z_jac_smoother_cseti + end interface + + interface + subroutine amg_z_jac_smoother_csetc(sm,what,val,info,idx) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_dpk_, amg_z_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_z_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_z_jac_smoother_csetc + end interface + + interface + subroutine amg_z_jac_smoother_csetr(sm,what,val,info,idx) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_dpk_, amg_z_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ + implicit none + class(amg_z_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_z_jac_smoother_csetr + end interface + + + interface + subroutine amg_z_l1_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + import :: psb_desc_type, amg_z_l1_jac_smoother_type, psb_z_vect_type, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_l1_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_l1_jac_smoother_bld + end interface + + interface + subroutine amg_z_l1_jac_smoother_clone(sm,smout,info) + import :: amg_z_l1_jac_smoother_type, & + & amg_z_base_smoother_type, psb_ipk_ + class(amg_z_l1_jac_smoother_type), intent(inout) :: sm + class(amg_z_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_l1_jac_smoother_clone + end interface + + interface + subroutine amg_z_l1_jac_smoother_clone_settings(sm,smout,info) + import :: amg_z_l1_jac_smoother_type, & + & amg_z_base_smoother_type, psb_ipk_ + class(amg_z_l1_jac_smoother_type), intent(inout) :: sm + class(amg_z_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_l1_jac_smoother_clone_settings + end interface + + interface + subroutine amg_z_l1_jac_smoother_clear_data(sm,info) + import :: amg_z_l1_jac_smoother_type, & + & amg_z_base_smoother_type, psb_ipk_ + class(amg_z_l1_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_l1_jac_smoother_clear_data + end interface + + interface + subroutine amg_z_l1_jac_smoother_descr(sm,info,iout,coarse) + import :: amg_z_l1_jac_smoother_type, psb_ipk_ + class(amg_z_l1_jac_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + end subroutine amg_z_l1_jac_smoother_descr + end interface + +contains + + + subroutine z_jac_smoother_free(sm,info) + + + Implicit None + + ! Arguments + class(amg_z_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_jac_smoother_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + + + if (allocated(sm%sv)) then + call sm%sv%free(info) + if (info == psb_success_) deallocate(sm%sv,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + end if + call sm%nd%free() + sm%pa => null() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_jac_smoother_free + + function z_jac_smoother_sizeof(sm) result(val) + + implicit none + ! Arguments + class(amg_z_jac_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = psb_sizeof_lp + if (allocated(sm%sv)) val = val + sm%sv%sizeof() + val = val + sm%nd%sizeof() + + return + end function z_jac_smoother_sizeof + + subroutine z_jac_smoother_default(sm) + + Implicit None + + ! Arguments + class(amg_z_jac_smoother_type), intent(inout) :: sm + + ! + ! Default: BJAC with no residual check + ! + sm%checkres = .false. + sm%printres = .false. + sm%checkiter = -1 + sm%printiter = -1 + sm%tol = 0 + + if (allocated(sm%sv)) then + call sm%sv%default() + end if + + return + end subroutine z_jac_smoother_default + + function z_jac_smoother_get_nzeros(sm) result(val) + + implicit none + ! Arguments + class(amg_z_jac_smoother_type), intent(in) :: sm + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = 0 + if (allocated(sm%sv)) val = val + sm%sv%get_nzeros() + val = val + sm%nd%get_nzeros() + + return + end function z_jac_smoother_get_nzeros + + function z_jac_smoother_get_wrksize(sm) result(val) + implicit none + class(amg_z_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_) :: val + + val = 2 + if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() + + end function z_jac_smoother_get_wrksize + + function z_jac_smoother_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Jacobi smoother" + end function z_jac_smoother_get_fmt + + function z_jac_smoother_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_jac_ + end function z_jac_smoother_get_id + + function z_l1_jac_smoother_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "L1-Jacobi smoother" + end function z_l1_jac_smoother_get_fmt + + function z_l1_jac_smoother_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_l1_jac_ + end function z_l1_jac_smoother_get_id + +end module amg_z_jac_smoother diff --git a/mlprec/amg_z_mumps_solver.F90 b/mlprec/amg_z_mumps_solver.F90 new file mode 100644 index 00000000..85376cec --- /dev/null +++ b/mlprec/amg_z_mumps_solver.F90 @@ -0,0 +1,590 @@ + +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +! File: amg_z_mumps_solver_mod.f90 +! +! Module: amg_z_mumps_solver_mod +! +! This module defines: +! - the amg_z_mumps_solver_type data structure containing the ingredients +! to interface with the MUMPS package. +! 1. The factorization can be either restricted to the diagonal block of the +! current image or distributed (and thus exact). +! +module amg_z_mumps_solver + use amg_z_base_solver_mod +#if defined(HAVE_MUMPS_) && defined(HAVE_MUMPS_MODULES_) + use zmumps_struc_def +#endif +#if defined(HAVE_MUMPS_) && defined(HAVE_MUMPS_INCLUDES_) + include 'zmumps_struc.h' +#endif + + + type :: amg_z_mumps_icntl_item + integer(psb_ipk_), allocatable :: item + end type amg_z_mumps_icntl_item + type :: amg_z_mumps_rcntl_item + real(psb_dpk_), allocatable :: item + end type amg_z_mumps_rcntl_item + + type, extends(amg_z_base_solver_type) :: amg_z_mumps_solver_type +#if defined(HAVE_MUMPS_) + type(zmumps_struc), allocatable :: id +#else + integer, allocatable :: id +#endif + type(amg_z_mumps_icntl_item), allocatable :: icntl(:) + type(amg_z_mumps_rcntl_item), allocatable :: rcntl(:) + ! + ! Controls to be set before MUMPS instantiation: + ! + ! IPAR(1) : MUMPS_LOC_GLOB 0==amg_local_solver_: LOCAL 1==amg_global_solver_: GLOBAL + ! IPAR(2) : MUMPS_PRINT_ERR print verbosity (see MUMPS) + ! IPAR(3) : MUMPS_SYM 0: non-symmetric 2: symmetric + integer(psb_ipk_), dimension(3) :: ipar + integer(psb_ipk_), allocatable :: local_ictxt + logical :: built = .false. + contains + procedure, pass(sv) :: build => z_mumps_solver_bld + procedure, pass(sv) :: apply_a => z_mumps_solver_apply + procedure, pass(sv) :: apply_v => z_mumps_solver_apply_vect + procedure, pass(sv) :: clone_settings => z_mumps_solver_clone_settings + procedure, pass(sv) :: clear_data => z_mumps_solver_clear_data + procedure, pass(sv) :: free => z_mumps_solver_free + procedure, pass(sv) :: descr => z_mumps_solver_descr + procedure, pass(sv) :: sizeof => z_mumps_solver_sizeof + procedure, pass(sv) :: csetc => z_mumps_solver_csetc + procedure, pass(sv) :: cseti => z_mumps_solver_cseti + procedure, pass(sv) :: csetr => z_mumps_solver_csetr + procedure, pass(sv) :: default => z_mumps_solver_default + procedure, nopass :: get_fmt => z_mumps_solver_get_fmt + procedure, nopass :: get_id => z_mumps_solver_get_id + procedure, pass(sv) :: is_global => z_mumps_solver_is_global + final :: z_mumps_solver_finalize + end type amg_z_mumps_solver_type + + + private :: z_mumps_solver_bld, z_mumps_solver_apply, & + & z_mumps_solver_free, z_mumps_solver_descr, & + & z_mumps_solver_sizeof, z_mumps_solver_apply_vect,& + & z_mumps_solver_cseti, z_mumps_solver_csetr, & + & z_mumps_solver_csetc, z_mumps_solver_clear_data, & + & z_mumps_solver_default, z_mumps_solver_get_fmt, & + & z_mumps_solver_clone_settings, & + & z_mumps_solver_get_id, z_mumps_solver_is_global + private :: z_mumps_solver_finalize + + interface + subroutine z_mumps_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + import :: psb_desc_type, amg_z_mumps_solver_type, psb_z_vect_type, psb_dpk_, psb_spk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_mumps_solver_type), intent(inout) :: sv + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + end subroutine z_mumps_solver_apply_vect + end interface + + interface + subroutine z_mumps_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info,init,initu) + import :: psb_desc_type, amg_z_mumps_solver_type, psb_z_vect_type, psb_dpk_, psb_spk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_mumps_solver_type), intent(inout) :: sv + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + end subroutine z_mumps_solver_apply + end interface + + interface + subroutine z_mumps_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + import :: psb_desc_type, amg_z_mumps_solver_type, psb_z_vect_type, psb_dpk_, & + & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type,& + & psb_ipk_, psb_i_base_vect_type + + Implicit None + + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine z_mumps_solver_bld + end interface + +contains + + subroutine z_mumps_solver_clone_settings(sv,svout,info) + + use psb_base_mod + Implicit None + ! Arguments + class(amg_z_mumps_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: k,err_act + character(len=20) :: name='z_mumps_solver_clone_settings' + + info = 0 + +#if defined(HAVE_MUMPS_) + + call psb_erractionsave(err_act) + + select type(svout) + class is(amg_z_mumps_solver_type) + svout%ipar(:) = sv%ipar(:) + svout%built = .false. + if (allocated(svout%icntl)) deallocate(svout%icntl,stat=info) + if (info == 0) allocate(svout%icntl(amg_mumps_icntl_size),stat=info) + if (info == 0) then + do k=1,amg_mumps_icntl_size + call psb_safe_ab_cpy(sv%icntl(k)%item,svout%icntl(k)%item,info) + end do + end if + + if (allocated(svout%rcntl)) deallocate(svout%rcntl,stat=info) + if (info == 0) allocate(svout%rcntl(amg_mumps_rcntl_size),stat=info) + if (info == 0) then + do k=1,amg_mumps_rcntl_size + call psb_safe_ab_cpy(sv%rcntl(k)%item,svout%rcntl(k)%item,info) + end do + end if + + class default + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +#endif + end subroutine z_mumps_solver_clone_settings + + subroutine z_mumps_solver_clear_data(sv,info) + use psb_base_mod, only : psb_exit + Implicit None + + ! Arguments + class(amg_z_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + Integer(psb_ipk_) :: err_act + character(len=20) :: name='z_mumps_solver_clear_data' + + info = 0 +#if defined(HAVE_MUMPS_) + call psb_erractionsave(err_act) + if (allocated(sv%id)) then + if (sv%built) then + sv%id%job = -2 + call zmumps(sv%id) + info = sv%id%infog(1) + if (info /= psb_success_) goto 9999 + end if + deallocate(sv%id, stat=info) + if (allocated(sv%local_ictxt)) then + call psb_exit(sv%local_ictxt,close=.false.) + deallocate(sv%local_ictxt,stat=info) + end if + sv%built=.false. + end if + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +#endif + end subroutine z_mumps_solver_clear_data + + subroutine z_mumps_solver_free(sv,info) + use psb_base_mod, only : psb_exit + Implicit None + + ! Arguments + class(amg_z_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + Integer(psb_ipk_) :: err_act + character(len=20) :: name='z_mumps_solver_free' + + info = 0 +#if defined(HAVE_MUMPS_) + call psb_erractionsave(err_act) + call sv%clear_data(info) + if ((info == 0).and.allocated(sv%icntl)) deallocate(sv%icntl,stat=info) + if ((info == 0).and.allocated(sv%rcntl)) deallocate(sv%rcntl,stat=info) + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +#endif + end subroutine z_mumps_solver_free + +subroutine z_mumps_solver_finalize(sv) + + Implicit None + + ! Arguments + type(amg_z_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_) :: info + Integer(psb_ipk_) :: err_act + character(len=20) :: name='z_mumps_solver_finalize' + + call sv%free(info) + + return + +end subroutine z_mumps_solver_finalize + +subroutine z_mumps_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_z_mumps_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt, me, np + character(len=20), parameter :: name='amg_z_mumps_solver_descr' + integer(psb_ipk_) :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' MUMPS Solver. ' + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +end subroutine z_mumps_solver_descr + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! WARNING: OTHER PARAMETERS OF MUMPS COULD BE ADDED. !! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + +subroutine z_mumps_solver_csetc(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_z_mumps_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_mumps_solver_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + + + select case(psb_toupper(trim(what))) +#if defined(HAVE_MUMPS_) + case('MUMPS_LOC_GLOB') + sv%ipar(1) = sv%stringval(psb_toupper(trim(val))) +#endif + case default + call sv%amg_z_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +end subroutine z_mumps_solver_csetc + + +subroutine z_mumps_solver_cseti(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_z_mumps_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_mumps_solver_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) +#if defined(HAVE_MUMPS_) + case('MUMPS_LOC_GLOB') + sv%ipar(1) = val + case('MUMPS_PRINT_ERR') + sv%ipar(2) = val + case('MUMPS_SYM') + sv%ipar(3) = val + case('MUMPS_IPAR_ENTRY') + if(present(idx)) then + ! Note: this will allocate %item + sv%icntl(idx)%item = val + end if +#endif + case default + call sv%amg_z_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +end subroutine z_mumps_solver_cseti + +subroutine z_mumps_solver_csetr(sv,what,val,info,idx) + + Implicit None + + ! Arguments + class(amg_z_mumps_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_mumps_solver_csetr' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) +#if defined(HAVE_MUMPS_) + case('MUMPS_RPAR_ENTRY') + if(present(idx)) then + ! Note: this will allocate %item + sv%rcntl(idx)%item = val + end if +#endif + case default + call sv%amg_z_base_solver_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +end subroutine z_mumps_solver_csetr + +!!NOTE: BY DEFAULT BLR is activated with a dropping parameter to 1d-4 !! +subroutine z_mumps_solver_default(sv) + + Implicit none + + !Argument + class(amg_z_mumps_solver_type),intent(inout) :: sv + integer(psb_ipk_) :: info + integer(psb_ipk_) :: err_act,ictx,icomm + character(len=20) :: name='z_mumps_default' + + info = psb_success_ + call psb_erractionsave(err_act) + +#if defined(HAVE_MUMPS_) + if (.not.allocated(sv%id)) then + allocate(sv%id,stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_dealloc_ + call psb_errpush(info,name,a_err='amg_zmumps_default') + goto 9999 + end if + sv%built=.false. + end if + if (.not.allocated(sv%icntl)) then + allocate(sv%icntl(amg_mumps_icntl_size),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_dealloc_ + call psb_errpush(info,name,a_err='amg_zmumps_default') + goto 9999 + end if + end if + if (.not.allocated(sv%rcntl)) then + allocate(sv%rcntl(amg_mumps_rcntl_size),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_dealloc_ + call psb_errpush(info,name,a_err='amg_zmumps_default') + goto 9999 + end if + end if + ! INSTANTIATION OF sv%id needed to set parmater but mpi communicator needed + ! sv%id%job = -1 + ! sv%id%par=1 + ! call dmumps(sv%id) + sv%ipar = 0 + sv%ipar(1) = amg_global_solver_ + !sv%ipar(10)=6 + !sv%ipar(11)=0 + !sv%ipar(12)=6 + +#endif + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return + +end subroutine z_mumps_solver_default + +function z_mumps_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_z_mumps_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer :: i +#if defined(HAVE_MUMPS_) + val = (sv%id%INFOG(22)+sv%id%INFOG(32))*1d+6 +#else + val = 0 +#endif + ! val = 2*psb_sizeof_ip + psb_sizeof_dp + ! val = val + sv%symbsize + ! val = val + sv%numsize + return +end function z_mumps_solver_sizeof + +function z_mumps_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "MUMPS solver" +end function z_mumps_solver_get_fmt + +function z_mumps_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_mumps_ +end function z_mumps_solver_get_id + + +function z_mumps_solver_is_global(sv) result(val) + implicit none + class(amg_z_mumps_solver_type), intent(in) :: sv + logical :: val + + val = (sv%ipar(1) == amg_global_solver_ ) +end function z_mumps_solver_is_global + +end module amg_z_mumps_solver + diff --git a/mlprec/amg_z_onelev_mod.f90 b/mlprec/amg_z_onelev_mod.f90 new file mode 100644 index 00000000..ea0d7b3d --- /dev/null +++ b/mlprec/amg_z_onelev_mod.f90 @@ -0,0 +1,824 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_z_onelev_mod.f90 +! +! Module: amg_z_onelev_mod +! +! This module defines: +! - the amg_z_onelev_type data structure containing one level +! of a multilevel preconditioner and related +! data structures; +! +! It contains routines for +! - Building and applying; +! - checking if the preconditioner is correctly defined; +! - printing a description of the preconditioner; +! - deallocating the preconditioner data structure. +! + +module amg_z_onelev_mod + + use amg_base_prec_type + use amg_z_base_smoother_mod + use amg_z_dec_aggregator_mod + use psb_base_mod, only : psb_zspmat_type, psb_z_vect_type, & + & psb_z_base_vect_type, psb_lzspmat_type, psb_zlinmap_type, psb_dpk_, & + & psb_ipk_, psb_epk_, psb_lpk_, psb_desc_type, psb_i_base_vect_type, & + & psb_erractionsave, psb_error_handler + ! + ! + ! Type: amg_zonelev_type. + ! + ! It is the data type containing the necessary items for the current + ! level (essentially, the smoother, the current-level matrix + ! and the restriction and prolongation operators). + ! + ! type amg_zonelev_type + ! class(amg_z_base_smoother_type), allocatable :: sm, sm2a + ! class(amg_z_base_smoother_type), pointer :: sm2 => null() + ! class(amg_zmlprec_wrk_type), allocatable :: wrk + ! class(amg_z_base_aggregator_type), allocatable :: aggr + ! type(amg_dml_parms) :: parms + ! type(psb_zspmat_type) :: ac + ! type(psb_zesc_type) :: desc_ac + ! type(psb_zspmat_type), pointer :: base_a => null() + ! type(psb_desc_type), pointer :: base_desc => null() + ! type(psb_zlinmap_type) :: map + ! end type amg_zonelev_type + ! + ! Note that d denotes the kind of the real data type to be chosen + ! according to single/double precision version of MLD2P4. + ! + ! sm,sm2a - class(amg_z_base_smoother_type), allocatable + ! The current level pre- and post-smooother. + ! sm2 - class(amg_z_base_smoother_type), pointer + ! The current level post-smooother; if sm2a is allocated + ! explicitly, then sm2 => sm2a, otherwise sm2 => sm. + ! wrk - class(amg_zmlprec_wrk_type), allocatable + ! Workspace for application of preconditioner; may be + ! pre-allocated to save time in the application within a + ! Krylov solver. + ! aggr - class(amg_z_base_aggregator_type), allocatable + ! The aggregator object: holds the algorithmic choices and + ! (possibly) additional data for building the aggregation. + ! parms - type(amg_dml_parms) + ! The parameters defining the multilevel strategy. + ! ac - The local part of the current-level matrix, built by + ! coarsening the previous-level matrix. + ! desc_ac - type(psb_desc_type). + ! The communication descriptor associated to the matrix + ! stored in ac. + ! base_a - type(psb_zspmat_type), pointer. + ! Pointer (really a pointer!) to the local part of the current + ! matrix (so we have a unified treatment of residuals). + ! We need this to avoid passing explicitly the current matrix + ! to the routine which applies the preconditioner. + ! base_desc - type(psb_desc_type), pointer. + ! Pointer to the communication descriptor associated to the + ! matrix pointed by base_a. + ! map - Stores the maps (restriction and prolongation) between the + ! vector spaces associated to the index spaces of the previous + ! and current levels. + ! + ! Methods: + ! Most methods follow the encapsulation hierarchy: they take whatever action + ! is appropriate for the current object, then call the corresponding method for + ! the contained object. + ! As an example: the descr() method prints out a description of the + ! level. It starts by invoking the descr() method of the parms object, + ! then calls the descr() method of the smoother object. + ! + ! descr - Prints a description of the object. + ! default - Set default values + ! dump - Dump to file object contents + ! set - Sets various parameters; when a request is unknown + ! it is passed to the smoother object for further processing. + ! check - Sanity checks. + ! sizeof - Total memory occupation in bytes + ! get_nzeros - Number of nonzeros + ! get_wrksz - How many workspace vector does apply_vect need + ! allocate_wrk - Allocate auxiliary workspace + ! free_wrk - Free auxiliary workspace + ! bld_tprol - Invoke the aggr method to build the tentative prolongator + ! mat_asb - Build the final (possibly smoothed) prolongator and coarse matrix. + ! + ! + type amg_zmlprec_wrk_type + complex(psb_dpk_), allocatable :: tx(:), ty(:), x2l(:), y2l(:) + type(psb_z_vect_type) :: vtx, vty, vx2l, vy2l + type(psb_z_vect_type), allocatable :: wv(:) + contains + procedure, pass(wk) :: alloc => z_wrk_alloc + procedure, pass(wk) :: free => z_wrk_free + procedure, pass(wk) :: clone => z_wrk_clone + procedure, pass(wk) :: move_alloc => z_wrk_move_alloc + procedure, pass(wk) :: cnv => z_wrk_cnv + procedure, pass(wk) :: sizeof => z_wrk_sizeof + end type amg_zmlprec_wrk_type + private :: z_wrk_alloc, z_wrk_free, & + & z_wrk_clone, z_wrk_move_alloc, z_wrk_cnv, z_wrk_sizeof + + type amg_z_onelev_type + class(amg_z_base_smoother_type), allocatable :: sm, sm2a + class(amg_z_base_smoother_type), pointer :: sm2 => null() + class(amg_zmlprec_wrk_type), allocatable :: wrk + class(amg_z_base_aggregator_type), allocatable :: aggr + type(amg_dml_parms) :: parms + type(psb_zspmat_type) :: ac + integer(psb_ipk_) :: ac_nz_loc + integer(psb_lpk_) :: ac_nz_tot + type(psb_desc_type) :: desc_ac + type(psb_zspmat_type), pointer :: base_a => null() + type(psb_desc_type), pointer :: base_desc => null() + type(psb_lzspmat_type) :: tprol + type(psb_zlinmap_type) :: map + real(psb_dpk_) :: szratio + contains + procedure, pass(lv) :: bld_tprol => z_base_onelev_bld_tprol + procedure, pass(lv) :: mat_asb => amg_z_base_onelev_mat_asb + procedure, pass(lv) :: update_aggr => z_base_onelev_update_aggr + procedure, pass(lv) :: bld => amg_z_base_onelev_build + procedure, pass(lv) :: clone => z_base_onelev_clone + procedure, pass(lv) :: cnv => amg_z_base_onelev_cnv + procedure, pass(lv) :: descr => amg_z_base_onelev_descr + procedure, pass(lv) :: default => z_base_onelev_default + procedure, pass(lv) :: free => amg_z_base_onelev_free + procedure, pass(lv) :: nullify => z_base_onelev_nullify + procedure, pass(lv) :: check => amg_z_base_onelev_check + procedure, pass(lv) :: dump => amg_z_base_onelev_dump + procedure, pass(lv) :: cseti => amg_z_base_onelev_cseti + procedure, pass(lv) :: csetr => amg_z_base_onelev_csetr + procedure, pass(lv) :: csetc => amg_z_base_onelev_csetc + procedure, pass(lv) :: setsm => amg_z_base_onelev_setsm + procedure, pass(lv) :: setsv => amg_z_base_onelev_setsv + procedure, pass(lv) :: setag => amg_z_base_onelev_setag + generic, public :: set => cseti, csetr, csetc, setsm, setsv, setag + procedure, pass(lv) :: sizeof => z_base_onelev_sizeof + procedure, pass(lv) :: get_nzeros => z_base_onelev_get_nzeros + procedure, pass(lv) :: get_wrksz => z_base_onelev_get_wrksize + procedure, pass(lv) :: allocate_wrk => z_base_onelev_allocate_wrk + procedure, pass(lv) :: free_wrk => z_base_onelev_free_wrk + procedure, nopass :: stringval => amg_stringval + procedure, pass(lv) :: move_alloc => z_base_onelev_move_alloc + + end type amg_z_onelev_type + + type amg_z_onelev_node + type(amg_z_onelev_type) :: item + type(amg_z_onelev_node), pointer :: prev=>null(), next=>null() + end type amg_z_onelev_node + + private :: z_base_onelev_default, z_base_onelev_sizeof, & + & z_base_onelev_nullify, z_base_onelev_get_nzeros, & + & z_base_onelev_clone, z_base_onelev_move_alloc, & + & z_base_onelev_get_wrksize, z_base_onelev_allocate_wrk, & + & z_base_onelev_free_wrk + + interface + subroutine amg_z_base_onelev_mat_asb(lv,a,desc_a,ilaggr,nlaggr,t_prol,info) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, psb_ipk_, psb_lzspmat_type, psb_lpk_ + import :: amg_z_onelev_type + implicit none + class(amg_z_onelev_type), intent(inout), target :: lv + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:),nlaggr(:) + type(psb_lzspmat_type), intent(inout) :: t_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_base_onelev_mat_asb + end interface + + interface + subroutine amg_z_base_onelev_build(lv,info,amold,vmold,imold,ilv) + import :: psb_z_base_sparse_mat, psb_z_base_vect_type, & + & psb_i_base_vect_type, psb_dpk_, amg_z_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + implicit none + class(amg_z_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + integer(psb_ipk_), intent(in), optional :: ilv + end subroutine amg_z_base_onelev_build + end interface + + interface + subroutine amg_z_base_onelev_descr(lv,il,nl,ilmin,info,iout) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_zlinmap_type, psb_dpk_, amg_z_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + ! Arguments + class(amg_z_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: il,nl,ilmin + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + end subroutine amg_z_base_onelev_descr + end interface + + interface + subroutine amg_z_base_onelev_cnv(lv,info,amold,vmold,imold) + import :: amg_z_onelev_type, psb_z_base_vect_type, psb_dpk_, & + & psb_z_base_sparse_mat, psb_ipk_, psb_i_base_vect_type + ! Arguments + class(amg_z_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + end subroutine amg_z_base_onelev_cnv + end interface + +interface + subroutine amg_z_base_onelev_free(lv,info) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_zlinmap_type, psb_dpk_, amg_z_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + implicit none + + class(amg_z_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_base_onelev_free + end interface + + interface + subroutine amg_z_base_onelev_check(lv,info) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_zlinmap_type, psb_dpk_, amg_z_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + ! Arguments + class(amg_z_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_base_onelev_check + end interface + + interface + subroutine amg_z_base_onelev_setsm(lv,val,info,pos) + import :: psb_dpk_, amg_z_onelev_type, amg_z_base_smoother_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + ! Arguments + class(amg_z_onelev_type), target, intent(inout) :: lv + class(amg_z_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + end subroutine amg_z_base_onelev_setsm + end interface + + interface + subroutine amg_z_base_onelev_setsv(lv,val,info,pos) + import :: psb_dpk_, amg_z_onelev_type, amg_z_base_solver_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + ! Arguments + class(amg_z_onelev_type), target, intent(inout) :: lv + class(amg_z_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + end subroutine amg_z_base_onelev_setsv + end interface + + interface + subroutine amg_z_base_onelev_setag(lv,val,info,pos) + import :: psb_dpk_, amg_z_onelev_type, amg_z_base_aggregator_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + ! Arguments + class(amg_z_onelev_type), target, intent(inout) :: lv + class(amg_z_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + end subroutine amg_z_base_onelev_setag + end interface + + interface + subroutine amg_z_base_onelev_cseti(lv,what,val,info,pos,idx) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_zlinmap_type, psb_dpk_, amg_z_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + ! Arguments + class(amg_z_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_z_base_onelev_cseti + end interface + + interface + subroutine amg_z_base_onelev_csetc(lv,what,val,info,pos,idx) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_zlinmap_type, psb_dpk_, amg_z_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + ! Arguments + class(amg_z_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_z_base_onelev_csetc + end interface + + interface + subroutine amg_z_base_onelev_csetr(lv,what,val,info,pos,idx) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_zlinmap_type, psb_dpk_, amg_z_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + Implicit None + + class(amg_z_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + end subroutine amg_z_base_onelev_csetr + end interface + + interface + subroutine amg_z_base_onelev_dump(lv,level,info,prefix,head,ac,rp,smoother,& + & solver,tprol,global_num) + import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & + & psb_zlinmap_type, psb_dpk_, amg_z_onelev_type, & + & psb_ipk_, psb_epk_, psb_desc_type + implicit none + class(amg_z_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: ac, rp, smoother, solver, tprol, global_num + end subroutine amg_z_base_onelev_dump + end interface + +contains + ! + ! Function returning the size of the amg_prec_type data structure + ! in bytes or in number of nonzeros of the operator(s) involved. + ! + + function z_base_onelev_get_nzeros(lv) result(val) + implicit none + class(amg_z_onelev_type), intent(in) :: lv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + if (allocated(lv%sm)) & + & val = lv%sm%get_nzeros() + if (allocated(lv%sm2a)) & + & val = val + lv%sm2a%get_nzeros() + end function z_base_onelev_get_nzeros + + function z_base_onelev_sizeof(lv) result(val) + implicit none + class(amg_z_onelev_type), intent(in) :: lv + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + + val = psb_sizeof_ip+psb_sizeof_lp + val = val + lv%desc_ac%sizeof() + val = val + lv%ac%sizeof() + val = val + lv%tprol%sizeof() + val = val + lv%map%sizeof() + if (allocated(lv%sm)) val = val + lv%sm%sizeof() + if (allocated(lv%sm2a)) val = val + lv%sm2a%sizeof() + if (allocated(lv%aggr)) val = val + lv%aggr%sizeof() + if (allocated(lv%wrk)) val = val + lv%wrk%sizeof() + end function z_base_onelev_sizeof + + + subroutine z_base_onelev_nullify(lv) + implicit none + + class(amg_z_onelev_type), intent(inout) :: lv + + nullify(lv%base_a) + nullify(lv%base_desc) + nullify(lv%sm2) + end subroutine z_base_onelev_nullify + + ! + ! Multilevel defaults: + ! multiplicative vs. additive ML framework; + ! Smoothed decoupled aggregation with zero threshold; + ! distributed coarse matrix; + ! damping omega computed with the max-norm estimate of the + ! dominant eigenvalue; + ! two-sided smoothing (i.e. V-cycle) with 1 smoothing sweep; + ! + + subroutine z_base_onelev_default(lv) + + Implicit None + + ! Arguments + class(amg_z_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_) :: info + + lv%parms%sweeps_pre = 1 + lv%parms%sweeps_post = 1 + lv%parms%ml_cycle = amg_vcycle_ml_ + lv%parms%aggr_type = amg_soc1_ + lv%parms%par_aggr_alg = amg_dec_aggr_ + lv%parms%aggr_ord = amg_aggr_ord_nat_ + lv%parms%aggr_prol = amg_smooth_prol_ + lv%parms%coarse_mat = amg_distr_mat_ + lv%parms%aggr_omega_alg = amg_eig_est_ + lv%parms%aggr_eig = amg_max_norm_ + lv%parms%aggr_filter = amg_no_filter_mat_ + lv%parms%aggr_omega_val = dzero + lv%parms%aggr_thresh = 0.01_psb_dpk_ + + if (allocated(lv%sm)) call lv%sm%default() + if (allocated(lv%sm2a)) then + call lv%sm2a%default() + lv%sm2 => lv%sm2a + else + lv%sm2 => lv%sm + end if + if (.not.allocated(lv%aggr)) allocate(amg_z_dec_aggregator_type :: lv%aggr,stat=info) + if (allocated(lv%aggr)) call lv%aggr%default() + + return + + end subroutine z_base_onelev_default + + subroutine z_base_onelev_bld_tprol(lv,a,desc_a,& + & ilaggr,nlaggr,t_prol,ag_data,info) + implicit none + class(amg_z_onelev_type), intent(inout), target :: lv + type(psb_zspmat_type), intent(inout) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lzspmat_type), intent(out) :: t_prol + type(amg_daggr_data), intent(in) :: ag_data + integer(psb_ipk_), intent(out) :: info + + call lv%aggr%bld_tprol(lv%parms,ag_data,a,desc_a,ilaggr,nlaggr,t_prol,info) + + end subroutine z_base_onelev_bld_tprol + + + subroutine z_base_onelev_update_aggr(lv,lvnext,info) + implicit none + class(amg_z_onelev_type), intent(inout), target :: lv, lvnext + integer(psb_ipk_), intent(out) :: info + + call lv%aggr%update_next(lvnext%aggr,info) + + end subroutine z_base_onelev_update_aggr + + + subroutine z_base_onelev_clone(lv,lvout,info) + + Implicit None + + ! Arguments + class(amg_z_onelev_type), target, intent(inout) :: lv + class(amg_z_onelev_type), target, intent(inout) :: lvout + integer(psb_ipk_), intent(out) :: info + + info = psb_success_ + if (allocated(lv%sm)) then + call lv%sm%clone(lvout%sm,info) + else + if (allocated(lvout%sm)) then + call lvout%sm%free(info) + if (info==psb_success_) deallocate(lvout%sm,stat=info) + end if + end if + if (allocated(lv%sm2a)) then + call lv%sm%clone(lvout%sm2a,info) + lvout%sm2 => lvout%sm2a + else + if (allocated(lvout%sm2a)) then + call lvout%sm2a%free(info) + if (info==psb_success_) deallocate(lvout%sm2a,stat=info) + end if + lvout%sm2 => lvout%sm + end if + if (allocated(lv%aggr)) then + call lv%aggr%clone(lvout%aggr,info) + else + if (allocated(lvout%aggr)) then + call lvout%aggr%free(info) + if (info==psb_success_) deallocate(lvout%aggr,stat=info) + end if + end if + if (info == psb_success_) call lv%parms%clone(lvout%parms,info) + if (info == psb_success_) call lv%ac%clone(lvout%ac,info) + if (info == psb_success_) call lv%tprol%clone(lvout%tprol,info) + if (info == psb_success_) call lv%desc_ac%clone(lvout%desc_ac,info) + if (info == psb_success_) call lv%map%clone(lvout%map,info) + lvout%base_a => lv%base_a + lvout%base_desc => lv%base_desc + + return + + end subroutine z_base_onelev_clone + + subroutine z_base_onelev_move_alloc(lv, b,info) + use psb_base_mod + implicit none + class(amg_z_onelev_type), target, intent(inout) :: lv, b + integer(psb_ipk_), intent(out) :: info + + call b%free(info) + b%parms = lv%parms + b%szratio = lv%szratio + if (associated(lv%sm2,lv%sm2a)) then + call move_alloc(lv%sm,b%sm) + call move_alloc(lv%sm2a,b%sm2a) + b%sm2 =>b%sm2a + else + call move_alloc(lv%sm,b%sm) + call move_alloc(lv%sm2a,b%sm2a) + b%sm2 =>b%sm + end if + + call move_alloc(lv%aggr,b%aggr) + if (info == psb_success_) call psb_move_alloc(lv%ac,b%ac,info) + if (info == psb_success_) call psb_move_alloc(lv%tprol,b%tprol,info) + if (info == psb_success_) call psb_move_alloc(lv%desc_ac,b%desc_ac,info) + if (info == psb_success_) call psb_move_alloc(lv%map,b%map,info) + b%base_a => lv%base_a + b%base_desc => lv%base_desc + + end subroutine z_base_onelev_move_alloc + + + function z_base_onelev_get_wrksize(lv) result(val) + implicit none + class(amg_z_onelev_type), intent(inout) :: lv + integer(psb_ipk_) :: val + + val = 0 + ! SM and SM2A can share work vectors + if (allocated(lv%sm)) val = val + lv%sm%get_wrksz() + if (allocated(lv%sm2a)) val = max(val,lv%sm2a%get_wrksz()) + ! + ! Now for the ML application itself + ! + + ! VTX/VTY/VX2L/VY2L are stored explicitly + ! + + ! + ! additions for specific ML/cycles + ! + select case(lv%parms%ml_cycle) + case(amg_add_ml_,amg_mult_ml_,amg_vcycle_ml_, amg_wcycle_ml_) + ! We're good + + case(amg_kcycle_ml_, amg_kcyclesym_ml_) + ! + ! We need 7 in inneritkcycle. + ! Can we reuse vtx? + ! + val = val + 7 + + case default + ! Need a better error signaling ? + val = -1 + end select + + end function z_base_onelev_get_wrksize + + subroutine z_base_onelev_allocate_wrk(lv,info,vmold) + use psb_base_mod + implicit none + class(amg_z_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_vect_type), intent(in), optional :: vmold + ! + integer(psb_ipk_) :: nwv, i + info = psb_success_ + nwv = lv%get_wrksz() + if (.not.allocated(lv%wrk)) allocate(lv%wrk,stat=info) + if (info == 0) call lv%wrk%alloc(nwv,lv%base_desc,info,vmold=vmold) + + end subroutine z_base_onelev_allocate_wrk + + + subroutine z_base_onelev_free_wrk(lv,info) + use psb_base_mod + implicit none + class(amg_z_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: nwv,i + info = psb_success_ + + if (allocated(lv%wrk)) then + call lv%wrk%free(info) + if (info == 0) deallocate(lv%wrk,stat=info) + end if + end subroutine z_base_onelev_free_wrk + + subroutine z_wrk_alloc(wk,nwv,desc,info,vmold) + use psb_base_mod + + Implicit None + + ! Arguments + class(amg_zmlprec_wrk_type), target, intent(inout) :: wk + integer(psb_ipk_), intent(in) :: nwv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_vect_type), intent(in), optional :: vmold + ! + integer(psb_ipk_) :: i + + info = psb_success_ + call wk%free(info) + call psb_geasb(wk%vx2l,desc,info,& + & scratch=.true.,mold=vmold) + call psb_geasb(wk%vy2l,desc,info,& + & scratch=.true.,mold=vmold) + call psb_geasb(wk%vtx,desc,info,& + & scratch=.true.,mold=vmold) + call psb_geasb(wk%vty,desc,info,& + & scratch=.true.,mold=vmold) + allocate(wk%wv(nwv),stat=info) + do i=1,nwv + call psb_geasb(wk%wv(i),desc,info,& + & scratch=.true.,mold=vmold) + end do + + end subroutine z_wrk_alloc + + subroutine z_wrk_free(wk,info) + + Implicit None + + ! Arguments + class(amg_zmlprec_wrk_type), target, intent(inout) :: wk + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: i + info = psb_success_ + + if (allocated(wk%tx)) deallocate(wk%tx, stat=info) + if (allocated(wk%ty)) deallocate(wk%ty, stat=info) + if (allocated(wk%x2l)) deallocate(wk%x2l, stat=info) + if (allocated(wk%y2l)) deallocate(wk%y2l, stat=info) + call wk%vtx%free(info) + call wk%vty%free(info) + call wk%vx2l%free(info) + call wk%vy2l%free(info) + if (allocated(wk%wv)) then + do i=1,size(wk%wv) + call wk%wv(i)%free(info) + end do + deallocate(wk%wv, stat=info) + end if + + end subroutine z_wrk_free + + subroutine z_wrk_clone(wk,wkout,info) + use psb_base_mod + Implicit None + + ! Arguments + class(amg_zmlprec_wrk_type), target, intent(inout) :: wk + class(amg_zmlprec_wrk_type), target, intent(inout) :: wkout + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: i + info = psb_success_ + + call psb_safe_ab_cpy(wk%tx,wkout%tx,info) + call psb_safe_ab_cpy(wk%ty,wkout%ty,info) + call psb_safe_ab_cpy(wk%x2l,wkout%x2l,info) + call psb_safe_ab_cpy(wk%y2l,wkout%y2l,info) + call wk%vtx%clone(wkout%vtx,info) + call wk%vty%clone(wkout%vty,info) + call wk%vx2l%clone(wkout%vx2l,info) + call wk%vy2l%clone(wkout%vy2l,info) + if (allocated(wkout%wv)) then + do i=1,size(wkout%wv) + call wkout%wv(i)%free(info) + end do + deallocate( wkout%wv) + end if + allocate(wkout%wv(size(wk%wv)),stat=info) + do i=1,size(wk%wv) + call wk%wv(i)%clone(wkout%wv(i),info) + end do + return + + end subroutine z_wrk_clone + + subroutine z_wrk_move_alloc(wk, b,info) + implicit none + class(amg_zmlprec_wrk_type), target, intent(inout) :: wk, b + integer(psb_ipk_), intent(out) :: info + + call b%free(info) + call move_alloc(wk%tx,b%tx) + call move_alloc(wk%ty,b%ty) + call move_alloc(wk%x2l,b%x2l) + call move_alloc(wk%y2l,b%y2l) + ! + ! Should define V%move_alloc.... + call move_alloc(wk%vtx%v,b%vtx%v) + call move_alloc(wk%vty%v,b%vty%v) + call move_alloc(wk%vx2l%v,b%vx2l%v) + call move_alloc(wk%vy2l%v,b%vy2l%v) + call move_alloc(wk%wv,b%wv) + + end subroutine z_wrk_move_alloc + + subroutine z_wrk_cnv(wk,info,vmold) + use psb_base_mod + + Implicit None + + ! Arguments + class(amg_zmlprec_wrk_type), target, intent(inout) :: wk + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_vect_type), intent(in), optional :: vmold + ! + integer(psb_ipk_) :: i + + info = psb_success_ + if (present(vmold)) then + call wk%vtx%cnv(vmold) + call wk%vty%cnv(vmold) + call wk%vx2l%cnv(vmold) + call wk%vy2l%cnv(vmold) + if (allocated(wk%wv)) then + do i=1,size(wk%wv) + call wk%wv(i)%cnv(vmold) + end do + end if + end if + end subroutine z_wrk_cnv + + function z_wrk_sizeof(wk) result(val) + use psb_realloc_mod + implicit none + class(amg_zmlprec_wrk_type), intent(in) :: wk + integer(psb_epk_) :: val + integer :: i + val = 0 + val = val + (1_psb_epk_ * (2*psb_sizeof_dp)) * psb_size(wk%tx) + val = val + (1_psb_epk_ * (2*psb_sizeof_dp)) * psb_size(wk%ty) + val = val + (1_psb_epk_ * (2*psb_sizeof_dp)) * psb_size(wk%x2l) + val = val + (1_psb_epk_ * (2*psb_sizeof_dp)) * psb_size(wk%y2l) + val = val + wk%vtx%sizeof() + val = val + wk%vty%sizeof() + val = val + wk%vx2l%sizeof() + val = val + wk%vy2l%sizeof() + if (allocated(wk%wv)) then + do i=1, size(wk%wv) + val = val + wk%wv(i)%sizeof() + end do + end if + end function z_wrk_sizeof + +end module amg_z_onelev_mod diff --git a/mlprec/amg_z_prec_mod.f90 b/mlprec/amg_z_prec_mod.f90 new file mode 100644 index 00000000..35f4f89e --- /dev/null +++ b/mlprec/amg_z_prec_mod.f90 @@ -0,0 +1,139 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_z_prec_mod.f90 +! +! Module: amg_z_prec_mod +! +! This module defines the user interfaces to the real/complex, single/double +! precision versions of the user-level MLD2P4 routines. +! +module amg_z_prec_mod + + use amg_z_prec_type + use amg_z_jac_smoother + use amg_z_as_smoother + use amg_z_id_solver + use amg_z_diag_solver + use amg_z_l1_diag_solver + use amg_z_ilu_solver + use amg_z_gs_solver + + interface amg_precset + module procedure amg_z_iprecsetsm, amg_z_iprecsetsv, & + & amg_z_cprecseti, amg_z_cprecsetc, amg_z_cprecsetr, & + & amg_z_iprecsetag + end interface amg_precset + + interface amg_extprol_bld + subroutine amg_z_extprol_bld(a,desc_a,p,prolv,restrv,info,amold,vmold,imold) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & + & psb_z_base_sparse_mat, psb_z_base_vect_type, & + & psb_i_base_vect_type, amg_zprec_type, psb_ipk_ + + ! Arguments + type(psb_zspmat_type),intent(in), target :: a + type(psb_zspmat_type),intent(inout), target :: prolv(:) + type(psb_zspmat_type),intent(inout), target :: restrv(:) + type(psb_desc_type), intent(inout), target :: desc_a + type(amg_zprec_type),intent(inout),target :: p + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! !$ character, intent(in), optional :: upd + end subroutine amg_z_extprol_bld + end interface amg_extprol_bld + +contains + + subroutine amg_z_iprecsetsm(p,val,info,pos) + type(amg_zprec_type), intent(inout) :: p + class(amg_z_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + call p%set(val,info,pos=pos) + end subroutine amg_z_iprecsetsm + + subroutine amg_z_iprecsetsv(p,val,info,pos) + type(amg_zprec_type), intent(inout) :: p + class(amg_z_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + call p%set(val,info, pos=pos) + end subroutine amg_z_iprecsetsv + + subroutine amg_z_iprecsetag(p,val,info,pos) + type(amg_zprec_type), intent(inout) :: p + class(amg_z_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + call p%set(val,info, pos=pos) + end subroutine amg_z_iprecsetag + + subroutine amg_z_cprecseti(p,what,val,info,pos) + type(amg_zprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + call p%set(what,val,info,pos=pos) + end subroutine amg_z_cprecseti + + subroutine amg_z_cprecsetr(p,what,val,info,pos) + type(amg_zprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + call p%set(what,val,info,pos=pos) + end subroutine amg_z_cprecsetr + + subroutine amg_z_cprecsetc(p,what,val,info,pos) + type(amg_zprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + call p%set(what,val,info,pos=pos) + end subroutine amg_z_cprecsetc + +end module amg_z_prec_mod diff --git a/mlprec/amg_z_prec_type.f90 b/mlprec/amg_z_prec_type.f90 new file mode 100644 index 00000000..420a45c1 --- /dev/null +++ b/mlprec/amg_z_prec_type.f90 @@ -0,0 +1,964 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_z_prec_type.f90 +! +! Module: amg_z_prec_type +! +! This module defines: +! - the amg_z_prec_type data structure containing the preconditioner and related +! data structures; +! +! It contains routines for +! - Building and applying; +! - checking if the preconditioner is correctly defined; +! - printing a description of the preconditioner; +! - deallocating the preconditioner data structure. +! + +module amg_z_prec_type + + use amg_base_prec_type + use amg_z_base_solver_mod + use amg_z_base_smoother_mod + use amg_z_base_aggregator_mod + use amg_z_onelev_mod + use psb_base_mod, only : psb_erractionsave, psb_erractionrestore, psb_errstatus_fatal + use psb_prec_mod, only : psb_zprec_type + + ! + ! Type: amg_zprec_type. + ! + ! This is the data type containing all the information about the multilevel + ! preconditioner ('d', 's', 'c' and 'z', according to the real/complex, + ! single/double precision version of MLD2P4). + ! It consists of an array of 'one-level' intermediate data structures + ! of type amg_zonelev_type, each containing the information needed to apply + ! the smoothing and the coarse-space correction at a generic level. RT is the + ! real data type, i.e. S for both S and C, and D for both D and Z. + ! + ! type amg_zprec_type + ! type(amg_zonelev_type), allocatable :: precv(:) + ! end type amg_zprec_type + ! + ! Note that the levels are numbered in increasing order starting from + ! the level 1 as the finest one, and the number of levels is given by + ! size(precv(:)) which is the id of the coarsest level. + ! In the multigrid literature many authors number the levels in the opposite + ! order, with level 0 being the id of the coarsest level. + ! + ! + integer, parameter, private :: wv_size_=4 + + type, extends(psb_zprec_type) :: amg_zprec_type + ! integer(psb_ipk_) :: ictxt ! Now it's in the PSBLAS prec. + type(amg_daggr_data) :: ag_data + ! + ! Number of outer sweeps. Sometimes 2 V-cycles may be better than 1 W-cycle. + ! + integer(psb_ipk_) :: outer_sweeps = 1 + ! + ! Coarse solver requires some tricky checks, and for this we need to + ! record the choice in the format given by the user, + ! to keep track against what is put later in the multilevel array + ! + integer(psb_ipk_) :: coarse_solver = -1 + + ! + ! The multilevel hierarchy + ! + type(amg_z_onelev_type), allocatable :: precv(:) + contains + procedure, pass(prec) :: psb_z_apply2_vect => amg_z_apply2_vect + procedure, pass(prec) :: psb_z_apply1_vect => amg_z_apply1_vect + procedure, pass(prec) :: psb_z_apply2v => amg_z_apply2v + procedure, pass(prec) :: psb_z_apply1v => amg_z_apply1v + procedure, pass(prec) :: dump => amg_z_dump + procedure, pass(prec) :: cnv => amg_z_cnv + procedure, pass(prec) :: clone => amg_z_clone + procedure, pass(prec) :: free => amg_z_prec_free + procedure, pass(prec) :: allocate_wrk => amg_z_allocate_wrk + procedure, pass(prec) :: free_wrk => amg_z_free_wrk + procedure, pass(prec) :: is_allocated_wrk => amg_z_is_allocated_wrk + procedure, pass(prec) :: get_complexity => amg_z_get_compl + procedure, pass(prec) :: cmp_complexity => amg_z_cmp_compl + procedure, pass(prec) :: get_avg_cr => amg_z_get_avg_cr + procedure, pass(prec) :: cmp_avg_cr => amg_z_cmp_avg_cr + procedure, pass(prec) :: get_nlevs => amg_z_get_nlevs + procedure, pass(prec) :: get_nzeros => amg_z_get_nzeros + procedure, pass(prec) :: sizeof => amg_zprec_sizeof + procedure, pass(prec) :: setsm => amg_zprecsetsm + procedure, pass(prec) :: setsv => amg_zprecsetsv + procedure, pass(prec) :: setag => amg_zprecsetag + procedure, pass(prec) :: cseti => amg_zcprecseti + procedure, pass(prec) :: csetc => amg_zcprecsetc + procedure, pass(prec) :: csetr => amg_zcprecsetr + generic, public :: set => cseti, csetc, csetr, setsm, setsv, setag + procedure, pass(prec) :: get_smoother => amg_z_get_smootherp + procedure, pass(prec) :: get_solver => amg_z_get_solverp + procedure, pass(prec) :: move_alloc => z_prec_move_alloc + procedure, pass(prec) :: init => amg_zprecinit + procedure, pass(prec) :: build => amg_zprecbld + procedure, pass(prec) :: hierarchy_build => amg_z_hierarchy_bld + procedure, pass(prec) :: smoothers_build => amg_z_smoothers_bld + procedure, pass(prec) :: descr => amg_zfile_prec_descr + end type amg_zprec_type + + private :: amg_z_dump, amg_z_get_compl, amg_z_cmp_compl,& + & amg_z_get_avg_cr, amg_z_cmp_avg_cr,& + & amg_z_get_nzeros, amg_z_get_nlevs, z_prec_move_alloc + + + ! + ! Interfaces to routines for checking the definition of the preconditioner, + ! for printing its description and for deallocating its data structure + ! + + interface amg_precfree + module procedure amg_zprecfree + end interface + + + interface amg_precdescr + subroutine amg_zfile_prec_descr(prec,iout,root) + import :: amg_zprec_type, psb_ipk_ + implicit none + ! Arguments + class(amg_zprec_type), intent(in) :: prec + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: root + end subroutine amg_zfile_prec_descr + end interface + + interface amg_sizeof + module procedure amg_zprec_sizeof + end interface + + interface amg_precapply + subroutine amg_zprecaply2_vect(prec,x,y,desc_data,info,trans,work) + import :: psb_zspmat_type, psb_desc_type, & + & psb_dpk_, psb_z_vect_type, amg_zprec_type, psb_ipk_ + type(psb_desc_type),intent(in) :: desc_data + type(amg_zprec_type), intent(inout) :: prec + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_dpk_),intent(inout), optional, target :: work(:) + end subroutine amg_zprecaply2_vect + subroutine amg_zprecaply1_vect(prec,x,desc_data,info,trans,work) + import :: psb_zspmat_type, psb_desc_type, & + & psb_dpk_, psb_z_vect_type, amg_zprec_type, psb_ipk_ + type(psb_desc_type),intent(in) :: desc_data + type(amg_zprec_type), intent(inout) :: prec + type(psb_z_vect_type),intent(inout) :: x + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_dpk_),intent(inout), optional, target :: work(:) + end subroutine amg_zprecaply1_vect + subroutine amg_zprecaply(prec,x,y,desc_data,info,trans,work) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, amg_zprec_type, psb_ipk_ + type(psb_desc_type),intent(in) :: desc_data + type(amg_zprec_type), intent(inout) :: prec + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_dpk_),intent(inout), optional, target :: work(:) + end subroutine amg_zprecaply + subroutine amg_zprecaply1(prec,x,desc_data,info,trans) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, amg_zprec_type, psb_ipk_ + type(psb_desc_type),intent(in) :: desc_data + type(amg_zprec_type), intent(inout) :: prec + complex(psb_dpk_),intent(inout) :: x(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + end subroutine amg_zprecaply1 + end interface + + interface + subroutine amg_zprecsetsm(prec,val,info,ilev,ilmax,pos) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & + & amg_zprec_type, amg_z_base_smoother_type, psb_ipk_ + class(amg_zprec_type), target, intent(inout):: prec + class(amg_z_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + end subroutine amg_zprecsetsm + subroutine amg_zprecsetsv(prec,val,info,ilev,ilmax,pos) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & + & amg_zprec_type, amg_z_base_solver_type, psb_ipk_ + class(amg_zprec_type), intent(inout) :: prec + class(amg_z_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + end subroutine amg_zprecsetsv + subroutine amg_zprecsetag(prec,val,info,ilev,ilmax,pos) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & + & amg_zprec_type, amg_z_base_aggregator_type, psb_ipk_ + class(amg_zprec_type), intent(inout) :: prec + class(amg_z_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + end subroutine amg_zprecsetag + subroutine amg_zcprecseti(prec,what,val,info,ilev,ilmax,pos,idx) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & + & amg_zprec_type, psb_ipk_ + class(amg_zprec_type), intent(inout) :: prec + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx + character(len=*), optional, intent(in) :: pos + end subroutine amg_zcprecseti + subroutine amg_zcprecsetr(prec,what,val,info,ilev,ilmax,pos,idx) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & + & amg_zprec_type, psb_ipk_ + class(amg_zprec_type), intent(inout) :: prec + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx + character(len=*), optional, intent(in) :: pos + end subroutine amg_zcprecsetr + subroutine amg_zcprecsetc(prec,what,string,info,ilev,ilmax,pos,idx) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & + & amg_zprec_type, psb_ipk_ + class(amg_zprec_type), intent(inout) :: prec + character(len=*), intent(in) :: what + character(len=*), intent(in) :: string + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx + character(len=*), optional, intent(in) :: pos + end subroutine amg_zcprecsetc + end interface + + interface amg_precinit + subroutine amg_zprecinit(ictxt,prec,ptype,info) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & + & amg_zprec_type, psb_ipk_ + integer(psb_ipk_), intent(in) :: ictxt + class(amg_zprec_type), intent(inout) :: prec + character(len=*), intent(in) :: ptype + integer(psb_ipk_), intent(out) :: info + end subroutine amg_zprecinit + end interface amg_precinit + + interface amg_precbld + subroutine amg_zprecbld(a,desc_a,prec,info,amold,vmold,imold) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & + & psb_z_base_sparse_mat, psb_z_base_vect_type, & + & psb_i_base_vect_type, amg_zprec_type, psb_ipk_ + implicit none + type(psb_zspmat_type), intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_zprec_type), intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! character, intent(in),optional :: upd + end subroutine amg_zprecbld + end interface amg_precbld + + interface amg_hierarchy_bld + subroutine amg_z_hierarchy_bld(a,desc_a,prec,info) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & + & amg_zprec_type, psb_ipk_ + implicit none + type(psb_zspmat_type), intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_zprec_type), intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + ! character, intent(in),optional :: upd + end subroutine amg_z_hierarchy_bld + end interface amg_hierarchy_bld + + interface amg_smoothers_bld + subroutine amg_z_smoothers_bld(a,desc_a,prec,info,amold,vmold,imold) + import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & + & psb_z_base_sparse_mat, psb_z_base_vect_type, & + & psb_i_base_vect_type, amg_zprec_type, psb_ipk_ + implicit none + type(psb_zspmat_type), intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_zprec_type), intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! character, intent(in),optional :: upd + end subroutine amg_z_smoothers_bld + end interface amg_smoothers_bld + +contains + ! + ! Function returning a pointer to the smoother + ! + function amg_z_get_smootherp(prec,ilev) result(val) + implicit none + class(amg_zprec_type), target, intent(in) :: prec + integer(psb_ipk_), optional :: ilev + class(amg_z_base_smoother_type), pointer :: val + integer(psb_ipk_) :: ilev_ + + val => null() + if (present(ilev)) then + ilev_ = ilev + else + ! What is a good default? + ilev_ = 1 + end if + if (allocated(prec%precv)) then + if ((1<=ilev_).and.(ilev_<=size(prec%precv))) then + if (allocated(prec%precv(ilev_)%sm)) then + val => prec%precv(ilev_)%sm + end if + end if + end if + end function amg_z_get_smootherp + ! + ! Function returning a pointer to the solver + ! + function amg_z_get_solverp(prec,ilev) result(val) + implicit none + class(amg_zprec_type), target, intent(in) :: prec + integer(psb_ipk_), optional :: ilev + class(amg_z_base_solver_type), pointer :: val + integer(psb_ipk_) :: ilev_ + + val => null() + if (present(ilev)) then + ilev_ = ilev + else + ! What is a good default? + ilev_ = 1 + end if + if (allocated(prec%precv)) then + if ((1<=ilev_).and.(ilev_<=size(prec%precv))) then + if (allocated(prec%precv(ilev_)%sm)) then + if (allocated(prec%precv(ilev_)%sm%sv)) then + val => prec%precv(ilev_)%sm%sv + end if + end if + end if + end if + end function amg_z_get_solverp + ! + ! Function returning the size of the precv(:) array + ! + function amg_z_get_nlevs(prec) result(val) + implicit none + class(amg_zprec_type), intent(in) :: prec + integer(psb_ipk_) :: val + val = 0 + if (allocated(prec%precv)) then + val = size(prec%precv) + end if + end function amg_z_get_nlevs + ! + ! Function returning the size of the amg_prec_type data structure + ! in bytes or in number of nonzeros of the operator(s) involved. + ! + function amg_z_get_nzeros(prec) result(val) + implicit none + class(amg_zprec_type), intent(in) :: prec + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + if (allocated(prec%precv)) then + do i=1, size(prec%precv) + val = val + prec%precv(i)%get_nzeros() + end do + end if + end function amg_z_get_nzeros + + function amg_zprec_sizeof(prec) result(val) + implicit none + class(amg_zprec_type), intent(in) :: prec + integer(psb_epk_) :: val + integer(psb_ipk_) :: i + val = 0 + val = val + psb_sizeof_ip + if (allocated(prec%precv)) then + do i=1, size(prec%precv) + val = val + prec%precv(i)%sizeof() + end do + end if + end function amg_zprec_sizeof + + ! + ! Operator complexity: ratio of total number + ! of nonzeros in the aggregated matrices at the + ! various level to the nonzeroes at the fine level + ! (original matrix) + ! + + function amg_z_get_compl(prec) result(val) + implicit none + class(amg_zprec_type), intent(in) :: prec + complex(psb_dpk_) :: val + + val = prec%ag_data%op_complexity + + end function amg_z_get_compl + + subroutine amg_z_cmp_compl(prec) + + implicit none + class(amg_zprec_type), intent(inout) :: prec + + real(psb_dpk_) :: num, den, nmin + integer(psb_ipk_) :: ictxt + integer(psb_ipk_) :: il + + num = -done + den = done + ictxt = prec%ictxt + if (allocated(prec%precv)) then + il = 1 + num = prec%precv(il)%base_a%get_nzeros() + if (num >= dzero) then + den = num + do il=2,size(prec%precv) + num = num + max(0,prec%precv(il)%base_a%get_nzeros()) + end do + end if + end if + nmin = num + call psb_min(ictxt,nmin) + if (nmin < dzero) then + num = dzero + den = done + else + call psb_sum(ictxt,num) + call psb_sum(ictxt,den) + end if + prec%ag_data%op_complexity = num/den + end subroutine amg_z_cmp_compl + + ! + ! Average coarsening ratio + ! + + function amg_z_get_avg_cr(prec) result(val) + implicit none + class(amg_zprec_type), intent(in) :: prec + complex(psb_dpk_) :: val + + val = prec%ag_data%avg_cr + + end function amg_z_get_avg_cr + + subroutine amg_z_cmp_avg_cr(prec) + + implicit none + class(amg_zprec_type), intent(inout) :: prec + + real(psb_dpk_) :: avgcr + integer(psb_ipk_) :: ictxt + integer(psb_ipk_) :: il, nl, iam, np + + + avgcr = dzero + ictxt = prec%ictxt + call psb_info(ictxt,iam,np) + if (allocated(prec%precv)) then + nl = size(prec%precv) + do il=2,nl + avgcr = avgcr + max(dzero,prec%precv(il)%szratio) + end do + avgcr = avgcr / (nl-1) + end if + call psb_sum(ictxt,avgcr) + prec%ag_data%avg_cr = avgcr/np + end subroutine amg_z_cmp_avg_cr + + ! + ! Subroutines: amg_Tprec_free + ! Version: complex + ! + ! These routines deallocate the amg_Tprec_type data structures. + ! + ! Arguments: + ! p - type(amg_Tprec_type), input. + ! The data structure to be deallocated. + ! info - integer, output. + ! error code. + ! + subroutine amg_zprecfree(p,info) + + implicit none + + ! Arguments + type(amg_zprec_type), intent(inout) :: p + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: me,err_act,i + character(len=20) :: name + + info=psb_success_ + name = 'amg_zprecfree' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; return + end if + + me=-1 + + call p%free(info) + + + return + + end subroutine amg_zprecfree + + subroutine amg_z_prec_free(prec,info) + + implicit none + + ! Arguments + class(amg_zprec_type), intent(inout) :: prec + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: me,err_act,i + character(len=20) :: name + + info=psb_success_ + name = 'amg_zprecfree' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + + me=-1 + if (allocated(prec%precv)) then + do i=1,size(prec%precv) + call prec%precv(i)%free(info) + end do + deallocate(prec%precv,stat=info) + end if + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_z_prec_free + + + + ! + ! Top level methods. + ! + subroutine amg_z_apply2_vect(prec,x,y,desc_data,info,trans,work) + implicit none + type(psb_desc_type),intent(in) :: desc_data + class(amg_zprec_type), intent(inout) :: prec + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_dpk_),intent(inout), optional, target :: work(:) + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_prec_apply' + + call psb_erractionsave(err_act) + + select type(prec) + type is (amg_zprec_type) + call amg_precapply(prec,x,y,desc_data,info,trans,work) + class default + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_z_apply2_vect + + subroutine amg_z_apply1_vect(prec,x,desc_data,info,trans,work) + implicit none + type(psb_desc_type),intent(in) :: desc_data + class(amg_zprec_type), intent(inout) :: prec + type(psb_z_vect_type),intent(inout) :: x + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_dpk_),intent(inout), optional, target :: work(:) + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_prec_apply' + + call psb_erractionsave(err_act) + + select type(prec) + type is (amg_zprec_type) + call amg_precapply(prec,x,desc_data,info,trans,work) + class default + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_z_apply1_vect + + + subroutine amg_z_apply2v(prec,x,y,desc_data,info,trans,work) + implicit none + type(psb_desc_type),intent(in) :: desc_data + class(amg_zprec_type), intent(inout) :: prec + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_dpk_),intent(inout), optional, target :: work(:) + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_prec_apply' + + call psb_erractionsave(err_act) + + select type(prec) + type is (amg_zprec_type) + call amg_precapply(prec,x,y,desc_data,info,trans,work) + class default + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_z_apply2v + + subroutine amg_z_apply1v(prec,x,desc_data,info,trans) + implicit none + type(psb_desc_type),intent(in) :: desc_data + class(amg_zprec_type), intent(inout) :: prec + complex(psb_dpk_),intent(inout) :: x(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + Integer(psb_ipk_) :: err_act + character(len=20) :: name='d_prec_apply' + + call psb_erractionsave(err_act) + + select type(prec) + type is (amg_zprec_type) + call amg_precapply(prec,x,desc_data,info,trans) + class default + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_z_apply1v + + + subroutine amg_z_dump(prec,info,istart,iend,iproc,prefix,head,& + & ac,rp,smoother,solver,tprol,& + & global_num) + + implicit none + class(amg_zprec_type), intent(in) :: prec + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: istart, iend, iproc + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver,ac, rp, tprol, global_num + integer(psb_ipk_) :: i, j, il1, iln, lev + integer(psb_ipk_) :: icontxt, iam, np, iproc_ + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + ! len of prefix_ + + info = 0 + icontxt = prec%ictxt + call psb_info(icontxt,iam,np) + + iln = size(prec%precv) + if (present(istart)) then + il1 = max(1,istart) + else + il1 = min(2,iln) + end if + if (present(iend)) then + iln = min(iln, iend) + end if + iproc_ = -1 + if (present(iproc)) then + iproc_ = iproc + end if + + if ((iproc_ == -1).or.(iproc_==iam)) then + do lev=il1, iln + call prec%precv(lev)%dump(lev,info,prefix=prefix,head=head,& + & ac=ac,smoother=smoother,solver=solver,rp=rp,tprol=tprol, & + & global_num=global_num) + end do + end if + end subroutine amg_z_dump + + subroutine amg_z_cnv(prec,info,amold,vmold,imold) + + implicit none + class(amg_zprec_type), intent(inout) :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + integer(psb_ipk_) :: i + + info = psb_success_ + if (allocated(prec%precv)) then + do i=1,size(prec%precv) + if (info == psb_success_ ) & + & call prec%precv(i)%cnv(info,amold=amold,vmold=vmold,imold=imold) + end do + end if + + end subroutine amg_z_cnv + + subroutine amg_z_clone(prec,precout,info) + + implicit none + class(amg_zprec_type), intent(inout) :: prec + class(psb_zprec_type), intent(inout) :: precout + integer(psb_ipk_), intent(out) :: info + + call precout%free(info) + if (info == 0) call amg_z_inner_clone(prec,precout,info) + + end subroutine amg_z_clone + + subroutine amg_z_inner_clone(prec,precout,info) + + implicit none + class(amg_zprec_type), intent(inout) :: prec + class(psb_zprec_type), target, intent(inout) :: precout + integer(psb_ipk_), intent(out) :: info + ! Local vars + integer(psb_ipk_) :: i, j, ln, lev + integer(psb_ipk_) :: icontxt,iam, np + + info = psb_success_ + select type(pout => precout) + class is (amg_zprec_type) + pout%ictxt = prec%ictxt + pout%ag_data = prec%ag_data + pout%outer_sweeps = prec%outer_sweeps + if (allocated(prec%precv)) then + ln = size(prec%precv) + allocate(pout%precv(ln),stat=info) + if (info /= psb_success_) goto 9999 + if (ln >= 1) then + call prec%precv(1)%clone(pout%precv(1),info) + end if + do lev=2, ln + if (info /= psb_success_) exit + call prec%precv(lev)%clone(pout%precv(lev),info) + if (info == psb_success_) then + pout%precv(lev)%base_a => pout%precv(lev)%ac + pout%precv(lev)%base_desc => pout%precv(lev)%desc_ac + pout%precv(lev)%map%p_desc_U => pout%precv(lev-1)%base_desc + pout%precv(lev)%map%p_desc_V => pout%precv(lev)%base_desc + end if + end do + end if + if (allocated(prec%precv(1)%wrk)) & + & call pout%allocate_wrk(info,vmold=prec%precv(1)%wrk%vx2l%v) + + class default + write(0,*) 'Error: wrong out type' + info = psb_err_invalid_input_ + end select +9999 continue + end subroutine amg_z_inner_clone + + subroutine z_prec_move_alloc(prec, b,info) + use psb_base_mod + implicit none + class(amg_zprec_type), intent(inout) :: prec + class(amg_zprec_type), intent(inout), target :: b + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: i + + if (same_type_as(prec,b)) then + if (allocated(b%precv)) then + ! This might not be required if FINAL procedures are available. + call b%free(info) + if (info /= psb_success_) then + !????? +!!$ return + endif + end if + b%ictxt = prec%ictxt + b%ag_data = prec%ag_data + b%outer_sweeps = prec%outer_sweeps + + call move_alloc(prec%precv,b%precv) + ! Fix the pointers except on level 1. + do i=2, size(b%precv) + b%precv(i)%base_a => b%precv(i)%ac + b%precv(i)%base_desc => b%precv(i)%desc_ac + b%precv(i)%map%p_desc_U => b%precv(i-1)%base_desc + b%precv(i)%map%p_desc_V => b%precv(i)%base_desc + end do + + else + write(0,*) 'Warning: PREC%move_alloc onto different type?' + info = psb_err_internal_error_ + end if + end subroutine z_prec_move_alloc + + subroutine amg_z_allocate_wrk(prec,info,vmold,desc) + use psb_base_mod + implicit none + + ! Arguments + class(amg_zprec_type), intent(inout) :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_vect_type), intent(in), optional :: vmold + ! + ! In MLD the DESC optional argument is ignored, since + ! the necessary info is contained in the various entries of the + ! PRECV component. + type(psb_desc_type), intent(in), optional :: desc + + ! Local variables + integer(psb_ipk_) :: me,err_act,i,j,level,nlev, nc2l + character(len=20) :: name + + info=psb_success_ + name = 'amg_z_allocate_wrk' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + nlev = size(prec%precv) + level = 1 + do level = 1, nlev + call prec%precv(level)%allocate_wrk(info,vmold=vmold) + if (psb_errstatus_fatal()) then + nc2l = prec%precv(level)%base_desc%get_local_cols() + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nc2l/), a_err='complex(psb_dpk_)') + goto 9999 + end if + end do + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_z_allocate_wrk + + subroutine amg_z_free_wrk(prec,info) + use psb_base_mod + implicit none + + ! Arguments + class(amg_zprec_type), intent(inout) :: prec + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: me,err_act,i,j,level, nlev, nc2l + character(len=20) :: name + + info=psb_success_ + name = 'amg_z_free_wrk' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + + if (allocated(prec%precv)) then + nlev = size(prec%precv) + do level = 1, nlev + call prec%precv(level)%free_wrk(info) + end do + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_z_free_wrk + + function amg_z_is_allocated_wrk(prec) result(res) + use psb_base_mod + implicit none + + ! Arguments + class(amg_zprec_type), intent(in) :: prec + logical :: res + + res = .false. + if (.not.allocated(prec%precv)) return + res = allocated(prec%precv(1)%wrk) + + end function amg_z_is_allocated_wrk + +end module amg_z_prec_type diff --git a/mlprec/amg_z_slu_solver.F90 b/mlprec/amg_z_slu_solver.F90 new file mode 100644 index 00000000..1ca007ad --- /dev/null +++ b/mlprec/amg_z_slu_solver.F90 @@ -0,0 +1,447 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_z_slu_solver_mod.f90 +! +! Module: amg_z_slu_solver_mod +! +! This module defines: +! - the amg_z_slu_solver_type data structure containing the ingredients +! to interface with the SuperLU package. +! 1. The factorization is restricted to the diagonal block of the +! current image. +! +module amg_z_slu_solver + + use iso_c_binding + use amg_z_base_solver_mod + +#if defined(IPK8) + + type, extends(amg_z_base_solver_type) :: amg_z_slu_solver_type + + end type amg_z_slu_solver_type + +#else + + type, extends(amg_z_base_solver_type) :: amg_z_slu_solver_type + type(c_ptr) :: lufactors=c_null_ptr + integer(c_long_long) :: symbsize=0, numsize=0 + contains + procedure, pass(sv) :: build => z_slu_solver_bld + procedure, pass(sv) :: apply_a => z_slu_solver_apply + procedure, pass(sv) :: apply_v => z_slu_solver_apply_vect + procedure, pass(sv) :: free => z_slu_solver_free + procedure, pass(sv) :: clear_data => z_slu_solver_clear_data + procedure, pass(sv) :: descr => z_slu_solver_descr + procedure, pass(sv) :: sizeof => z_slu_solver_sizeof + procedure, nopass :: get_fmt => z_slu_solver_get_fmt + procedure, nopass :: get_id => z_slu_solver_get_id + final :: z_slu_solver_finalize + end type amg_z_slu_solver_type + + + private :: z_slu_solver_bld, z_slu_solver_apply, & + & z_slu_solver_free, z_slu_solver_descr, & + & z_slu_solver_sizeof, z_slu_solver_apply_vect, & + & z_slu_solver_get_fmt, z_slu_solver_get_id, & + & z_slu_solver_clear_data + private :: z_slu_solver_finalize + + + + interface + function amg_zslu_fact(n,nnz,values,rowptr,colind,& + & lufactors)& + & bind(c,name='amg_zslu_fact') result(info) + use iso_c_binding + integer(c_int), value :: n,nnz + integer(c_int) :: info + integer(c_int) :: rowptr(*),colind(*) + complex(c_double_complex) :: values(*) + type(c_ptr) :: lufactors + end function amg_zslu_fact + end interface + + interface + function amg_zslu_solve(itrans,n,nrhs,b,ldb,lufactors)& + & bind(c,name='amg_zslu_solve') result(info) + use iso_c_binding + integer(c_int) :: info + integer(c_int), value :: itrans,n,nrhs,ldb + complex(c_double_complex) :: b(ldb,*) + type(c_ptr), value :: lufactors + end function amg_zslu_solve + end interface + + interface + function amg_zslu_free(lufactors)& + & bind(c,name='amg_zslu_free') result(info) + use iso_c_binding + integer(c_int) :: info + type(c_ptr), value :: lufactors + end function amg_zslu_free + end interface + +contains + + subroutine z_slu_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + use psb_base_mod + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_slu_solver_type), intent(inout) :: sv + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer, intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + + integer :: n_row,n_col + complex(psb_dpk_), pointer :: ww(:) + integer :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='z_slu_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + else + allocate(ww(n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/n_col,0,0,0,0/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + endif + + ww(1:n_row) = x(1:n_row) + select case(trans_) + case('N') + info = amg_zslu_solve(0,n_row,1,ww,n_row,sv%lufactors) + case('T') + info = amg_zslu_solve(1,n_row,1,ww,n_row,sv%lufactors) + case('C') + info = amg_zslu_solve(2,n_row,1,ww,n_row,sv%lufactors) + case default + call psb_errpush(psb_err_internal_error_, & + & name,a_err='Invalid TRANS in ILU subsolve') + goto 9999 + end select + + if (info == psb_success_) & + & call psb_geaxpby(alpha,ww,beta,y,desc_data,info) + + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in subsolve') + goto 9999 + endif + + if (n_col > size(work)) then + deallocate(ww) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine z_slu_solver_apply + + subroutine z_slu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + use psb_base_mod + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_slu_solver_type), intent(inout) :: sv + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer, intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + + integer :: err_act + character(len=20) :: name='z_slu_solver_apply_vect' + + call psb_erractionsave(err_act) + + info = psb_success_ + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call x%v%sync() + call y%v%sync() + call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) + call y%v%set_host() + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine z_slu_solver_apply_vect + + subroutine z_slu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + + Implicit None + + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_slu_solver_type), intent(inout) :: sv + integer, intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + type(psb_zspmat_type) :: atmp + type(psb_z_csc_sparse_mat) :: acsc + type(psb_z_coo_sparse_mat) :: acoo + integer :: n_row,n_col, nrow_a, nztota + integer :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='z_slu_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + n_col = desc_a%get_local_cols() + + + call a%cscnv(atmp,info,type='coo') + call psb_rwextd(n_row,atmp,info,b=b) + call atmp%cscnv(info,type='coo',dupl=psb_dupl_add_) + nrow_a = atmp%get_nrows() + call atmp%a%csclip(acoo,info,jmax=nrow_a) + call acsc%mv_from_coo(acoo,info) + nztota = acsc%get_nzeros() + ! Fix the entries to call C-base SuperLU + acsc%ia(:) = acsc%ia(:) - 1 + acsc%icp(:) = acsc%icp(:) - 1 + info = amg_zslu_fact(nrow_a,nztota,acsc%val,& + & acsc%icp,acsc%ia,sv%lufactors) + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='amg_zslu_fact' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + call acsc%free() + call atmp%free() + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_slu_solver_bld + + subroutine z_slu_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_z_slu_solver_type), intent(inout) :: sv + integer, intent(out) :: info + Integer :: err_act + character(len=20) :: name='z_slu_solver_free' + + call psb_erractionsave(err_act) + + info = psb_success_ + + call sv%clear_data(info) + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_slu_solver_free + + subroutine z_slu_solver_clear_data(sv,info) + + Implicit None + + ! Arguments + class(amg_z_slu_solver_type), intent(inout) :: sv + integer, intent(out) :: info + Integer :: err_act + character(len=20) :: name='z_slu_solver_clear_data' + + call psb_erractionsave(err_act) + + info = psb_success_ + if (c_associated(sv%lufactors)) info = amg_zslu_free(sv%lufactors) + sv%lufactors = c_null_ptr + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_slu_solver_clear_data + + subroutine z_slu_solver_finalize(sv) + + Implicit None + + ! Arguments + type(amg_z_slu_solver_type), intent(inout) :: sv + integer :: info + Integer :: err_act + character(len=20) :: name='z_slu_solver_finalize' + + call sv%free(info) + + return + + end subroutine z_slu_solver_finalize + + subroutine z_slu_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_z_slu_solver_type), intent(in) :: sv + integer, intent(out) :: info + integer, intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer :: err_act + integer :: ictxt, me, np + character(len=20), parameter :: name='amg_z_slu_solver_descr' + integer :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' SuperLU Sparse Factorization Solver. ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_slu_solver_descr + + function z_slu_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_z_slu_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer :: i + + val = 2*psb_sizeof_ip + psb_sizeof_dp + val = val + sv%symbsize + val = val + sv%numsize + return + end function z_slu_solver_sizeof + + function z_slu_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "SuperLU solver" + end function z_slu_solver_get_fmt + + function z_slu_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_slu_ + end function z_slu_solver_get_id +#endif +end module amg_z_slu_solver diff --git a/mlprec/amg_z_sludist_solver.F90 b/mlprec/amg_z_sludist_solver.F90 new file mode 100644 index 00000000..69aaf214 --- /dev/null +++ b/mlprec/amg_z_sludist_solver.F90 @@ -0,0 +1,465 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_z_sludist_solver_mod.f90 +! +! Module: amg_z_sludist_solver_mod +! +! This module defines: +! - the amg_z_sludist_solver_type data structure containing the ingredients +! to interface with the SuperLU_Dist package. +! 1. The factorization is distributed (and thus exact) +! +! +! +module amg_z_sludist_solver + + use iso_c_binding + use amg_z_base_solver_mod + +#if defined(LPK8) + + type, extends(amg_z_base_solver_type) :: amg_z_sludist_solver_type + + end type amg_z_sludist_solver_type +#else + type, extends(amg_z_base_solver_type) :: amg_z_sludist_solver_type + type(c_ptr) :: lufactors=c_null_ptr + integer(c_long_long) :: symbsize=0, numsize=0 + contains + procedure, pass(sv) :: build => z_sludist_solver_bld + procedure, pass(sv) :: apply_a => z_sludist_solver_apply + procedure, pass(sv) :: apply_v => z_sludist_solver_apply_vect + procedure, pass(sv) :: free => z_sludist_solver_free + procedure, pass(sv) :: clear_data => z_sludist_solver_clear_data + procedure, pass(sv) :: descr => z_sludist_solver_descr + procedure, pass(sv) :: sizeof => z_sludist_solver_sizeof + procedure, nopass :: get_fmt => z_sludist_solver_get_fmt + procedure, nopass :: get_id => z_sludist_solver_get_id + procedure, pass(sv) :: is_global => z_sludist_solver_is_global + final :: z_sludist_solver_finalize + end type amg_z_sludist_solver_type + + + private :: z_sludist_solver_bld, z_sludist_solver_apply, & + & z_sludist_solver_free, z_sludist_solver_descr, & + & z_sludist_solver_sizeof, z_sludist_solver_apply_vect, & + & z_sludist_solver_get_fmt, z_sludist_solver_get_id, & + & z_sludist_solver_is_global, z_sludist_solver_clear_data + private :: z_sludist_solver_finalize + + + interface + function amg_zsludist_fact(n,nl,nnz,ifrst, & + & values,rowptr,colind,lufactors,npr,npc) & + & bind(c,name='amg_zsludist_fact') result(info) + use iso_c_binding + integer(c_int), value :: n,nl,nnz,ifrst,npr,npc + integer(c_int) :: info + integer(c_int) :: rowptr(*),colind(*) + complex(c_double_complex) :: values(*) + type(c_ptr) :: lufactors + end function amg_zsludist_fact + end interface + + interface + function amg_zsludist_solve(itrans,n,nrhs, b, ldb, lufactors)& + & bind(c,name='amg_zsludist_solve') result(info) + use iso_c_binding + integer(c_int) :: info + integer(c_int), value :: itrans,n,nrhs,ldb + complex(c_double_complex) :: b(ldb,*) + type(c_ptr), value :: lufactors + end function amg_zsludist_solve + end interface + + interface + function amg_zsludist_free(lufactors)& + & bind(c,name='amg_zsludist_free') result(info) + use iso_c_binding + integer(c_int) :: info + type(c_ptr), value :: lufactors + end function amg_zsludist_free + end interface + +contains + + subroutine z_sludist_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + use psb_base_mod + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_sludist_solver_type), intent(inout) :: sv + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer, intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + + integer :: n_row,n_col + complex(psb_dpk_), pointer :: ww(:) + integer :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='z_sludist_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + else + allocate(ww(n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/n_col/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + endif + + if (info == psb_success_)& + & call psb_geaxpby(zone,x,zzero,ww,desc_data,info) + + select case(trans_) + case('N') + info = amg_zsludist_solve(0,n_row,1,ww,n_row,sv%lufactors) + case('T') + info = amg_zsludist_solve(1,n_row,1,ww,n_row,sv%lufactors) + case('C') + info = amg_zsludist_solve(2,n_row,1,ww,n_row,sv%lufactors) + case default + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Invalid TRANS in subsolve') + goto 9999 + end select + + if (info == psb_success_)& + & call psb_geaxpby(alpha,ww,beta,y,desc_data,info) + + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in subsolve') + goto 9999 + endif + + if (n_col > size(work)) then + deallocate(ww) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine z_sludist_solver_apply + + subroutine z_sludist_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + use psb_base_mod + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_sludist_solver_type), intent(inout) :: sv + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer, intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + + integer :: err_act + character(len=20) :: name='z_sludist_solver_apply_vect' + + call psb_erractionsave(err_act) + + info = psb_success_ + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + + call x%v%sync() + call y%v%sync() + call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) + call y%v%set_host() + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine z_sludist_solver_apply_vect + + subroutine z_sludist_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + + Implicit None + + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_sludist_solver_type), intent(inout) :: sv + integer, intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + type(psb_zspmat_type) :: atmp + type(psb_z_csr_sparse_mat) :: acsr + integer :: n_row,n_col, nrow_a, nztota, nglob, nzt, npr, npc + integer :: ifrst, ibcheck + integer :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='z_sludist_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + npr = np + npc = 1 + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + + n_row = desc_a%get_local_rows() + n_col = desc_a%get_local_cols() + nglob = desc_a%get_global_rows() + + call a%cscnv(atmp,info,type='coo') + call psb_rwextd(n_row,atmp,info,b=b) + call atmp%cscnv(info,type='csr',dupl=psb_dupl_add_) + call atmp%mv_to(acsr) + nrow_a = acsr%get_nrows() + nztota = acsr%get_nzeros() + ! Fix the entries to call C-base SuperLU + call psb_loc_to_glob(1,ifrst,desc_a,info) + call psb_loc_to_glob(nrow_a,ibcheck,desc_a,info) + call psb_loc_to_glob(acsr%ja(1:nztota),desc_a,info,iact='I') + acsr%ja(:) = acsr%ja(:) - 1 + acsr%irp(:) = acsr%irp(:) - 1 + ifrst = ifrst - 1 + info = amg_zsludist_fact(nglob,nrow_a,nztota,ifrst,& + & acsr%val,acsr%irp,acsr%ja,sv%lufactors,& + & npr,npc) + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='amg_zsludist_fact' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + call acsr%free() + call atmp%free() + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_sludist_solver_bld + + subroutine z_sludist_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_z_sludist_solver_type), intent(inout) :: sv + integer, intent(out) :: info + Integer :: err_act + character(len=20) :: name='z_sludist_solver_free' + + call psb_erractionsave(err_act) + info = 0 + call sv%clear_data(info) + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_sludist_solver_free + + subroutine z_sludist_solver_clear_data(sv,info) + + Implicit None + + ! Arguments + class(amg_z_sludist_solver_type), intent(inout) :: sv + integer, intent(out) :: info + Integer :: err_act + character(len=20) :: name='z_sludist_solver_clear_data' + + call psb_erractionsave(err_act) + + info = psb_success_ + if (c_associated(sv%lufactors)) info = amg_zsludist_free(sv%lufactors) + sv%lufactors = c_null_ptr + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_sludist_solver_clear_data + + ! + function z_sludist_solver_is_global(sv) result(val) + implicit none + class(amg_z_sludist_solver_type), intent(in) :: sv + logical :: val + + val = .true. + end function z_sludist_solver_is_global + + subroutine z_sludist_solver_finalize(sv) + + Implicit None + + ! Arguments + type(amg_z_sludist_solver_type), intent(inout) :: sv + integer :: info + Integer :: err_act + character(len=20) :: name='z_sludist_solver_finalize' + + call sv%free(info) + + return + + end subroutine z_sludist_solver_finalize + + subroutine z_sludist_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_z_sludist_solver_type), intent(in) :: sv + integer, intent(out) :: info + integer, intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer :: err_act + integer :: ictxt, me, np + character(len=20), parameter :: name='amg_z_sludist_solver_descr' + integer :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' SuperLU_Dist Sparse Factorization Solver. ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_sludist_solver_descr + + function z_sludist_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_z_sludist_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer :: i + + val = 2*psb_sizeof_ip + psb_sizeof_dp + val = val + sv%symbsize + val = val + sv%numsize + return + end function z_sludist_solver_sizeof + + function z_sludist_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "SuperLU_Dist solver" + end function z_sludist_solver_get_fmt + + function z_sludist_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_sludist_ + end function z_sludist_solver_get_id +#endif +end module amg_z_sludist_solver diff --git a/mlprec/amg_z_symdec_aggregator_mod.f90 b/mlprec/amg_z_symdec_aggregator_mod.f90 new file mode 100644 index 00000000..312e2b6f --- /dev/null +++ b/mlprec/amg_z_symdec_aggregator_mod.f90 @@ -0,0 +1,105 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! +! Locally symmetrized (decoupled) aggregation algorithm. +! This version differs from the basic decoupled aggregation algorithm +! only because it works on (the pattern of) A+A^T instead of A. +! +! +module amg_z_symdec_aggregator_mod + + use amg_z_dec_aggregator_mod + !> \namespace amg_z_symdec_aggregator_mod \class amg_z_symdec_aggregator_type + !! \extends amg_z_dec_aggregator_mod::amg_z_dec_aggregator_type + !! + !! This version differs from the basic decoupled aggregation algorithm + !! only because it works on (the pattern of) A+A^T instead of A. + !! + ! + type, extends(amg_z_dec_aggregator_type) :: amg_z_symdec_aggregator_type + + contains + procedure, pass(ag) :: bld_tprol => amg_z_symdec_aggregator_build_tprol + procedure, pass(ag) :: descr => amg_z_symdec_aggregator_descr + procedure, nopass :: fmt => amg_z_symdec_aggregator_fmt + end type amg_z_symdec_aggregator_type + + + interface + subroutine amg_z_symdec_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,t_prol,info) + import :: amg_z_symdec_aggregator_type, psb_desc_type, psb_zspmat_type, psb_dpk_, & + & psb_ipk_, psb_lpk_, psb_lzspmat_type, amg_dml_parms, amg_daggr_data + implicit none + class(amg_z_symdec_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(amg_daggr_data), intent(in) :: ag_data + type(psb_zspmat_type), intent(inout) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lzspmat_type), intent(out) :: t_prol + integer(psb_ipk_), intent(out) :: info + end subroutine amg_z_symdec_aggregator_build_tprol + end interface + + +contains + + function amg_z_symdec_aggregator_fmt() result(val) + implicit none + character(len=32) :: val + + val = "Symmetric Decoupled aggregation" + end function amg_z_symdec_aggregator_fmt + + subroutine amg_z_symdec_aggregator_descr(ag,parms,iout,info) + implicit none + class(amg_z_symdec_aggregator_type), intent(in) :: ag + type(amg_dml_parms), intent(in) :: parms + integer(psb_ipk_), intent(in) :: iout + integer(psb_ipk_), intent(out) :: info + + write(iout,*) 'Decoupled Aggregator locally-symmetrized' + write(iout,*) 'Aggregator object type: ',ag%fmt() + call parms%mldescr(iout,info) + + return + end subroutine amg_z_symdec_aggregator_descr + +end module amg_z_symdec_aggregator_mod diff --git a/mlprec/amg_z_umf_solver.F90 b/mlprec/amg_z_umf_solver.F90 new file mode 100644 index 00000000..62dfe213 --- /dev/null +++ b/mlprec/amg_z_umf_solver.F90 @@ -0,0 +1,453 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_z_umf_solver_mod.f90 +! +! Module: amg_z_umf_solver_mod +! +! This module defines: +! - the amg_z_umf_solver_type data structure containing the ingredients +! to interface with the UMFPACK package. +! 1. The factorization is restricted to the diagonal block of the +! current image. +! +module amg_z_umf_solver + + use iso_c_binding + use amg_z_base_solver_mod + +#if defined(IPK8) + type, extends(amg_z_base_solver_type) :: amg_z_umf_solver_type + + end type amg_z_umf_solver_type + +#else + + type, extends(amg_z_base_solver_type) :: amg_z_umf_solver_type + type(c_ptr) :: symbolic=c_null_ptr, numeric=c_null_ptr + integer(c_long_long) :: symbsize=0, numsize=0 + contains + procedure, pass(sv) :: build => z_umf_solver_bld + procedure, pass(sv) :: apply_a => z_umf_solver_apply + procedure, pass(sv) :: apply_v => z_umf_solver_apply_vect + procedure, pass(sv) :: free => z_umf_solver_free + procedure, pass(sv) :: clear_data => z_umf_solver_clear_data + procedure, pass(sv) :: descr => z_umf_solver_descr + procedure, pass(sv) :: sizeof => z_umf_solver_sizeof + procedure, nopass :: get_fmt => z_umf_solver_get_fmt + procedure, nopass :: get_id => z_umf_solver_get_id + final :: z_umf_solver_finalize + end type amg_z_umf_solver_type + + + private :: z_umf_solver_bld, z_umf_solver_apply, & + & z_umf_solver_free, z_umf_solver_descr, & + & z_umf_solver_sizeof, z_umf_solver_apply_vect, & + & z_umf_solver_get_fmt, z_umf_solver_get_id, & + & z_umf_solver_clear_data + private :: z_umf_solver_finalize + + + + interface + function amg_zumf_fact(n,nnz,values,rowind,colptr,& + & symptr,numptr,ssize,nsize)& + & bind(c,name='amg_zumf_fact') result(info) + use iso_c_binding + integer(c_int), value :: n,nnz + integer(c_int) :: info + integer(c_long_long) :: ssize, nsize + integer(c_int) :: rowind(*),colptr(*) + complex(c_double_complex) :: values(*) + type(c_ptr) :: symptr, numptr + end function amg_zumf_fact + end interface + + interface + function amg_zumf_solve(itrans,n,x, b, ldb, numptr)& + & bind(c,name='amg_zumf_solve') result(info) + use iso_c_binding + integer(c_int) :: info + integer(c_int), value :: itrans,n,ldb + complex(c_double_complex) :: x(*), b(ldb,*) + type(c_ptr), value :: numptr + end function amg_zumf_solve + end interface + + interface + function amg_zumf_free(symptr, numptr)& + & bind(c,name='amg_zumf_free') result(info) + use iso_c_binding + integer(c_int) :: info + type(c_ptr), value :: symptr, numptr + end function amg_zumf_free + end interface + +contains + + subroutine z_umf_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + use psb_base_mod + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_umf_solver_type), intent(inout) :: sv + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer, intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + + integer :: n_row,n_col + complex(psb_dpk_), pointer :: ww(:) + integer :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='z_umf_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + else + allocate(ww(n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/n_col,0,0,0,0/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + endif + + select case(trans_) + case('N') + info = amg_zumf_solve(0,n_row,ww,x,n_row,sv%numeric) + case('T') + ! + ! Note: with UMF, 1 meand Ctranspose, 2 means transpose + ! even for complex data. + ! + if (psb_z_is_complex_) then + info = amg_zumf_solve(2,n_row,ww,x,n_row,sv%numeric) + else + info = amg_zumf_solve(1,n_row,ww,x,n_row,sv%numeric) + end if + case('C') + info = amg_zumf_solve(1,n_row,ww,x,n_row,sv%numeric) + case default + call psb_errpush(psb_err_internal_error_,name,a_err='Invalid TRANS in ILU subsolve') + goto 9999 + end select + + if (info == psb_success_) call psb_geaxpby(alpha,ww,beta,y,desc_data,info) + + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Error in subsolve') + goto 9999 + endif + + if (n_col > size(work)) then + deallocate(ww) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine z_umf_solver_apply + + subroutine z_umf_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + use psb_base_mod + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_umf_solver_type), intent(inout) :: sv + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer, intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + + integer :: err_act + character(len=20) :: name='z_umf_solver_apply_vect' + + call psb_erractionsave(err_act) + + info = psb_success_ + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call x%v%sync() + call y%v%sync() + call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) + call y%v%set_host() + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine z_umf_solver_apply_vect + + subroutine z_umf_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + + Implicit None + + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_umf_solver_type), intent(inout) :: sv + integer, intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + type(psb_zspmat_type) :: atmp + type(psb_z_csc_sparse_mat) :: acsc + integer :: n_row,n_col, nrow_a, nztota + integer :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='z_umf_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + n_col = desc_a%get_local_cols() + + call a%cscnv(atmp,info,type='coo') + call psb_rwextd(n_row,atmp,info,b=b) + call atmp%cscnv(info,type='csc',dupl=psb_dupl_add_) + call atmp%mv_to(acsc) + nrow_a = acsc%get_nrows() + nztota = acsc%get_nzeros() + ! Fix the entres to call C-base UMFPACK. + acsc%ia(:) = acsc%ia(:) - 1 + acsc%icp(:) = acsc%icp(:) - 1 + info = amg_zumf_fact(nrow_a,nztota,acsc%val,& + & acsc%ia,acsc%icp,sv%symbolic,sv%numeric,& + & sv%symbsize,sv%numsize) + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='amg_zumf_fact' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + call acsc%free() + call atmp%free() + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_umf_solver_bld + + subroutine z_umf_solver_free(sv,info) + + Implicit None + + ! Arguments + class(amg_z_umf_solver_type), intent(inout) :: sv + integer, intent(out) :: info + Integer :: err_act + character(len=20) :: name='z_umf_solver_free' + + call psb_erractionsave(err_act) + + call sv%clear_data(info) + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_umf_solver_free + + + subroutine z_umf_solver_clear_data(sv,info) + + Implicit None + + ! Arguments + class(amg_z_umf_solver_type), intent(inout) :: sv + integer, intent(out) :: info + Integer :: err_act + character(len=20) :: name='z_umf_solver_clear_data' + + call psb_erractionsave(err_act) + info = 0 + if (c_associated(sv%symbolic).and.c_associated(sv%numeric)) then + info = amg_zumf_free(sv%symbolic,sv%numeric) + + if (info /= psb_success_) goto 9999 + sv%symbolic = c_null_ptr + sv%numeric = c_null_ptr + sv%symbsize = 0 + sv%numsize = 0 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_umf_solver_clear_data + + subroutine z_umf_solver_finalize(sv) + + Implicit None + + ! Arguments + type(amg_z_umf_solver_type), intent(inout) :: sv + integer :: info + Integer :: err_act + character(len=20) :: name='z_umf_solver_finalize' + + call sv%free(info) + + return + + end subroutine z_umf_solver_finalize + + subroutine z_umf_solver_descr(sv,info,iout,coarse) + + Implicit None + + ! Arguments + class(amg_z_umf_solver_type), intent(in) :: sv + integer, intent(out) :: info + integer, intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer :: err_act + integer :: ictxt, me, np + character(len=20), parameter :: name='amg_z_umf_solver_descr' + integer :: iout_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + write(iout_,*) ' UMFPACK Sparse Factorization Solver. ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + end subroutine z_umf_solver_descr + + function z_umf_solver_sizeof(sv) result(val) + + implicit none + ! Arguments + class(amg_z_umf_solver_type), intent(in) :: sv + integer(psb_epk_) :: val + integer :: i + + val = 2*psb_sizeof_lp + val = val + sv%symbsize + val = val + sv%numsize + return + end function z_umf_solver_sizeof + + function z_umf_solver_get_fmt() result(val) + implicit none + character(len=32) :: val + + val = "UMFPACK solver" + end function z_umf_solver_get_fmt + + function z_umf_solver_get_id() result(val) + implicit none + integer(psb_ipk_) :: val + + val = amg_umf_ + end function z_umf_solver_get_id +#endif +end module amg_z_umf_solver diff --git a/mlprec/impl/Makefile b/mlprec/impl/Makefile index 3a527d23..128b4a0d 100644 --- a/mlprec/impl/Makefile +++ b/mlprec/impl/Makefile @@ -19,53 +19,53 @@ CMPFOBJS= MPFOBJS=$(SMPFOBJS) $(DMPFOBJS) $(CMPFOBJS) $(ZMPFOBJS) -MPCOBJS=mld_dslud_interface.o mld_zslud_interface.o +MPCOBJS=amg_dslud_interface.o amg_zslud_interface.o -DINNEROBJS= mld_dmlprec_bld.o mld_dfile_prec_descr.o \ - mld_d_smoothers_bld.o mld_d_hierarchy_bld.o \ - mld_dmlprec_aply.o \ - $(DMPFOBJS) mld_d_extprol_bld.o +DINNEROBJS= amg_dmlprec_bld.o amg_dfile_prec_descr.o \ + amg_d_smoothers_bld.o amg_d_hierarchy_bld.o \ + amg_dmlprec_aply.o \ + $(DMPFOBJS) amg_d_extprol_bld.o -SINNEROBJS= mld_smlprec_bld.o mld_sfile_prec_descr.o \ - mld_s_smoothers_bld.o mld_s_hierarchy_bld.o \ - mld_smlprec_aply.o \ - $(SMPFOBJS) mld_s_extprol_bld.o +SINNEROBJS= amg_smlprec_bld.o amg_sfile_prec_descr.o \ + amg_s_smoothers_bld.o amg_s_hierarchy_bld.o \ + amg_smlprec_aply.o \ + $(SMPFOBJS) amg_s_extprol_bld.o -ZINNEROBJS= mld_zmlprec_bld.o mld_zfile_prec_descr.o \ - mld_z_smoothers_bld.o mld_z_hierarchy_bld.o \ - mld_zmlprec_aply.o \ - $(ZMPFOBJS) mld_z_extprol_bld.o +ZINNEROBJS= amg_zmlprec_bld.o amg_zfile_prec_descr.o \ + amg_z_smoothers_bld.o amg_z_hierarchy_bld.o \ + amg_zmlprec_aply.o \ + $(ZMPFOBJS) amg_z_extprol_bld.o -CINNEROBJS= mld_cmlprec_bld.o mld_cfile_prec_descr.o \ - mld_c_smoothers_bld.o mld_c_hierarchy_bld.o \ - mld_cmlprec_aply.o \ - $(CMPFOBJS) mld_c_extprol_bld.o +CINNEROBJS= amg_cmlprec_bld.o amg_cfile_prec_descr.o \ + amg_c_smoothers_bld.o amg_c_hierarchy_bld.o \ + amg_cmlprec_aply.o \ + $(CMPFOBJS) amg_c_extprol_bld.o INNEROBJS= $(SINNEROBJS) $(DINNEROBJS) $(CINNEROBJS) $(ZINNEROBJS) -DOUTEROBJS=mld_dprecbld.o mld_dprecset.o mld_dprecinit.o mld_dprecaply.o mld_dcprecset.o +DOUTEROBJS=amg_dprecbld.o amg_dprecset.o amg_dprecinit.o amg_dprecaply.o amg_dcprecset.o -SOUTEROBJS=mld_sprecbld.o mld_sprecset.o mld_sprecinit.o mld_sprecaply.o mld_scprecset.o +SOUTEROBJS=amg_sprecbld.o amg_sprecset.o amg_sprecinit.o amg_sprecaply.o amg_scprecset.o -ZOUTEROBJS=mld_zprecbld.o mld_zprecset.o mld_zprecinit.o mld_zprecaply.o mld_zcprecset.o +ZOUTEROBJS=amg_zprecbld.o amg_zprecset.o amg_zprecinit.o amg_zprecaply.o amg_zcprecset.o -COUTEROBJS=mld_cprecbld.o mld_cprecset.o mld_cprecinit.o mld_cprecaply.o mld_ccprecset.o +COUTEROBJS=amg_cprecbld.o amg_cprecset.o amg_cprecinit.o amg_cprecaply.o amg_ccprecset.o OUTEROBJS=$(SOUTEROBJS) $(DOUTEROBJS) $(COUTEROBJS) $(ZOUTEROBJS) F90OBJS=$(OUTEROBJS) $(INNEROBJS) -COBJS= mld_sslu_interface.o \ - mld_dslu_interface.o mld_dumf_interface.o \ - mld_cslu_interface.o \ - mld_zslu_interface.o mld_zumf_interface.o +COBJS= amg_sslu_interface.o \ + amg_dslu_interface.o amg_dumf_interface.o \ + amg_cslu_interface.o \ + amg_zslu_interface.o amg_zumf_interface.o OBJS=$(F90OBJS) $(COBJS) $(MPCOBJS) -LIBNAME=libmld_prec.a +LIBNAME=libamg_prec.a lib: $(OBJS) aggrd levd smoothd solvd $(AR) $(HERE)/$(LIBNAME) $(OBJS) diff --git a/mlprec/impl/aggregator/Makefile b/mlprec/impl/aggregator/Makefile index 57ba2229..71ebe6f3 100644 --- a/mlprec/impl/aggregator/Makefile +++ b/mlprec/impl/aggregator/Makefile @@ -9,41 +9,41 @@ FINCLUDES=$(FMFLAG)$(HERE) $(FMFLAG)$(MODDIR) $(FMFLAG)$(INCDIR) $(PSBLAS_INCLUD #CINCLUDES= -I${SUPERLU_INCDIR} -I${HSL_INCDIR} -I${SPRAL_INCDIR} -I/home/users/pasqua/Ambra/BootCMatch/include -lBCM -L/home/users/pasqua/Ambra/BootCMatch/lib -lm OBJS= \ -mld_s_dec_aggregator_mat_asb.o \ -mld_s_dec_aggregator_mat_bld.o \ -mld_s_dec_aggregator_tprol.o \ -mld_s_symdec_aggregator_tprol.o \ -mld_s_map_to_tprol.o mld_s_soc1_map_bld.o mld_s_soc2_map_bld.o\ -mld_s_ptap.o \ -mld_saggrmat_minnrg_bld.o\ -mld_saggrmat_nosmth_bld.o mld_saggrmat_smth_bld.o \ -mld_d_dec_aggregator_mat_asb.o \ -mld_d_dec_aggregator_mat_bld.o \ -mld_d_dec_aggregator_tprol.o \ -mld_d_symdec_aggregator_tprol.o \ -mld_d_map_to_tprol.o mld_d_soc1_map_bld.o mld_d_soc2_map_bld.o \ -mld_d_ptap.o \ -mld_daggrmat_minnrg_bld.o \ -mld_daggrmat_nosmth_bld.o mld_daggrmat_smth_bld.o \ -mld_c_dec_aggregator_mat_asb.o \ -mld_c_dec_aggregator_mat_bld.o \ -mld_c_dec_aggregator_tprol.o \ -mld_c_symdec_aggregator_tprol.o \ -mld_c_map_to_tprol.o mld_c_soc1_map_bld.o mld_c_soc2_map_bld.o\ -mld_c_ptap.o \ -mld_caggrmat_minnrg_bld.o\ -mld_caggrmat_nosmth_bld.o mld_caggrmat_smth_bld.o \ -mld_z_dec_aggregator_mat_asb.o \ -mld_z_dec_aggregator_mat_bld.o \ -mld_z_dec_aggregator_tprol.o \ -mld_z_symdec_aggregator_tprol.o \ -mld_z_map_to_tprol.o mld_z_soc1_map_bld.o mld_z_soc2_map_bld.o\ -mld_z_ptap.o \ -mld_zaggrmat_minnrg_bld.o\ -mld_zaggrmat_nosmth_bld.o mld_zaggrmat_smth_bld.o +amg_s_dec_aggregator_mat_asb.o \ +amg_s_dec_aggregator_mat_bld.o \ +amg_s_dec_aggregator_tprol.o \ +amg_s_symdec_aggregator_tprol.o \ +amg_s_map_to_tprol.o amg_s_soc1_map_bld.o amg_s_soc2_map_bld.o\ +amg_s_ptap.o \ +amg_saggrmat_minnrg_bld.o\ +amg_saggrmat_nosmth_bld.o amg_saggrmat_smth_bld.o \ +amg_d_dec_aggregator_mat_asb.o \ +amg_d_dec_aggregator_mat_bld.o \ +amg_d_dec_aggregator_tprol.o \ +amg_d_symdec_aggregator_tprol.o \ +amg_d_map_to_tprol.o amg_d_soc1_map_bld.o amg_d_soc2_map_bld.o \ +amg_d_ptap.o \ +amg_daggrmat_minnrg_bld.o \ +amg_daggrmat_nosmth_bld.o amg_daggrmat_smth_bld.o \ +amg_c_dec_aggregator_mat_asb.o \ +amg_c_dec_aggregator_mat_bld.o \ +amg_c_dec_aggregator_tprol.o \ +amg_c_symdec_aggregator_tprol.o \ +amg_c_map_to_tprol.o amg_c_soc1_map_bld.o amg_c_soc2_map_bld.o\ +amg_c_ptap.o \ +amg_caggrmat_minnrg_bld.o\ +amg_caggrmat_nosmth_bld.o amg_caggrmat_smth_bld.o \ +amg_z_dec_aggregator_mat_asb.o \ +amg_z_dec_aggregator_mat_bld.o \ +amg_z_dec_aggregator_tprol.o \ +amg_z_symdec_aggregator_tprol.o \ +amg_z_map_to_tprol.o amg_z_soc1_map_bld.o amg_z_soc2_map_bld.o\ +amg_z_ptap.o \ +amg_zaggrmat_minnrg_bld.o\ +amg_zaggrmat_nosmth_bld.o amg_zaggrmat_smth_bld.o -LIBNAME=libmld_prec.a +LIBNAME=libamg_prec.a lib: $(OBJS) $(AR) $(HERE)/$(LIBNAME) $(OBJS) diff --git a/mlprec/impl/aggregator/amg_c_dec_aggregator_mat_asb.f90 b/mlprec/impl/aggregator/amg_c_dec_aggregator_mat_asb.f90 new file mode 100644 index 00000000..c4f4d014 --- /dev/null +++ b/mlprec/impl/aggregator/amg_c_dec_aggregator_mat_asb.f90 @@ -0,0 +1,195 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_c_dec_aggregator_mat_asb.f90 +! +! Subroutine: amg_c_dec_aggregator_mat_asb +! Version: complex +! +! +! From a given AC to final format, generating DESC_AC +! +! Arguments: +! ag - type(amg_c_dec_aggregator_type), input/output. +! The aggregator object +! parms - type(amg_sml_parms), input +! The aggregation parameters +! a - type(psb_cspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! ac - type(psb_cspmat_type), inout +! The coarse matrix +! desc_ac - type(psb_desc_type), output. +! The communication descriptor of the fine-level matrix. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! +! op_prol - type(psb_cspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_cspmat_type), input/output +! The restrictor operator; normally, it is the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +subroutine amg_c_dec_aggregator_mat_asb(ag,parms,a,desc_a,& + & ac,desc_ac, op_prol,op_restr,info) + use psb_base_mod + use amg_base_prec_type + use amg_c_dec_aggregator_mod, amg_protect_name => amg_c_dec_aggregator_mat_asb + implicit none + class(amg_c_dec_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + type(psb_cspmat_type), intent(inout) :: op_prol, ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: ictxt, np, me + type(psb_lc_coo_sparse_mat) :: tmpcoo + type(psb_lcspmat_type) :: tmp_ac + integer(psb_ipk_) :: i_nr, i_nc, i_nl, nzl + integer(psb_lpk_) :: ntaggr + integer(psb_ipk_) :: err_act, debug_level, debug_unit + character(len=20) :: name='c_dec_aggregator_mat_asb' + + + if (psb_get_errstatus().ne.0) return + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + select case(parms%coarse_mat) + + case(amg_distr_mat_) + + call ac%cscnv(info,type='csr') + call op_prol%cscnv(info,type='csr') + call op_restr%cscnv(info,type='csr') + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ac ' + + case(amg_repl_mat_) + ! + ! We are assuming here that an c matrix + ! can hold all entries + ! + if (desc_ac%get_global_rows() < huge(1_psb_ipk_) ) then + ntaggr = desc_ac%get_global_rows() + i_nr = ntaggr + else + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_coarse_mat_') + goto 9999 + end if + + call op_prol%mv_to(tmpcoo) + nzl = tmpcoo%get_nzeros() + call psb_loc_to_glob(tmpcoo%ja(1:nzl),desc_ac,info,'I') + call tmpcoo%set_ncols(i_nr) + call op_prol%mv_from(tmpcoo) + + call op_restr%mv_to(tmpcoo) + nzl = tmpcoo%get_nzeros() + call psb_loc_to_glob(tmpcoo%ia(1:nzl),desc_ac,info,'I') + call tmpcoo%set_nrows(i_nr) + call op_restr%mv_from(tmpcoo) + + + call psb_gather(tmp_ac,ac,desc_ac,info,root=-ione,& + & dupl=psb_dupl_add_,keeploc=.false.) + call tmp_ac%mv_to(tmpcoo) + call ac%mv_from(tmpcoo) + + call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) + if (info == psb_success_) call psb_cdasb(desc_ac,info) + + if (info /= psb_success_) goto 9999 + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_coarse_mat_') + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_lc_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo +end subroutine amg_c_dec_aggregator_mat_asb diff --git a/mlprec/impl/aggregator/amg_c_dec_aggregator_mat_bld.f90 b/mlprec/impl/aggregator/amg_c_dec_aggregator_mat_bld.f90 new file mode 100644 index 00000000..83fab527 --- /dev/null +++ b/mlprec/impl/aggregator/amg_c_dec_aggregator_mat_bld.f90 @@ -0,0 +1,216 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_c_dec_aggregator_mat_bld.f90 +! +! Subroutine: amg_c_dec_aggregator_mat_bld +! Version: complex +! +! This routine builds the matrix associated to the current level of the +! multilevel preconditioner from the matrix associated to the previous level, +! by using the user-specified aggregation technique (therefore, it also builds the +! prolongation and restriction operators mapping the current level to the +! previous one and vice versa). +! The current level is regarded as the coarse one, while the previous as +! the fine one. This is in agreement with the fact that the routine is called, +! by amg_mlprec_bld, only on levels >=2. +! The coarse-level matrix A_C is built from a fine-level matrix A +! by using the Galerkin approach, i.e. +! +! A_C = P_C^T A P_C, +! +! where P_C is a prolongator from the coarse level to the fine one. +! +! A mapping from the nodes of the adjacency graph of A to the nodes of the +! adjacency graph of A_C has been computed by the amg_aggrmap_bld subroutine. +! The prolongator P_C is built here from this mapping, according to the +! value of p%iprcparm(amg_aggr_kind_), specified by the user through +! amg_cprecinit and amg_zprecset. +! On output from this routine the entries of AC, op_prol, op_restr +! are still in "global numbering" mode; this is fixed in the calling routine +! amg_c_lev_aggrmat_bld. +! +! Currently four different prolongators are implemented, corresponding to +! four aggregation algorithms: +! 1. un-smoothed aggregation, +! 2. smoothed aggregation, +! 3. "bizarre" aggregation. +! 4. minimum energy +! 1. The non-smoothed aggregation uses as prolongator the piecewise constant +! interpolation operator corresponding to the fine-to-coarse level mapping built +! by p%aggr%bld_tprol. This is called tentative prolongator. +! 2. The smoothed aggregation uses as prolongator the operator obtained by applying +! a damped Jacobi smoother to the tentative prolongator. +! 3. The "bizarre" aggregation uses a prolongator proposed by the authors of MLD2P4. +! This prolongator still requires a deep analysis and testing and its use is +! not recommended. +! 4. Minimum energy aggregation +! +! For more details see +! M. Brezina and P. Vanek, A black-box iterative solver based on a two-level +! Schwarz method, Computing, 63 (1999), 233-263. +! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed +! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 +! (1996), 179-196. +! P. D'Ambra, D. di Serafino and S. Filippone, On the development of PSBLAS-based +! parallel two-level Schwarz preconditioners, Appl. Num. Math., 57 (2007), +! 1181-1196. +! M. Sala, R. Tuminaro: A new Petrov-Galerkin smoothed aggregation preconditioner +! for nonsymmetric linear systems, SIAM J. Sci. Comput., 31(1):143-166 (2008) +! +! +! The main structure is: +! 1. Perform sanity checks; +! 2. Compute prolongator/restrictor/AC +! +! +! Arguments: +! ag - type(amg_c_dec_aggregator_type), input/output. +! The aggregator object +! parms - type(amg_sml_parms), input +! The aggregation parameters +! a - type(psb_cspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! ac - type(psb_cspmat_type), output +! The coarse matrix on output +! +! op_prol - type(psb_cspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_cspmat_type), output +! The restrictor operator; normally, it is the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +subroutine amg_c_dec_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + use psb_base_mod + use amg_c_prec_type, amg_protect_name => amg_c_dec_aggregator_mat_bld + use amg_c_inner_mod + implicit none + + class(amg_c_dec_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(psb_lcspmat_type), intent(inout) :: t_prol + type(psb_cspmat_type), intent(out) :: op_prol,ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + + ! Local variables + character(len=20) :: name + integer(psb_mpk_) :: ictxt, np, me + integer(psb_lpk_) :: nzl,ntaggr + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: debug_level, debug_unit + + name='amg_c_dec_aggregator_mat_bld' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + ! + ! Build the coarse-level matrix from the fine-level one, starting from + ! the mapping defined by amg_aggrmap_bld and applying the aggregation + ! algorithm specified by + ! + select case (parms%aggr_prol) + case (amg_no_smooth_) + + call amg_caggrmat_nosmth_bld(a,desc_a,ilaggr,nlaggr,& + & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) + + case(amg_smooth_prol_) + + call amg_caggrmat_smth_bld(a,desc_a,ilaggr,nlaggr, & + & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) + +!!$ case(amg_biz_prol_) +!!$ +!!$ call amg_caggrmat_biz_bld(a,desc_a,ilaggr,nlaggr, & +!!$ & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) + + case(amg_min_energy_) + + call amg_caggrmat_minnrg_bld(a,desc_a,ilaggr,nlaggr, & + & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='Invalid aggr kind') + goto 9999 + + end select + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='Inner aggrmat bld') + goto 9999 + end if + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + +end subroutine amg_c_dec_aggregator_mat_bld diff --git a/mlprec/impl/aggregator/amg_c_dec_aggregator_tprol.f90 b/mlprec/impl/aggregator/amg_c_dec_aggregator_tprol.f90 new file mode 100644 index 00000000..dcc2037e --- /dev/null +++ b/mlprec/impl/aggregator/amg_c_dec_aggregator_tprol.f90 @@ -0,0 +1,139 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_c_dec_aggregator_tprol.f90 +! +! Subroutine: amg_c_dec_aggregator_tprol +! Version: complex +! +! This routine is mainly an interface to soc_map_bld where the real work is performed. +! It takes care of some consistency checking, and calls map_to_tprol, which is +! refactored and shared among all the aggregation methods that produce a simple +! integer mapping. +! +! +! Arguments: +! ag - type(amg_c_dec_aggregator_type), input/output. +! The aggregator object, carrying with itself the mapping algorithm. +! parms - The auxiliary parameters object +! ag_data - Auxiliary global aggregation parameters object +! +! +! a - type(psb_cspmat_type). +! The sparse matrix structure containing the local part of the +! fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! ilaggr - integer, dimension(:), allocatable, output +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that on exit the indices +! will be shifted so as to make sure the ranges on the various processes do not +! overlap. +! nlaggr - integer, dimension(:), allocatable, output +! nlaggr(i) contains the aggregates held by process i. +! t_prol - type(psb_cspmat_type), output +! The tentative prolongator, based on ilaggr. +! +! info - integer, output. +! Error code. +! +subroutine amg_c_dec_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,t_prol,info) + use psb_base_mod + use amg_c_prec_type, amg_protect_name => amg_c_dec_aggregator_build_tprol + use amg_c_inner_mod + implicit none + class(amg_c_dec_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(amg_saggr_data), intent(in) :: ag_data + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lcspmat_type), intent(out) :: t_prol + integer(psb_ipk_), intent(out) :: info + + ! Local variables + character(len=20) :: name + integer(psb_mpk_) :: ictxt, np, me + integer(psb_ipk_) :: err_act + integer(psb_lpk_) :: ntaggr + integer(psb_ipk_) :: debug_level, debug_unit + logical :: clean_zeros + + name='amg_c_dec_aggregator_tprol' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + call amg_check_def(parms%ml_cycle,'Multilevel cycle',& + & amg_mult_ml_,is_legal_ml_cycle) + call amg_check_def(parms%par_aggr_alg,'Aggregation',& + & amg_dec_aggr_,is_legal_ml_par_aggr_alg) + call amg_check_def(parms%aggr_ord,'Ordering',& + & amg_aggr_ord_nat_,is_legal_ml_aggr_ord) + call amg_check_def(parms%aggr_thresh,'Aggr_Thresh',szero,is_legal_s_aggr_thrs) + + ! + ! The decoupled aggregator based on SOC measures ignores + ! ag_data except for clean_zeros; soc_map_bld is a procedure pointer. + ! + clean_zeros = ag%do_clean_zeros + call ag%soc_map_bld(parms%aggr_ord,parms%aggr_thresh,clean_zeros,a,desc_a,nlaggr,ilaggr,info) + + if (info==psb_success_) call amg_map_to_tprol(desc_a,ilaggr,nlaggr,t_prol,info) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='soc_map_bld/map_to_tprol') + goto 9999 + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_c_dec_aggregator_build_tprol diff --git a/mlprec/impl/aggregator/amg_c_map_to_tprol.f90 b/mlprec/impl/aggregator/amg_c_map_to_tprol.f90 new file mode 100644 index 00000000..3c17211e --- /dev/null +++ b/mlprec/impl/aggregator/amg_c_map_to_tprol.f90 @@ -0,0 +1,154 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_c_map_to_tprol.f90 +! +! Subroutine: amg_c_map_to_tprol +! Version: complex +! +! This routine uses a mapping from the row indices of the fine-level matrix +! to the row indices of the coarse-level matrix to build a tentative +! prolongator, i.e. a piecewise constant operator. +! This is later used to build the final operator; the code has been refactored here +! to be shared among all the methods that provide the tentative prolongator +! through a simple integer mapping. +! +! The aggregation algorithm is a parallel version of that described in +! * M. Brezina and P. Vanek, A black-box iterative solver based on a +! two-level Schwarz method, Computing, 63 (1999), 233-263. +! * P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed +! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 +! (1996), 179-196. +! For more details see +! P. D'Ambra, D. di Serafino and S. Filippone, On the development of +! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math. +! 57 (2007), 1181-1196. +! +! +! Arguments: +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! ilaggr - integer, dimension(:), allocatable. +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that on exit the indices +! will be shifted so as to make sure the ranges on the various processes do not +! overlap. +! nlaggr - integer, dimension(:), allocatable. +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_cspmat_type). +! The tentative prolongator, based on ilaggr. +! +! info - integer, output. +! Error code. +! +subroutine amg_c_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) + + use psb_base_mod + use amg_c_inner_mod, amg_protect_name => amg_c_map_to_tprol + + implicit none + + ! Arguments + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), allocatable, intent(inout) :: ilaggr(:),nlaggr(:) + type(psb_lcspmat_type), intent(out) :: op_prol + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_lpk_) :: icnt,nlp,k,n,ia,isz,nr, naggr,i,j,m,naggrm1, naggrp1, ntaggr + type(psb_lc_coo_sparse_mat) :: tmpcoo + integer(psb_ipk_) :: debug_level, debug_unit,err_act + integer(psb_ipk_) :: ictxt,np,me + integer(psb_lpk_) :: nrow, ncol, n_ne + character(len=20) :: name, ch_err + + info=psb_success_ + name = 'amg_map_to_tprol' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ! + ictxt=desc_a%get_context() + call psb_info(ictxt,me,np) + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + ilaggr(1:nrow) = ilaggr(1:nrow) + naggrm1 + call psb_halo(ilaggr,desc_a,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_halo') + goto 9999 + end if + + call tmpcoo%allocate(nrow,ntaggr,ncol) + k = 0 + do i=1,nrow + ! + ! Note: at this point, a value ilaggr(i)<=0 + ! tags a "singleton" row, and it has to be + ! left alone. + ! + if (ilaggr(i)>0) then + k = k + 1 + tmpcoo%val(k) = cone + tmpcoo%ia(k) = i + tmpcoo%ja(k) = ilaggr(i) + end if + end do + call tmpcoo%set_nzeros(k) + call tmpcoo%set_dupl(psb_dupl_add_) + call tmpcoo%set_sorted() ! At this point this is in row-major + call op_prol%mv_from(tmpcoo) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_map_to_tprol diff --git a/mlprec/impl/aggregator/amg_c_ptap.f90 b/mlprec/impl/aggregator/amg_c_ptap.f90 new file mode 100644 index 00000000..914fbe49 --- /dev/null +++ b/mlprec/impl/aggregator/amg_c_ptap.f90 @@ -0,0 +1,689 @@ +! +! +! MLD2P4 Extensions +! +! (C) Copyright 2019 +! +! Salvatore Filippone Cranfield University +! Pasqua D'Ambra IAC-CNR, Naples, IT +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_daggrmat_nosmth_bld.F90 +! +! +subroutine amg_c_ptap(a_csr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info,desc_ax) + use psb_base_mod + use amg_c_inner_mod + use amg_c_base_aggregator_mod, amg_protect_name => amg_c_ptap + implicit none + + ! Arguments + type(psb_c_csr_sparse_mat), intent(inout) :: a_csr + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + type(amg_sml_parms), intent(inout) :: parms + type(psb_c_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr + type(psb_desc_type), intent(inout) :: desc_ac + type(psb_cspmat_type), intent(out) :: ac + integer(psb_ipk_), intent(out) :: info + type(psb_desc_type), intent(inout), optional :: desc_ax + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo + character(len=40) :: name + integer(psb_ipk_) :: ierr(5) + type(psb_lc_coo_sparse_mat) :: ac_coo, tmpcoo + type(psb_c_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr + integer(psb_ipk_) :: debug_level, debug_unit, naggr + integer(psb_lpk_) :: nglob, ntaggr, naggrm1, naggrp1 + integer(psb_ipk_) :: nrow, ncol, nrl, nzl, ip, nzt, i, k + integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza + logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. + integer(psb_ipk_), save :: idx_spspmm=-1 + + name='amg_ptap' + if(psb_get_errstatus().ne.0) return + info=psb_success_ + call psb_erractionsave(err_act) + + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + call psb_info(ictxt, me, np) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + if ((do_timings).and.(idx_spspmm==-1)) & + & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr + + ! + ! COO_PROL should arrive here with local numbering + ! + if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& + & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& + & nrow,ntaggr,naggr + + call coo_prol%cp_to_fmt(csr_prol,info) + + if (debug) write(0,*) me,trim(name),' Product AxPROL ',& + & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & + & desc_a%get_local_rows(),desc_a%get_local_cols(),& + & desc_ac%get_local_rows(),desc_a%get_local_cols() + if (debug) flush(0) + + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + + if (debug) write(0,*) me,trim(name),' Done AxPROL ',& + & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& + & desc_ac%get_local_rows(),desc_ac%get_local_cols() + + ! + ! Ok first product done. + + if (present(desc_ax)) then + block + call coo_prol%cp_to_coo(coo_restr,info) + call coo_restr%set_ncols(desc_ac%get_local_cols()) + call coo_restr%set_nrows(desc_a%get_local_rows()) + call psb_c_coo_glob_transpose(coo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_ax%get_local_cols()) +! !$ write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& +! !$ & desc_a%get_local_cols(),desc_ax%get_local_cols(),coo_restr%get_nzeros() +! !$ if (desc_a%get_local_cols()= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + + else + + ! + ! Remember that RESTR must be built from PROL after halo extension, + ! which is done above in psb_par_spspmm + if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& + & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() + call csr_prol%mv_to_coo(coo_restr,info) +!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& +!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() + if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) + + call coo_restr%transp() + nzl = coo_restr%get_nzeros() + nrl = desc_ac%get_local_rows() + i=0 + ! + ! Only keep local rows + ! + do k=1, nzl + if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then + i = i+1 + coo_restr%val(i) = coo_restr%val(k) + coo_restr%ia(i) = coo_restr%ia(k) + coo_restr%ja(i) = coo_restr%ja(k) + end if + end do + call coo_restr%set_nzeros(i) + call coo_restr%fix(info) + nzl = coo_restr%get_nzeros() + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_a%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) + call csr_restr%cp_from_coo(coo_restr,info) + +!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + end if + + call psb_cdasb(desc_ac,info) + + call ac_csr%set_nrows(desc_ac%get_local_rows()) + call ac_csr%set_ncols(desc_ac%get_local_cols()) + call ac%mv_from(ac_csr) + call ac%set_asb() + + if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() + if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr + ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() + + call coo_prol%set_ncols(desc_ac%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ptap ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_c_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo + +end subroutine amg_c_ptap + +subroutine amg_c_lc_ptap(a_csr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info,desc_ax) + use psb_base_mod + use amg_c_inner_mod + use amg_c_base_aggregator_mod !, amg_protect_name => amg_c_lc_ptap + implicit none + + ! Arguments + type(psb_c_csr_sparse_mat), intent(inout) :: a_csr + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + type(amg_sml_parms), intent(inout) :: parms + type(psb_lc_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr + type(psb_desc_type), intent(inout) :: desc_ac + type(psb_lcspmat_type), intent(out) :: ac + integer(psb_ipk_), intent(out) :: info + type(psb_desc_type), intent(inout), optional :: desc_ax + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo + character(len=40) :: name + integer(psb_ipk_) :: ierr(5) + type(psb_lc_coo_sparse_mat) :: ac_coo, tmpcoo + type(psb_c_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr + integer(psb_ipk_) :: debug_level, debug_unit, naggr + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nrl, nzl, ip, & + & nzt, naggrm1, naggrp1, i, k + integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza + logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. + integer(psb_ipk_), save :: idx_spspmm=-1 + + name='amg_ptap' + if(psb_get_errstatus().ne.0) return + info=psb_success_ + call psb_erractionsave(err_act) + + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + call psb_info(ictxt, me, np) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + if ((do_timings).and.(idx_spspmm==-1)) & + & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr + + ! + ! COO_PROL should arrive here with local numbering + ! + if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& + & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& + & nrow,ntaggr,naggr + + call coo_prol%cp_to_ifmt(csr_prol,info) + + if (debug) write(0,*) me,trim(name),' Product AxPROL ',& + & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & + & desc_a%get_local_rows(),desc_a%get_local_cols(),& + & desc_ac%get_local_rows(),desc_a%get_local_cols() + if (debug) flush(0) + + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + + if (debug) write(0,*) me,trim(name),' Done AxPROL ',& + & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& + & desc_ac%get_local_rows(),desc_ac%get_local_cols() + + ! + ! Ok first product done. + + if (present(desc_ax)) then + block + type(psb_c_coo_sparse_mat) :: icoo_restr + + call coo_prol%cp_to_icoo(icoo_restr,info) + call icoo_restr%set_ncols(desc_ac%get_local_cols()) + call icoo_restr%set_nrows(desc_a%get_local_rows()) + call psb_c_coo_glob_transpose(icoo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) + call icoo_restr%set_nrows(desc_ac%get_local_rows()) + call icoo_restr%set_ncols(desc_ax%get_local_cols()) +! !$ write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& +! !$ & desc_a%get_local_cols(),desc_ax%get_local_cols(),icoo_restr%get_nzeros() +! !$ if (desc_a%get_local_cols()= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + + else + + ! + ! Remember that RESTR must be built from PROL after halo extension, + ! which is done above in psb_par_spspmm + if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& + & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() + call csr_prol%mv_to_lcoo(coo_restr,info) +!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& +!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() + if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) + + call coo_restr%transp() + nzl = coo_restr%get_nzeros() + nrl = desc_ac%get_local_rows() + i=0 + ! + ! Only keep local rows + ! + do k=1, nzl + if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then + i = i+1 + coo_restr%val(i) = coo_restr%val(k) + coo_restr%ia(i) = coo_restr%ia(k) + coo_restr%ja(i) = coo_restr%ja(k) + end if + end do + call coo_restr%set_nzeros(i) + call coo_restr%fix(info) + nzl = coo_restr%get_nzeros() + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_a%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) + call csr_restr%cp_from_lcoo(coo_restr,info) + +!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + end if + + call psb_cdasb(desc_ac,info) + + call ac_csr%set_nrows(desc_ac%get_local_rows()) + call ac_csr%set_ncols(desc_ac%get_local_cols()) + call ac%mv_from(ac_csr) + call ac%set_asb() + + if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() + if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr + ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() + + call coo_prol%set_ncols(desc_ac%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ptap ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_lc_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo + +end subroutine amg_c_lc_ptap + +subroutine amg_lc_ptap(a_csr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info,desc_ax) + use psb_base_mod + use amg_c_inner_mod + use amg_c_base_aggregator_mod!, amg_protect_name => amg_lc_ptap + implicit none + + ! Arguments + type(psb_lc_csr_sparse_mat), intent(inout) :: a_csr + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + type(amg_sml_parms), intent(inout) :: parms + type(psb_lc_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr + type(psb_desc_type), intent(inout) :: desc_ac + type(psb_lcspmat_type), intent(out) :: ac + integer(psb_ipk_), intent(out) :: info + type(psb_desc_type), intent(inout), optional :: desc_ax + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo + character(len=40) :: name + integer(psb_ipk_) :: ierr(5) + type(psb_lc_coo_sparse_mat) :: ac_coo, tmpcoo + type(psb_lc_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr + integer(psb_ipk_) :: debug_level, debug_unit, naggr + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nrl, nzl, ip, & + & nzt, naggrm1, naggrp1, i, k + integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza + logical, parameter :: do_timings=.true., oldstyle=.false., debug=.false. + integer(psb_ipk_), save :: idx_spspmm=-1 + + name='amg_ptap' + if(psb_get_errstatus().ne.0) return + info=psb_success_ + call psb_erractionsave(err_act) + + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + call psb_info(ictxt, me, np) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + if ((do_timings).and.(idx_spspmm==-1)) & + & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr + + ! + ! COO_PROL should arrive here with local numbering + ! + if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& + & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& + & nrow,ntaggr,naggr + + call coo_prol%cp_to_fmt(csr_prol,info) + + if (debug) write(0,*) me,trim(name),' Product AxPROL ',& + & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & + & desc_a%get_local_rows(),desc_a%get_local_cols(),& + & desc_ac%get_local_rows(),desc_a%get_local_cols() + if (debug) flush(0) + + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + + if (debug) write(0,*) me,trim(name),' Done AxPROL ',& + & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& + & desc_ac%get_local_rows(),desc_ac%get_local_cols() + + ! + ! Ok first product done. + + if (present(desc_ax)) then + block + type(psb_c_coo_sparse_mat) :: icoo_restr + + call coo_prol%cp_to_icoo(icoo_restr,info) + call icoo_restr%set_ncols(desc_ac%get_local_cols()) + call icoo_restr%set_nrows(desc_a%get_local_rows()) + call psb_c_coo_glob_transpose(icoo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) + call icoo_restr%set_nrows(desc_ac%get_local_rows()) + call icoo_restr%set_ncols(desc_ax%get_local_cols()) + write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& + & desc_a%get_local_cols(),desc_ax%get_local_cols(),icoo_restr%get_nzeros() + if (desc_a%get_local_cols()= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + + else + + ! + ! Remember that RESTR must be built from PROL after halo extension, + ! which is done above in psb_par_spspmm + if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& + & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() + call csr_prol%mv_to_coo(coo_restr,info) +!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& +!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() + if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) + + call coo_restr%transp() + nzl = coo_restr%get_nzeros() + nrl = desc_ac%get_local_rows() + i=0 + ! + ! Only keep local rows + ! + do k=1, nzl + if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then + i = i+1 + coo_restr%val(i) = coo_restr%val(k) + coo_restr%ia(i) = coo_restr%ia(k) + coo_restr%ja(i) = coo_restr%ja(k) + end if + end do + call coo_restr%set_nzeros(i) + call coo_restr%fix(info) + nzl = coo_restr%get_nzeros() + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_a%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) + call csr_restr%cp_from_coo(coo_restr,info) + +!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + end if + + call psb_cdasb(desc_ac,info) + + call ac_csr%set_nrows(desc_ac%get_local_rows()) + call ac_csr%set_ncols(desc_ac%get_local_cols()) + call ac%mv_from(ac_csr) + call ac%set_asb() + + if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() + if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr + ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() + + call coo_prol%set_ncols(desc_ac%get_local_cols()) + !call coo_restr%mv_from_ifmt(csr_restr,info) +!!$ call coo_restr%set_nrows(desc_ac%get_local_rows()) +!!$ call coo_restr%set_ncols(desc_a%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ptap ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_lc_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo + +end subroutine amg_lc_ptap diff --git a/mlprec/impl/aggregator/amg_c_soc1_map_bld.f90 b/mlprec/impl/aggregator/amg_c_soc1_map_bld.f90 new file mode 100644 index 00000000..06d17737 --- /dev/null +++ b/mlprec/impl/aggregator/amg_c_soc1_map_bld.f90 @@ -0,0 +1,349 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_c_soc1_map__bld.f90 +! +! Subroutine: amg_c_soc1_map_bld +! Version: complex +! +! This routine builds the tentative prolongator based on the +! strength of connection aggregation algorithm presented in +! +! M. Brezina and P. Vanek, A black-box iterative solver based on a +! two-level Schwarz method, Computing, 63 (1999), 233-263. +! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed +! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 +! (1996), 179-196. +! +! Note: upon exit +! +! Arguments: +! a - type(psb_cspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_cprec_type), input/output. +! The preconditioner data structure; upon exit it contains +! the multilevel hierarchy of prolongators, restrictors +! and coarse matrices. +! info - integer, output. +! Error code. +! +! +! +subroutine amg_c_soc1_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) + + use psb_base_mod + use amg_base_prec_type + use amg_c_inner_mod + + implicit none + + ! Arguments + integer(psb_ipk_), intent(in) :: iorder + logical, intent(in) :: clean_zeros + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + real(psb_spk_), intent(in) :: theta + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),& + & ideg(:), idxs(:) + integer(psb_lpk_), allocatable :: tmpaggr(:) + complex(psb_spk_), allocatable :: val(:), diag(:) + integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr, nc, naggr,i,j,m, nz, ilg, ii, ip + type(psb_c_csr_sparse_mat) :: acsr + real(psb_spk_) :: cpling, tcl + logical :: disjoint + integer(psb_ipk_) :: debug_level, debug_unit,err_act + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: nrow, ncol, n_ne + integer(psb_lpk_) :: nrglob + character(len=20) :: name, ch_err + + info=psb_success_ + name = 'amg_soc1_map_bld' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ! + ictxt=desc_a%get_context() + call psb_info(ictxt,me,np) + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + nrglob = desc_a%get_global_rows() + + nr = a%get_nrows() + nc = a%get_ncols() + allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),& + & icol(nc),val(nc),stat=info) + if(info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),& + & a_err='integer') + goto 9999 + end if + + diag = a%get_diag(info) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='psb_sp_getdiag') + goto 9999 + end if + + call a%cp_to(acsr) + if (clean_zeros) call acsr%clean_zeros(info) + if (iorder == amg_aggr_ord_nat_) then + do i=1, nr + ilaggr(i) = -(nr+1) + idxs(i) = i + end do + else + do i=1, nr + ilaggr(i) = -(nr+1) + ideg(i) = acsr%irp(i+1) - acsr%irp(i) + end do + call psb_msort(ideg,ix=idxs,dir=psb_sort_down_) + end if + + + ! + ! Phase one: Start with disjoint groups. + ! + naggr = 0 + icnt = 0 + step1: do ii=1, nr + i = idxs(ii) + if ((i<1).or.(i>nr)) then + info=psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + if (ilaggr(i) == -(nr+1)) then + nz = (acsr%irp(i+1)-acsr%irp(i)) + if ((nz<0).or.(nz>size(icol))) then + info=psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) + val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) + + ! + ! Build the set of all strongly coupled nodes + ! + ip = 0 + do k=1, nz + j = icol(k) + if ((1<=j).and.(j<=nr)) then + if (abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j)))) then + ip = ip + 1 + icol(ip) = icol(k) + end if + end if + enddo + + ! + ! If the whole strongly coupled neighborhood of I is + ! as yet unconnected, turn it into the next aggregate. + ! Same if ip==0 (in which case, neighborhood only + ! contains I even if it does not look like it from matrix) + ! + disjoint = all(ilaggr(icol(1:ip)) == -(nr+1)).or.(ip==0) + if (disjoint) then + icnt = icnt + 1 + naggr = naggr + 1 + do k=1, ip + ilaggr(icol(k)) = naggr + end do + ilaggr(i) = naggr + end if + endif + enddo step1 + + if (debug_level >= psb_debug_outer_) then + write(debug_unit,*) me,' ',trim(name),& + & ' Check 1:',count(ilaggr == -(nr+1)) + end if + + ! + ! Phase two: join the neighbours + ! + tmpaggr = ilaggr + step2: do ii=1,nr + i = idxs(ii) + + if (ilaggr(i) == -(nr+1)) then + nz = (acsr%irp(i+1)-acsr%irp(i)) + if (nz == 1) cycle step2 + icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) + val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) + + ! + ! Find the most strongly connected neighbour that is + ! already aggregated, if any, and join its aggregate + ! + cpling = szero + ip = 0 + do k=1, nz + j = icol(k) + if ((1<=j).and.(j<=nr)) then + if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))& + & .and. (tmpaggr(j) > 0).and. (abs(val(k)) > cpling)) then + ip = k + cpling = abs(val(k)) + end if + end if + enddo + if (ip > 0) then + ilaggr(i) = ilaggr(icol(ip)) + end if + end if + end do step2 + + + ! + ! Phase three: sweep over leftovers, if any + ! + step3: do ii=1,nr + i = idxs(ii) + + if (ilaggr(i) < 0) then + nz = (acsr%irp(i+1)-acsr%irp(i)) + if (nz == 1) cycle step3 + icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) + val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) + ! + ! Find its strongly connected neighbourhood not + ! already aggregated, and make it into a new aggregate. + ! + cpling = szero + ip = 0 + do k=1, nz + j = icol(k) + if ((1<=j).and.(j<=nr)) then + if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))& + & .and. (ilaggr(j) < 0)) then + ip = ip + 1 + icol(ip) = icol(k) + end if + end if + enddo + if (ip > 0) then + icnt = icnt + 1 + naggr = naggr + 1 + ilaggr(i) = naggr + do k=1, ip + ilaggr(icol(k)) = naggr + end do + else + ! + ! This should not happen: we did not even connect with ourselves, + ! but it's not a singleton. + ! + naggr = naggr + 1 + ilaggr(i) = naggr + end if + end if + end do step3 + + ! Any leftovers? + do i=1, nr + if (ilaggr(i) < 0) then + nz = (acsr%irp(i+1)-acsr%irp(i)) + if (nz == 1) then + ! Mark explicitly as a singleton so that + ! it will be ignored in map_to_tprol. + ! Need to use -(nrglob+nr) to make sure + ! it's still negative when shifted and combined with + ! other processes. + ilaggr(i) = -(nrglob+nr) + else + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers') + goto 9999 + endif + end if + end do + + if (naggr > ncol) then + !write(0,*) name,'Error : naggr > ncol',naggr,ncol + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Fatal error: naggr>ncol') + goto 9999 + end if + + call psb_realloc(ncol,ilaggr,info) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_realloc' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + allocate(nlaggr(np),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),& + & a_err='integer') + goto 9999 + end if + + nlaggr(:) = 0 + nlaggr(me+1) = naggr + call psb_sum(ictxt,nlaggr(1:np)) + + call acsr%free() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_soc1_map_bld + diff --git a/mlprec/impl/aggregator/amg_c_soc2_map_bld.f90 b/mlprec/impl/aggregator/amg_c_soc2_map_bld.f90 new file mode 100644 index 00000000..a7810639 --- /dev/null +++ b/mlprec/impl/aggregator/amg_c_soc2_map_bld.f90 @@ -0,0 +1,348 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_c_soc2_map__bld.f90 +! +! Subroutine: amg_c_soc2_map_bld +! Version: complex +! +! The aggregator object hosts the aggregation method for building +! the multilevel hierarchy. This variant is based on the method +! presented in +! +! S. Gratton, P. Henon, P. Jiranek and X. Vasseur: +! Reducing complexity of algebraic multigrid by aggregation +! Numerical Lin. Algebra with Applications, 2016, 23:501-518 +! +! Note: upon exit +! +! Arguments: +! a - type(psb_cspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_cprec_type), input/output. +! The preconditioner data structure; upon exit it contains +! the multilevel hierarchy of prolongators, restrictors +! and coarse matrices. +! info - integer, output. +! Error code. +! +! +! +subroutine amg_c_soc2_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) + + use psb_base_mod + use amg_base_prec_type + use amg_c_inner_mod + + implicit none + + ! Arguments + integer(psb_ipk_), intent(in) :: iorder + logical, intent(in) :: clean_zeros + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + real(psb_spk_), intent(in) :: theta + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),& + & ideg(:), idxs(:) + integer(psb_lpk_), allocatable :: tmpaggr(:) + complex(psb_spk_), allocatable :: val(:), diag(:) + integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr,nc,naggr,i,j,m, nz, ilg, ii, ip, ip1,nzcnt + integer(psb_lpk_) :: nrglob + type(psb_c_csr_sparse_mat) :: acsr, muij, s_neigh + type(psb_c_coo_sparse_mat) :: s_neigh_coo + real(psb_spk_) :: cpling, tcl + logical :: disjoint + integer(psb_ipk_) :: debug_level, debug_unit,err_act + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: nrow, ncol, n_ne + character(len=20) :: name, ch_err + + info=psb_success_ + name = 'amg_soc2_map_bld' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ! + ictxt=desc_a%get_context() + call psb_info(ictxt,me,np) + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + nrglob = desc_a%get_global_rows() + + nr = a%get_nrows() + nc = a%get_ncols() + allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),icol(nc),stat=info) + if(info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),& + & a_err='integer') + goto 9999 + end if + + diag = a%get_diag(info) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='psb_sp_getdiag') + goto 9999 + end if + + ! + ! Phase zero: compute muij + ! + call a%cp_to(muij) + if (clean_zeros) call muij%clean_zeros(info) + do i=1, nr + do k=muij%irp(i),muij%irp(i+1)-1 + j = muij%ja(k) + if (j<= nr) muij%val(k) = abs(muij%val(k))/sqrt(abs(diag(i)*diag(j))) + end do + end do + + ! + ! Compute the 1-neigbour; mark strong links with +1, weak links with -1 + ! + call s_neigh_coo%allocate(nr,nr,muij%get_nzeros()) + ip = 0 + do i=1, nr + do k=muij%irp(i),muij%irp(i+1)-1 + j = muij%ja(k) + if (j<=nr) then + ip = ip + 1 + s_neigh_coo%ia(ip) = i + s_neigh_coo%ja(ip) = j + if (real(muij%val(k)) >= theta) then + s_neigh_coo%val(ip) = sone + else + s_neigh_coo%val(ip) = -sone + end if + end if + end do + end do + !write(*,*) 'S_NEIGH: ',nr,ip + call s_neigh_coo%set_nzeros(ip) + call s_neigh%mv_from_coo(s_neigh_coo,info) + + if (iorder == amg_aggr_ord_nat_) then + do i=1, nr + ilaggr(i) = -(nr+1) + idxs(i) = i + end do + else + do i=1, nr + ilaggr(i) = -(nr+1) + ideg(i) = muij%irp(i+1) - muij%irp(i) + end do + call psb_msort(ideg,ix=idxs,dir=psb_sort_down_) + end if + + + ! + ! Phase one: Start with disjoint groups. + ! + naggr = 0 + icnt = 0 + step1: do ii=1, nr + i = idxs(ii) + + if (ilaggr(i) == -(nr+1)) then + ! + ! Get the 1-neighbourhood of I + ! + ip1 = s_neigh%irp(i) + nz = s_neigh%irp(i+1)-ip1 + ! + ! If the neighbourhood only contains I, skip it + ! + if (nz ==0) then + ilaggr(i) = 0 + cycle step1 + end if + if ((nz==1).and.(s_neigh%ja(ip1)==i)) then + ilaggr(i) = 0 + cycle step1 + end if + ! + ! If the whole strongly coupled neighborhood of I is + ! as yet unconnected, turn it into the next aggregate. + ! + nzcnt = count(real(s_neigh%val(ip1:ip1+nz-1)) > 0) + icol(1:nzcnt) = pack(s_neigh%ja(ip1:ip1+nz-1),(real(s_neigh%val(ip1:ip1+nz-1)) > 0)) + disjoint = all(ilaggr(icol(1:nzcnt)) == -(nr+1)) + if (disjoint) then + icnt = icnt + 1 + naggr = naggr + 1 + do k=1, nzcnt + ilaggr(icol(k)) = naggr + end do + ilaggr(i) = naggr + end if + endif + enddo step1 + + if (debug_level >= psb_debug_outer_) then + write(debug_unit,*) me,' ',trim(name),& + & ' Check 1:',count(ilaggr == -(nr+1)) + end if + + ! + ! Phase two: join the neighbours + ! + tmpaggr = ilaggr + step2: do ii=1,nr + i = idxs(ii) + + if (ilaggr(i) == -(nr+1)) then + ! + ! Find the most strongly connected neighbour that is + ! already aggregated, if any, and join its aggregate + ! + cpling = szero + ip = 0 + do k=s_neigh%irp(i), s_neigh%irp(i+1)-1 + j = s_neigh%ja(k) + if ((1<=j).and.(j<=nr)) then + if ( (tmpaggr(j) > 0).and. (real(muij%val(k)) > cpling)& + & .and.(real(s_neigh%val(k))>0)) then + ip = k + cpling = muij%val(k) + end if + end if + enddo + if (ip > 0) then + ilaggr(i) = ilaggr(s_neigh%ja(ip)) + end if + end if + end do step2 + + + ! + ! Phase three: sweep over leftovers, if any + ! + step3: do ii=1,nr + i = idxs(ii) + + if (ilaggr(i) < 0) then + ! + ! Find its strongly connected neighbourhood not + ! already aggregated, and make it into a new aggregate. + ! + ip = 0 + do k=s_neigh%irp(i), s_neigh%irp(i+1)-1 + j = s_neigh%ja(k) + if ((1<=j).and.(j<=nr)) then + if (ilaggr(j) < 0) then + ip = ip + 1 + icol(ip) = j + end if + end if + enddo + if (ip > 0) then + icnt = icnt + 1 + naggr = naggr + 1 + ilaggr(i) = naggr + do k=1, ip + ilaggr(icol(k)) = naggr + end do + end if + end if + end do step3 + + ! Any leftovers? + do i=1, nr + if (ilaggr(i) <= 0) then + nz = (s_neigh%irp(i+1)-s_neigh%irp(i)) + if (nz <= 1) then + ! Mark explicitly as a singleton so that + ! it will be ignored in map_to_tprol. + ! Need to use -(nrglob+nr) to make sure + ! it's still negative when shifted and combined with + ! other processes. + ilaggr(i) = -(nrglob+nr) + else + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers') + goto 9999 + endif + end if + end do + + if (naggr > ncol) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Fatal error: naggr>ncol') + goto 9999 + end if + + call psb_realloc(ncol,ilaggr,info) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_realloc' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + allocate(nlaggr(np),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),& + & a_err='integer') + goto 9999 + end if + + nlaggr(:) = 0 + nlaggr(me+1) = naggr + call psb_sum(ictxt,nlaggr(1:np)) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_soc2_map_bld + diff --git a/mlprec/impl/aggregator/amg_c_symdec_aggregator_tprol.f90 b/mlprec/impl/aggregator/amg_c_symdec_aggregator_tprol.f90 new file mode 100644 index 00000000..ea8eb812 --- /dev/null +++ b/mlprec/impl/aggregator/amg_c_symdec_aggregator_tprol.f90 @@ -0,0 +1,160 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_c_symdec_aggregator_tprol.f90 +! +! Subroutine: amg_c_symdec_aggregator_tprol +! Version: complex +! +! +! This routine is mainly an interface to soc_map_bld where the real work is performed. +! It takes care of some consistency checking, and calls map_to_tprol, which is +! refactored and shared among all the aggregation methods that produce a simple +! integer mapping. It also symmetrizes the pattern of the local matrix A. +! +! +! +! Arguments: +! Arguments: +! ag - type(amg_c_dec_aggregator_type), input/output. +! The aggregator object, carrying with itself the mapping algorithm. +! parms - The auxiliary parameters object +! ag_data - Auxiliary global aggregation parameters object +! +! a - type(psb_cspmat_type). +! The sparse matrix structure containing the local part of the +! fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! ilaggr - integer, dimension(:), allocatable, output +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that on exit the indices +! will be shifted so as to make sure the ranges on the various processes do not +! overlap. +! nlaggr - integer, dimension(:), allocatable, output +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_cspmat_type), output +! The tentative prolongator, based on ilaggr. +! +! info - integer, output. +! Error code. +! +subroutine amg_c_symdec_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,op_prol,info) + use psb_base_mod + use amg_c_prec_type + use amg_c_symdec_aggregator_mod, amg_protect_name => amg_c_symdec_aggregator_build_tprol + use amg_c_inner_mod + implicit none + class(amg_c_symdec_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(amg_saggr_data), intent(in) :: ag_data + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lcspmat_type), intent(out) :: op_prol + integer(psb_ipk_), intent(out) :: info + + ! Local variables + type(psb_cspmat_type) :: atmp, atrans + character(len=20) :: name + integer(psb_mpk_) :: ictxt, np, me + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: nr + integer(psb_lpk_) :: ntaggr + integer(psb_ipk_) :: debug_level, debug_unit + logical :: clean_zeros + + name='amg_c_symdec_aggregator_tprol' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + call amg_check_def(parms%ml_cycle,'Multilevel cycle',& + & amg_mult_ml_,is_legal_ml_cycle) + call amg_check_def(parms%par_aggr_alg,'Aggregation',& + & amg_dec_aggr_,is_legal_ml_par_aggr_alg) + call amg_check_def(parms%aggr_ord,'Ordering',& + & amg_aggr_ord_nat_,is_legal_ml_aggr_ord) + call amg_check_def(parms%aggr_thresh,'Aggr_Thresh',szero,is_legal_s_aggr_thrs) + + nr = a%get_nrows() + call a%csclip(atmp,info,imax=nr,jmax=nr,& + & rscale=.false.,cscale=.false.) + call atmp%set_nrows(nr) + call atmp%set_ncols(nr) + if (info == psb_success_) call atmp%transp(atrans) + if (info == psb_success_) call atrans%cscnv(info,type='COO') + if (info == psb_success_) call psb_rwextd(nr,atmp,info,b=atrans,rowscale=.false.) + call atmp%set_nrows(nr) + call atmp%set_ncols(nr) + if (info == psb_success_) call atrans%free() + if (info == psb_success_) call atmp%cscnv(info,type='CSR') + + ! + ! The decoupled aggregator based on SOC measures ignores + ! ag_data except for clean_zeros; soc_map_bld is a procedure pointer. + ! + clean_zeros = ag%do_clean_zeros + if (info == psb_success_) & + & call ag%soc_map_bld(parms%aggr_ord,parms%aggr_thresh,clean_zeros,atmp,& + & desc_a,nlaggr,ilaggr,info) + if (info == psb_success_) call atmp%free() + + if (info == psb_success_) call amg_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='soc_map_bld/map_to_tprol') + goto 9999 + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_c_symdec_aggregator_build_tprol diff --git a/mlprec/impl/aggregator/amg_caggrmat_minnrg_bld.f90 b/mlprec/impl/aggregator/amg_caggrmat_minnrg_bld.f90 new file mode 100644 index 00000000..e4654a41 --- /dev/null +++ b/mlprec/impl/aggregator/amg_caggrmat_minnrg_bld.f90 @@ -0,0 +1,656 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_caggrmat_minnrg_bld.F90 +! +! Subroutine: amg_caggrmat_minnrg_bld +! Version: complex +! +! This routine builds a coarse-level matrix A_C from a fine-level matrix A +! by using the Galerkin approach, i.e. +! +! A_C = P_C^T A P_C, +! +! where P_C is a prolongator from the coarse level to the fine one. +! +! The prolongator P_C is built according to a smoothed aggregation algorithm, +! i.e. it is obtained by applying a damped Jacobi smoother to the piecewise +! constant interpolation operator P corresponding to the fine-to-coarse level +! mapping built by the amg_aggrmap_bld subroutine: +! +! P_C = (I - omega*D^(-1)A) * P, +! +! where D is the diagonal matrix with main diagonal equal to the main diagonal +! of A, and omega is a suitable smoothing parameter. An estimate of the spectral +! radius of D^(-1)A, to be used in the computation of omega, is provided, +! according to the value of p%parms%aggr_omega_alg, specified by the user +! through amg_cprecinit and amg_cprecset. +! 4. Minimum energy aggregation: +! M. Sala, R. Tuminaro: A new Petrov-Galerkin smoothed aggregation preconditioner +! for nonsymmetric linear systems, SIAM J. Sci. Comput., 31(1):143-166 (2008) +! +! On output from this routine the entries of AC, op_prol, op_restr +! are still in "global numbering" mode; this is fixed in the calling routine +! aggregator%mat_bld. +! +! +! Arguments: +! a - type(psb_cspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! p - type(amg_c_onelev_type), input/output. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! parms - type(amg_sml_parms), input +! Parameters controlling the choice of algorithm +! ac - type(psb_cspmat_type), output +! The coarse matrix on output +! +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_cspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_cspmat_type), output +! The restrictor operator; in this particular case, it is different +! from the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +! +subroutine amg_caggrmat_minnrg_bld(a,desc_a,ilaggr,nlaggr,parms,& + & ac,desc_ac,op_prol,op_restr,info) + use psb_base_mod + use amg_base_prec_type + use amg_c_inner_mod, amg_protect_name => amg_caggrmat_minnrg_bld + + implicit none + + ! Arguments + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(amg_sml_parms), intent(inout) :: parms + type(psb_lcspmat_type), intent(inout) :: op_prol + type(psb_lcspmat_type), intent(out) :: ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nzac, ip, ndx,& + & naggr, nzl,naggrm1,naggrp1, i, j, k, jd, icolF, nrt + integer(psb_ipk_) :: ictxt,np,me, icomm + character(len=20) :: name + type(psb_lcspmat_type) :: la, af, ptilde, rtilde, atran, atp, atdatp + type(psb_lcspmat_type) :: am3,am4, ap, adap,atmp,rada, ra, atmp2, dap, dadap, da + type(psb_lcspmat_type) :: dat, datp, datdatp, atmp3, tmp_prol + type(psb_lc_coo_sparse_mat) :: tmpcoo + type(psb_lc_csr_sparse_mat) :: acsr1, acsr2, acsr3, acsr, acsrf + type(psb_lc_csc_sparse_mat) :: csc_dap, csc_dadap, csc_datp, csc_datdatp, acsc + complex(psb_spk_), allocatable :: adiag(:), adinv(:) + complex(psb_spk_), allocatable :: omf(:), omp(:), omi(:), oden(:) + logical :: filter_mat + integer(psb_ipk_) :: ierr(5) + integer(psb_ipk_) :: debug_level, debug_unit, err_act + integer(psb_ipk_), parameter :: ncmax=16 + real(psb_spk_) :: anorm, theta + complex(psb_spk_) :: tmp, alpha, beta, ommx + + name='amg_aggrmat_minnrg' + info=psb_success_ + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + ictxt = desc_a%get_context() + + call psb_info(ictxt, me, np) + + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + theta = parms%aggr_thresh + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + + filter_mat = (parms%aggr_filter == amg_filter_mat_) + + ! naggr: number of local aggregates + ! nrow: local rows. + ! + allocate(adinv(ncol),& + & omf(ncol),omp(ntaggr),oden(ntaggr),omi(ncol),stat=info) + + if (info /= psb_success_) then + info=psb_err_alloc_request_; ierr(1)=6*ncol+ntaggr; + call psb_errpush(info,name,i_err=ierr,a_err='complex(psb_spk_)') + goto 9999 + end if + + ! Get the diagonal D + adiag = a%get_diag(info) + if (info == psb_success_) & + & call psb_realloc(ncol,adiag,info) + if (info == psb_success_) & + & call psb_halo(adiag,desc_a,info) + if (info == psb_success_) call a%cp_to_l(la) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_getdiag') + goto 9999 + end if + + do i=1,size(adiag) + if (adiag(i) /= czero) then + adinv(i) = cone / adiag(i) + else + adinv(i) = cone + end if + end do + + + + ! 1. Allocate Ptilde in sparse matrix form + call op_prol%mv_to(tmpcoo) + call ptilde%mv_from(tmpcoo) + call ptilde%cscnv(info,type='csr') + + if (info == psb_success_) call la%cscnv(am3,info,type='csr',dupl=psb_dupl_add_) + if (info == psb_success_) call la%cscnv(da,info,type='csr',dupl=psb_dupl_add_) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Initial copies done.' + + call da%scal(adinv,info) + + call psb_spspmm(da,ptilde,dap,info) + + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 1') + goto 9999 + end if + + call dap%clone(atmp,info) + + call psb_sphalo(atmp,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.,outfmt='CSR ') + if (info == psb_success_) call psb_rwextd(ncol,atmp,info,b=am4) + if (info == psb_success_) call am4%free() + + call psb_spspmm(da,atmp,dadap,info) + call atmp%free() + + ! !$ write(0,*) 'Columns of AP',psb_sp_get_ncols(ap) + ! !$ write(0,*) 'Columns of ADAP',psb_sp_get_ncols(adap) + call dap%mv_to(csc_dap) + call dadap%mv_to(csc_dadap) + + call csc_mat_col_prod(csc_dap,csc_dadap,omp,info) + call csc_mat_col_prod(csc_dadap,csc_dadap,oden,info) + call psb_sum(ictxt,omp) + call psb_sum(ictxt,oden) + ! !$ write(0,*) trim(name),' OMP :',omp + ! !$ write(0,*) trim(name),' ODEN:',oden + + omp = omp/oden + + ! !$ write(0,*) 'Check on output prolongator ',omp(1:min(size(omp),10)) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done NUMBMM 1' + + call am3%mv_to(acsr3) + ! Compute omega_int + ommx = czero + do i=1, ncol + if (ilaggr(i) >0) then + omi(i) = omp(ilaggr(i)) + else + omi(i) = czero + end if + if(abs(omi(i)) .gt. abs(ommx)) ommx = omi(i) + end do + ! Compute omega_fine + do i=1, nrow + omf(i) = ommx + do j=acsr3%irp(i),acsr3%irp(i+1)-1 + if(abs(omi(acsr3%ja(j))) .lt. abs(omf(i))) omf(i)=omi(acsr3%ja(j)) + end do +!!$ if(min(real(omf(i)),aimag(omf(i))) < szero) omf(i) = czero + if(psb_minreal(omf(i)) < szero) omf(i) = czero + end do + + omf(1:nrow) = omf(1:nrow) * adinv(1:nrow) + + if (filter_mat) then + ! + ! Build the filtered matrix Af from A + ! + call la%cscnv(acsrf,info,dupl=psb_dupl_add_) + + do i=1,nrow + tmp = czero + jd = -1 + do j=acsrf%irp(i),acsrf%irp(i+1)-1 + if (acsrf%ja(j) == i) jd = j + if (abs(acsrf%val(j)) < theta*sqrt(abs(adiag(i)*adiag(acsrf%ja(j))))) then + tmp=tmp+acsrf%val(j) + acsrf%val(j)=czero + endif + enddo + if (jd == -1) then + write(0,*) 'Wrong input: we need the diagonal!!!!', i + else + acsrf%val(jd)=acsrf%val(jd)-tmp + end if + enddo + ! Take out zeroed terms + call acsrf%clean_zeros(info) + + ! + ! Build the smoothed prolongator using the filtered matrix + ! + do i=1,acsrf%get_nrows() + do j=acsrf%irp(i),acsrf%irp(i+1)-1 + if (acsrf%ja(j) == i) then + acsrf%val(j) = cone - omf(i)*acsrf%val(j) + else + acsrf%val(j) = - omf(i)*acsrf%val(j) + end if + end do + end do + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done gather, going for SYMBMM 1' + + call af%mv_from(acsrf) + ! + ! op_prol = (I-w*D*Af)Ptilde + ! Doing it this way means to consider diag(Af_i) + ! + ! + call psb_spspmm(af,ptilde,op_prol,info) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done SPSPMM 1' + else + ! + ! Build the smoothed prolongator using the original matrix + ! + do i=1,acsr3%get_nrows() + do j=acsr3%irp(i),acsr3%irp(i+1)-1 + if (acsr3%ja(j) == i) then + acsr3%val(j) = cone - omf(i)*acsr3%val(j) + else + acsr3%val(j) = - omf(i)*acsr3%val(j) + end if + end do + end do + + call am3%mv_from(acsr3) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done gather, going for SYMBMM 1' + ! + ! + ! op_prol = (I-w*D*A)Ptilde + ! + ! + call psb_spspmm(am3,ptilde,op_prol,info) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done NUMBMM 1' + + end if + + + ! + ! Ok, let's start over with the restrictor + ! + call ptilde%transc(rtilde) + call la%cscnv(atmp,info,type='csr') + call psb_sphalo(atmp,desc_a,am4,info,& + & colcnv=.true.,rowscale=.true.) + nrt = am4%get_nrows() + call am4%csclip(atmp2,info,lone,nrt,lone,ncol) + call atmp2%cscnv(info,type='CSR') + if (info == psb_success_) call psb_rwextd(ncol,atmp,info,b=atmp2) + call am4%free() + call atmp2%free() + + ! This is to compute the transpose. It ONLY works if the + ! original A has a symmetric pattern. + call atmp%transc(atmp2) + call atmp2%csclip(dat,info,lone,nrow,lone,ncol) + call dat%cscnv(info,type='csr') + call dat%scal(adinv,info) + + ! Now for the product. + call psb_spspmm(dat,ptilde,datp,info) + + call datp%clone(atmp2,info) + call psb_sphalo(atmp2,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.,outfmt='CSR ') + if (info == psb_success_) call psb_rwextd(ncol,atmp2,info,b=am4) + if (info == psb_success_) call am4%free() + + + call psb_symbmm(dat,atmp2,datdatp,info) + call psb_numbmm(dat,atmp2,datdatp) + call atmp2%free() + + call datp%mv_to(csc_datp) + call datdatp%mv_to(csc_datdatp) + + call csc_mat_col_prod(csc_datp,csc_datdatp,omp,info) + call csc_mat_col_prod(csc_datdatp,csc_datdatp,oden,info) + call psb_sum(ictxt,omp) + call psb_sum(ictxt,oden) + + + ! !$ write(debug_unit,*) trim(name),' OMP_R :',omp + ! ! $ write(debug_unit,*) trim(name),' ODEN_R:',oden + omp = omp/oden + ! !$ write(0,*) 'Check on output restrictor',omp(1:min(size(omp),10)) + ! Compute omega_int + ommx = czero + do i=1, ncol + if (ilaggr(i) >0) then + omi(i) = omp(ilaggr(i)) + else + omi(i) = czero + end if + if(abs(omi(i)) .gt. abs(ommx)) ommx = omi(i) + end do + ! Compute omega_fine + ! Going over the columns of atmp means going over the rows + ! of A^T. Hopefully ;-) + call atmp%cp_to(acsc) + + do i=1, nrow + omf(i) = ommx + do j= acsc%icp(i),acsc%icp(i+1)-1 + if(abs(omi(acsc%ia(j))) .lt. abs(omf(i))) omf(i)=omi(acsc%ia(j)) + end do +!!$ if(min(real(omf(i)),aimag(omf(i))) < szero) omf(i) = czero + if(psb_minreal(omf(i)) < szero) omf(i) = czero + end do + omf(1:nrow) = omf(1:nrow)*adinv(1:nrow) + call psb_halo(omf,desc_a,info) + call acsc%free() + + + call atmp%mv_to(acsr1) + + do i=1,acsr1%get_nrows() + do j=acsr1%irp(i),acsr1%irp(i+1)-1 + if (acsr1%ja(j) == i) then + acsr1%val(j) = cone - acsr1%val(j)*omf(acsr1%ja(j)) + else + acsr1%val(j) = - acsr1%val(j)*omf(acsr1%ja(j)) + end if + end do + end do + call atmp%mv_from(acsr1) + + call rtilde%mv_to(tmpcoo) + nzl = tmpcoo%get_nzeros() + i=0 + do k=1, nzl + if ((naggrm1 < tmpcoo%ia(k)) .and. (tmpcoo%ia(k) <= naggrp1)) then + i = i+1 + tmpcoo%val(i) = tmpcoo%val(k) + tmpcoo%ia(i) = tmpcoo%ia(k) + tmpcoo%ja(i) = tmpcoo%ja(k) + end if + end do + call tmpcoo%set_nzeros(i) + call rtilde%mv_from(tmpcoo) + call rtilde%cscnv(info,type='csr') + + call psb_spspmm(rtilde,atmp,op_restr,info) + + ! + ! Now we have to gather the halo of op_prol, and add it to itself + ! to multiply it by A, + ! + call op_prol%clone(tmp_prol,info) + if (info == psb_success_) call psb_sphalo(tmp_prol,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.) + if (info == psb_success_) call psb_rwextd(ncol,tmp_prol,info,b=am4) + if (info == psb_success_) call am4%free() + + if(info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Halo of op_prol') + goto 9999 + end if + + ! + ! Now we have to fix this. The only rows of B that are correct + ! are those corresponding to "local" aggregates, i.e. indices in ilaggr(:) + ! + call op_restr%mv_to(tmpcoo) + + nzl = tmpcoo%get_nzeros() + i=0 + do k=1, nzl + if ((naggrm1 < tmpcoo%ia(k)) .and. (tmpcoo%ia(k) <= naggrp1)) then + i = i+1 + tmpcoo%val(i) = tmpcoo%val(k) + tmpcoo%ia(i) = tmpcoo%ia(k) + tmpcoo%ja(i) = tmpcoo%ja(k) + end if + end do + call tmpcoo%set_nzeros(i) + call op_restr%mv_from(tmpcoo) + call op_restr%cscnv(info,type='csr') + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + call psb_spspmm(la,tmp_prol,am3,info) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done SPSPMM 2' + + call psb_sphalo(am3,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.) + if (info == psb_success_) call psb_rwextd(ncol,am3,info,b=am4) + if (info == psb_success_) call am4%free() + + if(info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Extend am3') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done sphalo/ rwxtd' + + call psb_spspmm(op_restr,am3,ac,info) + if (info == psb_success_) call am3%free() + if (info == psb_success_) call ac%cscnv(info,type='coo',dupl=psb_dupl_add_) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + &a_err='Build ac = op_restr x am3') + goto 9999 + end if + + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done smooth_aggregate ' + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_errpush(info,name) + call psb_error_handler(err_act) + return + + +contains + + subroutine csc_mat_col_prod(a,b,v,info) + implicit none + type(psb_lc_csc_sparse_mat), intent(in) :: a, b + complex(psb_spk_), intent(out) :: v(:) + integer(psb_ipk_), intent(out) :: info + + integer(psb_lpk_) :: i,j,k, nr, nc,iap,nra,ibp,nrb + + info = psb_success_ + nc = a%get_ncols() + if (nc /= b%get_ncols()) then + write(0,*) 'Matrices A and B should have same columns' + info = -1 + return + end if + + do j=1, nc + iap = a%icp(j) + nra = a%icp(j+1)-iap + ibp = b%icp(j) + nrb = b%icp(j+1)-ibp + v(j) = sparse_srtd_dot(nra,a%ia(iap:iap+nra-1),a%val(iap:iap+nra-1),& + & nrb,b%ia(ibp:ibp+nrb-1),b%val(ibp:ibp+nrb-1)) + end do + + end subroutine csc_mat_col_prod + + + subroutine csr_mat_row_prod(a,b,v,info) + implicit none + type(psb_lc_csr_sparse_mat), intent(in) :: a, b + complex(psb_spk_), intent(out) :: v(:) + integer(psb_ipk_), intent(out) :: info + + integer(psb_lpk_) :: i,j,k, nr, nc,iap,nca,ibp,ncb + + info = psb_success_ + nr = a%get_nrows() + if (nr /= b%get_nrows()) then + write(0,*) 'Matrices A and B should have same rows' + info = -1 + return + end if + + do j=1, nr + iap = a%irp(j) + nca = a%irp(j+1)-iap + ibp = b%irp(j) + ncb = b%irp(j+1)-ibp + v(j) = sparse_srtd_dot(nca,a%ja(iap:iap+nca-1),a%val(iap:iap+nca-1),& + & ncb,b%ja(ibp:ibp+ncb-1),b%val(ibp:ibp+ncb-1)) + end do + + end subroutine csr_mat_row_prod + + + function sparse_srtd_dot(nv1,iv1,v1,nv2,iv2,v2) result(dot) + implicit none + integer(psb_lpk_), intent(in) :: nv1,nv2 + integer(psb_lpk_), intent(in) :: iv1(:), iv2(:) + complex(psb_spk_), intent(in) :: v1(:),v2(:) + complex(psb_spk_) :: dot + + integer(psb_lpk_) :: i,j,k, ip1, ip2 + + dot = czero + ip1 = 1 + ip2 = 1 + + do + if (ip1 > nv1) exit + if (ip2 > nv2) exit + if (iv1(ip1) == iv2(ip2)) then + dot = dot + conjg(v1(ip1))*v2(ip2) + ip1 = ip1 + 1 + ip2 = ip2 + 1 + else if (iv1(ip1) < iv2(ip2)) then + ip1 = ip1 + 1 + else + ip2 = ip2 + 1 + end if + end do + + end function sparse_srtd_dot + + subroutine local_dump(me,mat,name,header) + type(psb_lcspmat_type), intent(in) :: mat + integer(psb_ipk_), intent(in) :: me + character(len=*), intent(in) :: name + character(len=*), intent(in) :: header + character(len=80) :: filename + + write(filename,'(a,a,i0,a,i0,a)') trim(name),'.p',me + open(20+me,file=filename) + call mat%print(20+me,head=trim(header)) + close(20+me) + end subroutine local_dump + +end subroutine amg_caggrmat_minnrg_bld diff --git a/mlprec/impl/aggregator/amg_caggrmat_nosmth_bld.f90 b/mlprec/impl/aggregator/amg_caggrmat_nosmth_bld.f90 new file mode 100644 index 00000000..bf5b354e --- /dev/null +++ b/mlprec/impl/aggregator/amg_caggrmat_nosmth_bld.f90 @@ -0,0 +1,198 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_caggrmat_nosmth_bld.F90 +! +! Subroutine: amg_caggrmat_nosmth_bld +! Version: complex +! +! This routine builds a coarse-level matrix A_C from a fine-level matrix A +! by using the Galerkin approach, i.e. +! +! A_C = P_C^T A P_C, +! +! where P_C is the piecewise constant interpolation operator corresponding +! the fine-to-coarse level mapping built by amg_aggrmap_bld. +! +! The coarse-level matrix A_C is distributed among the parallel processes or +! replicated on each of them, according to the value of p%parms%coarse_mat +! specified by the user through amg_cprecinit and amg_zprecset. +! On output from this routine the entries of AC, op_prol, op_restr +! are still in "global numbering" mode; this is fixed in the calling routine +! aggregator%mat_bld. +! +! For details see +! P. D'Ambra, D. di Serafino and S. Filippone, On the development of +! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math., +! 57 (2007), 1181-1196. +! +! +! Arguments: +! a - type(psb_cspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! p - type(amg_c_onelev_type), input/output. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! parms - type(amg_sml_parms), input +! Parameters controlling the choice of algorithm +! ac - type(psb_cspmat_type), output +! The coarse matrix on output +! +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_cspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_cspmat_type), output +! The restrictor operator; normally, it is the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +! +subroutine amg_caggrmat_nosmth_bld(a,desc_a,ilaggr,nlaggr,parms,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + use psb_base_mod + use amg_base_prec_type + use amg_c_inner_mod, amg_protect_name => amg_caggrmat_nosmth_bld + use amg_c_base_aggregator_mod + implicit none + + ! Arguments + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(amg_sml_parms), intent(inout) :: parms + type(psb_cspmat_type), intent(inout) :: op_prol,ac,op_restr + type(psb_lcspmat_type), intent(inout) :: t_prol + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt, np, me, icomm, minfo + character(len=20) :: name + type(psb_lc_coo_sparse_mat) :: lcoo_prol + type(psb_c_coo_sparse_mat) :: coo_prol, coo_restr + type(psb_c_csr_sparse_mat) :: acsr + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nzl, ip, & + & naggr, nzt, naggrm1, naggrp1, i, k + integer(psb_ipk_) :: inaggr, nzlp + logical, parameter :: debug = .false. + + name = 'amg_aggrmat_nosmth_bld' + info = psb_success_ + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + call psb_info(ictxt, me, np) + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + + call a%cp_to(acsr) + call t_prol%mv_to(lcoo_prol) + inaggr = naggr + call psb_cdall(ictxt,desc_ac,info,nl=inaggr) + nzlp = lcoo_prol%get_nzeros() + call desc_ac%indxmap%g2lip_ins(lcoo_prol%ja(1:nzlp),info) + call lcoo_prol%set_ncols(desc_ac%get_local_cols()) + call lcoo_prol%cp_to_icoo(coo_prol,info) + + if (debug) call check_coo(me,trim(name)//' Check 1 on coo_prol:',coo_prol) + + call psb_cdasb(desc_ac,info) + call psb_cd_reinit(desc_ac,info) + + call amg_ptap(acsr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info) + + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_a%get_local_cols()) + call coo_prol%set_nrows(desc_a%get_local_rows()) + call coo_prol%set_ncols(desc_ac%get_local_cols()) + + if (debug) call check_coo(me,trim(name)//' Check 1 on coo_restr:',coo_restr) + + call op_prol%mv_from(coo_prol) + call op_restr%mv_from(coo_restr) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_c_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo +end subroutine amg_caggrmat_nosmth_bld diff --git a/mlprec/impl/aggregator/amg_caggrmat_smth_bld.f90 b/mlprec/impl/aggregator/amg_caggrmat_smth_bld.f90 new file mode 100644 index 00000000..a6356cfa --- /dev/null +++ b/mlprec/impl/aggregator/amg_caggrmat_smth_bld.f90 @@ -0,0 +1,325 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_caggrmat_smth_bld.F90 +! +! Subroutine: amg_caggrmat_smth_bld +! Version: complex +! +! This routine builds a coarse-level matrix A_C from a fine-level matrix A +! by using the Galerkin approach, i.e. +! +! A_C = P_C^T A P_C, +! +! where P_C is a prolongator from the coarse level to the fine one. +! +! The prolongator P_C is built according to a smoothed aggregation algorithm, +! i.e. it is obtained by applying a damped Jacobi smoother to the piecewise +! constant interpolation operator P corresponding to the fine-to-coarse level +! mapping built by the amg_aggrmap_bld subroutine: +! +! P_C = (I - omega*D^(-1)A) * P, +! +! where D is the diagonal matrix with main diagonal equal to the main diagonal +! of A, and omega is a suitable smoothing parameter. An estimate of the spectral +! radius of D^(-1)A, to be used in the computation of omega, is provided, +! according to the value of p%parms%aggr_omega_alg, specified by the user +! through amg_cprecinit and amg_zprecset. +! +! The coarse-level matrix A_C is distributed among the parallel processes or +! replicated on each of them, according to the value of p%parms%coarse_mat, +! specified by the user through amg_cprecinit and amg_zprecset. +! On output from this routine the entries of AC, op_prol, op_restr +! are still in "global numbering" mode; this is fixed in the calling routine +! aggregator%mat_bld. +! +! +! Arguments: +! a - type(psb_cspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! p - type(amg_c_onelev_type), input/output. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! parms - type(amg_sml_parms), input +! Parameters controlling the choice of algorithm +! ac - type(psb_cspmat_type), output +! The coarse matrix on output +! +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_cspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_cspmat_type), output +! The restrictor operator; normally, it is the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +subroutine amg_caggrmat_smth_bld(a,desc_a,ilaggr,nlaggr,parms,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + use psb_base_mod + use amg_base_prec_type + use amg_c_inner_mod, amg_protect_name => amg_caggrmat_smth_bld + use amg_c_base_aggregator_mod + + implicit none + + ! Arguments + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(amg_sml_parms), intent(inout) :: parms + type(psb_cspmat_type), intent(out) :: op_prol,ac,op_restr + type(psb_lcspmat_type), intent(inout) :: t_prol + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, ip, & + & naggr, nzl,naggrm1,naggrp1, i, j, k, jd, icolF, nrw + integer(psb_ipk_) :: inaggr, nzlp + integer(psb_ipk_) :: ictxt, np, me + character(len=20) :: name + type(psb_lc_coo_sparse_mat) :: tmpcoo + type(psb_c_coo_sparse_mat) :: coo_prol, coo_restr + type(psb_c_csr_sparse_mat) :: acsr1, acsrf, csr_prol, acsr + complex(psb_spk_), allocatable :: adiag(:) + real(psb_spk_), allocatable :: arwsum(:) + integer(psb_ipk_) :: ierr(5) + logical :: filter_mat + integer(psb_ipk_) :: debug_level, debug_unit, err_act + integer(psb_ipk_), parameter :: ncmax=16 + real(psb_spk_) :: anorm, omega, tmp, dg, theta + logical, parameter :: debug_new=.false. + character(len=80) :: filename + + name='amg_aggrmat_smth_bld' + info=psb_success_ + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + ictxt = desc_a%get_context() + + call psb_info(ictxt, me, np) + + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + theta = parms%aggr_thresh + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + filter_mat = (parms%aggr_filter == amg_filter_mat_) + + ! + ! naggr: number of local aggregates + ! nrow: local rows. + ! + + ! Get the diagonal D + adiag = a%get_diag(info) + if (info == psb_success_) & + & call psb_realloc(ncol,adiag,info) + if (info == psb_success_) & + & call psb_halo(adiag,desc_a,info) + if (info == psb_success_) call a%cp_to(acsr) + + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_getdiag') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Initial copies done.' + + call acsr%cp_to_fmt(acsrf,info) + + + if (filter_mat) then + ! + ! Build the filtered matrix Af from A + ! + + do i=1, nrow + tmp = czero + jd = -1 + do j=acsrf%irp(i),acsrf%irp(i+1)-1 + if (acsrf%ja(j) == i) jd = j + if (abs(acsrf%val(j)) < theta*sqrt(abs(adiag(i)*adiag(acsrf%ja(j))))) then + tmp=tmp+acsrf%val(j) + acsrf%val(j)=czero + endif + + enddo + if (jd == -1) then + write(0,*) 'Wrong input: we need the diagonal!!!!', i + else + acsrf%val(jd)=acsrf%val(jd)-tmp + end if + enddo + ! Take out zeroed terms + call acsrf%clean_zeros(info) + end if + + + do i=1,size(adiag) + if (adiag(i) /= czero) then + adiag(i) = cone / adiag(i) + else + adiag(i) = cone + end if + end do + + if (parms%aggr_omega_alg == amg_eig_est_) then + + if (parms%aggr_eig == amg_max_norm_) then + allocate(arwsum(nrow)) + call acsr%arwsum(arwsum) + anorm = maxval(abs(adiag(1:nrow)*arwsum(1:nrow))) + call psb_amx(ictxt,anorm) + omega = 4.d0/(3.d0*anorm) + parms%aggr_omega_val = omega + + else + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_aggr_eig_') + goto 9999 + end if + + else if (parms%aggr_omega_alg == amg_user_choice_) then + + omega = parms%aggr_omega_val + + else if (parms%aggr_omega_alg /= amg_user_choice_) then + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_aggr_omega_alg_') + goto 9999 + end if + + + call acsrf%scal(adiag,info) + if (info /= psb_success_) goto 9999 + + call t_prol%mv_to(tmpcoo) + inaggr = naggr + call psb_cdall(ictxt,desc_ac,info,nl=inaggr) + nzlp = tmpcoo%get_nzeros() + call desc_ac%indxmap%g2lip_ins(tmpcoo%ja(1:nzlp),info) + call tmpcoo%set_ncols(desc_ac%get_local_cols()) + call tmpcoo%mv_to_ifmt(csr_prol,info) + + call psb_cdasb(desc_ac,info) + call psb_cd_reinit(desc_ac,info) + ! + ! Build the smoothed prolongator using either A or Af + ! acsr1 = (I-w*D*A) Prol acsr1 = (I-w*D*Af) Prol + ! This is always done through the variable acsrf which + ! is a bit less readable, but saves space and one matrix copy + ! + call omega_smooth(omega,acsrf) + call psb_par_spspmm(acsrf,desc_a,csr_prol,acsr1,desc_ac,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 1') + goto 9999 + end if + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done SPSPMM 1' + nzl = acsr1%get_nzeros() + call acsr1%mv_to_coo(coo_prol,info) + + call amg_ptap(acsr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info) + + call op_prol%mv_from(coo_prol) + call op_restr%mv_from(coo_restr) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done smooth_aggregate ' + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_errpush(info,name) + call psb_error_handler(err_act) + return + +contains + + subroutine omega_smooth(omega,acsr) + implicit none + real(psb_spk_),intent(in) :: omega + type(psb_c_csr_sparse_mat), intent(inout) :: acsr + ! + integer(psb_lpk_) :: i,j + do i=1,acsr%get_nrows() + do j=acsr%irp(i),acsr%irp(i+1)-1 + if (acsr%ja(j) == i) then + acsr%val(j) = cone - omega*acsr%val(j) + else + acsr%val(j) = - omega*acsr%val(j) + end if + end do + end do + end subroutine omega_smooth + +end subroutine amg_caggrmat_smth_bld diff --git a/mlprec/impl/aggregator/amg_d_dec_aggregator_mat_asb.f90 b/mlprec/impl/aggregator/amg_d_dec_aggregator_mat_asb.f90 new file mode 100644 index 00000000..812ba70b --- /dev/null +++ b/mlprec/impl/aggregator/amg_d_dec_aggregator_mat_asb.f90 @@ -0,0 +1,195 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_d_dec_aggregator_mat_asb.f90 +! +! Subroutine: amg_d_dec_aggregator_mat_asb +! Version: real +! +! +! From a given AC to final format, generating DESC_AC +! +! Arguments: +! ag - type(amg_d_dec_aggregator_type), input/output. +! The aggregator object +! parms - type(amg_dml_parms), input +! The aggregation parameters +! a - type(psb_dspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! ac - type(psb_dspmat_type), inout +! The coarse matrix +! desc_ac - type(psb_desc_type), output. +! The communication descriptor of the fine-level matrix. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! +! op_prol - type(psb_dspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_dspmat_type), input/output +! The restrictor operator; normally, it is the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +subroutine amg_d_dec_aggregator_mat_asb(ag,parms,a,desc_a,& + & ac,desc_ac, op_prol,op_restr,info) + use psb_base_mod + use amg_base_prec_type + use amg_d_dec_aggregator_mod, amg_protect_name => amg_d_dec_aggregator_mat_asb + implicit none + class(amg_d_dec_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + type(psb_dspmat_type), intent(inout) :: op_prol, ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: ictxt, np, me + type(psb_ld_coo_sparse_mat) :: tmpcoo + type(psb_ldspmat_type) :: tmp_ac + integer(psb_ipk_) :: i_nr, i_nc, i_nl, nzl + integer(psb_lpk_) :: ntaggr + integer(psb_ipk_) :: err_act, debug_level, debug_unit + character(len=20) :: name='d_dec_aggregator_mat_asb' + + + if (psb_get_errstatus().ne.0) return + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + select case(parms%coarse_mat) + + case(amg_distr_mat_) + + call ac%cscnv(info,type='csr') + call op_prol%cscnv(info,type='csr') + call op_restr%cscnv(info,type='csr') + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ac ' + + case(amg_repl_mat_) + ! + ! We are assuming here that an d matrix + ! can hold all entries + ! + if (desc_ac%get_global_rows() < huge(1_psb_ipk_) ) then + ntaggr = desc_ac%get_global_rows() + i_nr = ntaggr + else + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_coarse_mat_') + goto 9999 + end if + + call op_prol%mv_to(tmpcoo) + nzl = tmpcoo%get_nzeros() + call psb_loc_to_glob(tmpcoo%ja(1:nzl),desc_ac,info,'I') + call tmpcoo%set_ncols(i_nr) + call op_prol%mv_from(tmpcoo) + + call op_restr%mv_to(tmpcoo) + nzl = tmpcoo%get_nzeros() + call psb_loc_to_glob(tmpcoo%ia(1:nzl),desc_ac,info,'I') + call tmpcoo%set_nrows(i_nr) + call op_restr%mv_from(tmpcoo) + + + call psb_gather(tmp_ac,ac,desc_ac,info,root=-ione,& + & dupl=psb_dupl_add_,keeploc=.false.) + call tmp_ac%mv_to(tmpcoo) + call ac%mv_from(tmpcoo) + + call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) + if (info == psb_success_) call psb_cdasb(desc_ac,info) + + if (info /= psb_success_) goto 9999 + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_coarse_mat_') + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_ld_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo +end subroutine amg_d_dec_aggregator_mat_asb diff --git a/mlprec/impl/aggregator/amg_d_dec_aggregator_mat_bld.f90 b/mlprec/impl/aggregator/amg_d_dec_aggregator_mat_bld.f90 new file mode 100644 index 00000000..9dcd3740 --- /dev/null +++ b/mlprec/impl/aggregator/amg_d_dec_aggregator_mat_bld.f90 @@ -0,0 +1,216 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_d_dec_aggregator_mat_bld.f90 +! +! Subroutine: amg_d_dec_aggregator_mat_bld +! Version: real +! +! This routine builds the matrix associated to the current level of the +! multilevel preconditioner from the matrix associated to the previous level, +! by using the user-specified aggregation technique (therefore, it also builds the +! prolongation and restriction operators mapping the current level to the +! previous one and vice versa). +! The current level is regarded as the coarse one, while the previous as +! the fine one. This is in agreement with the fact that the routine is called, +! by amg_mlprec_bld, only on levels >=2. +! The coarse-level matrix A_C is built from a fine-level matrix A +! by using the Galerkin approach, i.e. +! +! A_C = P_C^T A P_C, +! +! where P_C is a prolongator from the coarse level to the fine one. +! +! A mapping from the nodes of the adjacency graph of A to the nodes of the +! adjacency graph of A_C has been computed by the amg_aggrmap_bld subroutine. +! The prolongator P_C is built here from this mapping, according to the +! value of p%iprcparm(amg_aggr_kind_), specified by the user through +! amg_dprecinit and amg_zprecset. +! On output from this routine the entries of AC, op_prol, op_restr +! are still in "global numbering" mode; this is fixed in the calling routine +! amg_d_lev_aggrmat_bld. +! +! Currently four different prolongators are implemented, corresponding to +! four aggregation algorithms: +! 1. un-smoothed aggregation, +! 2. smoothed aggregation, +! 3. "bizarre" aggregation. +! 4. minimum energy +! 1. The non-smoothed aggregation uses as prolongator the piecewise constant +! interpolation operator corresponding to the fine-to-coarse level mapping built +! by p%aggr%bld_tprol. This is called tentative prolongator. +! 2. The smoothed aggregation uses as prolongator the operator obtained by applying +! a damped Jacobi smoother to the tentative prolongator. +! 3. The "bizarre" aggregation uses a prolongator proposed by the authors of MLD2P4. +! This prolongator still requires a deep analysis and testing and its use is +! not recommended. +! 4. Minimum energy aggregation +! +! For more details see +! M. Brezina and P. Vanek, A black-box iterative solver based on a two-level +! Schwarz method, Computing, 63 (1999), 233-263. +! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed +! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 +! (1996), 179-196. +! P. D'Ambra, D. di Serafino and S. Filippone, On the development of PSBLAS-based +! parallel two-level Schwarz preconditioners, Appl. Num. Math., 57 (2007), +! 1181-1196. +! M. Sala, R. Tuminaro: A new Petrov-Galerkin smoothed aggregation preconditioner +! for nonsymmetric linear systems, SIAM J. Sci. Comput., 31(1):143-166 (2008) +! +! +! The main structure is: +! 1. Perform sanity checks; +! 2. Compute prolongator/restrictor/AC +! +! +! Arguments: +! ag - type(amg_d_dec_aggregator_type), input/output. +! The aggregator object +! parms - type(amg_dml_parms), input +! The aggregation parameters +! a - type(psb_dspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! ac - type(psb_dspmat_type), output +! The coarse matrix on output +! +! op_prol - type(psb_dspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_dspmat_type), output +! The restrictor operator; normally, it is the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +subroutine amg_d_dec_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + use psb_base_mod + use amg_d_prec_type, amg_protect_name => amg_d_dec_aggregator_mat_bld + use amg_d_inner_mod + implicit none + + class(amg_d_dec_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(psb_ldspmat_type), intent(inout) :: t_prol + type(psb_dspmat_type), intent(out) :: op_prol,ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + + ! Local variables + character(len=20) :: name + integer(psb_mpk_) :: ictxt, np, me + integer(psb_lpk_) :: nzl,ntaggr + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: debug_level, debug_unit + + name='amg_d_dec_aggregator_mat_bld' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + ! + ! Build the coarse-level matrix from the fine-level one, starting from + ! the mapping defined by amg_aggrmap_bld and applying the aggregation + ! algorithm specified by + ! + select case (parms%aggr_prol) + case (amg_no_smooth_) + + call amg_daggrmat_nosmth_bld(a,desc_a,ilaggr,nlaggr,& + & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) + + case(amg_smooth_prol_) + + call amg_daggrmat_smth_bld(a,desc_a,ilaggr,nlaggr, & + & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) + +!!$ case(amg_biz_prol_) +!!$ +!!$ call amg_daggrmat_biz_bld(a,desc_a,ilaggr,nlaggr, & +!!$ & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) + + case(amg_min_energy_) + + call amg_daggrmat_minnrg_bld(a,desc_a,ilaggr,nlaggr, & + & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='Invalid aggr kind') + goto 9999 + + end select + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='Inner aggrmat bld') + goto 9999 + end if + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + +end subroutine amg_d_dec_aggregator_mat_bld diff --git a/mlprec/impl/aggregator/amg_d_dec_aggregator_tprol.f90 b/mlprec/impl/aggregator/amg_d_dec_aggregator_tprol.f90 new file mode 100644 index 00000000..9a6a3bd8 --- /dev/null +++ b/mlprec/impl/aggregator/amg_d_dec_aggregator_tprol.f90 @@ -0,0 +1,139 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_d_dec_aggregator_tprol.f90 +! +! Subroutine: amg_d_dec_aggregator_tprol +! Version: real +! +! This routine is mainly an interface to soc_map_bld where the real work is performed. +! It takes care of some consistency checking, and calls map_to_tprol, which is +! refactored and shared among all the aggregation methods that produce a simple +! integer mapping. +! +! +! Arguments: +! ag - type(amg_d_dec_aggregator_type), input/output. +! The aggregator object, carrying with itself the mapping algorithm. +! parms - The auxiliary parameters object +! ag_data - Auxiliary global aggregation parameters object +! +! +! a - type(psb_dspmat_type). +! The sparse matrix structure containing the local part of the +! fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! ilaggr - integer, dimension(:), allocatable, output +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that on exit the indices +! will be shifted so as to make sure the ranges on the various processes do not +! overlap. +! nlaggr - integer, dimension(:), allocatable, output +! nlaggr(i) contains the aggregates held by process i. +! t_prol - type(psb_dspmat_type), output +! The tentative prolongator, based on ilaggr. +! +! info - integer, output. +! Error code. +! +subroutine amg_d_dec_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,t_prol,info) + use psb_base_mod + use amg_d_prec_type, amg_protect_name => amg_d_dec_aggregator_build_tprol + use amg_d_inner_mod + implicit none + class(amg_d_dec_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(amg_daggr_data), intent(in) :: ag_data + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_ldspmat_type), intent(out) :: t_prol + integer(psb_ipk_), intent(out) :: info + + ! Local variables + character(len=20) :: name + integer(psb_mpk_) :: ictxt, np, me + integer(psb_ipk_) :: err_act + integer(psb_lpk_) :: ntaggr + integer(psb_ipk_) :: debug_level, debug_unit + logical :: clean_zeros + + name='amg_d_dec_aggregator_tprol' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + call amg_check_def(parms%ml_cycle,'Multilevel cycle',& + & amg_mult_ml_,is_legal_ml_cycle) + call amg_check_def(parms%par_aggr_alg,'Aggregation',& + & amg_dec_aggr_,is_legal_ml_par_aggr_alg) + call amg_check_def(parms%aggr_ord,'Ordering',& + & amg_aggr_ord_nat_,is_legal_ml_aggr_ord) + call amg_check_def(parms%aggr_thresh,'Aggr_Thresh',dzero,is_legal_d_aggr_thrs) + + ! + ! The decoupled aggregator based on SOC measures ignores + ! ag_data except for clean_zeros; soc_map_bld is a procedure pointer. + ! + clean_zeros = ag%do_clean_zeros + call ag%soc_map_bld(parms%aggr_ord,parms%aggr_thresh,clean_zeros,a,desc_a,nlaggr,ilaggr,info) + + if (info==psb_success_) call amg_map_to_tprol(desc_a,ilaggr,nlaggr,t_prol,info) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='soc_map_bld/map_to_tprol') + goto 9999 + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_d_dec_aggregator_build_tprol diff --git a/mlprec/impl/aggregator/amg_d_map_to_tprol.f90 b/mlprec/impl/aggregator/amg_d_map_to_tprol.f90 new file mode 100644 index 00000000..a6288cda --- /dev/null +++ b/mlprec/impl/aggregator/amg_d_map_to_tprol.f90 @@ -0,0 +1,154 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_d_map_to_tprol.f90 +! +! Subroutine: amg_d_map_to_tprol +! Version: real +! +! This routine uses a mapping from the row indices of the fine-level matrix +! to the row indices of the coarse-level matrix to build a tentative +! prolongator, i.e. a piecewise constant operator. +! This is later used to build the final operator; the code has been refactored here +! to be shared among all the methods that provide the tentative prolongator +! through a simple integer mapping. +! +! The aggregation algorithm is a parallel version of that described in +! * M. Brezina and P. Vanek, A black-box iterative solver based on a +! two-level Schwarz method, Computing, 63 (1999), 233-263. +! * P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed +! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 +! (1996), 179-196. +! For more details see +! P. D'Ambra, D. di Serafino and S. Filippone, On the development of +! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math. +! 57 (2007), 1181-1196. +! +! +! Arguments: +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! ilaggr - integer, dimension(:), allocatable. +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that on exit the indices +! will be shifted so as to make sure the ranges on the various processes do not +! overlap. +! nlaggr - integer, dimension(:), allocatable. +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_dspmat_type). +! The tentative prolongator, based on ilaggr. +! +! info - integer, output. +! Error code. +! +subroutine amg_d_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) + + use psb_base_mod + use amg_d_inner_mod, amg_protect_name => amg_d_map_to_tprol + + implicit none + + ! Arguments + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), allocatable, intent(inout) :: ilaggr(:),nlaggr(:) + type(psb_ldspmat_type), intent(out) :: op_prol + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_lpk_) :: icnt,nlp,k,n,ia,isz,nr, naggr,i,j,m,naggrm1, naggrp1, ntaggr + type(psb_ld_coo_sparse_mat) :: tmpcoo + integer(psb_ipk_) :: debug_level, debug_unit,err_act + integer(psb_ipk_) :: ictxt,np,me + integer(psb_lpk_) :: nrow, ncol, n_ne + character(len=20) :: name, ch_err + + info=psb_success_ + name = 'amg_map_to_tprol' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ! + ictxt=desc_a%get_context() + call psb_info(ictxt,me,np) + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + ilaggr(1:nrow) = ilaggr(1:nrow) + naggrm1 + call psb_halo(ilaggr,desc_a,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_halo') + goto 9999 + end if + + call tmpcoo%allocate(nrow,ntaggr,ncol) + k = 0 + do i=1,nrow + ! + ! Note: at this point, a value ilaggr(i)<=0 + ! tags a "singleton" row, and it has to be + ! left alone. + ! + if (ilaggr(i)>0) then + k = k + 1 + tmpcoo%val(k) = done + tmpcoo%ia(k) = i + tmpcoo%ja(k) = ilaggr(i) + end if + end do + call tmpcoo%set_nzeros(k) + call tmpcoo%set_dupl(psb_dupl_add_) + call tmpcoo%set_sorted() ! At this point this is in row-major + call op_prol%mv_from(tmpcoo) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_map_to_tprol diff --git a/mlprec/impl/aggregator/amg_d_ptap.f90 b/mlprec/impl/aggregator/amg_d_ptap.f90 new file mode 100644 index 00000000..f85692f0 --- /dev/null +++ b/mlprec/impl/aggregator/amg_d_ptap.f90 @@ -0,0 +1,689 @@ +! +! +! MLD2P4 Extensions +! +! (C) Copyright 2019 +! +! Salvatore Filippone Cranfield University +! Pasqua D'Ambra IAC-CNR, Naples, IT +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_daggrmat_nosmth_bld.F90 +! +! +subroutine amg_d_ptap(a_csr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info,desc_ax) + use psb_base_mod + use amg_d_inner_mod + use amg_d_base_aggregator_mod, amg_protect_name => amg_d_ptap + implicit none + + ! Arguments + type(psb_d_csr_sparse_mat), intent(inout) :: a_csr + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + type(amg_dml_parms), intent(inout) :: parms + type(psb_d_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr + type(psb_desc_type), intent(inout) :: desc_ac + type(psb_dspmat_type), intent(out) :: ac + integer(psb_ipk_), intent(out) :: info + type(psb_desc_type), intent(inout), optional :: desc_ax + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo + character(len=40) :: name + integer(psb_ipk_) :: ierr(5) + type(psb_ld_coo_sparse_mat) :: ac_coo, tmpcoo + type(psb_d_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr + integer(psb_ipk_) :: debug_level, debug_unit, naggr + integer(psb_lpk_) :: nglob, ntaggr, naggrm1, naggrp1 + integer(psb_ipk_) :: nrow, ncol, nrl, nzl, ip, nzt, i, k + integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza + logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. + integer(psb_ipk_), save :: idx_spspmm=-1 + + name='amg_ptap' + if(psb_get_errstatus().ne.0) return + info=psb_success_ + call psb_erractionsave(err_act) + + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + call psb_info(ictxt, me, np) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + if ((do_timings).and.(idx_spspmm==-1)) & + & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr + + ! + ! COO_PROL should arrive here with local numbering + ! + if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& + & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& + & nrow,ntaggr,naggr + + call coo_prol%cp_to_fmt(csr_prol,info) + + if (debug) write(0,*) me,trim(name),' Product AxPROL ',& + & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & + & desc_a%get_local_rows(),desc_a%get_local_cols(),& + & desc_ac%get_local_rows(),desc_a%get_local_cols() + if (debug) flush(0) + + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + + if (debug) write(0,*) me,trim(name),' Done AxPROL ',& + & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& + & desc_ac%get_local_rows(),desc_ac%get_local_cols() + + ! + ! Ok first product done. + + if (present(desc_ax)) then + block + call coo_prol%cp_to_coo(coo_restr,info) + call coo_restr%set_ncols(desc_ac%get_local_cols()) + call coo_restr%set_nrows(desc_a%get_local_rows()) + call psb_d_coo_glob_transpose(coo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_ax%get_local_cols()) +! !$ write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& +! !$ & desc_a%get_local_cols(),desc_ax%get_local_cols(),coo_restr%get_nzeros() +! !$ if (desc_a%get_local_cols()= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + + else + + ! + ! Remember that RESTR must be built from PROL after halo extension, + ! which is done above in psb_par_spspmm + if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& + & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() + call csr_prol%mv_to_coo(coo_restr,info) +!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& +!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() + if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) + + call coo_restr%transp() + nzl = coo_restr%get_nzeros() + nrl = desc_ac%get_local_rows() + i=0 + ! + ! Only keep local rows + ! + do k=1, nzl + if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then + i = i+1 + coo_restr%val(i) = coo_restr%val(k) + coo_restr%ia(i) = coo_restr%ia(k) + coo_restr%ja(i) = coo_restr%ja(k) + end if + end do + call coo_restr%set_nzeros(i) + call coo_restr%fix(info) + nzl = coo_restr%get_nzeros() + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_a%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) + call csr_restr%cp_from_coo(coo_restr,info) + +!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + end if + + call psb_cdasb(desc_ac,info) + + call ac_csr%set_nrows(desc_ac%get_local_rows()) + call ac_csr%set_ncols(desc_ac%get_local_cols()) + call ac%mv_from(ac_csr) + call ac%set_asb() + + if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() + if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr + ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() + + call coo_prol%set_ncols(desc_ac%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ptap ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_d_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo + +end subroutine amg_d_ptap + +subroutine amg_d_ld_ptap(a_csr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info,desc_ax) + use psb_base_mod + use amg_d_inner_mod + use amg_d_base_aggregator_mod !, amg_protect_name => amg_d_ld_ptap + implicit none + + ! Arguments + type(psb_d_csr_sparse_mat), intent(inout) :: a_csr + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + type(amg_dml_parms), intent(inout) :: parms + type(psb_ld_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr + type(psb_desc_type), intent(inout) :: desc_ac + type(psb_ldspmat_type), intent(out) :: ac + integer(psb_ipk_), intent(out) :: info + type(psb_desc_type), intent(inout), optional :: desc_ax + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo + character(len=40) :: name + integer(psb_ipk_) :: ierr(5) + type(psb_ld_coo_sparse_mat) :: ac_coo, tmpcoo + type(psb_d_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr + integer(psb_ipk_) :: debug_level, debug_unit, naggr + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nrl, nzl, ip, & + & nzt, naggrm1, naggrp1, i, k + integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza + logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. + integer(psb_ipk_), save :: idx_spspmm=-1 + + name='amg_ptap' + if(psb_get_errstatus().ne.0) return + info=psb_success_ + call psb_erractionsave(err_act) + + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + call psb_info(ictxt, me, np) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + if ((do_timings).and.(idx_spspmm==-1)) & + & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr + + ! + ! COO_PROL should arrive here with local numbering + ! + if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& + & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& + & nrow,ntaggr,naggr + + call coo_prol%cp_to_ifmt(csr_prol,info) + + if (debug) write(0,*) me,trim(name),' Product AxPROL ',& + & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & + & desc_a%get_local_rows(),desc_a%get_local_cols(),& + & desc_ac%get_local_rows(),desc_a%get_local_cols() + if (debug) flush(0) + + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + + if (debug) write(0,*) me,trim(name),' Done AxPROL ',& + & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& + & desc_ac%get_local_rows(),desc_ac%get_local_cols() + + ! + ! Ok first product done. + + if (present(desc_ax)) then + block + type(psb_d_coo_sparse_mat) :: icoo_restr + + call coo_prol%cp_to_icoo(icoo_restr,info) + call icoo_restr%set_ncols(desc_ac%get_local_cols()) + call icoo_restr%set_nrows(desc_a%get_local_rows()) + call psb_d_coo_glob_transpose(icoo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) + call icoo_restr%set_nrows(desc_ac%get_local_rows()) + call icoo_restr%set_ncols(desc_ax%get_local_cols()) +! !$ write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& +! !$ & desc_a%get_local_cols(),desc_ax%get_local_cols(),icoo_restr%get_nzeros() +! !$ if (desc_a%get_local_cols()= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + + else + + ! + ! Remember that RESTR must be built from PROL after halo extension, + ! which is done above in psb_par_spspmm + if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& + & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() + call csr_prol%mv_to_lcoo(coo_restr,info) +!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& +!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() + if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) + + call coo_restr%transp() + nzl = coo_restr%get_nzeros() + nrl = desc_ac%get_local_rows() + i=0 + ! + ! Only keep local rows + ! + do k=1, nzl + if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then + i = i+1 + coo_restr%val(i) = coo_restr%val(k) + coo_restr%ia(i) = coo_restr%ia(k) + coo_restr%ja(i) = coo_restr%ja(k) + end if + end do + call coo_restr%set_nzeros(i) + call coo_restr%fix(info) + nzl = coo_restr%get_nzeros() + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_a%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) + call csr_restr%cp_from_lcoo(coo_restr,info) + +!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + end if + + call psb_cdasb(desc_ac,info) + + call ac_csr%set_nrows(desc_ac%get_local_rows()) + call ac_csr%set_ncols(desc_ac%get_local_cols()) + call ac%mv_from(ac_csr) + call ac%set_asb() + + if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() + if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr + ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() + + call coo_prol%set_ncols(desc_ac%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ptap ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_ld_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo + +end subroutine amg_d_ld_ptap + +subroutine amg_ld_ptap(a_csr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info,desc_ax) + use psb_base_mod + use amg_d_inner_mod + use amg_d_base_aggregator_mod!, amg_protect_name => amg_ld_ptap + implicit none + + ! Arguments + type(psb_ld_csr_sparse_mat), intent(inout) :: a_csr + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + type(amg_dml_parms), intent(inout) :: parms + type(psb_ld_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr + type(psb_desc_type), intent(inout) :: desc_ac + type(psb_ldspmat_type), intent(out) :: ac + integer(psb_ipk_), intent(out) :: info + type(psb_desc_type), intent(inout), optional :: desc_ax + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo + character(len=40) :: name + integer(psb_ipk_) :: ierr(5) + type(psb_ld_coo_sparse_mat) :: ac_coo, tmpcoo + type(psb_ld_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr + integer(psb_ipk_) :: debug_level, debug_unit, naggr + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nrl, nzl, ip, & + & nzt, naggrm1, naggrp1, i, k + integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza + logical, parameter :: do_timings=.true., oldstyle=.false., debug=.false. + integer(psb_ipk_), save :: idx_spspmm=-1 + + name='amg_ptap' + if(psb_get_errstatus().ne.0) return + info=psb_success_ + call psb_erractionsave(err_act) + + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + call psb_info(ictxt, me, np) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + if ((do_timings).and.(idx_spspmm==-1)) & + & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr + + ! + ! COO_PROL should arrive here with local numbering + ! + if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& + & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& + & nrow,ntaggr,naggr + + call coo_prol%cp_to_fmt(csr_prol,info) + + if (debug) write(0,*) me,trim(name),' Product AxPROL ',& + & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & + & desc_a%get_local_rows(),desc_a%get_local_cols(),& + & desc_ac%get_local_rows(),desc_a%get_local_cols() + if (debug) flush(0) + + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + + if (debug) write(0,*) me,trim(name),' Done AxPROL ',& + & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& + & desc_ac%get_local_rows(),desc_ac%get_local_cols() + + ! + ! Ok first product done. + + if (present(desc_ax)) then + block + type(psb_d_coo_sparse_mat) :: icoo_restr + + call coo_prol%cp_to_icoo(icoo_restr,info) + call icoo_restr%set_ncols(desc_ac%get_local_cols()) + call icoo_restr%set_nrows(desc_a%get_local_rows()) + call psb_d_coo_glob_transpose(icoo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) + call icoo_restr%set_nrows(desc_ac%get_local_rows()) + call icoo_restr%set_ncols(desc_ax%get_local_cols()) + write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& + & desc_a%get_local_cols(),desc_ax%get_local_cols(),icoo_restr%get_nzeros() + if (desc_a%get_local_cols()= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + + else + + ! + ! Remember that RESTR must be built from PROL after halo extension, + ! which is done above in psb_par_spspmm + if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& + & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() + call csr_prol%mv_to_coo(coo_restr,info) +!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& +!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() + if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) + + call coo_restr%transp() + nzl = coo_restr%get_nzeros() + nrl = desc_ac%get_local_rows() + i=0 + ! + ! Only keep local rows + ! + do k=1, nzl + if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then + i = i+1 + coo_restr%val(i) = coo_restr%val(k) + coo_restr%ia(i) = coo_restr%ia(k) + coo_restr%ja(i) = coo_restr%ja(k) + end if + end do + call coo_restr%set_nzeros(i) + call coo_restr%fix(info) + nzl = coo_restr%get_nzeros() + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_a%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) + call csr_restr%cp_from_coo(coo_restr,info) + +!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + end if + + call psb_cdasb(desc_ac,info) + + call ac_csr%set_nrows(desc_ac%get_local_rows()) + call ac_csr%set_ncols(desc_ac%get_local_cols()) + call ac%mv_from(ac_csr) + call ac%set_asb() + + if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() + if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr + ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() + + call coo_prol%set_ncols(desc_ac%get_local_cols()) + !call coo_restr%mv_from_ifmt(csr_restr,info) +!!$ call coo_restr%set_nrows(desc_ac%get_local_rows()) +!!$ call coo_restr%set_ncols(desc_a%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ptap ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_ld_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo + +end subroutine amg_ld_ptap diff --git a/mlprec/impl/aggregator/amg_d_soc1_map_bld.f90 b/mlprec/impl/aggregator/amg_d_soc1_map_bld.f90 new file mode 100644 index 00000000..2926ebe2 --- /dev/null +++ b/mlprec/impl/aggregator/amg_d_soc1_map_bld.f90 @@ -0,0 +1,349 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_d_soc1_map__bld.f90 +! +! Subroutine: amg_d_soc1_map_bld +! Version: real +! +! This routine builds the tentative prolongator based on the +! strength of connection aggregation algorithm presented in +! +! M. Brezina and P. Vanek, A black-box iterative solver based on a +! two-level Schwarz method, Computing, 63 (1999), 233-263. +! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed +! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 +! (1996), 179-196. +! +! Note: upon exit +! +! Arguments: +! a - type(psb_dspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_dprec_type), input/output. +! The preconditioner data structure; upon exit it contains +! the multilevel hierarchy of prolongators, restrictors +! and coarse matrices. +! info - integer, output. +! Error code. +! +! +! +subroutine amg_d_soc1_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) + + use psb_base_mod + use amg_base_prec_type + use amg_d_inner_mod + + implicit none + + ! Arguments + integer(psb_ipk_), intent(in) :: iorder + logical, intent(in) :: clean_zeros + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + real(psb_dpk_), intent(in) :: theta + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),& + & ideg(:), idxs(:) + integer(psb_lpk_), allocatable :: tmpaggr(:) + real(psb_dpk_), allocatable :: val(:), diag(:) + integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr, nc, naggr,i,j,m, nz, ilg, ii, ip + type(psb_d_csr_sparse_mat) :: acsr + real(psb_dpk_) :: cpling, tcl + logical :: disjoint + integer(psb_ipk_) :: debug_level, debug_unit,err_act + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: nrow, ncol, n_ne + integer(psb_lpk_) :: nrglob + character(len=20) :: name, ch_err + + info=psb_success_ + name = 'amg_soc1_map_bld' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ! + ictxt=desc_a%get_context() + call psb_info(ictxt,me,np) + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + nrglob = desc_a%get_global_rows() + + nr = a%get_nrows() + nc = a%get_ncols() + allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),& + & icol(nc),val(nc),stat=info) + if(info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),& + & a_err='integer') + goto 9999 + end if + + diag = a%get_diag(info) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='psb_sp_getdiag') + goto 9999 + end if + + call a%cp_to(acsr) + if (clean_zeros) call acsr%clean_zeros(info) + if (iorder == amg_aggr_ord_nat_) then + do i=1, nr + ilaggr(i) = -(nr+1) + idxs(i) = i + end do + else + do i=1, nr + ilaggr(i) = -(nr+1) + ideg(i) = acsr%irp(i+1) - acsr%irp(i) + end do + call psb_msort(ideg,ix=idxs,dir=psb_sort_down_) + end if + + + ! + ! Phase one: Start with disjoint groups. + ! + naggr = 0 + icnt = 0 + step1: do ii=1, nr + i = idxs(ii) + if ((i<1).or.(i>nr)) then + info=psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + if (ilaggr(i) == -(nr+1)) then + nz = (acsr%irp(i+1)-acsr%irp(i)) + if ((nz<0).or.(nz>size(icol))) then + info=psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) + val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) + + ! + ! Build the set of all strongly coupled nodes + ! + ip = 0 + do k=1, nz + j = icol(k) + if ((1<=j).and.(j<=nr)) then + if (abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j)))) then + ip = ip + 1 + icol(ip) = icol(k) + end if + end if + enddo + + ! + ! If the whole strongly coupled neighborhood of I is + ! as yet unconnected, turn it into the next aggregate. + ! Same if ip==0 (in which case, neighborhood only + ! contains I even if it does not look like it from matrix) + ! + disjoint = all(ilaggr(icol(1:ip)) == -(nr+1)).or.(ip==0) + if (disjoint) then + icnt = icnt + 1 + naggr = naggr + 1 + do k=1, ip + ilaggr(icol(k)) = naggr + end do + ilaggr(i) = naggr + end if + endif + enddo step1 + + if (debug_level >= psb_debug_outer_) then + write(debug_unit,*) me,' ',trim(name),& + & ' Check 1:',count(ilaggr == -(nr+1)) + end if + + ! + ! Phase two: join the neighbours + ! + tmpaggr = ilaggr + step2: do ii=1,nr + i = idxs(ii) + + if (ilaggr(i) == -(nr+1)) then + nz = (acsr%irp(i+1)-acsr%irp(i)) + if (nz == 1) cycle step2 + icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) + val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) + + ! + ! Find the most strongly connected neighbour that is + ! already aggregated, if any, and join its aggregate + ! + cpling = dzero + ip = 0 + do k=1, nz + j = icol(k) + if ((1<=j).and.(j<=nr)) then + if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))& + & .and. (tmpaggr(j) > 0).and. (abs(val(k)) > cpling)) then + ip = k + cpling = abs(val(k)) + end if + end if + enddo + if (ip > 0) then + ilaggr(i) = ilaggr(icol(ip)) + end if + end if + end do step2 + + + ! + ! Phase three: sweep over leftovers, if any + ! + step3: do ii=1,nr + i = idxs(ii) + + if (ilaggr(i) < 0) then + nz = (acsr%irp(i+1)-acsr%irp(i)) + if (nz == 1) cycle step3 + icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) + val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) + ! + ! Find its strongly connected neighbourhood not + ! already aggregated, and make it into a new aggregate. + ! + cpling = dzero + ip = 0 + do k=1, nz + j = icol(k) + if ((1<=j).and.(j<=nr)) then + if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))& + & .and. (ilaggr(j) < 0)) then + ip = ip + 1 + icol(ip) = icol(k) + end if + end if + enddo + if (ip > 0) then + icnt = icnt + 1 + naggr = naggr + 1 + ilaggr(i) = naggr + do k=1, ip + ilaggr(icol(k)) = naggr + end do + else + ! + ! This should not happen: we did not even connect with ourselves, + ! but it's not a singleton. + ! + naggr = naggr + 1 + ilaggr(i) = naggr + end if + end if + end do step3 + + ! Any leftovers? + do i=1, nr + if (ilaggr(i) < 0) then + nz = (acsr%irp(i+1)-acsr%irp(i)) + if (nz == 1) then + ! Mark explicitly as a singleton so that + ! it will be ignored in map_to_tprol. + ! Need to use -(nrglob+nr) to make sure + ! it's still negative when shifted and combined with + ! other processes. + ilaggr(i) = -(nrglob+nr) + else + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers') + goto 9999 + endif + end if + end do + + if (naggr > ncol) then + !write(0,*) name,'Error : naggr > ncol',naggr,ncol + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Fatal error: naggr>ncol') + goto 9999 + end if + + call psb_realloc(ncol,ilaggr,info) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_realloc' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + allocate(nlaggr(np),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),& + & a_err='integer') + goto 9999 + end if + + nlaggr(:) = 0 + nlaggr(me+1) = naggr + call psb_sum(ictxt,nlaggr(1:np)) + + call acsr%free() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_soc1_map_bld + diff --git a/mlprec/impl/aggregator/amg_d_soc2_map_bld.f90 b/mlprec/impl/aggregator/amg_d_soc2_map_bld.f90 new file mode 100644 index 00000000..ed0f6b29 --- /dev/null +++ b/mlprec/impl/aggregator/amg_d_soc2_map_bld.f90 @@ -0,0 +1,348 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_d_soc2_map__bld.f90 +! +! Subroutine: amg_d_soc2_map_bld +! Version: real +! +! The aggregator object hosts the aggregation method for building +! the multilevel hierarchy. This variant is based on the method +! presented in +! +! S. Gratton, P. Henon, P. Jiranek and X. Vasseur: +! Reducing complexity of algebraic multigrid by aggregation +! Numerical Lin. Algebra with Applications, 2016, 23:501-518 +! +! Note: upon exit +! +! Arguments: +! a - type(psb_dspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_dprec_type), input/output. +! The preconditioner data structure; upon exit it contains +! the multilevel hierarchy of prolongators, restrictors +! and coarse matrices. +! info - integer, output. +! Error code. +! +! +! +subroutine amg_d_soc2_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) + + use psb_base_mod + use amg_base_prec_type + use amg_d_inner_mod + + implicit none + + ! Arguments + integer(psb_ipk_), intent(in) :: iorder + logical, intent(in) :: clean_zeros + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + real(psb_dpk_), intent(in) :: theta + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),& + & ideg(:), idxs(:) + integer(psb_lpk_), allocatable :: tmpaggr(:) + real(psb_dpk_), allocatable :: val(:), diag(:) + integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr,nc,naggr,i,j,m, nz, ilg, ii, ip, ip1,nzcnt + integer(psb_lpk_) :: nrglob + type(psb_d_csr_sparse_mat) :: acsr, muij, s_neigh + type(psb_d_coo_sparse_mat) :: s_neigh_coo + real(psb_dpk_) :: cpling, tcl + logical :: disjoint + integer(psb_ipk_) :: debug_level, debug_unit,err_act + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: nrow, ncol, n_ne + character(len=20) :: name, ch_err + + info=psb_success_ + name = 'amg_soc2_map_bld' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ! + ictxt=desc_a%get_context() + call psb_info(ictxt,me,np) + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + nrglob = desc_a%get_global_rows() + + nr = a%get_nrows() + nc = a%get_ncols() + allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),icol(nc),stat=info) + if(info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),& + & a_err='integer') + goto 9999 + end if + + diag = a%get_diag(info) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='psb_sp_getdiag') + goto 9999 + end if + + ! + ! Phase zero: compute muij + ! + call a%cp_to(muij) + if (clean_zeros) call muij%clean_zeros(info) + do i=1, nr + do k=muij%irp(i),muij%irp(i+1)-1 + j = muij%ja(k) + if (j<= nr) muij%val(k) = abs(muij%val(k))/sqrt(abs(diag(i)*diag(j))) + end do + end do + + ! + ! Compute the 1-neigbour; mark strong links with +1, weak links with -1 + ! + call s_neigh_coo%allocate(nr,nr,muij%get_nzeros()) + ip = 0 + do i=1, nr + do k=muij%irp(i),muij%irp(i+1)-1 + j = muij%ja(k) + if (j<=nr) then + ip = ip + 1 + s_neigh_coo%ia(ip) = i + s_neigh_coo%ja(ip) = j + if (real(muij%val(k)) >= theta) then + s_neigh_coo%val(ip) = done + else + s_neigh_coo%val(ip) = -done + end if + end if + end do + end do + !write(*,*) 'S_NEIGH: ',nr,ip + call s_neigh_coo%set_nzeros(ip) + call s_neigh%mv_from_coo(s_neigh_coo,info) + + if (iorder == amg_aggr_ord_nat_) then + do i=1, nr + ilaggr(i) = -(nr+1) + idxs(i) = i + end do + else + do i=1, nr + ilaggr(i) = -(nr+1) + ideg(i) = muij%irp(i+1) - muij%irp(i) + end do + call psb_msort(ideg,ix=idxs,dir=psb_sort_down_) + end if + + + ! + ! Phase one: Start with disjoint groups. + ! + naggr = 0 + icnt = 0 + step1: do ii=1, nr + i = idxs(ii) + + if (ilaggr(i) == -(nr+1)) then + ! + ! Get the 1-neighbourhood of I + ! + ip1 = s_neigh%irp(i) + nz = s_neigh%irp(i+1)-ip1 + ! + ! If the neighbourhood only contains I, skip it + ! + if (nz ==0) then + ilaggr(i) = 0 + cycle step1 + end if + if ((nz==1).and.(s_neigh%ja(ip1)==i)) then + ilaggr(i) = 0 + cycle step1 + end if + ! + ! If the whole strongly coupled neighborhood of I is + ! as yet unconnected, turn it into the next aggregate. + ! + nzcnt = count(real(s_neigh%val(ip1:ip1+nz-1)) > 0) + icol(1:nzcnt) = pack(s_neigh%ja(ip1:ip1+nz-1),(real(s_neigh%val(ip1:ip1+nz-1)) > 0)) + disjoint = all(ilaggr(icol(1:nzcnt)) == -(nr+1)) + if (disjoint) then + icnt = icnt + 1 + naggr = naggr + 1 + do k=1, nzcnt + ilaggr(icol(k)) = naggr + end do + ilaggr(i) = naggr + end if + endif + enddo step1 + + if (debug_level >= psb_debug_outer_) then + write(debug_unit,*) me,' ',trim(name),& + & ' Check 1:',count(ilaggr == -(nr+1)) + end if + + ! + ! Phase two: join the neighbours + ! + tmpaggr = ilaggr + step2: do ii=1,nr + i = idxs(ii) + + if (ilaggr(i) == -(nr+1)) then + ! + ! Find the most strongly connected neighbour that is + ! already aggregated, if any, and join its aggregate + ! + cpling = dzero + ip = 0 + do k=s_neigh%irp(i), s_neigh%irp(i+1)-1 + j = s_neigh%ja(k) + if ((1<=j).and.(j<=nr)) then + if ( (tmpaggr(j) > 0).and. (real(muij%val(k)) > cpling)& + & .and.(real(s_neigh%val(k))>0)) then + ip = k + cpling = muij%val(k) + end if + end if + enddo + if (ip > 0) then + ilaggr(i) = ilaggr(s_neigh%ja(ip)) + end if + end if + end do step2 + + + ! + ! Phase three: sweep over leftovers, if any + ! + step3: do ii=1,nr + i = idxs(ii) + + if (ilaggr(i) < 0) then + ! + ! Find its strongly connected neighbourhood not + ! already aggregated, and make it into a new aggregate. + ! + ip = 0 + do k=s_neigh%irp(i), s_neigh%irp(i+1)-1 + j = s_neigh%ja(k) + if ((1<=j).and.(j<=nr)) then + if (ilaggr(j) < 0) then + ip = ip + 1 + icol(ip) = j + end if + end if + enddo + if (ip > 0) then + icnt = icnt + 1 + naggr = naggr + 1 + ilaggr(i) = naggr + do k=1, ip + ilaggr(icol(k)) = naggr + end do + end if + end if + end do step3 + + ! Any leftovers? + do i=1, nr + if (ilaggr(i) <= 0) then + nz = (s_neigh%irp(i+1)-s_neigh%irp(i)) + if (nz <= 1) then + ! Mark explicitly as a singleton so that + ! it will be ignored in map_to_tprol. + ! Need to use -(nrglob+nr) to make sure + ! it's still negative when shifted and combined with + ! other processes. + ilaggr(i) = -(nrglob+nr) + else + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers') + goto 9999 + endif + end if + end do + + if (naggr > ncol) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Fatal error: naggr>ncol') + goto 9999 + end if + + call psb_realloc(ncol,ilaggr,info) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_realloc' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + allocate(nlaggr(np),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),& + & a_err='integer') + goto 9999 + end if + + nlaggr(:) = 0 + nlaggr(me+1) = naggr + call psb_sum(ictxt,nlaggr(1:np)) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_soc2_map_bld + diff --git a/mlprec/impl/aggregator/amg_d_symdec_aggregator_tprol.f90 b/mlprec/impl/aggregator/amg_d_symdec_aggregator_tprol.f90 new file mode 100644 index 00000000..d257389c --- /dev/null +++ b/mlprec/impl/aggregator/amg_d_symdec_aggregator_tprol.f90 @@ -0,0 +1,160 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_d_symdec_aggregator_tprol.f90 +! +! Subroutine: amg_d_symdec_aggregator_tprol +! Version: real +! +! +! This routine is mainly an interface to soc_map_bld where the real work is performed. +! It takes care of some consistency checking, and calls map_to_tprol, which is +! refactored and shared among all the aggregation methods that produce a simple +! integer mapping. It also symmetrizes the pattern of the local matrix A. +! +! +! +! Arguments: +! Arguments: +! ag - type(amg_d_dec_aggregator_type), input/output. +! The aggregator object, carrying with itself the mapping algorithm. +! parms - The auxiliary parameters object +! ag_data - Auxiliary global aggregation parameters object +! +! a - type(psb_dspmat_type). +! The sparse matrix structure containing the local part of the +! fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! ilaggr - integer, dimension(:), allocatable, output +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that on exit the indices +! will be shifted so as to make sure the ranges on the various processes do not +! overlap. +! nlaggr - integer, dimension(:), allocatable, output +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_dspmat_type), output +! The tentative prolongator, based on ilaggr. +! +! info - integer, output. +! Error code. +! +subroutine amg_d_symdec_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,op_prol,info) + use psb_base_mod + use amg_d_prec_type + use amg_d_symdec_aggregator_mod, amg_protect_name => amg_d_symdec_aggregator_build_tprol + use amg_d_inner_mod + implicit none + class(amg_d_symdec_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(amg_daggr_data), intent(in) :: ag_data + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_ldspmat_type), intent(out) :: op_prol + integer(psb_ipk_), intent(out) :: info + + ! Local variables + type(psb_dspmat_type) :: atmp, atrans + character(len=20) :: name + integer(psb_mpk_) :: ictxt, np, me + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: nr + integer(psb_lpk_) :: ntaggr + integer(psb_ipk_) :: debug_level, debug_unit + logical :: clean_zeros + + name='amg_d_symdec_aggregator_tprol' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + call amg_check_def(parms%ml_cycle,'Multilevel cycle',& + & amg_mult_ml_,is_legal_ml_cycle) + call amg_check_def(parms%par_aggr_alg,'Aggregation',& + & amg_dec_aggr_,is_legal_ml_par_aggr_alg) + call amg_check_def(parms%aggr_ord,'Ordering',& + & amg_aggr_ord_nat_,is_legal_ml_aggr_ord) + call amg_check_def(parms%aggr_thresh,'Aggr_Thresh',dzero,is_legal_d_aggr_thrs) + + nr = a%get_nrows() + call a%csclip(atmp,info,imax=nr,jmax=nr,& + & rscale=.false.,cscale=.false.) + call atmp%set_nrows(nr) + call atmp%set_ncols(nr) + if (info == psb_success_) call atmp%transp(atrans) + if (info == psb_success_) call atrans%cscnv(info,type='COO') + if (info == psb_success_) call psb_rwextd(nr,atmp,info,b=atrans,rowscale=.false.) + call atmp%set_nrows(nr) + call atmp%set_ncols(nr) + if (info == psb_success_) call atrans%free() + if (info == psb_success_) call atmp%cscnv(info,type='CSR') + + ! + ! The decoupled aggregator based on SOC measures ignores + ! ag_data except for clean_zeros; soc_map_bld is a procedure pointer. + ! + clean_zeros = ag%do_clean_zeros + if (info == psb_success_) & + & call ag%soc_map_bld(parms%aggr_ord,parms%aggr_thresh,clean_zeros,atmp,& + & desc_a,nlaggr,ilaggr,info) + if (info == psb_success_) call atmp%free() + + if (info == psb_success_) call amg_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='soc_map_bld/map_to_tprol') + goto 9999 + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_d_symdec_aggregator_build_tprol diff --git a/mlprec/impl/aggregator/amg_daggrmat_minnrg_bld.f90 b/mlprec/impl/aggregator/amg_daggrmat_minnrg_bld.f90 new file mode 100644 index 00000000..24ffc270 --- /dev/null +++ b/mlprec/impl/aggregator/amg_daggrmat_minnrg_bld.f90 @@ -0,0 +1,656 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_daggrmat_minnrg_bld.F90 +! +! Subroutine: amg_daggrmat_minnrg_bld +! Version: real +! +! This routine builds a coarse-level matrix A_C from a fine-level matrix A +! by using the Galerkin approach, i.e. +! +! A_C = P_C^T A P_C, +! +! where P_C is a prolongator from the coarse level to the fine one. +! +! The prolongator P_C is built according to a smoothed aggregation algorithm, +! i.e. it is obtained by applying a damped Jacobi smoother to the piecewise +! constant interpolation operator P corresponding to the fine-to-coarse level +! mapping built by the amg_aggrmap_bld subroutine: +! +! P_C = (I - omega*D^(-1)A) * P, +! +! where D is the diagonal matrix with main diagonal equal to the main diagonal +! of A, and omega is a suitable smoothing parameter. An estimate of the spectral +! radius of D^(-1)A, to be used in the computation of omega, is provided, +! according to the value of p%parms%aggr_omega_alg, specified by the user +! through amg_dprecinit and amg_dprecset. +! 4. Minimum energy aggregation: +! M. Sala, R. Tuminaro: A new Petrov-Galerkin smoothed aggregation preconditioner +! for nonsymmetric linear systems, SIAM J. Sci. Comput., 31(1):143-166 (2008) +! +! On output from this routine the entries of AC, op_prol, op_restr +! are still in "global numbering" mode; this is fixed in the calling routine +! aggregator%mat_bld. +! +! +! Arguments: +! a - type(psb_dspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! p - type(amg_d_onelev_type), input/output. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! parms - type(amg_dml_parms), input +! Parameters controlling the choice of algorithm +! ac - type(psb_dspmat_type), output +! The coarse matrix on output +! +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_dspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_dspmat_type), output +! The restrictor operator; in this particular case, it is different +! from the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +! +subroutine amg_daggrmat_minnrg_bld(a,desc_a,ilaggr,nlaggr,parms,& + & ac,desc_ac,op_prol,op_restr,info) + use psb_base_mod + use amg_base_prec_type + use amg_d_inner_mod, amg_protect_name => amg_daggrmat_minnrg_bld + + implicit none + + ! Arguments + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(amg_dml_parms), intent(inout) :: parms + type(psb_ldspmat_type), intent(inout) :: op_prol + type(psb_ldspmat_type), intent(out) :: ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nzac, ip, ndx,& + & naggr, nzl,naggrm1,naggrp1, i, j, k, jd, icolF, nrt + integer(psb_ipk_) :: ictxt,np,me, icomm + character(len=20) :: name + type(psb_ldspmat_type) :: la, af, ptilde, rtilde, atran, atp, atdatp + type(psb_ldspmat_type) :: am3,am4, ap, adap,atmp,rada, ra, atmp2, dap, dadap, da + type(psb_ldspmat_type) :: dat, datp, datdatp, atmp3, tmp_prol + type(psb_ld_coo_sparse_mat) :: tmpcoo + type(psb_ld_csr_sparse_mat) :: acsr1, acsr2, acsr3, acsr, acsrf + type(psb_ld_csc_sparse_mat) :: csc_dap, csc_dadap, csc_datp, csc_datdatp, acsc + real(psb_dpk_), allocatable :: adiag(:), adinv(:) + real(psb_dpk_), allocatable :: omf(:), omp(:), omi(:), oden(:) + logical :: filter_mat + integer(psb_ipk_) :: ierr(5) + integer(psb_ipk_) :: debug_level, debug_unit, err_act + integer(psb_ipk_), parameter :: ncmax=16 + real(psb_dpk_) :: anorm, theta + real(psb_dpk_) :: tmp, alpha, beta, ommx + + name='amg_aggrmat_minnrg' + info=psb_success_ + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + ictxt = desc_a%get_context() + + call psb_info(ictxt, me, np) + + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + theta = parms%aggr_thresh + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + + filter_mat = (parms%aggr_filter == amg_filter_mat_) + + ! naggr: number of local aggregates + ! nrow: local rows. + ! + allocate(adinv(ncol),& + & omf(ncol),omp(ntaggr),oden(ntaggr),omi(ncol),stat=info) + + if (info /= psb_success_) then + info=psb_err_alloc_request_; ierr(1)=6*ncol+ntaggr; + call psb_errpush(info,name,i_err=ierr,a_err='real(psb_dpk_)') + goto 9999 + end if + + ! Get the diagonal D + adiag = a%get_diag(info) + if (info == psb_success_) & + & call psb_realloc(ncol,adiag,info) + if (info == psb_success_) & + & call psb_halo(adiag,desc_a,info) + if (info == psb_success_) call a%cp_to_l(la) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_getdiag') + goto 9999 + end if + + do i=1,size(adiag) + if (adiag(i) /= dzero) then + adinv(i) = done / adiag(i) + else + adinv(i) = done + end if + end do + + + + ! 1. Allocate Ptilde in sparse matrix form + call op_prol%mv_to(tmpcoo) + call ptilde%mv_from(tmpcoo) + call ptilde%cscnv(info,type='csr') + + if (info == psb_success_) call la%cscnv(am3,info,type='csr',dupl=psb_dupl_add_) + if (info == psb_success_) call la%cscnv(da,info,type='csr',dupl=psb_dupl_add_) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Initial copies done.' + + call da%scal(adinv,info) + + call psb_spspmm(da,ptilde,dap,info) + + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 1') + goto 9999 + end if + + call dap%clone(atmp,info) + + call psb_sphalo(atmp,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.,outfmt='CSR ') + if (info == psb_success_) call psb_rwextd(ncol,atmp,info,b=am4) + if (info == psb_success_) call am4%free() + + call psb_spspmm(da,atmp,dadap,info) + call atmp%free() + + ! !$ write(0,*) 'Columns of AP',psb_sp_get_ncols(ap) + ! !$ write(0,*) 'Columns of ADAP',psb_sp_get_ncols(adap) + call dap%mv_to(csc_dap) + call dadap%mv_to(csc_dadap) + + call csc_mat_col_prod(csc_dap,csc_dadap,omp,info) + call csc_mat_col_prod(csc_dadap,csc_dadap,oden,info) + call psb_sum(ictxt,omp) + call psb_sum(ictxt,oden) + ! !$ write(0,*) trim(name),' OMP :',omp + ! !$ write(0,*) trim(name),' ODEN:',oden + + omp = omp/oden + + ! !$ write(0,*) 'Check on output prolongator ',omp(1:min(size(omp),10)) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done NUMBMM 1' + + call am3%mv_to(acsr3) + ! Compute omega_int + ommx = dzero + do i=1, ncol + if (ilaggr(i) >0) then + omi(i) = omp(ilaggr(i)) + else + omi(i) = dzero + end if + if(abs(omi(i)) .gt. abs(ommx)) ommx = omi(i) + end do + ! Compute omega_fine + do i=1, nrow + omf(i) = ommx + do j=acsr3%irp(i),acsr3%irp(i+1)-1 + if(abs(omi(acsr3%ja(j))) .lt. abs(omf(i))) omf(i)=omi(acsr3%ja(j)) + end do +!!$ if(min(real(omf(i)),aimag(omf(i))) < dzero) omf(i) = dzero + if(psb_minreal(omf(i)) < dzero) omf(i) = dzero + end do + + omf(1:nrow) = omf(1:nrow) * adinv(1:nrow) + + if (filter_mat) then + ! + ! Build the filtered matrix Af from A + ! + call la%cscnv(acsrf,info,dupl=psb_dupl_add_) + + do i=1,nrow + tmp = dzero + jd = -1 + do j=acsrf%irp(i),acsrf%irp(i+1)-1 + if (acsrf%ja(j) == i) jd = j + if (abs(acsrf%val(j)) < theta*sqrt(abs(adiag(i)*adiag(acsrf%ja(j))))) then + tmp=tmp+acsrf%val(j) + acsrf%val(j)=dzero + endif + enddo + if (jd == -1) then + write(0,*) 'Wrong input: we need the diagonal!!!!', i + else + acsrf%val(jd)=acsrf%val(jd)-tmp + end if + enddo + ! Take out zeroed terms + call acsrf%clean_zeros(info) + + ! + ! Build the smoothed prolongator using the filtered matrix + ! + do i=1,acsrf%get_nrows() + do j=acsrf%irp(i),acsrf%irp(i+1)-1 + if (acsrf%ja(j) == i) then + acsrf%val(j) = done - omf(i)*acsrf%val(j) + else + acsrf%val(j) = - omf(i)*acsrf%val(j) + end if + end do + end do + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done gather, going for SYMBMM 1' + + call af%mv_from(acsrf) + ! + ! op_prol = (I-w*D*Af)Ptilde + ! Doing it this way means to consider diag(Af_i) + ! + ! + call psb_spspmm(af,ptilde,op_prol,info) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done SPSPMM 1' + else + ! + ! Build the smoothed prolongator using the original matrix + ! + do i=1,acsr3%get_nrows() + do j=acsr3%irp(i),acsr3%irp(i+1)-1 + if (acsr3%ja(j) == i) then + acsr3%val(j) = done - omf(i)*acsr3%val(j) + else + acsr3%val(j) = - omf(i)*acsr3%val(j) + end if + end do + end do + + call am3%mv_from(acsr3) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done gather, going for SYMBMM 1' + ! + ! + ! op_prol = (I-w*D*A)Ptilde + ! + ! + call psb_spspmm(am3,ptilde,op_prol,info) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done NUMBMM 1' + + end if + + + ! + ! Ok, let's start over with the restrictor + ! + call ptilde%transc(rtilde) + call la%cscnv(atmp,info,type='csr') + call psb_sphalo(atmp,desc_a,am4,info,& + & colcnv=.true.,rowscale=.true.) + nrt = am4%get_nrows() + call am4%csclip(atmp2,info,lone,nrt,lone,ncol) + call atmp2%cscnv(info,type='CSR') + if (info == psb_success_) call psb_rwextd(ncol,atmp,info,b=atmp2) + call am4%free() + call atmp2%free() + + ! This is to compute the transpose. It ONLY works if the + ! original A has a symmetric pattern. + call atmp%transc(atmp2) + call atmp2%csclip(dat,info,lone,nrow,lone,ncol) + call dat%cscnv(info,type='csr') + call dat%scal(adinv,info) + + ! Now for the product. + call psb_spspmm(dat,ptilde,datp,info) + + call datp%clone(atmp2,info) + call psb_sphalo(atmp2,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.,outfmt='CSR ') + if (info == psb_success_) call psb_rwextd(ncol,atmp2,info,b=am4) + if (info == psb_success_) call am4%free() + + + call psb_symbmm(dat,atmp2,datdatp,info) + call psb_numbmm(dat,atmp2,datdatp) + call atmp2%free() + + call datp%mv_to(csc_datp) + call datdatp%mv_to(csc_datdatp) + + call csc_mat_col_prod(csc_datp,csc_datdatp,omp,info) + call csc_mat_col_prod(csc_datdatp,csc_datdatp,oden,info) + call psb_sum(ictxt,omp) + call psb_sum(ictxt,oden) + + + ! !$ write(debug_unit,*) trim(name),' OMP_R :',omp + ! ! $ write(debug_unit,*) trim(name),' ODEN_R:',oden + omp = omp/oden + ! !$ write(0,*) 'Check on output restrictor',omp(1:min(size(omp),10)) + ! Compute omega_int + ommx = dzero + do i=1, ncol + if (ilaggr(i) >0) then + omi(i) = omp(ilaggr(i)) + else + omi(i) = dzero + end if + if(abs(omi(i)) .gt. abs(ommx)) ommx = omi(i) + end do + ! Compute omega_fine + ! Going over the columns of atmp means going over the rows + ! of A^T. Hopefully ;-) + call atmp%cp_to(acsc) + + do i=1, nrow + omf(i) = ommx + do j= acsc%icp(i),acsc%icp(i+1)-1 + if(abs(omi(acsc%ia(j))) .lt. abs(omf(i))) omf(i)=omi(acsc%ia(j)) + end do +!!$ if(min(real(omf(i)),aimag(omf(i))) < dzero) omf(i) = dzero + if(psb_minreal(omf(i)) < dzero) omf(i) = dzero + end do + omf(1:nrow) = omf(1:nrow)*adinv(1:nrow) + call psb_halo(omf,desc_a,info) + call acsc%free() + + + call atmp%mv_to(acsr1) + + do i=1,acsr1%get_nrows() + do j=acsr1%irp(i),acsr1%irp(i+1)-1 + if (acsr1%ja(j) == i) then + acsr1%val(j) = done - acsr1%val(j)*omf(acsr1%ja(j)) + else + acsr1%val(j) = - acsr1%val(j)*omf(acsr1%ja(j)) + end if + end do + end do + call atmp%mv_from(acsr1) + + call rtilde%mv_to(tmpcoo) + nzl = tmpcoo%get_nzeros() + i=0 + do k=1, nzl + if ((naggrm1 < tmpcoo%ia(k)) .and. (tmpcoo%ia(k) <= naggrp1)) then + i = i+1 + tmpcoo%val(i) = tmpcoo%val(k) + tmpcoo%ia(i) = tmpcoo%ia(k) + tmpcoo%ja(i) = tmpcoo%ja(k) + end if + end do + call tmpcoo%set_nzeros(i) + call rtilde%mv_from(tmpcoo) + call rtilde%cscnv(info,type='csr') + + call psb_spspmm(rtilde,atmp,op_restr,info) + + ! + ! Now we have to gather the halo of op_prol, and add it to itself + ! to multiply it by A, + ! + call op_prol%clone(tmp_prol,info) + if (info == psb_success_) call psb_sphalo(tmp_prol,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.) + if (info == psb_success_) call psb_rwextd(ncol,tmp_prol,info,b=am4) + if (info == psb_success_) call am4%free() + + if(info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Halo of op_prol') + goto 9999 + end if + + ! + ! Now we have to fix this. The only rows of B that are correct + ! are those corresponding to "local" aggregates, i.e. indices in ilaggr(:) + ! + call op_restr%mv_to(tmpcoo) + + nzl = tmpcoo%get_nzeros() + i=0 + do k=1, nzl + if ((naggrm1 < tmpcoo%ia(k)) .and. (tmpcoo%ia(k) <= naggrp1)) then + i = i+1 + tmpcoo%val(i) = tmpcoo%val(k) + tmpcoo%ia(i) = tmpcoo%ia(k) + tmpcoo%ja(i) = tmpcoo%ja(k) + end if + end do + call tmpcoo%set_nzeros(i) + call op_restr%mv_from(tmpcoo) + call op_restr%cscnv(info,type='csr') + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + call psb_spspmm(la,tmp_prol,am3,info) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done SPSPMM 2' + + call psb_sphalo(am3,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.) + if (info == psb_success_) call psb_rwextd(ncol,am3,info,b=am4) + if (info == psb_success_) call am4%free() + + if(info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Extend am3') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done sphalo/ rwxtd' + + call psb_spspmm(op_restr,am3,ac,info) + if (info == psb_success_) call am3%free() + if (info == psb_success_) call ac%cscnv(info,type='coo',dupl=psb_dupl_add_) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + &a_err='Build ac = op_restr x am3') + goto 9999 + end if + + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done smooth_aggregate ' + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_errpush(info,name) + call psb_error_handler(err_act) + return + + +contains + + subroutine csc_mat_col_prod(a,b,v,info) + implicit none + type(psb_ld_csc_sparse_mat), intent(in) :: a, b + real(psb_dpk_), intent(out) :: v(:) + integer(psb_ipk_), intent(out) :: info + + integer(psb_lpk_) :: i,j,k, nr, nc,iap,nra,ibp,nrb + + info = psb_success_ + nc = a%get_ncols() + if (nc /= b%get_ncols()) then + write(0,*) 'Matrices A and B should have same columns' + info = -1 + return + end if + + do j=1, nc + iap = a%icp(j) + nra = a%icp(j+1)-iap + ibp = b%icp(j) + nrb = b%icp(j+1)-ibp + v(j) = sparse_srtd_dot(nra,a%ia(iap:iap+nra-1),a%val(iap:iap+nra-1),& + & nrb,b%ia(ibp:ibp+nrb-1),b%val(ibp:ibp+nrb-1)) + end do + + end subroutine csc_mat_col_prod + + + subroutine csr_mat_row_prod(a,b,v,info) + implicit none + type(psb_ld_csr_sparse_mat), intent(in) :: a, b + real(psb_dpk_), intent(out) :: v(:) + integer(psb_ipk_), intent(out) :: info + + integer(psb_lpk_) :: i,j,k, nr, nc,iap,nca,ibp,ncb + + info = psb_success_ + nr = a%get_nrows() + if (nr /= b%get_nrows()) then + write(0,*) 'Matrices A and B should have same rows' + info = -1 + return + end if + + do j=1, nr + iap = a%irp(j) + nca = a%irp(j+1)-iap + ibp = b%irp(j) + ncb = b%irp(j+1)-ibp + v(j) = sparse_srtd_dot(nca,a%ja(iap:iap+nca-1),a%val(iap:iap+nca-1),& + & ncb,b%ja(ibp:ibp+ncb-1),b%val(ibp:ibp+ncb-1)) + end do + + end subroutine csr_mat_row_prod + + + function sparse_srtd_dot(nv1,iv1,v1,nv2,iv2,v2) result(dot) + implicit none + integer(psb_lpk_), intent(in) :: nv1,nv2 + integer(psb_lpk_), intent(in) :: iv1(:), iv2(:) + real(psb_dpk_), intent(in) :: v1(:),v2(:) + real(psb_dpk_) :: dot + + integer(psb_lpk_) :: i,j,k, ip1, ip2 + + dot = dzero + ip1 = 1 + ip2 = 1 + + do + if (ip1 > nv1) exit + if (ip2 > nv2) exit + if (iv1(ip1) == iv2(ip2)) then + dot = dot + (v1(ip1))*v2(ip2) + ip1 = ip1 + 1 + ip2 = ip2 + 1 + else if (iv1(ip1) < iv2(ip2)) then + ip1 = ip1 + 1 + else + ip2 = ip2 + 1 + end if + end do + + end function sparse_srtd_dot + + subroutine local_dump(me,mat,name,header) + type(psb_ldspmat_type), intent(in) :: mat + integer(psb_ipk_), intent(in) :: me + character(len=*), intent(in) :: name + character(len=*), intent(in) :: header + character(len=80) :: filename + + write(filename,'(a,a,i0,a,i0,a)') trim(name),'.p',me + open(20+me,file=filename) + call mat%print(20+me,head=trim(header)) + close(20+me) + end subroutine local_dump + +end subroutine amg_daggrmat_minnrg_bld diff --git a/mlprec/impl/aggregator/amg_daggrmat_nosmth_bld.f90 b/mlprec/impl/aggregator/amg_daggrmat_nosmth_bld.f90 new file mode 100644 index 00000000..cae5aaa3 --- /dev/null +++ b/mlprec/impl/aggregator/amg_daggrmat_nosmth_bld.f90 @@ -0,0 +1,198 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_daggrmat_nosmth_bld.F90 +! +! Subroutine: amg_daggrmat_nosmth_bld +! Version: real +! +! This routine builds a coarse-level matrix A_C from a fine-level matrix A +! by using the Galerkin approach, i.e. +! +! A_C = P_C^T A P_C, +! +! where P_C is the piecewise constant interpolation operator corresponding +! the fine-to-coarse level mapping built by amg_aggrmap_bld. +! +! The coarse-level matrix A_C is distributed among the parallel processes or +! replicated on each of them, according to the value of p%parms%coarse_mat +! specified by the user through amg_dprecinit and amg_zprecset. +! On output from this routine the entries of AC, op_prol, op_restr +! are still in "global numbering" mode; this is fixed in the calling routine +! aggregator%mat_bld. +! +! For details see +! P. D'Ambra, D. di Serafino and S. Filippone, On the development of +! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math., +! 57 (2007), 1181-1196. +! +! +! Arguments: +! a - type(psb_dspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! p - type(amg_d_onelev_type), input/output. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! parms - type(amg_dml_parms), input +! Parameters controlling the choice of algorithm +! ac - type(psb_dspmat_type), output +! The coarse matrix on output +! +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_dspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_dspmat_type), output +! The restrictor operator; normally, it is the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +! +subroutine amg_daggrmat_nosmth_bld(a,desc_a,ilaggr,nlaggr,parms,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + use psb_base_mod + use amg_base_prec_type + use amg_d_inner_mod, amg_protect_name => amg_daggrmat_nosmth_bld + use amg_d_base_aggregator_mod + implicit none + + ! Arguments + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(amg_dml_parms), intent(inout) :: parms + type(psb_dspmat_type), intent(inout) :: op_prol,ac,op_restr + type(psb_ldspmat_type), intent(inout) :: t_prol + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt, np, me, icomm, minfo + character(len=20) :: name + type(psb_ld_coo_sparse_mat) :: lcoo_prol + type(psb_d_coo_sparse_mat) :: coo_prol, coo_restr + type(psb_d_csr_sparse_mat) :: acsr + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nzl, ip, & + & naggr, nzt, naggrm1, naggrp1, i, k + integer(psb_ipk_) :: inaggr, nzlp + logical, parameter :: debug = .false. + + name = 'amg_aggrmat_nosmth_bld' + info = psb_success_ + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + call psb_info(ictxt, me, np) + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + + call a%cp_to(acsr) + call t_prol%mv_to(lcoo_prol) + inaggr = naggr + call psb_cdall(ictxt,desc_ac,info,nl=inaggr) + nzlp = lcoo_prol%get_nzeros() + call desc_ac%indxmap%g2lip_ins(lcoo_prol%ja(1:nzlp),info) + call lcoo_prol%set_ncols(desc_ac%get_local_cols()) + call lcoo_prol%cp_to_icoo(coo_prol,info) + + if (debug) call check_coo(me,trim(name)//' Check 1 on coo_prol:',coo_prol) + + call psb_cdasb(desc_ac,info) + call psb_cd_reinit(desc_ac,info) + + call amg_ptap(acsr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info) + + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_a%get_local_cols()) + call coo_prol%set_nrows(desc_a%get_local_rows()) + call coo_prol%set_ncols(desc_ac%get_local_cols()) + + if (debug) call check_coo(me,trim(name)//' Check 1 on coo_restr:',coo_restr) + + call op_prol%mv_from(coo_prol) + call op_restr%mv_from(coo_restr) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_d_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo +end subroutine amg_daggrmat_nosmth_bld diff --git a/mlprec/impl/aggregator/amg_daggrmat_smth_bld.f90 b/mlprec/impl/aggregator/amg_daggrmat_smth_bld.f90 new file mode 100644 index 00000000..cbcd3a6a --- /dev/null +++ b/mlprec/impl/aggregator/amg_daggrmat_smth_bld.f90 @@ -0,0 +1,325 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_daggrmat_smth_bld.F90 +! +! Subroutine: amg_daggrmat_smth_bld +! Version: real +! +! This routine builds a coarse-level matrix A_C from a fine-level matrix A +! by using the Galerkin approach, i.e. +! +! A_C = P_C^T A P_C, +! +! where P_C is a prolongator from the coarse level to the fine one. +! +! The prolongator P_C is built according to a smoothed aggregation algorithm, +! i.e. it is obtained by applying a damped Jacobi smoother to the piecewise +! constant interpolation operator P corresponding to the fine-to-coarse level +! mapping built by the amg_aggrmap_bld subroutine: +! +! P_C = (I - omega*D^(-1)A) * P, +! +! where D is the diagonal matrix with main diagonal equal to the main diagonal +! of A, and omega is a suitable smoothing parameter. An estimate of the spectral +! radius of D^(-1)A, to be used in the computation of omega, is provided, +! according to the value of p%parms%aggr_omega_alg, specified by the user +! through amg_dprecinit and amg_zprecset. +! +! The coarse-level matrix A_C is distributed among the parallel processes or +! replicated on each of them, according to the value of p%parms%coarse_mat, +! specified by the user through amg_dprecinit and amg_zprecset. +! On output from this routine the entries of AC, op_prol, op_restr +! are still in "global numbering" mode; this is fixed in the calling routine +! aggregator%mat_bld. +! +! +! Arguments: +! a - type(psb_dspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! p - type(amg_d_onelev_type), input/output. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! parms - type(amg_dml_parms), input +! Parameters controlling the choice of algorithm +! ac - type(psb_dspmat_type), output +! The coarse matrix on output +! +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_dspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_dspmat_type), output +! The restrictor operator; normally, it is the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +subroutine amg_daggrmat_smth_bld(a,desc_a,ilaggr,nlaggr,parms,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + use psb_base_mod + use amg_base_prec_type + use amg_d_inner_mod, amg_protect_name => amg_daggrmat_smth_bld + use amg_d_base_aggregator_mod + + implicit none + + ! Arguments + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(amg_dml_parms), intent(inout) :: parms + type(psb_dspmat_type), intent(out) :: op_prol,ac,op_restr + type(psb_ldspmat_type), intent(inout) :: t_prol + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, ip, & + & naggr, nzl,naggrm1,naggrp1, i, j, k, jd, icolF, nrw + integer(psb_ipk_) :: inaggr, nzlp + integer(psb_ipk_) :: ictxt, np, me + character(len=20) :: name + type(psb_ld_coo_sparse_mat) :: tmpcoo + type(psb_d_coo_sparse_mat) :: coo_prol, coo_restr + type(psb_d_csr_sparse_mat) :: acsr1, acsrf, csr_prol, acsr + real(psb_dpk_), allocatable :: adiag(:) + real(psb_dpk_), allocatable :: arwsum(:) + integer(psb_ipk_) :: ierr(5) + logical :: filter_mat + integer(psb_ipk_) :: debug_level, debug_unit, err_act + integer(psb_ipk_), parameter :: ncmax=16 + real(psb_dpk_) :: anorm, omega, tmp, dg, theta + logical, parameter :: debug_new=.false. + character(len=80) :: filename + + name='amg_aggrmat_smth_bld' + info=psb_success_ + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + ictxt = desc_a%get_context() + + call psb_info(ictxt, me, np) + + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + theta = parms%aggr_thresh + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + filter_mat = (parms%aggr_filter == amg_filter_mat_) + + ! + ! naggr: number of local aggregates + ! nrow: local rows. + ! + + ! Get the diagonal D + adiag = a%get_diag(info) + if (info == psb_success_) & + & call psb_realloc(ncol,adiag,info) + if (info == psb_success_) & + & call psb_halo(adiag,desc_a,info) + if (info == psb_success_) call a%cp_to(acsr) + + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_getdiag') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Initial copies done.' + + call acsr%cp_to_fmt(acsrf,info) + + + if (filter_mat) then + ! + ! Build the filtered matrix Af from A + ! + + do i=1, nrow + tmp = dzero + jd = -1 + do j=acsrf%irp(i),acsrf%irp(i+1)-1 + if (acsrf%ja(j) == i) jd = j + if (abs(acsrf%val(j)) < theta*sqrt(abs(adiag(i)*adiag(acsrf%ja(j))))) then + tmp=tmp+acsrf%val(j) + acsrf%val(j)=dzero + endif + + enddo + if (jd == -1) then + write(0,*) 'Wrong input: we need the diagonal!!!!', i + else + acsrf%val(jd)=acsrf%val(jd)-tmp + end if + enddo + ! Take out zeroed terms + call acsrf%clean_zeros(info) + end if + + + do i=1,size(adiag) + if (adiag(i) /= dzero) then + adiag(i) = done / adiag(i) + else + adiag(i) = done + end if + end do + + if (parms%aggr_omega_alg == amg_eig_est_) then + + if (parms%aggr_eig == amg_max_norm_) then + allocate(arwsum(nrow)) + call acsr%arwsum(arwsum) + anorm = maxval(abs(adiag(1:nrow)*arwsum(1:nrow))) + call psb_amx(ictxt,anorm) + omega = 4.d0/(3.d0*anorm) + parms%aggr_omega_val = omega + + else + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_aggr_eig_') + goto 9999 + end if + + else if (parms%aggr_omega_alg == amg_user_choice_) then + + omega = parms%aggr_omega_val + + else if (parms%aggr_omega_alg /= amg_user_choice_) then + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_aggr_omega_alg_') + goto 9999 + end if + + + call acsrf%scal(adiag,info) + if (info /= psb_success_) goto 9999 + + call t_prol%mv_to(tmpcoo) + inaggr = naggr + call psb_cdall(ictxt,desc_ac,info,nl=inaggr) + nzlp = tmpcoo%get_nzeros() + call desc_ac%indxmap%g2lip_ins(tmpcoo%ja(1:nzlp),info) + call tmpcoo%set_ncols(desc_ac%get_local_cols()) + call tmpcoo%mv_to_ifmt(csr_prol,info) + + call psb_cdasb(desc_ac,info) + call psb_cd_reinit(desc_ac,info) + ! + ! Build the smoothed prolongator using either A or Af + ! acsr1 = (I-w*D*A) Prol acsr1 = (I-w*D*Af) Prol + ! This is always done through the variable acsrf which + ! is a bit less readable, but saves space and one matrix copy + ! + call omega_smooth(omega,acsrf) + call psb_par_spspmm(acsrf,desc_a,csr_prol,acsr1,desc_ac,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 1') + goto 9999 + end if + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done SPSPMM 1' + nzl = acsr1%get_nzeros() + call acsr1%mv_to_coo(coo_prol,info) + + call amg_ptap(acsr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info) + + call op_prol%mv_from(coo_prol) + call op_restr%mv_from(coo_restr) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done smooth_aggregate ' + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_errpush(info,name) + call psb_error_handler(err_act) + return + +contains + + subroutine omega_smooth(omega,acsr) + implicit none + real(psb_dpk_),intent(in) :: omega + type(psb_d_csr_sparse_mat), intent(inout) :: acsr + ! + integer(psb_lpk_) :: i,j + do i=1,acsr%get_nrows() + do j=acsr%irp(i),acsr%irp(i+1)-1 + if (acsr%ja(j) == i) then + acsr%val(j) = done - omega*acsr%val(j) + else + acsr%val(j) = - omega*acsr%val(j) + end if + end do + end do + end subroutine omega_smooth + +end subroutine amg_daggrmat_smth_bld diff --git a/mlprec/impl/aggregator/amg_s_dec_aggregator_mat_asb.f90 b/mlprec/impl/aggregator/amg_s_dec_aggregator_mat_asb.f90 new file mode 100644 index 00000000..4994bdf6 --- /dev/null +++ b/mlprec/impl/aggregator/amg_s_dec_aggregator_mat_asb.f90 @@ -0,0 +1,195 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_s_dec_aggregator_mat_asb.f90 +! +! Subroutine: amg_s_dec_aggregator_mat_asb +! Version: real +! +! +! From a given AC to final format, generating DESC_AC +! +! Arguments: +! ag - type(amg_s_dec_aggregator_type), input/output. +! The aggregator object +! parms - type(amg_sml_parms), input +! The aggregation parameters +! a - type(psb_sspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! ac - type(psb_sspmat_type), inout +! The coarse matrix +! desc_ac - type(psb_desc_type), output. +! The communication descriptor of the fine-level matrix. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! +! op_prol - type(psb_sspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_sspmat_type), input/output +! The restrictor operator; normally, it is the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +subroutine amg_s_dec_aggregator_mat_asb(ag,parms,a,desc_a,& + & ac,desc_ac, op_prol,op_restr,info) + use psb_base_mod + use amg_base_prec_type + use amg_s_dec_aggregator_mod, amg_protect_name => amg_s_dec_aggregator_mat_asb + implicit none + class(amg_s_dec_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + type(psb_sspmat_type), intent(inout) :: op_prol, ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: ictxt, np, me + type(psb_ls_coo_sparse_mat) :: tmpcoo + type(psb_lsspmat_type) :: tmp_ac + integer(psb_ipk_) :: i_nr, i_nc, i_nl, nzl + integer(psb_lpk_) :: ntaggr + integer(psb_ipk_) :: err_act, debug_level, debug_unit + character(len=20) :: name='s_dec_aggregator_mat_asb' + + + if (psb_get_errstatus().ne.0) return + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + select case(parms%coarse_mat) + + case(amg_distr_mat_) + + call ac%cscnv(info,type='csr') + call op_prol%cscnv(info,type='csr') + call op_restr%cscnv(info,type='csr') + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ac ' + + case(amg_repl_mat_) + ! + ! We are assuming here that an s matrix + ! can hold all entries + ! + if (desc_ac%get_global_rows() < huge(1_psb_ipk_) ) then + ntaggr = desc_ac%get_global_rows() + i_nr = ntaggr + else + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_coarse_mat_') + goto 9999 + end if + + call op_prol%mv_to(tmpcoo) + nzl = tmpcoo%get_nzeros() + call psb_loc_to_glob(tmpcoo%ja(1:nzl),desc_ac,info,'I') + call tmpcoo%set_ncols(i_nr) + call op_prol%mv_from(tmpcoo) + + call op_restr%mv_to(tmpcoo) + nzl = tmpcoo%get_nzeros() + call psb_loc_to_glob(tmpcoo%ia(1:nzl),desc_ac,info,'I') + call tmpcoo%set_nrows(i_nr) + call op_restr%mv_from(tmpcoo) + + + call psb_gather(tmp_ac,ac,desc_ac,info,root=-ione,& + & dupl=psb_dupl_add_,keeploc=.false.) + call tmp_ac%mv_to(tmpcoo) + call ac%mv_from(tmpcoo) + + call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) + if (info == psb_success_) call psb_cdasb(desc_ac,info) + + if (info /= psb_success_) goto 9999 + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_coarse_mat_') + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_ls_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo +end subroutine amg_s_dec_aggregator_mat_asb diff --git a/mlprec/impl/aggregator/amg_s_dec_aggregator_mat_bld.f90 b/mlprec/impl/aggregator/amg_s_dec_aggregator_mat_bld.f90 new file mode 100644 index 00000000..265c7cc7 --- /dev/null +++ b/mlprec/impl/aggregator/amg_s_dec_aggregator_mat_bld.f90 @@ -0,0 +1,216 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_s_dec_aggregator_mat_bld.f90 +! +! Subroutine: amg_s_dec_aggregator_mat_bld +! Version: real +! +! This routine builds the matrix associated to the current level of the +! multilevel preconditioner from the matrix associated to the previous level, +! by using the user-specified aggregation technique (therefore, it also builds the +! prolongation and restriction operators mapping the current level to the +! previous one and vice versa). +! The current level is regarded as the coarse one, while the previous as +! the fine one. This is in agreement with the fact that the routine is called, +! by amg_mlprec_bld, only on levels >=2. +! The coarse-level matrix A_C is built from a fine-level matrix A +! by using the Galerkin approach, i.e. +! +! A_C = P_C^T A P_C, +! +! where P_C is a prolongator from the coarse level to the fine one. +! +! A mapping from the nodes of the adjacency graph of A to the nodes of the +! adjacency graph of A_C has been computed by the amg_aggrmap_bld subroutine. +! The prolongator P_C is built here from this mapping, according to the +! value of p%iprcparm(amg_aggr_kind_), specified by the user through +! amg_sprecinit and amg_zprecset. +! On output from this routine the entries of AC, op_prol, op_restr +! are still in "global numbering" mode; this is fixed in the calling routine +! amg_s_lev_aggrmat_bld. +! +! Currently four different prolongators are implemented, corresponding to +! four aggregation algorithms: +! 1. un-smoothed aggregation, +! 2. smoothed aggregation, +! 3. "bizarre" aggregation. +! 4. minimum energy +! 1. The non-smoothed aggregation uses as prolongator the piecewise constant +! interpolation operator corresponding to the fine-to-coarse level mapping built +! by p%aggr%bld_tprol. This is called tentative prolongator. +! 2. The smoothed aggregation uses as prolongator the operator obtained by applying +! a damped Jacobi smoother to the tentative prolongator. +! 3. The "bizarre" aggregation uses a prolongator proposed by the authors of MLD2P4. +! This prolongator still requires a deep analysis and testing and its use is +! not recommended. +! 4. Minimum energy aggregation +! +! For more details see +! M. Brezina and P. Vanek, A black-box iterative solver based on a two-level +! Schwarz method, Computing, 63 (1999), 233-263. +! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed +! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 +! (1996), 179-196. +! P. D'Ambra, D. di Serafino and S. Filippone, On the development of PSBLAS-based +! parallel two-level Schwarz preconditioners, Appl. Num. Math., 57 (2007), +! 1181-1196. +! M. Sala, R. Tuminaro: A new Petrov-Galerkin smoothed aggregation preconditioner +! for nonsymmetric linear systems, SIAM J. Sci. Comput., 31(1):143-166 (2008) +! +! +! The main structure is: +! 1. Perform sanity checks; +! 2. Compute prolongator/restrictor/AC +! +! +! Arguments: +! ag - type(amg_s_dec_aggregator_type), input/output. +! The aggregator object +! parms - type(amg_sml_parms), input +! The aggregation parameters +! a - type(psb_sspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! ac - type(psb_sspmat_type), output +! The coarse matrix on output +! +! op_prol - type(psb_sspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_sspmat_type), output +! The restrictor operator; normally, it is the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +subroutine amg_s_dec_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + use psb_base_mod + use amg_s_prec_type, amg_protect_name => amg_s_dec_aggregator_mat_bld + use amg_s_inner_mod + implicit none + + class(amg_s_dec_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(psb_lsspmat_type), intent(inout) :: t_prol + type(psb_sspmat_type), intent(out) :: op_prol,ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + + ! Local variables + character(len=20) :: name + integer(psb_mpk_) :: ictxt, np, me + integer(psb_lpk_) :: nzl,ntaggr + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: debug_level, debug_unit + + name='amg_s_dec_aggregator_mat_bld' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + ! + ! Build the coarse-level matrix from the fine-level one, starting from + ! the mapping defined by amg_aggrmap_bld and applying the aggregation + ! algorithm specified by + ! + select case (parms%aggr_prol) + case (amg_no_smooth_) + + call amg_saggrmat_nosmth_bld(a,desc_a,ilaggr,nlaggr,& + & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) + + case(amg_smooth_prol_) + + call amg_saggrmat_smth_bld(a,desc_a,ilaggr,nlaggr, & + & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) + +!!$ case(amg_biz_prol_) +!!$ +!!$ call amg_saggrmat_biz_bld(a,desc_a,ilaggr,nlaggr, & +!!$ & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) + + case(amg_min_energy_) + + call amg_saggrmat_minnrg_bld(a,desc_a,ilaggr,nlaggr, & + & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='Invalid aggr kind') + goto 9999 + + end select + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='Inner aggrmat bld') + goto 9999 + end if + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + +end subroutine amg_s_dec_aggregator_mat_bld diff --git a/mlprec/impl/aggregator/amg_s_dec_aggregator_tprol.f90 b/mlprec/impl/aggregator/amg_s_dec_aggregator_tprol.f90 new file mode 100644 index 00000000..bee7cd3e --- /dev/null +++ b/mlprec/impl/aggregator/amg_s_dec_aggregator_tprol.f90 @@ -0,0 +1,139 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_s_dec_aggregator_tprol.f90 +! +! Subroutine: amg_s_dec_aggregator_tprol +! Version: real +! +! This routine is mainly an interface to soc_map_bld where the real work is performed. +! It takes care of some consistency checking, and calls map_to_tprol, which is +! refactored and shared among all the aggregation methods that produce a simple +! integer mapping. +! +! +! Arguments: +! ag - type(amg_s_dec_aggregator_type), input/output. +! The aggregator object, carrying with itself the mapping algorithm. +! parms - The auxiliary parameters object +! ag_data - Auxiliary global aggregation parameters object +! +! +! a - type(psb_sspmat_type). +! The sparse matrix structure containing the local part of the +! fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! ilaggr - integer, dimension(:), allocatable, output +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that on exit the indices +! will be shifted so as to make sure the ranges on the various processes do not +! overlap. +! nlaggr - integer, dimension(:), allocatable, output +! nlaggr(i) contains the aggregates held by process i. +! t_prol - type(psb_sspmat_type), output +! The tentative prolongator, based on ilaggr. +! +! info - integer, output. +! Error code. +! +subroutine amg_s_dec_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,t_prol,info) + use psb_base_mod + use amg_s_prec_type, amg_protect_name => amg_s_dec_aggregator_build_tprol + use amg_s_inner_mod + implicit none + class(amg_s_dec_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(amg_saggr_data), intent(in) :: ag_data + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lsspmat_type), intent(out) :: t_prol + integer(psb_ipk_), intent(out) :: info + + ! Local variables + character(len=20) :: name + integer(psb_mpk_) :: ictxt, np, me + integer(psb_ipk_) :: err_act + integer(psb_lpk_) :: ntaggr + integer(psb_ipk_) :: debug_level, debug_unit + logical :: clean_zeros + + name='amg_s_dec_aggregator_tprol' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + call amg_check_def(parms%ml_cycle,'Multilevel cycle',& + & amg_mult_ml_,is_legal_ml_cycle) + call amg_check_def(parms%par_aggr_alg,'Aggregation',& + & amg_dec_aggr_,is_legal_ml_par_aggr_alg) + call amg_check_def(parms%aggr_ord,'Ordering',& + & amg_aggr_ord_nat_,is_legal_ml_aggr_ord) + call amg_check_def(parms%aggr_thresh,'Aggr_Thresh',szero,is_legal_s_aggr_thrs) + + ! + ! The decoupled aggregator based on SOC measures ignores + ! ag_data except for clean_zeros; soc_map_bld is a procedure pointer. + ! + clean_zeros = ag%do_clean_zeros + call ag%soc_map_bld(parms%aggr_ord,parms%aggr_thresh,clean_zeros,a,desc_a,nlaggr,ilaggr,info) + + if (info==psb_success_) call amg_map_to_tprol(desc_a,ilaggr,nlaggr,t_prol,info) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='soc_map_bld/map_to_tprol') + goto 9999 + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_s_dec_aggregator_build_tprol diff --git a/mlprec/impl/aggregator/amg_s_map_to_tprol.f90 b/mlprec/impl/aggregator/amg_s_map_to_tprol.f90 new file mode 100644 index 00000000..56eeb291 --- /dev/null +++ b/mlprec/impl/aggregator/amg_s_map_to_tprol.f90 @@ -0,0 +1,154 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_s_map_to_tprol.f90 +! +! Subroutine: amg_s_map_to_tprol +! Version: real +! +! This routine uses a mapping from the row indices of the fine-level matrix +! to the row indices of the coarse-level matrix to build a tentative +! prolongator, i.e. a piecewise constant operator. +! This is later used to build the final operator; the code has been refactored here +! to be shared among all the methods that provide the tentative prolongator +! through a simple integer mapping. +! +! The aggregation algorithm is a parallel version of that described in +! * M. Brezina and P. Vanek, A black-box iterative solver based on a +! two-level Schwarz method, Computing, 63 (1999), 233-263. +! * P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed +! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 +! (1996), 179-196. +! For more details see +! P. D'Ambra, D. di Serafino and S. Filippone, On the development of +! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math. +! 57 (2007), 1181-1196. +! +! +! Arguments: +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! ilaggr - integer, dimension(:), allocatable. +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that on exit the indices +! will be shifted so as to make sure the ranges on the various processes do not +! overlap. +! nlaggr - integer, dimension(:), allocatable. +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_sspmat_type). +! The tentative prolongator, based on ilaggr. +! +! info - integer, output. +! Error code. +! +subroutine amg_s_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) + + use psb_base_mod + use amg_s_inner_mod, amg_protect_name => amg_s_map_to_tprol + + implicit none + + ! Arguments + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), allocatable, intent(inout) :: ilaggr(:),nlaggr(:) + type(psb_lsspmat_type), intent(out) :: op_prol + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_lpk_) :: icnt,nlp,k,n,ia,isz,nr, naggr,i,j,m,naggrm1, naggrp1, ntaggr + type(psb_ls_coo_sparse_mat) :: tmpcoo + integer(psb_ipk_) :: debug_level, debug_unit,err_act + integer(psb_ipk_) :: ictxt,np,me + integer(psb_lpk_) :: nrow, ncol, n_ne + character(len=20) :: name, ch_err + + info=psb_success_ + name = 'amg_map_to_tprol' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ! + ictxt=desc_a%get_context() + call psb_info(ictxt,me,np) + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + ilaggr(1:nrow) = ilaggr(1:nrow) + naggrm1 + call psb_halo(ilaggr,desc_a,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_halo') + goto 9999 + end if + + call tmpcoo%allocate(nrow,ntaggr,ncol) + k = 0 + do i=1,nrow + ! + ! Note: at this point, a value ilaggr(i)<=0 + ! tags a "singleton" row, and it has to be + ! left alone. + ! + if (ilaggr(i)>0) then + k = k + 1 + tmpcoo%val(k) = sone + tmpcoo%ia(k) = i + tmpcoo%ja(k) = ilaggr(i) + end if + end do + call tmpcoo%set_nzeros(k) + call tmpcoo%set_dupl(psb_dupl_add_) + call tmpcoo%set_sorted() ! At this point this is in row-major + call op_prol%mv_from(tmpcoo) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_map_to_tprol diff --git a/mlprec/impl/aggregator/amg_s_ptap.f90 b/mlprec/impl/aggregator/amg_s_ptap.f90 new file mode 100644 index 00000000..cd59abaa --- /dev/null +++ b/mlprec/impl/aggregator/amg_s_ptap.f90 @@ -0,0 +1,689 @@ +! +! +! MLD2P4 Extensions +! +! (C) Copyright 2019 +! +! Salvatore Filippone Cranfield University +! Pasqua D'Ambra IAC-CNR, Naples, IT +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_daggrmat_nosmth_bld.F90 +! +! +subroutine amg_s_ptap(a_csr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info,desc_ax) + use psb_base_mod + use amg_s_inner_mod + use amg_s_base_aggregator_mod, amg_protect_name => amg_s_ptap + implicit none + + ! Arguments + type(psb_s_csr_sparse_mat), intent(inout) :: a_csr + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + type(amg_sml_parms), intent(inout) :: parms + type(psb_s_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr + type(psb_desc_type), intent(inout) :: desc_ac + type(psb_sspmat_type), intent(out) :: ac + integer(psb_ipk_), intent(out) :: info + type(psb_desc_type), intent(inout), optional :: desc_ax + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo + character(len=40) :: name + integer(psb_ipk_) :: ierr(5) + type(psb_ls_coo_sparse_mat) :: ac_coo, tmpcoo + type(psb_s_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr + integer(psb_ipk_) :: debug_level, debug_unit, naggr + integer(psb_lpk_) :: nglob, ntaggr, naggrm1, naggrp1 + integer(psb_ipk_) :: nrow, ncol, nrl, nzl, ip, nzt, i, k + integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza + logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. + integer(psb_ipk_), save :: idx_spspmm=-1 + + name='amg_ptap' + if(psb_get_errstatus().ne.0) return + info=psb_success_ + call psb_erractionsave(err_act) + + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + call psb_info(ictxt, me, np) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + if ((do_timings).and.(idx_spspmm==-1)) & + & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr + + ! + ! COO_PROL should arrive here with local numbering + ! + if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& + & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& + & nrow,ntaggr,naggr + + call coo_prol%cp_to_fmt(csr_prol,info) + + if (debug) write(0,*) me,trim(name),' Product AxPROL ',& + & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & + & desc_a%get_local_rows(),desc_a%get_local_cols(),& + & desc_ac%get_local_rows(),desc_a%get_local_cols() + if (debug) flush(0) + + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + + if (debug) write(0,*) me,trim(name),' Done AxPROL ',& + & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& + & desc_ac%get_local_rows(),desc_ac%get_local_cols() + + ! + ! Ok first product done. + + if (present(desc_ax)) then + block + call coo_prol%cp_to_coo(coo_restr,info) + call coo_restr%set_ncols(desc_ac%get_local_cols()) + call coo_restr%set_nrows(desc_a%get_local_rows()) + call psb_s_coo_glob_transpose(coo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_ax%get_local_cols()) +! !$ write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& +! !$ & desc_a%get_local_cols(),desc_ax%get_local_cols(),coo_restr%get_nzeros() +! !$ if (desc_a%get_local_cols()= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + + else + + ! + ! Remember that RESTR must be built from PROL after halo extension, + ! which is done above in psb_par_spspmm + if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& + & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() + call csr_prol%mv_to_coo(coo_restr,info) +!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& +!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() + if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) + + call coo_restr%transp() + nzl = coo_restr%get_nzeros() + nrl = desc_ac%get_local_rows() + i=0 + ! + ! Only keep local rows + ! + do k=1, nzl + if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then + i = i+1 + coo_restr%val(i) = coo_restr%val(k) + coo_restr%ia(i) = coo_restr%ia(k) + coo_restr%ja(i) = coo_restr%ja(k) + end if + end do + call coo_restr%set_nzeros(i) + call coo_restr%fix(info) + nzl = coo_restr%get_nzeros() + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_a%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) + call csr_restr%cp_from_coo(coo_restr,info) + +!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + end if + + call psb_cdasb(desc_ac,info) + + call ac_csr%set_nrows(desc_ac%get_local_rows()) + call ac_csr%set_ncols(desc_ac%get_local_cols()) + call ac%mv_from(ac_csr) + call ac%set_asb() + + if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() + if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr + ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() + + call coo_prol%set_ncols(desc_ac%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ptap ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_s_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo + +end subroutine amg_s_ptap + +subroutine amg_s_ls_ptap(a_csr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info,desc_ax) + use psb_base_mod + use amg_s_inner_mod + use amg_s_base_aggregator_mod !, amg_protect_name => amg_s_ls_ptap + implicit none + + ! Arguments + type(psb_s_csr_sparse_mat), intent(inout) :: a_csr + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + type(amg_sml_parms), intent(inout) :: parms + type(psb_ls_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr + type(psb_desc_type), intent(inout) :: desc_ac + type(psb_lsspmat_type), intent(out) :: ac + integer(psb_ipk_), intent(out) :: info + type(psb_desc_type), intent(inout), optional :: desc_ax + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo + character(len=40) :: name + integer(psb_ipk_) :: ierr(5) + type(psb_ls_coo_sparse_mat) :: ac_coo, tmpcoo + type(psb_s_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr + integer(psb_ipk_) :: debug_level, debug_unit, naggr + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nrl, nzl, ip, & + & nzt, naggrm1, naggrp1, i, k + integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza + logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. + integer(psb_ipk_), save :: idx_spspmm=-1 + + name='amg_ptap' + if(psb_get_errstatus().ne.0) return + info=psb_success_ + call psb_erractionsave(err_act) + + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + call psb_info(ictxt, me, np) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + if ((do_timings).and.(idx_spspmm==-1)) & + & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr + + ! + ! COO_PROL should arrive here with local numbering + ! + if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& + & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& + & nrow,ntaggr,naggr + + call coo_prol%cp_to_ifmt(csr_prol,info) + + if (debug) write(0,*) me,trim(name),' Product AxPROL ',& + & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & + & desc_a%get_local_rows(),desc_a%get_local_cols(),& + & desc_ac%get_local_rows(),desc_a%get_local_cols() + if (debug) flush(0) + + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + + if (debug) write(0,*) me,trim(name),' Done AxPROL ',& + & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& + & desc_ac%get_local_rows(),desc_ac%get_local_cols() + + ! + ! Ok first product done. + + if (present(desc_ax)) then + block + type(psb_s_coo_sparse_mat) :: icoo_restr + + call coo_prol%cp_to_icoo(icoo_restr,info) + call icoo_restr%set_ncols(desc_ac%get_local_cols()) + call icoo_restr%set_nrows(desc_a%get_local_rows()) + call psb_s_coo_glob_transpose(icoo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) + call icoo_restr%set_nrows(desc_ac%get_local_rows()) + call icoo_restr%set_ncols(desc_ax%get_local_cols()) +! !$ write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& +! !$ & desc_a%get_local_cols(),desc_ax%get_local_cols(),icoo_restr%get_nzeros() +! !$ if (desc_a%get_local_cols()= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + + else + + ! + ! Remember that RESTR must be built from PROL after halo extension, + ! which is done above in psb_par_spspmm + if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& + & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() + call csr_prol%mv_to_lcoo(coo_restr,info) +!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& +!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() + if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) + + call coo_restr%transp() + nzl = coo_restr%get_nzeros() + nrl = desc_ac%get_local_rows() + i=0 + ! + ! Only keep local rows + ! + do k=1, nzl + if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then + i = i+1 + coo_restr%val(i) = coo_restr%val(k) + coo_restr%ia(i) = coo_restr%ia(k) + coo_restr%ja(i) = coo_restr%ja(k) + end if + end do + call coo_restr%set_nzeros(i) + call coo_restr%fix(info) + nzl = coo_restr%get_nzeros() + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_a%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) + call csr_restr%cp_from_lcoo(coo_restr,info) + +!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + end if + + call psb_cdasb(desc_ac,info) + + call ac_csr%set_nrows(desc_ac%get_local_rows()) + call ac_csr%set_ncols(desc_ac%get_local_cols()) + call ac%mv_from(ac_csr) + call ac%set_asb() + + if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() + if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr + ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() + + call coo_prol%set_ncols(desc_ac%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ptap ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_ls_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo + +end subroutine amg_s_ls_ptap + +subroutine amg_ls_ptap(a_csr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info,desc_ax) + use psb_base_mod + use amg_s_inner_mod + use amg_s_base_aggregator_mod!, amg_protect_name => amg_ls_ptap + implicit none + + ! Arguments + type(psb_ls_csr_sparse_mat), intent(inout) :: a_csr + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + type(amg_sml_parms), intent(inout) :: parms + type(psb_ls_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr + type(psb_desc_type), intent(inout) :: desc_ac + type(psb_lsspmat_type), intent(out) :: ac + integer(psb_ipk_), intent(out) :: info + type(psb_desc_type), intent(inout), optional :: desc_ax + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo + character(len=40) :: name + integer(psb_ipk_) :: ierr(5) + type(psb_ls_coo_sparse_mat) :: ac_coo, tmpcoo + type(psb_ls_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr + integer(psb_ipk_) :: debug_level, debug_unit, naggr + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nrl, nzl, ip, & + & nzt, naggrm1, naggrp1, i, k + integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza + logical, parameter :: do_timings=.true., oldstyle=.false., debug=.false. + integer(psb_ipk_), save :: idx_spspmm=-1 + + name='amg_ptap' + if(psb_get_errstatus().ne.0) return + info=psb_success_ + call psb_erractionsave(err_act) + + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + call psb_info(ictxt, me, np) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + if ((do_timings).and.(idx_spspmm==-1)) & + & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr + + ! + ! COO_PROL should arrive here with local numbering + ! + if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& + & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& + & nrow,ntaggr,naggr + + call coo_prol%cp_to_fmt(csr_prol,info) + + if (debug) write(0,*) me,trim(name),' Product AxPROL ',& + & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & + & desc_a%get_local_rows(),desc_a%get_local_cols(),& + & desc_ac%get_local_rows(),desc_a%get_local_cols() + if (debug) flush(0) + + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + + if (debug) write(0,*) me,trim(name),' Done AxPROL ',& + & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& + & desc_ac%get_local_rows(),desc_ac%get_local_cols() + + ! + ! Ok first product done. + + if (present(desc_ax)) then + block + type(psb_s_coo_sparse_mat) :: icoo_restr + + call coo_prol%cp_to_icoo(icoo_restr,info) + call icoo_restr%set_ncols(desc_ac%get_local_cols()) + call icoo_restr%set_nrows(desc_a%get_local_rows()) + call psb_s_coo_glob_transpose(icoo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) + call icoo_restr%set_nrows(desc_ac%get_local_rows()) + call icoo_restr%set_ncols(desc_ax%get_local_cols()) + write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& + & desc_a%get_local_cols(),desc_ax%get_local_cols(),icoo_restr%get_nzeros() + if (desc_a%get_local_cols()= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + + else + + ! + ! Remember that RESTR must be built from PROL after halo extension, + ! which is done above in psb_par_spspmm + if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& + & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() + call csr_prol%mv_to_coo(coo_restr,info) +!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& +!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() + if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) + + call coo_restr%transp() + nzl = coo_restr%get_nzeros() + nrl = desc_ac%get_local_rows() + i=0 + ! + ! Only keep local rows + ! + do k=1, nzl + if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then + i = i+1 + coo_restr%val(i) = coo_restr%val(k) + coo_restr%ia(i) = coo_restr%ia(k) + coo_restr%ja(i) = coo_restr%ja(k) + end if + end do + call coo_restr%set_nzeros(i) + call coo_restr%fix(info) + nzl = coo_restr%get_nzeros() + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_a%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) + call csr_restr%cp_from_coo(coo_restr,info) + +!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + end if + + call psb_cdasb(desc_ac,info) + + call ac_csr%set_nrows(desc_ac%get_local_rows()) + call ac_csr%set_ncols(desc_ac%get_local_cols()) + call ac%mv_from(ac_csr) + call ac%set_asb() + + if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() + if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr + ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() + + call coo_prol%set_ncols(desc_ac%get_local_cols()) + !call coo_restr%mv_from_ifmt(csr_restr,info) +!!$ call coo_restr%set_nrows(desc_ac%get_local_rows()) +!!$ call coo_restr%set_ncols(desc_a%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ptap ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_ls_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo + +end subroutine amg_ls_ptap diff --git a/mlprec/impl/aggregator/amg_s_soc1_map_bld.f90 b/mlprec/impl/aggregator/amg_s_soc1_map_bld.f90 new file mode 100644 index 00000000..ff8654e2 --- /dev/null +++ b/mlprec/impl/aggregator/amg_s_soc1_map_bld.f90 @@ -0,0 +1,349 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_s_soc1_map__bld.f90 +! +! Subroutine: amg_s_soc1_map_bld +! Version: real +! +! This routine builds the tentative prolongator based on the +! strength of connection aggregation algorithm presented in +! +! M. Brezina and P. Vanek, A black-box iterative solver based on a +! two-level Schwarz method, Computing, 63 (1999), 233-263. +! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed +! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 +! (1996), 179-196. +! +! Note: upon exit +! +! Arguments: +! a - type(psb_sspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_sprec_type), input/output. +! The preconditioner data structure; upon exit it contains +! the multilevel hierarchy of prolongators, restrictors +! and coarse matrices. +! info - integer, output. +! Error code. +! +! +! +subroutine amg_s_soc1_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) + + use psb_base_mod + use amg_base_prec_type + use amg_s_inner_mod + + implicit none + + ! Arguments + integer(psb_ipk_), intent(in) :: iorder + logical, intent(in) :: clean_zeros + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + real(psb_spk_), intent(in) :: theta + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),& + & ideg(:), idxs(:) + integer(psb_lpk_), allocatable :: tmpaggr(:) + real(psb_spk_), allocatable :: val(:), diag(:) + integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr, nc, naggr,i,j,m, nz, ilg, ii, ip + type(psb_s_csr_sparse_mat) :: acsr + real(psb_spk_) :: cpling, tcl + logical :: disjoint + integer(psb_ipk_) :: debug_level, debug_unit,err_act + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: nrow, ncol, n_ne + integer(psb_lpk_) :: nrglob + character(len=20) :: name, ch_err + + info=psb_success_ + name = 'amg_soc1_map_bld' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ! + ictxt=desc_a%get_context() + call psb_info(ictxt,me,np) + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + nrglob = desc_a%get_global_rows() + + nr = a%get_nrows() + nc = a%get_ncols() + allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),& + & icol(nc),val(nc),stat=info) + if(info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),& + & a_err='integer') + goto 9999 + end if + + diag = a%get_diag(info) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='psb_sp_getdiag') + goto 9999 + end if + + call a%cp_to(acsr) + if (clean_zeros) call acsr%clean_zeros(info) + if (iorder == amg_aggr_ord_nat_) then + do i=1, nr + ilaggr(i) = -(nr+1) + idxs(i) = i + end do + else + do i=1, nr + ilaggr(i) = -(nr+1) + ideg(i) = acsr%irp(i+1) - acsr%irp(i) + end do + call psb_msort(ideg,ix=idxs,dir=psb_sort_down_) + end if + + + ! + ! Phase one: Start with disjoint groups. + ! + naggr = 0 + icnt = 0 + step1: do ii=1, nr + i = idxs(ii) + if ((i<1).or.(i>nr)) then + info=psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + if (ilaggr(i) == -(nr+1)) then + nz = (acsr%irp(i+1)-acsr%irp(i)) + if ((nz<0).or.(nz>size(icol))) then + info=psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) + val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) + + ! + ! Build the set of all strongly coupled nodes + ! + ip = 0 + do k=1, nz + j = icol(k) + if ((1<=j).and.(j<=nr)) then + if (abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j)))) then + ip = ip + 1 + icol(ip) = icol(k) + end if + end if + enddo + + ! + ! If the whole strongly coupled neighborhood of I is + ! as yet unconnected, turn it into the next aggregate. + ! Same if ip==0 (in which case, neighborhood only + ! contains I even if it does not look like it from matrix) + ! + disjoint = all(ilaggr(icol(1:ip)) == -(nr+1)).or.(ip==0) + if (disjoint) then + icnt = icnt + 1 + naggr = naggr + 1 + do k=1, ip + ilaggr(icol(k)) = naggr + end do + ilaggr(i) = naggr + end if + endif + enddo step1 + + if (debug_level >= psb_debug_outer_) then + write(debug_unit,*) me,' ',trim(name),& + & ' Check 1:',count(ilaggr == -(nr+1)) + end if + + ! + ! Phase two: join the neighbours + ! + tmpaggr = ilaggr + step2: do ii=1,nr + i = idxs(ii) + + if (ilaggr(i) == -(nr+1)) then + nz = (acsr%irp(i+1)-acsr%irp(i)) + if (nz == 1) cycle step2 + icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) + val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) + + ! + ! Find the most strongly connected neighbour that is + ! already aggregated, if any, and join its aggregate + ! + cpling = szero + ip = 0 + do k=1, nz + j = icol(k) + if ((1<=j).and.(j<=nr)) then + if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))& + & .and. (tmpaggr(j) > 0).and. (abs(val(k)) > cpling)) then + ip = k + cpling = abs(val(k)) + end if + end if + enddo + if (ip > 0) then + ilaggr(i) = ilaggr(icol(ip)) + end if + end if + end do step2 + + + ! + ! Phase three: sweep over leftovers, if any + ! + step3: do ii=1,nr + i = idxs(ii) + + if (ilaggr(i) < 0) then + nz = (acsr%irp(i+1)-acsr%irp(i)) + if (nz == 1) cycle step3 + icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) + val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) + ! + ! Find its strongly connected neighbourhood not + ! already aggregated, and make it into a new aggregate. + ! + cpling = szero + ip = 0 + do k=1, nz + j = icol(k) + if ((1<=j).and.(j<=nr)) then + if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))& + & .and. (ilaggr(j) < 0)) then + ip = ip + 1 + icol(ip) = icol(k) + end if + end if + enddo + if (ip > 0) then + icnt = icnt + 1 + naggr = naggr + 1 + ilaggr(i) = naggr + do k=1, ip + ilaggr(icol(k)) = naggr + end do + else + ! + ! This should not happen: we did not even connect with ourselves, + ! but it's not a singleton. + ! + naggr = naggr + 1 + ilaggr(i) = naggr + end if + end if + end do step3 + + ! Any leftovers? + do i=1, nr + if (ilaggr(i) < 0) then + nz = (acsr%irp(i+1)-acsr%irp(i)) + if (nz == 1) then + ! Mark explicitly as a singleton so that + ! it will be ignored in map_to_tprol. + ! Need to use -(nrglob+nr) to make sure + ! it's still negative when shifted and combined with + ! other processes. + ilaggr(i) = -(nrglob+nr) + else + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers') + goto 9999 + endif + end if + end do + + if (naggr > ncol) then + !write(0,*) name,'Error : naggr > ncol',naggr,ncol + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Fatal error: naggr>ncol') + goto 9999 + end if + + call psb_realloc(ncol,ilaggr,info) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_realloc' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + allocate(nlaggr(np),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),& + & a_err='integer') + goto 9999 + end if + + nlaggr(:) = 0 + nlaggr(me+1) = naggr + call psb_sum(ictxt,nlaggr(1:np)) + + call acsr%free() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_soc1_map_bld + diff --git a/mlprec/impl/aggregator/amg_s_soc2_map_bld.f90 b/mlprec/impl/aggregator/amg_s_soc2_map_bld.f90 new file mode 100644 index 00000000..1c5d236b --- /dev/null +++ b/mlprec/impl/aggregator/amg_s_soc2_map_bld.f90 @@ -0,0 +1,348 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_s_soc2_map__bld.f90 +! +! Subroutine: amg_s_soc2_map_bld +! Version: real +! +! The aggregator object hosts the aggregation method for building +! the multilevel hierarchy. This variant is based on the method +! presented in +! +! S. Gratton, P. Henon, P. Jiranek and X. Vasseur: +! Reducing complexity of algebraic multigrid by aggregation +! Numerical Lin. Algebra with Applications, 2016, 23:501-518 +! +! Note: upon exit +! +! Arguments: +! a - type(psb_sspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_sprec_type), input/output. +! The preconditioner data structure; upon exit it contains +! the multilevel hierarchy of prolongators, restrictors +! and coarse matrices. +! info - integer, output. +! Error code. +! +! +! +subroutine amg_s_soc2_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) + + use psb_base_mod + use amg_base_prec_type + use amg_s_inner_mod + + implicit none + + ! Arguments + integer(psb_ipk_), intent(in) :: iorder + logical, intent(in) :: clean_zeros + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + real(psb_spk_), intent(in) :: theta + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),& + & ideg(:), idxs(:) + integer(psb_lpk_), allocatable :: tmpaggr(:) + real(psb_spk_), allocatable :: val(:), diag(:) + integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr,nc,naggr,i,j,m, nz, ilg, ii, ip, ip1,nzcnt + integer(psb_lpk_) :: nrglob + type(psb_s_csr_sparse_mat) :: acsr, muij, s_neigh + type(psb_s_coo_sparse_mat) :: s_neigh_coo + real(psb_spk_) :: cpling, tcl + logical :: disjoint + integer(psb_ipk_) :: debug_level, debug_unit,err_act + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: nrow, ncol, n_ne + character(len=20) :: name, ch_err + + info=psb_success_ + name = 'amg_soc2_map_bld' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ! + ictxt=desc_a%get_context() + call psb_info(ictxt,me,np) + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + nrglob = desc_a%get_global_rows() + + nr = a%get_nrows() + nc = a%get_ncols() + allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),icol(nc),stat=info) + if(info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),& + & a_err='integer') + goto 9999 + end if + + diag = a%get_diag(info) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='psb_sp_getdiag') + goto 9999 + end if + + ! + ! Phase zero: compute muij + ! + call a%cp_to(muij) + if (clean_zeros) call muij%clean_zeros(info) + do i=1, nr + do k=muij%irp(i),muij%irp(i+1)-1 + j = muij%ja(k) + if (j<= nr) muij%val(k) = abs(muij%val(k))/sqrt(abs(diag(i)*diag(j))) + end do + end do + + ! + ! Compute the 1-neigbour; mark strong links with +1, weak links with -1 + ! + call s_neigh_coo%allocate(nr,nr,muij%get_nzeros()) + ip = 0 + do i=1, nr + do k=muij%irp(i),muij%irp(i+1)-1 + j = muij%ja(k) + if (j<=nr) then + ip = ip + 1 + s_neigh_coo%ia(ip) = i + s_neigh_coo%ja(ip) = j + if (real(muij%val(k)) >= theta) then + s_neigh_coo%val(ip) = sone + else + s_neigh_coo%val(ip) = -sone + end if + end if + end do + end do + !write(*,*) 'S_NEIGH: ',nr,ip + call s_neigh_coo%set_nzeros(ip) + call s_neigh%mv_from_coo(s_neigh_coo,info) + + if (iorder == amg_aggr_ord_nat_) then + do i=1, nr + ilaggr(i) = -(nr+1) + idxs(i) = i + end do + else + do i=1, nr + ilaggr(i) = -(nr+1) + ideg(i) = muij%irp(i+1) - muij%irp(i) + end do + call psb_msort(ideg,ix=idxs,dir=psb_sort_down_) + end if + + + ! + ! Phase one: Start with disjoint groups. + ! + naggr = 0 + icnt = 0 + step1: do ii=1, nr + i = idxs(ii) + + if (ilaggr(i) == -(nr+1)) then + ! + ! Get the 1-neighbourhood of I + ! + ip1 = s_neigh%irp(i) + nz = s_neigh%irp(i+1)-ip1 + ! + ! If the neighbourhood only contains I, skip it + ! + if (nz ==0) then + ilaggr(i) = 0 + cycle step1 + end if + if ((nz==1).and.(s_neigh%ja(ip1)==i)) then + ilaggr(i) = 0 + cycle step1 + end if + ! + ! If the whole strongly coupled neighborhood of I is + ! as yet unconnected, turn it into the next aggregate. + ! + nzcnt = count(real(s_neigh%val(ip1:ip1+nz-1)) > 0) + icol(1:nzcnt) = pack(s_neigh%ja(ip1:ip1+nz-1),(real(s_neigh%val(ip1:ip1+nz-1)) > 0)) + disjoint = all(ilaggr(icol(1:nzcnt)) == -(nr+1)) + if (disjoint) then + icnt = icnt + 1 + naggr = naggr + 1 + do k=1, nzcnt + ilaggr(icol(k)) = naggr + end do + ilaggr(i) = naggr + end if + endif + enddo step1 + + if (debug_level >= psb_debug_outer_) then + write(debug_unit,*) me,' ',trim(name),& + & ' Check 1:',count(ilaggr == -(nr+1)) + end if + + ! + ! Phase two: join the neighbours + ! + tmpaggr = ilaggr + step2: do ii=1,nr + i = idxs(ii) + + if (ilaggr(i) == -(nr+1)) then + ! + ! Find the most strongly connected neighbour that is + ! already aggregated, if any, and join its aggregate + ! + cpling = szero + ip = 0 + do k=s_neigh%irp(i), s_neigh%irp(i+1)-1 + j = s_neigh%ja(k) + if ((1<=j).and.(j<=nr)) then + if ( (tmpaggr(j) > 0).and. (real(muij%val(k)) > cpling)& + & .and.(real(s_neigh%val(k))>0)) then + ip = k + cpling = muij%val(k) + end if + end if + enddo + if (ip > 0) then + ilaggr(i) = ilaggr(s_neigh%ja(ip)) + end if + end if + end do step2 + + + ! + ! Phase three: sweep over leftovers, if any + ! + step3: do ii=1,nr + i = idxs(ii) + + if (ilaggr(i) < 0) then + ! + ! Find its strongly connected neighbourhood not + ! already aggregated, and make it into a new aggregate. + ! + ip = 0 + do k=s_neigh%irp(i), s_neigh%irp(i+1)-1 + j = s_neigh%ja(k) + if ((1<=j).and.(j<=nr)) then + if (ilaggr(j) < 0) then + ip = ip + 1 + icol(ip) = j + end if + end if + enddo + if (ip > 0) then + icnt = icnt + 1 + naggr = naggr + 1 + ilaggr(i) = naggr + do k=1, ip + ilaggr(icol(k)) = naggr + end do + end if + end if + end do step3 + + ! Any leftovers? + do i=1, nr + if (ilaggr(i) <= 0) then + nz = (s_neigh%irp(i+1)-s_neigh%irp(i)) + if (nz <= 1) then + ! Mark explicitly as a singleton so that + ! it will be ignored in map_to_tprol. + ! Need to use -(nrglob+nr) to make sure + ! it's still negative when shifted and combined with + ! other processes. + ilaggr(i) = -(nrglob+nr) + else + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers') + goto 9999 + endif + end if + end do + + if (naggr > ncol) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Fatal error: naggr>ncol') + goto 9999 + end if + + call psb_realloc(ncol,ilaggr,info) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_realloc' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + allocate(nlaggr(np),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),& + & a_err='integer') + goto 9999 + end if + + nlaggr(:) = 0 + nlaggr(me+1) = naggr + call psb_sum(ictxt,nlaggr(1:np)) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_soc2_map_bld + diff --git a/mlprec/impl/aggregator/amg_s_symdec_aggregator_tprol.f90 b/mlprec/impl/aggregator/amg_s_symdec_aggregator_tprol.f90 new file mode 100644 index 00000000..ec8a67f0 --- /dev/null +++ b/mlprec/impl/aggregator/amg_s_symdec_aggregator_tprol.f90 @@ -0,0 +1,160 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_s_symdec_aggregator_tprol.f90 +! +! Subroutine: amg_s_symdec_aggregator_tprol +! Version: real +! +! +! This routine is mainly an interface to soc_map_bld where the real work is performed. +! It takes care of some consistency checking, and calls map_to_tprol, which is +! refactored and shared among all the aggregation methods that produce a simple +! integer mapping. It also symmetrizes the pattern of the local matrix A. +! +! +! +! Arguments: +! Arguments: +! ag - type(amg_s_dec_aggregator_type), input/output. +! The aggregator object, carrying with itself the mapping algorithm. +! parms - The auxiliary parameters object +! ag_data - Auxiliary global aggregation parameters object +! +! a - type(psb_sspmat_type). +! The sparse matrix structure containing the local part of the +! fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! ilaggr - integer, dimension(:), allocatable, output +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that on exit the indices +! will be shifted so as to make sure the ranges on the various processes do not +! overlap. +! nlaggr - integer, dimension(:), allocatable, output +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_sspmat_type), output +! The tentative prolongator, based on ilaggr. +! +! info - integer, output. +! Error code. +! +subroutine amg_s_symdec_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,op_prol,info) + use psb_base_mod + use amg_s_prec_type + use amg_s_symdec_aggregator_mod, amg_protect_name => amg_s_symdec_aggregator_build_tprol + use amg_s_inner_mod + implicit none + class(amg_s_symdec_aggregator_type), target, intent(inout) :: ag + type(amg_sml_parms), intent(inout) :: parms + type(amg_saggr_data), intent(in) :: ag_data + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lsspmat_type), intent(out) :: op_prol + integer(psb_ipk_), intent(out) :: info + + ! Local variables + type(psb_sspmat_type) :: atmp, atrans + character(len=20) :: name + integer(psb_mpk_) :: ictxt, np, me + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: nr + integer(psb_lpk_) :: ntaggr + integer(psb_ipk_) :: debug_level, debug_unit + logical :: clean_zeros + + name='amg_s_symdec_aggregator_tprol' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + call amg_check_def(parms%ml_cycle,'Multilevel cycle',& + & amg_mult_ml_,is_legal_ml_cycle) + call amg_check_def(parms%par_aggr_alg,'Aggregation',& + & amg_dec_aggr_,is_legal_ml_par_aggr_alg) + call amg_check_def(parms%aggr_ord,'Ordering',& + & amg_aggr_ord_nat_,is_legal_ml_aggr_ord) + call amg_check_def(parms%aggr_thresh,'Aggr_Thresh',szero,is_legal_s_aggr_thrs) + + nr = a%get_nrows() + call a%csclip(atmp,info,imax=nr,jmax=nr,& + & rscale=.false.,cscale=.false.) + call atmp%set_nrows(nr) + call atmp%set_ncols(nr) + if (info == psb_success_) call atmp%transp(atrans) + if (info == psb_success_) call atrans%cscnv(info,type='COO') + if (info == psb_success_) call psb_rwextd(nr,atmp,info,b=atrans,rowscale=.false.) + call atmp%set_nrows(nr) + call atmp%set_ncols(nr) + if (info == psb_success_) call atrans%free() + if (info == psb_success_) call atmp%cscnv(info,type='CSR') + + ! + ! The decoupled aggregator based on SOC measures ignores + ! ag_data except for clean_zeros; soc_map_bld is a procedure pointer. + ! + clean_zeros = ag%do_clean_zeros + if (info == psb_success_) & + & call ag%soc_map_bld(parms%aggr_ord,parms%aggr_thresh,clean_zeros,atmp,& + & desc_a,nlaggr,ilaggr,info) + if (info == psb_success_) call atmp%free() + + if (info == psb_success_) call amg_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='soc_map_bld/map_to_tprol') + goto 9999 + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_s_symdec_aggregator_build_tprol diff --git a/mlprec/impl/aggregator/amg_saggrmat_minnrg_bld.f90 b/mlprec/impl/aggregator/amg_saggrmat_minnrg_bld.f90 new file mode 100644 index 00000000..99ca39bf --- /dev/null +++ b/mlprec/impl/aggregator/amg_saggrmat_minnrg_bld.f90 @@ -0,0 +1,656 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_saggrmat_minnrg_bld.F90 +! +! Subroutine: amg_saggrmat_minnrg_bld +! Version: real +! +! This routine builds a coarse-level matrix A_C from a fine-level matrix A +! by using the Galerkin approach, i.e. +! +! A_C = P_C^T A P_C, +! +! where P_C is a prolongator from the coarse level to the fine one. +! +! The prolongator P_C is built according to a smoothed aggregation algorithm, +! i.e. it is obtained by applying a damped Jacobi smoother to the piecewise +! constant interpolation operator P corresponding to the fine-to-coarse level +! mapping built by the amg_aggrmap_bld subroutine: +! +! P_C = (I - omega*D^(-1)A) * P, +! +! where D is the diagonal matrix with main diagonal equal to the main diagonal +! of A, and omega is a suitable smoothing parameter. An estimate of the spectral +! radius of D^(-1)A, to be used in the computation of omega, is provided, +! according to the value of p%parms%aggr_omega_alg, specified by the user +! through amg_sprecinit and amg_sprecset. +! 4. Minimum energy aggregation: +! M. Sala, R. Tuminaro: A new Petrov-Galerkin smoothed aggregation preconditioner +! for nonsymmetric linear systems, SIAM J. Sci. Comput., 31(1):143-166 (2008) +! +! On output from this routine the entries of AC, op_prol, op_restr +! are still in "global numbering" mode; this is fixed in the calling routine +! aggregator%mat_bld. +! +! +! Arguments: +! a - type(psb_sspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! p - type(amg_s_onelev_type), input/output. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! parms - type(amg_sml_parms), input +! Parameters controlling the choice of algorithm +! ac - type(psb_sspmat_type), output +! The coarse matrix on output +! +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_sspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_sspmat_type), output +! The restrictor operator; in this particular case, it is different +! from the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +! +subroutine amg_saggrmat_minnrg_bld(a,desc_a,ilaggr,nlaggr,parms,& + & ac,desc_ac,op_prol,op_restr,info) + use psb_base_mod + use amg_base_prec_type + use amg_s_inner_mod, amg_protect_name => amg_saggrmat_minnrg_bld + + implicit none + + ! Arguments + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(amg_sml_parms), intent(inout) :: parms + type(psb_lsspmat_type), intent(inout) :: op_prol + type(psb_lsspmat_type), intent(out) :: ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nzac, ip, ndx,& + & naggr, nzl,naggrm1,naggrp1, i, j, k, jd, icolF, nrt + integer(psb_ipk_) :: ictxt,np,me, icomm + character(len=20) :: name + type(psb_lsspmat_type) :: la, af, ptilde, rtilde, atran, atp, atdatp + type(psb_lsspmat_type) :: am3,am4, ap, adap,atmp,rada, ra, atmp2, dap, dadap, da + type(psb_lsspmat_type) :: dat, datp, datdatp, atmp3, tmp_prol + type(psb_ls_coo_sparse_mat) :: tmpcoo + type(psb_ls_csr_sparse_mat) :: acsr1, acsr2, acsr3, acsr, acsrf + type(psb_ls_csc_sparse_mat) :: csc_dap, csc_dadap, csc_datp, csc_datdatp, acsc + real(psb_spk_), allocatable :: adiag(:), adinv(:) + real(psb_spk_), allocatable :: omf(:), omp(:), omi(:), oden(:) + logical :: filter_mat + integer(psb_ipk_) :: ierr(5) + integer(psb_ipk_) :: debug_level, debug_unit, err_act + integer(psb_ipk_), parameter :: ncmax=16 + real(psb_spk_) :: anorm, theta + real(psb_spk_) :: tmp, alpha, beta, ommx + + name='amg_aggrmat_minnrg' + info=psb_success_ + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + ictxt = desc_a%get_context() + + call psb_info(ictxt, me, np) + + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + theta = parms%aggr_thresh + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + + filter_mat = (parms%aggr_filter == amg_filter_mat_) + + ! naggr: number of local aggregates + ! nrow: local rows. + ! + allocate(adinv(ncol),& + & omf(ncol),omp(ntaggr),oden(ntaggr),omi(ncol),stat=info) + + if (info /= psb_success_) then + info=psb_err_alloc_request_; ierr(1)=6*ncol+ntaggr; + call psb_errpush(info,name,i_err=ierr,a_err='real(psb_spk_)') + goto 9999 + end if + + ! Get the diagonal D + adiag = a%get_diag(info) + if (info == psb_success_) & + & call psb_realloc(ncol,adiag,info) + if (info == psb_success_) & + & call psb_halo(adiag,desc_a,info) + if (info == psb_success_) call a%cp_to_l(la) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_getdiag') + goto 9999 + end if + + do i=1,size(adiag) + if (adiag(i) /= szero) then + adinv(i) = sone / adiag(i) + else + adinv(i) = sone + end if + end do + + + + ! 1. Allocate Ptilde in sparse matrix form + call op_prol%mv_to(tmpcoo) + call ptilde%mv_from(tmpcoo) + call ptilde%cscnv(info,type='csr') + + if (info == psb_success_) call la%cscnv(am3,info,type='csr',dupl=psb_dupl_add_) + if (info == psb_success_) call la%cscnv(da,info,type='csr',dupl=psb_dupl_add_) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Initial copies done.' + + call da%scal(adinv,info) + + call psb_spspmm(da,ptilde,dap,info) + + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 1') + goto 9999 + end if + + call dap%clone(atmp,info) + + call psb_sphalo(atmp,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.,outfmt='CSR ') + if (info == psb_success_) call psb_rwextd(ncol,atmp,info,b=am4) + if (info == psb_success_) call am4%free() + + call psb_spspmm(da,atmp,dadap,info) + call atmp%free() + + ! !$ write(0,*) 'Columns of AP',psb_sp_get_ncols(ap) + ! !$ write(0,*) 'Columns of ADAP',psb_sp_get_ncols(adap) + call dap%mv_to(csc_dap) + call dadap%mv_to(csc_dadap) + + call csc_mat_col_prod(csc_dap,csc_dadap,omp,info) + call csc_mat_col_prod(csc_dadap,csc_dadap,oden,info) + call psb_sum(ictxt,omp) + call psb_sum(ictxt,oden) + ! !$ write(0,*) trim(name),' OMP :',omp + ! !$ write(0,*) trim(name),' ODEN:',oden + + omp = omp/oden + + ! !$ write(0,*) 'Check on output prolongator ',omp(1:min(size(omp),10)) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done NUMBMM 1' + + call am3%mv_to(acsr3) + ! Compute omega_int + ommx = szero + do i=1, ncol + if (ilaggr(i) >0) then + omi(i) = omp(ilaggr(i)) + else + omi(i) = szero + end if + if(abs(omi(i)) .gt. abs(ommx)) ommx = omi(i) + end do + ! Compute omega_fine + do i=1, nrow + omf(i) = ommx + do j=acsr3%irp(i),acsr3%irp(i+1)-1 + if(abs(omi(acsr3%ja(j))) .lt. abs(omf(i))) omf(i)=omi(acsr3%ja(j)) + end do +!!$ if(min(real(omf(i)),aimag(omf(i))) < szero) omf(i) = szero + if(psb_minreal(omf(i)) < szero) omf(i) = szero + end do + + omf(1:nrow) = omf(1:nrow) * adinv(1:nrow) + + if (filter_mat) then + ! + ! Build the filtered matrix Af from A + ! + call la%cscnv(acsrf,info,dupl=psb_dupl_add_) + + do i=1,nrow + tmp = szero + jd = -1 + do j=acsrf%irp(i),acsrf%irp(i+1)-1 + if (acsrf%ja(j) == i) jd = j + if (abs(acsrf%val(j)) < theta*sqrt(abs(adiag(i)*adiag(acsrf%ja(j))))) then + tmp=tmp+acsrf%val(j) + acsrf%val(j)=szero + endif + enddo + if (jd == -1) then + write(0,*) 'Wrong input: we need the diagonal!!!!', i + else + acsrf%val(jd)=acsrf%val(jd)-tmp + end if + enddo + ! Take out zeroed terms + call acsrf%clean_zeros(info) + + ! + ! Build the smoothed prolongator using the filtered matrix + ! + do i=1,acsrf%get_nrows() + do j=acsrf%irp(i),acsrf%irp(i+1)-1 + if (acsrf%ja(j) == i) then + acsrf%val(j) = sone - omf(i)*acsrf%val(j) + else + acsrf%val(j) = - omf(i)*acsrf%val(j) + end if + end do + end do + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done gather, going for SYMBMM 1' + + call af%mv_from(acsrf) + ! + ! op_prol = (I-w*D*Af)Ptilde + ! Doing it this way means to consider diag(Af_i) + ! + ! + call psb_spspmm(af,ptilde,op_prol,info) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done SPSPMM 1' + else + ! + ! Build the smoothed prolongator using the original matrix + ! + do i=1,acsr3%get_nrows() + do j=acsr3%irp(i),acsr3%irp(i+1)-1 + if (acsr3%ja(j) == i) then + acsr3%val(j) = sone - omf(i)*acsr3%val(j) + else + acsr3%val(j) = - omf(i)*acsr3%val(j) + end if + end do + end do + + call am3%mv_from(acsr3) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done gather, going for SYMBMM 1' + ! + ! + ! op_prol = (I-w*D*A)Ptilde + ! + ! + call psb_spspmm(am3,ptilde,op_prol,info) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done NUMBMM 1' + + end if + + + ! + ! Ok, let's start over with the restrictor + ! + call ptilde%transc(rtilde) + call la%cscnv(atmp,info,type='csr') + call psb_sphalo(atmp,desc_a,am4,info,& + & colcnv=.true.,rowscale=.true.) + nrt = am4%get_nrows() + call am4%csclip(atmp2,info,lone,nrt,lone,ncol) + call atmp2%cscnv(info,type='CSR') + if (info == psb_success_) call psb_rwextd(ncol,atmp,info,b=atmp2) + call am4%free() + call atmp2%free() + + ! This is to compute the transpose. It ONLY works if the + ! original A has a symmetric pattern. + call atmp%transc(atmp2) + call atmp2%csclip(dat,info,lone,nrow,lone,ncol) + call dat%cscnv(info,type='csr') + call dat%scal(adinv,info) + + ! Now for the product. + call psb_spspmm(dat,ptilde,datp,info) + + call datp%clone(atmp2,info) + call psb_sphalo(atmp2,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.,outfmt='CSR ') + if (info == psb_success_) call psb_rwextd(ncol,atmp2,info,b=am4) + if (info == psb_success_) call am4%free() + + + call psb_symbmm(dat,atmp2,datdatp,info) + call psb_numbmm(dat,atmp2,datdatp) + call atmp2%free() + + call datp%mv_to(csc_datp) + call datdatp%mv_to(csc_datdatp) + + call csc_mat_col_prod(csc_datp,csc_datdatp,omp,info) + call csc_mat_col_prod(csc_datdatp,csc_datdatp,oden,info) + call psb_sum(ictxt,omp) + call psb_sum(ictxt,oden) + + + ! !$ write(debug_unit,*) trim(name),' OMP_R :',omp + ! ! $ write(debug_unit,*) trim(name),' ODEN_R:',oden + omp = omp/oden + ! !$ write(0,*) 'Check on output restrictor',omp(1:min(size(omp),10)) + ! Compute omega_int + ommx = szero + do i=1, ncol + if (ilaggr(i) >0) then + omi(i) = omp(ilaggr(i)) + else + omi(i) = szero + end if + if(abs(omi(i)) .gt. abs(ommx)) ommx = omi(i) + end do + ! Compute omega_fine + ! Going over the columns of atmp means going over the rows + ! of A^T. Hopefully ;-) + call atmp%cp_to(acsc) + + do i=1, nrow + omf(i) = ommx + do j= acsc%icp(i),acsc%icp(i+1)-1 + if(abs(omi(acsc%ia(j))) .lt. abs(omf(i))) omf(i)=omi(acsc%ia(j)) + end do +!!$ if(min(real(omf(i)),aimag(omf(i))) < szero) omf(i) = szero + if(psb_minreal(omf(i)) < szero) omf(i) = szero + end do + omf(1:nrow) = omf(1:nrow)*adinv(1:nrow) + call psb_halo(omf,desc_a,info) + call acsc%free() + + + call atmp%mv_to(acsr1) + + do i=1,acsr1%get_nrows() + do j=acsr1%irp(i),acsr1%irp(i+1)-1 + if (acsr1%ja(j) == i) then + acsr1%val(j) = sone - acsr1%val(j)*omf(acsr1%ja(j)) + else + acsr1%val(j) = - acsr1%val(j)*omf(acsr1%ja(j)) + end if + end do + end do + call atmp%mv_from(acsr1) + + call rtilde%mv_to(tmpcoo) + nzl = tmpcoo%get_nzeros() + i=0 + do k=1, nzl + if ((naggrm1 < tmpcoo%ia(k)) .and. (tmpcoo%ia(k) <= naggrp1)) then + i = i+1 + tmpcoo%val(i) = tmpcoo%val(k) + tmpcoo%ia(i) = tmpcoo%ia(k) + tmpcoo%ja(i) = tmpcoo%ja(k) + end if + end do + call tmpcoo%set_nzeros(i) + call rtilde%mv_from(tmpcoo) + call rtilde%cscnv(info,type='csr') + + call psb_spspmm(rtilde,atmp,op_restr,info) + + ! + ! Now we have to gather the halo of op_prol, and add it to itself + ! to multiply it by A, + ! + call op_prol%clone(tmp_prol,info) + if (info == psb_success_) call psb_sphalo(tmp_prol,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.) + if (info == psb_success_) call psb_rwextd(ncol,tmp_prol,info,b=am4) + if (info == psb_success_) call am4%free() + + if(info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Halo of op_prol') + goto 9999 + end if + + ! + ! Now we have to fix this. The only rows of B that are correct + ! are those corresponding to "local" aggregates, i.e. indices in ilaggr(:) + ! + call op_restr%mv_to(tmpcoo) + + nzl = tmpcoo%get_nzeros() + i=0 + do k=1, nzl + if ((naggrm1 < tmpcoo%ia(k)) .and. (tmpcoo%ia(k) <= naggrp1)) then + i = i+1 + tmpcoo%val(i) = tmpcoo%val(k) + tmpcoo%ia(i) = tmpcoo%ia(k) + tmpcoo%ja(i) = tmpcoo%ja(k) + end if + end do + call tmpcoo%set_nzeros(i) + call op_restr%mv_from(tmpcoo) + call op_restr%cscnv(info,type='csr') + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + call psb_spspmm(la,tmp_prol,am3,info) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done SPSPMM 2' + + call psb_sphalo(am3,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.) + if (info == psb_success_) call psb_rwextd(ncol,am3,info,b=am4) + if (info == psb_success_) call am4%free() + + if(info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Extend am3') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done sphalo/ rwxtd' + + call psb_spspmm(op_restr,am3,ac,info) + if (info == psb_success_) call am3%free() + if (info == psb_success_) call ac%cscnv(info,type='coo',dupl=psb_dupl_add_) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + &a_err='Build ac = op_restr x am3') + goto 9999 + end if + + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done smooth_aggregate ' + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_errpush(info,name) + call psb_error_handler(err_act) + return + + +contains + + subroutine csc_mat_col_prod(a,b,v,info) + implicit none + type(psb_ls_csc_sparse_mat), intent(in) :: a, b + real(psb_spk_), intent(out) :: v(:) + integer(psb_ipk_), intent(out) :: info + + integer(psb_lpk_) :: i,j,k, nr, nc,iap,nra,ibp,nrb + + info = psb_success_ + nc = a%get_ncols() + if (nc /= b%get_ncols()) then + write(0,*) 'Matrices A and B should have same columns' + info = -1 + return + end if + + do j=1, nc + iap = a%icp(j) + nra = a%icp(j+1)-iap + ibp = b%icp(j) + nrb = b%icp(j+1)-ibp + v(j) = sparse_srtd_dot(nra,a%ia(iap:iap+nra-1),a%val(iap:iap+nra-1),& + & nrb,b%ia(ibp:ibp+nrb-1),b%val(ibp:ibp+nrb-1)) + end do + + end subroutine csc_mat_col_prod + + + subroutine csr_mat_row_prod(a,b,v,info) + implicit none + type(psb_ls_csr_sparse_mat), intent(in) :: a, b + real(psb_spk_), intent(out) :: v(:) + integer(psb_ipk_), intent(out) :: info + + integer(psb_lpk_) :: i,j,k, nr, nc,iap,nca,ibp,ncb + + info = psb_success_ + nr = a%get_nrows() + if (nr /= b%get_nrows()) then + write(0,*) 'Matrices A and B should have same rows' + info = -1 + return + end if + + do j=1, nr + iap = a%irp(j) + nca = a%irp(j+1)-iap + ibp = b%irp(j) + ncb = b%irp(j+1)-ibp + v(j) = sparse_srtd_dot(nca,a%ja(iap:iap+nca-1),a%val(iap:iap+nca-1),& + & ncb,b%ja(ibp:ibp+ncb-1),b%val(ibp:ibp+ncb-1)) + end do + + end subroutine csr_mat_row_prod + + + function sparse_srtd_dot(nv1,iv1,v1,nv2,iv2,v2) result(dot) + implicit none + integer(psb_lpk_), intent(in) :: nv1,nv2 + integer(psb_lpk_), intent(in) :: iv1(:), iv2(:) + real(psb_spk_), intent(in) :: v1(:),v2(:) + real(psb_spk_) :: dot + + integer(psb_lpk_) :: i,j,k, ip1, ip2 + + dot = szero + ip1 = 1 + ip2 = 1 + + do + if (ip1 > nv1) exit + if (ip2 > nv2) exit + if (iv1(ip1) == iv2(ip2)) then + dot = dot + (v1(ip1))*v2(ip2) + ip1 = ip1 + 1 + ip2 = ip2 + 1 + else if (iv1(ip1) < iv2(ip2)) then + ip1 = ip1 + 1 + else + ip2 = ip2 + 1 + end if + end do + + end function sparse_srtd_dot + + subroutine local_dump(me,mat,name,header) + type(psb_lsspmat_type), intent(in) :: mat + integer(psb_ipk_), intent(in) :: me + character(len=*), intent(in) :: name + character(len=*), intent(in) :: header + character(len=80) :: filename + + write(filename,'(a,a,i0,a,i0,a)') trim(name),'.p',me + open(20+me,file=filename) + call mat%print(20+me,head=trim(header)) + close(20+me) + end subroutine local_dump + +end subroutine amg_saggrmat_minnrg_bld diff --git a/mlprec/impl/aggregator/amg_saggrmat_nosmth_bld.f90 b/mlprec/impl/aggregator/amg_saggrmat_nosmth_bld.f90 new file mode 100644 index 00000000..757b3b6b --- /dev/null +++ b/mlprec/impl/aggregator/amg_saggrmat_nosmth_bld.f90 @@ -0,0 +1,198 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_saggrmat_nosmth_bld.F90 +! +! Subroutine: amg_saggrmat_nosmth_bld +! Version: real +! +! This routine builds a coarse-level matrix A_C from a fine-level matrix A +! by using the Galerkin approach, i.e. +! +! A_C = P_C^T A P_C, +! +! where P_C is the piecewise constant interpolation operator corresponding +! the fine-to-coarse level mapping built by amg_aggrmap_bld. +! +! The coarse-level matrix A_C is distributed among the parallel processes or +! replicated on each of them, according to the value of p%parms%coarse_mat +! specified by the user through amg_sprecinit and amg_zprecset. +! On output from this routine the entries of AC, op_prol, op_restr +! are still in "global numbering" mode; this is fixed in the calling routine +! aggregator%mat_bld. +! +! For details see +! P. D'Ambra, D. di Serafino and S. Filippone, On the development of +! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math., +! 57 (2007), 1181-1196. +! +! +! Arguments: +! a - type(psb_sspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! p - type(amg_s_onelev_type), input/output. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! parms - type(amg_sml_parms), input +! Parameters controlling the choice of algorithm +! ac - type(psb_sspmat_type), output +! The coarse matrix on output +! +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_sspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_sspmat_type), output +! The restrictor operator; normally, it is the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +! +subroutine amg_saggrmat_nosmth_bld(a,desc_a,ilaggr,nlaggr,parms,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + use psb_base_mod + use amg_base_prec_type + use amg_s_inner_mod, amg_protect_name => amg_saggrmat_nosmth_bld + use amg_s_base_aggregator_mod + implicit none + + ! Arguments + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(amg_sml_parms), intent(inout) :: parms + type(psb_sspmat_type), intent(inout) :: op_prol,ac,op_restr + type(psb_lsspmat_type), intent(inout) :: t_prol + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt, np, me, icomm, minfo + character(len=20) :: name + type(psb_ls_coo_sparse_mat) :: lcoo_prol + type(psb_s_coo_sparse_mat) :: coo_prol, coo_restr + type(psb_s_csr_sparse_mat) :: acsr + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nzl, ip, & + & naggr, nzt, naggrm1, naggrp1, i, k + integer(psb_ipk_) :: inaggr, nzlp + logical, parameter :: debug = .false. + + name = 'amg_aggrmat_nosmth_bld' + info = psb_success_ + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + call psb_info(ictxt, me, np) + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + + call a%cp_to(acsr) + call t_prol%mv_to(lcoo_prol) + inaggr = naggr + call psb_cdall(ictxt,desc_ac,info,nl=inaggr) + nzlp = lcoo_prol%get_nzeros() + call desc_ac%indxmap%g2lip_ins(lcoo_prol%ja(1:nzlp),info) + call lcoo_prol%set_ncols(desc_ac%get_local_cols()) + call lcoo_prol%cp_to_icoo(coo_prol,info) + + if (debug) call check_coo(me,trim(name)//' Check 1 on coo_prol:',coo_prol) + + call psb_cdasb(desc_ac,info) + call psb_cd_reinit(desc_ac,info) + + call amg_ptap(acsr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info) + + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_a%get_local_cols()) + call coo_prol%set_nrows(desc_a%get_local_rows()) + call coo_prol%set_ncols(desc_ac%get_local_cols()) + + if (debug) call check_coo(me,trim(name)//' Check 1 on coo_restr:',coo_restr) + + call op_prol%mv_from(coo_prol) + call op_restr%mv_from(coo_restr) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_s_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo +end subroutine amg_saggrmat_nosmth_bld diff --git a/mlprec/impl/aggregator/amg_saggrmat_smth_bld.f90 b/mlprec/impl/aggregator/amg_saggrmat_smth_bld.f90 new file mode 100644 index 00000000..76d39b0f --- /dev/null +++ b/mlprec/impl/aggregator/amg_saggrmat_smth_bld.f90 @@ -0,0 +1,325 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_saggrmat_smth_bld.F90 +! +! Subroutine: amg_saggrmat_smth_bld +! Version: real +! +! This routine builds a coarse-level matrix A_C from a fine-level matrix A +! by using the Galerkin approach, i.e. +! +! A_C = P_C^T A P_C, +! +! where P_C is a prolongator from the coarse level to the fine one. +! +! The prolongator P_C is built according to a smoothed aggregation algorithm, +! i.e. it is obtained by applying a damped Jacobi smoother to the piecewise +! constant interpolation operator P corresponding to the fine-to-coarse level +! mapping built by the amg_aggrmap_bld subroutine: +! +! P_C = (I - omega*D^(-1)A) * P, +! +! where D is the diagonal matrix with main diagonal equal to the main diagonal +! of A, and omega is a suitable smoothing parameter. An estimate of the spectral +! radius of D^(-1)A, to be used in the computation of omega, is provided, +! according to the value of p%parms%aggr_omega_alg, specified by the user +! through amg_sprecinit and amg_zprecset. +! +! The coarse-level matrix A_C is distributed among the parallel processes or +! replicated on each of them, according to the value of p%parms%coarse_mat, +! specified by the user through amg_sprecinit and amg_zprecset. +! On output from this routine the entries of AC, op_prol, op_restr +! are still in "global numbering" mode; this is fixed in the calling routine +! aggregator%mat_bld. +! +! +! Arguments: +! a - type(psb_sspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! p - type(amg_s_onelev_type), input/output. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! parms - type(amg_sml_parms), input +! Parameters controlling the choice of algorithm +! ac - type(psb_sspmat_type), output +! The coarse matrix on output +! +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_sspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_sspmat_type), output +! The restrictor operator; normally, it is the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +subroutine amg_saggrmat_smth_bld(a,desc_a,ilaggr,nlaggr,parms,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + use psb_base_mod + use amg_base_prec_type + use amg_s_inner_mod, amg_protect_name => amg_saggrmat_smth_bld + use amg_s_base_aggregator_mod + + implicit none + + ! Arguments + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(amg_sml_parms), intent(inout) :: parms + type(psb_sspmat_type), intent(out) :: op_prol,ac,op_restr + type(psb_lsspmat_type), intent(inout) :: t_prol + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, ip, & + & naggr, nzl,naggrm1,naggrp1, i, j, k, jd, icolF, nrw + integer(psb_ipk_) :: inaggr, nzlp + integer(psb_ipk_) :: ictxt, np, me + character(len=20) :: name + type(psb_ls_coo_sparse_mat) :: tmpcoo + type(psb_s_coo_sparse_mat) :: coo_prol, coo_restr + type(psb_s_csr_sparse_mat) :: acsr1, acsrf, csr_prol, acsr + real(psb_spk_), allocatable :: adiag(:) + real(psb_spk_), allocatable :: arwsum(:) + integer(psb_ipk_) :: ierr(5) + logical :: filter_mat + integer(psb_ipk_) :: debug_level, debug_unit, err_act + integer(psb_ipk_), parameter :: ncmax=16 + real(psb_spk_) :: anorm, omega, tmp, dg, theta + logical, parameter :: debug_new=.false. + character(len=80) :: filename + + name='amg_aggrmat_smth_bld' + info=psb_success_ + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + ictxt = desc_a%get_context() + + call psb_info(ictxt, me, np) + + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + theta = parms%aggr_thresh + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + filter_mat = (parms%aggr_filter == amg_filter_mat_) + + ! + ! naggr: number of local aggregates + ! nrow: local rows. + ! + + ! Get the diagonal D + adiag = a%get_diag(info) + if (info == psb_success_) & + & call psb_realloc(ncol,adiag,info) + if (info == psb_success_) & + & call psb_halo(adiag,desc_a,info) + if (info == psb_success_) call a%cp_to(acsr) + + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_getdiag') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Initial copies done.' + + call acsr%cp_to_fmt(acsrf,info) + + + if (filter_mat) then + ! + ! Build the filtered matrix Af from A + ! + + do i=1, nrow + tmp = szero + jd = -1 + do j=acsrf%irp(i),acsrf%irp(i+1)-1 + if (acsrf%ja(j) == i) jd = j + if (abs(acsrf%val(j)) < theta*sqrt(abs(adiag(i)*adiag(acsrf%ja(j))))) then + tmp=tmp+acsrf%val(j) + acsrf%val(j)=szero + endif + + enddo + if (jd == -1) then + write(0,*) 'Wrong input: we need the diagonal!!!!', i + else + acsrf%val(jd)=acsrf%val(jd)-tmp + end if + enddo + ! Take out zeroed terms + call acsrf%clean_zeros(info) + end if + + + do i=1,size(adiag) + if (adiag(i) /= szero) then + adiag(i) = sone / adiag(i) + else + adiag(i) = sone + end if + end do + + if (parms%aggr_omega_alg == amg_eig_est_) then + + if (parms%aggr_eig == amg_max_norm_) then + allocate(arwsum(nrow)) + call acsr%arwsum(arwsum) + anorm = maxval(abs(adiag(1:nrow)*arwsum(1:nrow))) + call psb_amx(ictxt,anorm) + omega = 4.d0/(3.d0*anorm) + parms%aggr_omega_val = omega + + else + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_aggr_eig_') + goto 9999 + end if + + else if (parms%aggr_omega_alg == amg_user_choice_) then + + omega = parms%aggr_omega_val + + else if (parms%aggr_omega_alg /= amg_user_choice_) then + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_aggr_omega_alg_') + goto 9999 + end if + + + call acsrf%scal(adiag,info) + if (info /= psb_success_) goto 9999 + + call t_prol%mv_to(tmpcoo) + inaggr = naggr + call psb_cdall(ictxt,desc_ac,info,nl=inaggr) + nzlp = tmpcoo%get_nzeros() + call desc_ac%indxmap%g2lip_ins(tmpcoo%ja(1:nzlp),info) + call tmpcoo%set_ncols(desc_ac%get_local_cols()) + call tmpcoo%mv_to_ifmt(csr_prol,info) + + call psb_cdasb(desc_ac,info) + call psb_cd_reinit(desc_ac,info) + ! + ! Build the smoothed prolongator using either A or Af + ! acsr1 = (I-w*D*A) Prol acsr1 = (I-w*D*Af) Prol + ! This is always done through the variable acsrf which + ! is a bit less readable, but saves space and one matrix copy + ! + call omega_smooth(omega,acsrf) + call psb_par_spspmm(acsrf,desc_a,csr_prol,acsr1,desc_ac,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 1') + goto 9999 + end if + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done SPSPMM 1' + nzl = acsr1%get_nzeros() + call acsr1%mv_to_coo(coo_prol,info) + + call amg_ptap(acsr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info) + + call op_prol%mv_from(coo_prol) + call op_restr%mv_from(coo_restr) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done smooth_aggregate ' + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_errpush(info,name) + call psb_error_handler(err_act) + return + +contains + + subroutine omega_smooth(omega,acsr) + implicit none + real(psb_spk_),intent(in) :: omega + type(psb_s_csr_sparse_mat), intent(inout) :: acsr + ! + integer(psb_lpk_) :: i,j + do i=1,acsr%get_nrows() + do j=acsr%irp(i),acsr%irp(i+1)-1 + if (acsr%ja(j) == i) then + acsr%val(j) = sone - omega*acsr%val(j) + else + acsr%val(j) = - omega*acsr%val(j) + end if + end do + end do + end subroutine omega_smooth + +end subroutine amg_saggrmat_smth_bld diff --git a/mlprec/impl/aggregator/amg_z_dec_aggregator_mat_asb.f90 b/mlprec/impl/aggregator/amg_z_dec_aggregator_mat_asb.f90 new file mode 100644 index 00000000..548321b0 --- /dev/null +++ b/mlprec/impl/aggregator/amg_z_dec_aggregator_mat_asb.f90 @@ -0,0 +1,195 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_z_dec_aggregator_mat_asb.f90 +! +! Subroutine: amg_z_dec_aggregator_mat_asb +! Version: complex +! +! +! From a given AC to final format, generating DESC_AC +! +! Arguments: +! ag - type(amg_z_dec_aggregator_type), input/output. +! The aggregator object +! parms - type(amg_dml_parms), input +! The aggregation parameters +! a - type(psb_zspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! ac - type(psb_zspmat_type), inout +! The coarse matrix +! desc_ac - type(psb_desc_type), output. +! The communication descriptor of the fine-level matrix. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! +! op_prol - type(psb_zspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_zspmat_type), input/output +! The restrictor operator; normally, it is the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +subroutine amg_z_dec_aggregator_mat_asb(ag,parms,a,desc_a,& + & ac,desc_ac, op_prol,op_restr,info) + use psb_base_mod + use amg_base_prec_type + use amg_z_dec_aggregator_mod, amg_protect_name => amg_z_dec_aggregator_mat_asb + implicit none + class(amg_z_dec_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + type(psb_zspmat_type), intent(inout) :: op_prol, ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: ictxt, np, me + type(psb_lz_coo_sparse_mat) :: tmpcoo + type(psb_lzspmat_type) :: tmp_ac + integer(psb_ipk_) :: i_nr, i_nc, i_nl, nzl + integer(psb_lpk_) :: ntaggr + integer(psb_ipk_) :: err_act, debug_level, debug_unit + character(len=20) :: name='z_dec_aggregator_mat_asb' + + + if (psb_get_errstatus().ne.0) return + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + select case(parms%coarse_mat) + + case(amg_distr_mat_) + + call ac%cscnv(info,type='csr') + call op_prol%cscnv(info,type='csr') + call op_restr%cscnv(info,type='csr') + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ac ' + + case(amg_repl_mat_) + ! + ! We are assuming here that an z matrix + ! can hold all entries + ! + if (desc_ac%get_global_rows() < huge(1_psb_ipk_) ) then + ntaggr = desc_ac%get_global_rows() + i_nr = ntaggr + else + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_coarse_mat_') + goto 9999 + end if + + call op_prol%mv_to(tmpcoo) + nzl = tmpcoo%get_nzeros() + call psb_loc_to_glob(tmpcoo%ja(1:nzl),desc_ac,info,'I') + call tmpcoo%set_ncols(i_nr) + call op_prol%mv_from(tmpcoo) + + call op_restr%mv_to(tmpcoo) + nzl = tmpcoo%get_nzeros() + call psb_loc_to_glob(tmpcoo%ia(1:nzl),desc_ac,info,'I') + call tmpcoo%set_nrows(i_nr) + call op_restr%mv_from(tmpcoo) + + + call psb_gather(tmp_ac,ac,desc_ac,info,root=-ione,& + & dupl=psb_dupl_add_,keeploc=.false.) + call tmp_ac%mv_to(tmpcoo) + call ac%mv_from(tmpcoo) + + call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) + if (info == psb_success_) call psb_cdasb(desc_ac,info) + + if (info /= psb_success_) goto 9999 + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_coarse_mat_') + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_lz_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo +end subroutine amg_z_dec_aggregator_mat_asb diff --git a/mlprec/impl/aggregator/amg_z_dec_aggregator_mat_bld.f90 b/mlprec/impl/aggregator/amg_z_dec_aggregator_mat_bld.f90 new file mode 100644 index 00000000..4a8946bc --- /dev/null +++ b/mlprec/impl/aggregator/amg_z_dec_aggregator_mat_bld.f90 @@ -0,0 +1,216 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_z_dec_aggregator_mat_bld.f90 +! +! Subroutine: amg_z_dec_aggregator_mat_bld +! Version: complex +! +! This routine builds the matrix associated to the current level of the +! multilevel preconditioner from the matrix associated to the previous level, +! by using the user-specified aggregation technique (therefore, it also builds the +! prolongation and restriction operators mapping the current level to the +! previous one and vice versa). +! The current level is regarded as the coarse one, while the previous as +! the fine one. This is in agreement with the fact that the routine is called, +! by amg_mlprec_bld, only on levels >=2. +! The coarse-level matrix A_C is built from a fine-level matrix A +! by using the Galerkin approach, i.e. +! +! A_C = P_C^T A P_C, +! +! where P_C is a prolongator from the coarse level to the fine one. +! +! A mapping from the nodes of the adjacency graph of A to the nodes of the +! adjacency graph of A_C has been computed by the amg_aggrmap_bld subroutine. +! The prolongator P_C is built here from this mapping, according to the +! value of p%iprcparm(amg_aggr_kind_), specified by the user through +! amg_zprecinit and amg_zprecset. +! On output from this routine the entries of AC, op_prol, op_restr +! are still in "global numbering" mode; this is fixed in the calling routine +! amg_z_lev_aggrmat_bld. +! +! Currently four different prolongators are implemented, corresponding to +! four aggregation algorithms: +! 1. un-smoothed aggregation, +! 2. smoothed aggregation, +! 3. "bizarre" aggregation. +! 4. minimum energy +! 1. The non-smoothed aggregation uses as prolongator the piecewise constant +! interpolation operator corresponding to the fine-to-coarse level mapping built +! by p%aggr%bld_tprol. This is called tentative prolongator. +! 2. The smoothed aggregation uses as prolongator the operator obtained by applying +! a damped Jacobi smoother to the tentative prolongator. +! 3. The "bizarre" aggregation uses a prolongator proposed by the authors of MLD2P4. +! This prolongator still requires a deep analysis and testing and its use is +! not recommended. +! 4. Minimum energy aggregation +! +! For more details see +! M. Brezina and P. Vanek, A black-box iterative solver based on a two-level +! Schwarz method, Computing, 63 (1999), 233-263. +! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed +! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 +! (1996), 179-196. +! P. D'Ambra, D. di Serafino and S. Filippone, On the development of PSBLAS-based +! parallel two-level Schwarz preconditioners, Appl. Num. Math., 57 (2007), +! 1181-1196. +! M. Sala, R. Tuminaro: A new Petrov-Galerkin smoothed aggregation preconditioner +! for nonsymmetric linear systems, SIAM J. Sci. Comput., 31(1):143-166 (2008) +! +! +! The main structure is: +! 1. Perform sanity checks; +! 2. Compute prolongator/restrictor/AC +! +! +! Arguments: +! ag - type(amg_z_dec_aggregator_type), input/output. +! The aggregator object +! parms - type(amg_dml_parms), input +! The aggregation parameters +! a - type(psb_zspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! ac - type(psb_zspmat_type), output +! The coarse matrix on output +! +! op_prol - type(psb_zspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_zspmat_type), output +! The restrictor operator; normally, it is the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +subroutine amg_z_dec_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + use psb_base_mod + use amg_z_prec_type, amg_protect_name => amg_z_dec_aggregator_mat_bld + use amg_z_inner_mod + implicit none + + class(amg_z_dec_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(psb_lzspmat_type), intent(inout) :: t_prol + type(psb_zspmat_type), intent(out) :: op_prol,ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + + ! Local variables + character(len=20) :: name + integer(psb_mpk_) :: ictxt, np, me + integer(psb_lpk_) :: nzl,ntaggr + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: debug_level, debug_unit + + name='amg_z_dec_aggregator_mat_bld' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + ! + ! Build the coarse-level matrix from the fine-level one, starting from + ! the mapping defined by amg_aggrmap_bld and applying the aggregation + ! algorithm specified by + ! + select case (parms%aggr_prol) + case (amg_no_smooth_) + + call amg_zaggrmat_nosmth_bld(a,desc_a,ilaggr,nlaggr,& + & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) + + case(amg_smooth_prol_) + + call amg_zaggrmat_smth_bld(a,desc_a,ilaggr,nlaggr, & + & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) + +!!$ case(amg_biz_prol_) +!!$ +!!$ call amg_zaggrmat_biz_bld(a,desc_a,ilaggr,nlaggr, & +!!$ & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) + + case(amg_min_energy_) + + call amg_zaggrmat_minnrg_bld(a,desc_a,ilaggr,nlaggr, & + & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='Invalid aggr kind') + goto 9999 + + end select + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='Inner aggrmat bld') + goto 9999 + end if + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + +end subroutine amg_z_dec_aggregator_mat_bld diff --git a/mlprec/impl/aggregator/amg_z_dec_aggregator_tprol.f90 b/mlprec/impl/aggregator/amg_z_dec_aggregator_tprol.f90 new file mode 100644 index 00000000..e4575316 --- /dev/null +++ b/mlprec/impl/aggregator/amg_z_dec_aggregator_tprol.f90 @@ -0,0 +1,139 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_z_dec_aggregator_tprol.f90 +! +! Subroutine: amg_z_dec_aggregator_tprol +! Version: complex +! +! This routine is mainly an interface to soc_map_bld where the real work is performed. +! It takes care of some consistency checking, and calls map_to_tprol, which is +! refactored and shared among all the aggregation methods that produce a simple +! integer mapping. +! +! +! Arguments: +! ag - type(amg_z_dec_aggregator_type), input/output. +! The aggregator object, carrying with itself the mapping algorithm. +! parms - The auxiliary parameters object +! ag_data - Auxiliary global aggregation parameters object +! +! +! a - type(psb_zspmat_type). +! The sparse matrix structure containing the local part of the +! fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! ilaggr - integer, dimension(:), allocatable, output +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that on exit the indices +! will be shifted so as to make sure the ranges on the various processes do not +! overlap. +! nlaggr - integer, dimension(:), allocatable, output +! nlaggr(i) contains the aggregates held by process i. +! t_prol - type(psb_zspmat_type), output +! The tentative prolongator, based on ilaggr. +! +! info - integer, output. +! Error code. +! +subroutine amg_z_dec_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,t_prol,info) + use psb_base_mod + use amg_z_prec_type, amg_protect_name => amg_z_dec_aggregator_build_tprol + use amg_z_inner_mod + implicit none + class(amg_z_dec_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(amg_daggr_data), intent(in) :: ag_data + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lzspmat_type), intent(out) :: t_prol + integer(psb_ipk_), intent(out) :: info + + ! Local variables + character(len=20) :: name + integer(psb_mpk_) :: ictxt, np, me + integer(psb_ipk_) :: err_act + integer(psb_lpk_) :: ntaggr + integer(psb_ipk_) :: debug_level, debug_unit + logical :: clean_zeros + + name='amg_z_dec_aggregator_tprol' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + call amg_check_def(parms%ml_cycle,'Multilevel cycle',& + & amg_mult_ml_,is_legal_ml_cycle) + call amg_check_def(parms%par_aggr_alg,'Aggregation',& + & amg_dec_aggr_,is_legal_ml_par_aggr_alg) + call amg_check_def(parms%aggr_ord,'Ordering',& + & amg_aggr_ord_nat_,is_legal_ml_aggr_ord) + call amg_check_def(parms%aggr_thresh,'Aggr_Thresh',dzero,is_legal_d_aggr_thrs) + + ! + ! The decoupled aggregator based on SOC measures ignores + ! ag_data except for clean_zeros; soc_map_bld is a procedure pointer. + ! + clean_zeros = ag%do_clean_zeros + call ag%soc_map_bld(parms%aggr_ord,parms%aggr_thresh,clean_zeros,a,desc_a,nlaggr,ilaggr,info) + + if (info==psb_success_) call amg_map_to_tprol(desc_a,ilaggr,nlaggr,t_prol,info) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='soc_map_bld/map_to_tprol') + goto 9999 + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_z_dec_aggregator_build_tprol diff --git a/mlprec/impl/aggregator/amg_z_map_to_tprol.f90 b/mlprec/impl/aggregator/amg_z_map_to_tprol.f90 new file mode 100644 index 00000000..2ca76882 --- /dev/null +++ b/mlprec/impl/aggregator/amg_z_map_to_tprol.f90 @@ -0,0 +1,154 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_z_map_to_tprol.f90 +! +! Subroutine: amg_z_map_to_tprol +! Version: complex +! +! This routine uses a mapping from the row indices of the fine-level matrix +! to the row indices of the coarse-level matrix to build a tentative +! prolongator, i.e. a piecewise constant operator. +! This is later used to build the final operator; the code has been refactored here +! to be shared among all the methods that provide the tentative prolongator +! through a simple integer mapping. +! +! The aggregation algorithm is a parallel version of that described in +! * M. Brezina and P. Vanek, A black-box iterative solver based on a +! two-level Schwarz method, Computing, 63 (1999), 233-263. +! * P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed +! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 +! (1996), 179-196. +! For more details see +! P. D'Ambra, D. di Serafino and S. Filippone, On the development of +! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math. +! 57 (2007), 1181-1196. +! +! +! Arguments: +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! ilaggr - integer, dimension(:), allocatable. +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that on exit the indices +! will be shifted so as to make sure the ranges on the various processes do not +! overlap. +! nlaggr - integer, dimension(:), allocatable. +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_zspmat_type). +! The tentative prolongator, based on ilaggr. +! +! info - integer, output. +! Error code. +! +subroutine amg_z_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) + + use psb_base_mod + use amg_z_inner_mod, amg_protect_name => amg_z_map_to_tprol + + implicit none + + ! Arguments + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), allocatable, intent(inout) :: ilaggr(:),nlaggr(:) + type(psb_lzspmat_type), intent(out) :: op_prol + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_lpk_) :: icnt,nlp,k,n,ia,isz,nr, naggr,i,j,m,naggrm1, naggrp1, ntaggr + type(psb_lz_coo_sparse_mat) :: tmpcoo + integer(psb_ipk_) :: debug_level, debug_unit,err_act + integer(psb_ipk_) :: ictxt,np,me + integer(psb_lpk_) :: nrow, ncol, n_ne + character(len=20) :: name, ch_err + + info=psb_success_ + name = 'amg_map_to_tprol' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ! + ictxt=desc_a%get_context() + call psb_info(ictxt,me,np) + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + ilaggr(1:nrow) = ilaggr(1:nrow) + naggrm1 + call psb_halo(ilaggr,desc_a,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_halo') + goto 9999 + end if + + call tmpcoo%allocate(nrow,ntaggr,ncol) + k = 0 + do i=1,nrow + ! + ! Note: at this point, a value ilaggr(i)<=0 + ! tags a "singleton" row, and it has to be + ! left alone. + ! + if (ilaggr(i)>0) then + k = k + 1 + tmpcoo%val(k) = zone + tmpcoo%ia(k) = i + tmpcoo%ja(k) = ilaggr(i) + end if + end do + call tmpcoo%set_nzeros(k) + call tmpcoo%set_dupl(psb_dupl_add_) + call tmpcoo%set_sorted() ! At this point this is in row-major + call op_prol%mv_from(tmpcoo) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_map_to_tprol diff --git a/mlprec/impl/aggregator/amg_z_ptap.f90 b/mlprec/impl/aggregator/amg_z_ptap.f90 new file mode 100644 index 00000000..edf025d4 --- /dev/null +++ b/mlprec/impl/aggregator/amg_z_ptap.f90 @@ -0,0 +1,689 @@ +! +! +! MLD2P4 Extensions +! +! (C) Copyright 2019 +! +! Salvatore Filippone Cranfield University +! Pasqua D'Ambra IAC-CNR, Naples, IT +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_daggrmat_nosmth_bld.F90 +! +! +subroutine amg_z_ptap(a_csr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info,desc_ax) + use psb_base_mod + use amg_z_inner_mod + use amg_z_base_aggregator_mod, amg_protect_name => amg_z_ptap + implicit none + + ! Arguments + type(psb_z_csr_sparse_mat), intent(inout) :: a_csr + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + type(amg_dml_parms), intent(inout) :: parms + type(psb_z_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr + type(psb_desc_type), intent(inout) :: desc_ac + type(psb_zspmat_type), intent(out) :: ac + integer(psb_ipk_), intent(out) :: info + type(psb_desc_type), intent(inout), optional :: desc_ax + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo + character(len=40) :: name + integer(psb_ipk_) :: ierr(5) + type(psb_lz_coo_sparse_mat) :: ac_coo, tmpcoo + type(psb_z_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr + integer(psb_ipk_) :: debug_level, debug_unit, naggr + integer(psb_lpk_) :: nglob, ntaggr, naggrm1, naggrp1 + integer(psb_ipk_) :: nrow, ncol, nrl, nzl, ip, nzt, i, k + integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza + logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. + integer(psb_ipk_), save :: idx_spspmm=-1 + + name='amg_ptap' + if(psb_get_errstatus().ne.0) return + info=psb_success_ + call psb_erractionsave(err_act) + + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + call psb_info(ictxt, me, np) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + if ((do_timings).and.(idx_spspmm==-1)) & + & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr + + ! + ! COO_PROL should arrive here with local numbering + ! + if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& + & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& + & nrow,ntaggr,naggr + + call coo_prol%cp_to_fmt(csr_prol,info) + + if (debug) write(0,*) me,trim(name),' Product AxPROL ',& + & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & + & desc_a%get_local_rows(),desc_a%get_local_cols(),& + & desc_ac%get_local_rows(),desc_a%get_local_cols() + if (debug) flush(0) + + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + + if (debug) write(0,*) me,trim(name),' Done AxPROL ',& + & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& + & desc_ac%get_local_rows(),desc_ac%get_local_cols() + + ! + ! Ok first product done. + + if (present(desc_ax)) then + block + call coo_prol%cp_to_coo(coo_restr,info) + call coo_restr%set_ncols(desc_ac%get_local_cols()) + call coo_restr%set_nrows(desc_a%get_local_rows()) + call psb_z_coo_glob_transpose(coo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_ax%get_local_cols()) +! !$ write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& +! !$ & desc_a%get_local_cols(),desc_ax%get_local_cols(),coo_restr%get_nzeros() +! !$ if (desc_a%get_local_cols()= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + + else + + ! + ! Remember that RESTR must be built from PROL after halo extension, + ! which is done above in psb_par_spspmm + if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& + & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() + call csr_prol%mv_to_coo(coo_restr,info) +!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& +!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() + if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) + + call coo_restr%transp() + nzl = coo_restr%get_nzeros() + nrl = desc_ac%get_local_rows() + i=0 + ! + ! Only keep local rows + ! + do k=1, nzl + if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then + i = i+1 + coo_restr%val(i) = coo_restr%val(k) + coo_restr%ia(i) = coo_restr%ia(k) + coo_restr%ja(i) = coo_restr%ja(k) + end if + end do + call coo_restr%set_nzeros(i) + call coo_restr%fix(info) + nzl = coo_restr%get_nzeros() + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_a%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) + call csr_restr%cp_from_coo(coo_restr,info) + +!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + end if + + call psb_cdasb(desc_ac,info) + + call ac_csr%set_nrows(desc_ac%get_local_rows()) + call ac_csr%set_ncols(desc_ac%get_local_cols()) + call ac%mv_from(ac_csr) + call ac%set_asb() + + if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() + if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr + ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() + + call coo_prol%set_ncols(desc_ac%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ptap ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_z_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo + +end subroutine amg_z_ptap + +subroutine amg_z_lz_ptap(a_csr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info,desc_ax) + use psb_base_mod + use amg_z_inner_mod + use amg_z_base_aggregator_mod !, amg_protect_name => amg_z_lz_ptap + implicit none + + ! Arguments + type(psb_z_csr_sparse_mat), intent(inout) :: a_csr + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + type(amg_dml_parms), intent(inout) :: parms + type(psb_lz_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr + type(psb_desc_type), intent(inout) :: desc_ac + type(psb_lzspmat_type), intent(out) :: ac + integer(psb_ipk_), intent(out) :: info + type(psb_desc_type), intent(inout), optional :: desc_ax + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo + character(len=40) :: name + integer(psb_ipk_) :: ierr(5) + type(psb_lz_coo_sparse_mat) :: ac_coo, tmpcoo + type(psb_z_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr + integer(psb_ipk_) :: debug_level, debug_unit, naggr + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nrl, nzl, ip, & + & nzt, naggrm1, naggrp1, i, k + integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza + logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. + integer(psb_ipk_), save :: idx_spspmm=-1 + + name='amg_ptap' + if(psb_get_errstatus().ne.0) return + info=psb_success_ + call psb_erractionsave(err_act) + + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + call psb_info(ictxt, me, np) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + if ((do_timings).and.(idx_spspmm==-1)) & + & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr + + ! + ! COO_PROL should arrive here with local numbering + ! + if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& + & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& + & nrow,ntaggr,naggr + + call coo_prol%cp_to_ifmt(csr_prol,info) + + if (debug) write(0,*) me,trim(name),' Product AxPROL ',& + & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & + & desc_a%get_local_rows(),desc_a%get_local_cols(),& + & desc_ac%get_local_rows(),desc_a%get_local_cols() + if (debug) flush(0) + + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + + if (debug) write(0,*) me,trim(name),' Done AxPROL ',& + & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& + & desc_ac%get_local_rows(),desc_ac%get_local_cols() + + ! + ! Ok first product done. + + if (present(desc_ax)) then + block + type(psb_z_coo_sparse_mat) :: icoo_restr + + call coo_prol%cp_to_icoo(icoo_restr,info) + call icoo_restr%set_ncols(desc_ac%get_local_cols()) + call icoo_restr%set_nrows(desc_a%get_local_rows()) + call psb_z_coo_glob_transpose(icoo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) + call icoo_restr%set_nrows(desc_ac%get_local_rows()) + call icoo_restr%set_ncols(desc_ax%get_local_cols()) +! !$ write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& +! !$ & desc_a%get_local_cols(),desc_ax%get_local_cols(),icoo_restr%get_nzeros() +! !$ if (desc_a%get_local_cols()= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + + else + + ! + ! Remember that RESTR must be built from PROL after halo extension, + ! which is done above in psb_par_spspmm + if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& + & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() + call csr_prol%mv_to_lcoo(coo_restr,info) +!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& +!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() + if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) + + call coo_restr%transp() + nzl = coo_restr%get_nzeros() + nrl = desc_ac%get_local_rows() + i=0 + ! + ! Only keep local rows + ! + do k=1, nzl + if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then + i = i+1 + coo_restr%val(i) = coo_restr%val(k) + coo_restr%ia(i) = coo_restr%ia(k) + coo_restr%ja(i) = coo_restr%ja(k) + end if + end do + call coo_restr%set_nzeros(i) + call coo_restr%fix(info) + nzl = coo_restr%get_nzeros() + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_a%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) + call csr_restr%cp_from_lcoo(coo_restr,info) + +!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + end if + + call psb_cdasb(desc_ac,info) + + call ac_csr%set_nrows(desc_ac%get_local_rows()) + call ac_csr%set_ncols(desc_ac%get_local_cols()) + call ac%mv_from(ac_csr) + call ac%set_asb() + + if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() + if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr + ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() + + call coo_prol%set_ncols(desc_ac%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ptap ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_lz_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo + +end subroutine amg_z_lz_ptap + +subroutine amg_lz_ptap(a_csr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info,desc_ax) + use psb_base_mod + use amg_z_inner_mod + use amg_z_base_aggregator_mod!, amg_protect_name => amg_lz_ptap + implicit none + + ! Arguments + type(psb_lz_csr_sparse_mat), intent(inout) :: a_csr + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + type(amg_dml_parms), intent(inout) :: parms + type(psb_lz_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr + type(psb_desc_type), intent(inout) :: desc_ac + type(psb_lzspmat_type), intent(out) :: ac + integer(psb_ipk_), intent(out) :: info + type(psb_desc_type), intent(inout), optional :: desc_ax + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo + character(len=40) :: name + integer(psb_ipk_) :: ierr(5) + type(psb_lz_coo_sparse_mat) :: ac_coo, tmpcoo + type(psb_lz_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr + integer(psb_ipk_) :: debug_level, debug_unit, naggr + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nrl, nzl, ip, & + & nzt, naggrm1, naggrp1, i, k + integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza + logical, parameter :: do_timings=.true., oldstyle=.false., debug=.false. + integer(psb_ipk_), save :: idx_spspmm=-1 + + name='amg_ptap' + if(psb_get_errstatus().ne.0) return + info=psb_success_ + call psb_erractionsave(err_act) + + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + call psb_info(ictxt, me, np) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + if ((do_timings).and.(idx_spspmm==-1)) & + & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr + + ! + ! COO_PROL should arrive here with local numbering + ! + if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& + & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& + & nrow,ntaggr,naggr + + call coo_prol%cp_to_fmt(csr_prol,info) + + if (debug) write(0,*) me,trim(name),' Product AxPROL ',& + & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & + & desc_a%get_local_rows(),desc_a%get_local_cols(),& + & desc_ac%get_local_rows(),desc_a%get_local_cols() + if (debug) flush(0) + + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + + if (debug) write(0,*) me,trim(name),' Done AxPROL ',& + & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& + & desc_ac%get_local_rows(),desc_ac%get_local_cols() + + ! + ! Ok first product done. + + if (present(desc_ax)) then + block + type(psb_z_coo_sparse_mat) :: icoo_restr + + call coo_prol%cp_to_icoo(icoo_restr,info) + call icoo_restr%set_ncols(desc_ac%get_local_cols()) + call icoo_restr%set_nrows(desc_a%get_local_rows()) + call psb_z_coo_glob_transpose(icoo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) + call icoo_restr%set_nrows(desc_ac%get_local_rows()) + call icoo_restr%set_ncols(desc_ax%get_local_cols()) + write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& + & desc_a%get_local_cols(),desc_ax%get_local_cols(),icoo_restr%get_nzeros() + if (desc_a%get_local_cols()= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + + else + + ! + ! Remember that RESTR must be built from PROL after halo extension, + ! which is done above in psb_par_spspmm + if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& + & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() + call csr_prol%mv_to_coo(coo_restr,info) +!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& +!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() + if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) + + call coo_restr%transp() + nzl = coo_restr%get_nzeros() + nrl = desc_ac%get_local_rows() + i=0 + ! + ! Only keep local rows + ! + do k=1, nzl + if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then + i = i+1 + coo_restr%val(i) = coo_restr%val(k) + coo_restr%ia(i) = coo_restr%ia(k) + coo_restr%ja(i) = coo_restr%ja(k) + end if + end do + call coo_restr%set_nzeros(i) + call coo_restr%fix(info) + nzl = coo_restr%get_nzeros() + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_a%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) + call csr_restr%cp_from_coo(coo_restr,info) + +!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& + & csr_restr%get_nrows(),csr_restr%get_ncols(), & + & desc_ac%get_local_rows(),desc_a%get_local_cols(),& + & acsr3%get_nrows(),acsr3%get_ncols() + if (do_timings) call psb_tic(idx_spspmm) + call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) + if (do_timings) call psb_toc(idx_spspmm) + call acsr3%free() + end if + + call psb_cdasb(desc_ac,info) + + call ac_csr%set_nrows(desc_ac%get_local_rows()) + call ac_csr%set_ncols(desc_ac%get_local_cols()) + call ac%mv_from(ac_csr) + call ac%set_asb() + + if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() + if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr + ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() + + call coo_prol%set_ncols(desc_ac%get_local_cols()) + !call coo_restr%mv_from_ifmt(csr_restr,info) +!!$ call coo_restr%set_nrows(desc_ac%get_local_rows()) +!!$ call coo_restr%set_ncols(desc_a%get_local_cols()) + if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ptap ' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_lz_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo + +end subroutine amg_lz_ptap diff --git a/mlprec/impl/aggregator/amg_z_soc1_map_bld.f90 b/mlprec/impl/aggregator/amg_z_soc1_map_bld.f90 new file mode 100644 index 00000000..d7b7e268 --- /dev/null +++ b/mlprec/impl/aggregator/amg_z_soc1_map_bld.f90 @@ -0,0 +1,349 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_z_soc1_map__bld.f90 +! +! Subroutine: amg_z_soc1_map_bld +! Version: complex +! +! This routine builds the tentative prolongator based on the +! strength of connection aggregation algorithm presented in +! +! M. Brezina and P. Vanek, A black-box iterative solver based on a +! two-level Schwarz method, Computing, 63 (1999), 233-263. +! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed +! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 +! (1996), 179-196. +! +! Note: upon exit +! +! Arguments: +! a - type(psb_zspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_zprec_type), input/output. +! The preconditioner data structure; upon exit it contains +! the multilevel hierarchy of prolongators, restrictors +! and coarse matrices. +! info - integer, output. +! Error code. +! +! +! +subroutine amg_z_soc1_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) + + use psb_base_mod + use amg_base_prec_type + use amg_z_inner_mod + + implicit none + + ! Arguments + integer(psb_ipk_), intent(in) :: iorder + logical, intent(in) :: clean_zeros + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + real(psb_dpk_), intent(in) :: theta + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),& + & ideg(:), idxs(:) + integer(psb_lpk_), allocatable :: tmpaggr(:) + complex(psb_dpk_), allocatable :: val(:), diag(:) + integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr, nc, naggr,i,j,m, nz, ilg, ii, ip + type(psb_z_csr_sparse_mat) :: acsr + real(psb_dpk_) :: cpling, tcl + logical :: disjoint + integer(psb_ipk_) :: debug_level, debug_unit,err_act + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: nrow, ncol, n_ne + integer(psb_lpk_) :: nrglob + character(len=20) :: name, ch_err + + info=psb_success_ + name = 'amg_soc1_map_bld' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ! + ictxt=desc_a%get_context() + call psb_info(ictxt,me,np) + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + nrglob = desc_a%get_global_rows() + + nr = a%get_nrows() + nc = a%get_ncols() + allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),& + & icol(nc),val(nc),stat=info) + if(info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),& + & a_err='integer') + goto 9999 + end if + + diag = a%get_diag(info) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='psb_sp_getdiag') + goto 9999 + end if + + call a%cp_to(acsr) + if (clean_zeros) call acsr%clean_zeros(info) + if (iorder == amg_aggr_ord_nat_) then + do i=1, nr + ilaggr(i) = -(nr+1) + idxs(i) = i + end do + else + do i=1, nr + ilaggr(i) = -(nr+1) + ideg(i) = acsr%irp(i+1) - acsr%irp(i) + end do + call psb_msort(ideg,ix=idxs,dir=psb_sort_down_) + end if + + + ! + ! Phase one: Start with disjoint groups. + ! + naggr = 0 + icnt = 0 + step1: do ii=1, nr + i = idxs(ii) + if ((i<1).or.(i>nr)) then + info=psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + if (ilaggr(i) == -(nr+1)) then + nz = (acsr%irp(i+1)-acsr%irp(i)) + if ((nz<0).or.(nz>size(icol))) then + info=psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) + val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) + + ! + ! Build the set of all strongly coupled nodes + ! + ip = 0 + do k=1, nz + j = icol(k) + if ((1<=j).and.(j<=nr)) then + if (abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j)))) then + ip = ip + 1 + icol(ip) = icol(k) + end if + end if + enddo + + ! + ! If the whole strongly coupled neighborhood of I is + ! as yet unconnected, turn it into the next aggregate. + ! Same if ip==0 (in which case, neighborhood only + ! contains I even if it does not look like it from matrix) + ! + disjoint = all(ilaggr(icol(1:ip)) == -(nr+1)).or.(ip==0) + if (disjoint) then + icnt = icnt + 1 + naggr = naggr + 1 + do k=1, ip + ilaggr(icol(k)) = naggr + end do + ilaggr(i) = naggr + end if + endif + enddo step1 + + if (debug_level >= psb_debug_outer_) then + write(debug_unit,*) me,' ',trim(name),& + & ' Check 1:',count(ilaggr == -(nr+1)) + end if + + ! + ! Phase two: join the neighbours + ! + tmpaggr = ilaggr + step2: do ii=1,nr + i = idxs(ii) + + if (ilaggr(i) == -(nr+1)) then + nz = (acsr%irp(i+1)-acsr%irp(i)) + if (nz == 1) cycle step2 + icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) + val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) + + ! + ! Find the most strongly connected neighbour that is + ! already aggregated, if any, and join its aggregate + ! + cpling = dzero + ip = 0 + do k=1, nz + j = icol(k) + if ((1<=j).and.(j<=nr)) then + if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))& + & .and. (tmpaggr(j) > 0).and. (abs(val(k)) > cpling)) then + ip = k + cpling = abs(val(k)) + end if + end if + enddo + if (ip > 0) then + ilaggr(i) = ilaggr(icol(ip)) + end if + end if + end do step2 + + + ! + ! Phase three: sweep over leftovers, if any + ! + step3: do ii=1,nr + i = idxs(ii) + + if (ilaggr(i) < 0) then + nz = (acsr%irp(i+1)-acsr%irp(i)) + if (nz == 1) cycle step3 + icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) + val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) + ! + ! Find its strongly connected neighbourhood not + ! already aggregated, and make it into a new aggregate. + ! + cpling = dzero + ip = 0 + do k=1, nz + j = icol(k) + if ((1<=j).and.(j<=nr)) then + if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))& + & .and. (ilaggr(j) < 0)) then + ip = ip + 1 + icol(ip) = icol(k) + end if + end if + enddo + if (ip > 0) then + icnt = icnt + 1 + naggr = naggr + 1 + ilaggr(i) = naggr + do k=1, ip + ilaggr(icol(k)) = naggr + end do + else + ! + ! This should not happen: we did not even connect with ourselves, + ! but it's not a singleton. + ! + naggr = naggr + 1 + ilaggr(i) = naggr + end if + end if + end do step3 + + ! Any leftovers? + do i=1, nr + if (ilaggr(i) < 0) then + nz = (acsr%irp(i+1)-acsr%irp(i)) + if (nz == 1) then + ! Mark explicitly as a singleton so that + ! it will be ignored in map_to_tprol. + ! Need to use -(nrglob+nr) to make sure + ! it's still negative when shifted and combined with + ! other processes. + ilaggr(i) = -(nrglob+nr) + else + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers') + goto 9999 + endif + end if + end do + + if (naggr > ncol) then + !write(0,*) name,'Error : naggr > ncol',naggr,ncol + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Fatal error: naggr>ncol') + goto 9999 + end if + + call psb_realloc(ncol,ilaggr,info) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_realloc' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + allocate(nlaggr(np),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),& + & a_err='integer') + goto 9999 + end if + + nlaggr(:) = 0 + nlaggr(me+1) = naggr + call psb_sum(ictxt,nlaggr(1:np)) + + call acsr%free() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_soc1_map_bld + diff --git a/mlprec/impl/aggregator/amg_z_soc2_map_bld.f90 b/mlprec/impl/aggregator/amg_z_soc2_map_bld.f90 new file mode 100644 index 00000000..02c22df2 --- /dev/null +++ b/mlprec/impl/aggregator/amg_z_soc2_map_bld.f90 @@ -0,0 +1,348 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! +! File: amg_z_soc2_map__bld.f90 +! +! Subroutine: amg_z_soc2_map_bld +! Version: complex +! +! The aggregator object hosts the aggregation method for building +! the multilevel hierarchy. This variant is based on the method +! presented in +! +! S. Gratton, P. Henon, P. Jiranek and X. Vasseur: +! Reducing complexity of algebraic multigrid by aggregation +! Numerical Lin. Algebra with Applications, 2016, 23:501-518 +! +! Note: upon exit +! +! Arguments: +! a - type(psb_zspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_zprec_type), input/output. +! The preconditioner data structure; upon exit it contains +! the multilevel hierarchy of prolongators, restrictors +! and coarse matrices. +! info - integer, output. +! Error code. +! +! +! +subroutine amg_z_soc2_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) + + use psb_base_mod + use amg_base_prec_type + use amg_z_inner_mod + + implicit none + + ! Arguments + integer(psb_ipk_), intent(in) :: iorder + logical, intent(in) :: clean_zeros + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + real(psb_dpk_), intent(in) :: theta + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),& + & ideg(:), idxs(:) + integer(psb_lpk_), allocatable :: tmpaggr(:) + complex(psb_dpk_), allocatable :: val(:), diag(:) + integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr,nc,naggr,i,j,m, nz, ilg, ii, ip, ip1,nzcnt + integer(psb_lpk_) :: nrglob + type(psb_z_csr_sparse_mat) :: acsr, muij, s_neigh + type(psb_z_coo_sparse_mat) :: s_neigh_coo + real(psb_dpk_) :: cpling, tcl + logical :: disjoint + integer(psb_ipk_) :: debug_level, debug_unit,err_act + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: nrow, ncol, n_ne + character(len=20) :: name, ch_err + + info=psb_success_ + name = 'amg_soc2_map_bld' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ! + ictxt=desc_a%get_context() + call psb_info(ictxt,me,np) + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + nrglob = desc_a%get_global_rows() + + nr = a%get_nrows() + nc = a%get_ncols() + allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),icol(nc),stat=info) + if(info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),& + & a_err='integer') + goto 9999 + end if + + diag = a%get_diag(info) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='psb_sp_getdiag') + goto 9999 + end if + + ! + ! Phase zero: compute muij + ! + call a%cp_to(muij) + if (clean_zeros) call muij%clean_zeros(info) + do i=1, nr + do k=muij%irp(i),muij%irp(i+1)-1 + j = muij%ja(k) + if (j<= nr) muij%val(k) = abs(muij%val(k))/sqrt(abs(diag(i)*diag(j))) + end do + end do + + ! + ! Compute the 1-neigbour; mark strong links with +1, weak links with -1 + ! + call s_neigh_coo%allocate(nr,nr,muij%get_nzeros()) + ip = 0 + do i=1, nr + do k=muij%irp(i),muij%irp(i+1)-1 + j = muij%ja(k) + if (j<=nr) then + ip = ip + 1 + s_neigh_coo%ia(ip) = i + s_neigh_coo%ja(ip) = j + if (real(muij%val(k)) >= theta) then + s_neigh_coo%val(ip) = done + else + s_neigh_coo%val(ip) = -done + end if + end if + end do + end do + !write(*,*) 'S_NEIGH: ',nr,ip + call s_neigh_coo%set_nzeros(ip) + call s_neigh%mv_from_coo(s_neigh_coo,info) + + if (iorder == amg_aggr_ord_nat_) then + do i=1, nr + ilaggr(i) = -(nr+1) + idxs(i) = i + end do + else + do i=1, nr + ilaggr(i) = -(nr+1) + ideg(i) = muij%irp(i+1) - muij%irp(i) + end do + call psb_msort(ideg,ix=idxs,dir=psb_sort_down_) + end if + + + ! + ! Phase one: Start with disjoint groups. + ! + naggr = 0 + icnt = 0 + step1: do ii=1, nr + i = idxs(ii) + + if (ilaggr(i) == -(nr+1)) then + ! + ! Get the 1-neighbourhood of I + ! + ip1 = s_neigh%irp(i) + nz = s_neigh%irp(i+1)-ip1 + ! + ! If the neighbourhood only contains I, skip it + ! + if (nz ==0) then + ilaggr(i) = 0 + cycle step1 + end if + if ((nz==1).and.(s_neigh%ja(ip1)==i)) then + ilaggr(i) = 0 + cycle step1 + end if + ! + ! If the whole strongly coupled neighborhood of I is + ! as yet unconnected, turn it into the next aggregate. + ! + nzcnt = count(real(s_neigh%val(ip1:ip1+nz-1)) > 0) + icol(1:nzcnt) = pack(s_neigh%ja(ip1:ip1+nz-1),(real(s_neigh%val(ip1:ip1+nz-1)) > 0)) + disjoint = all(ilaggr(icol(1:nzcnt)) == -(nr+1)) + if (disjoint) then + icnt = icnt + 1 + naggr = naggr + 1 + do k=1, nzcnt + ilaggr(icol(k)) = naggr + end do + ilaggr(i) = naggr + end if + endif + enddo step1 + + if (debug_level >= psb_debug_outer_) then + write(debug_unit,*) me,' ',trim(name),& + & ' Check 1:',count(ilaggr == -(nr+1)) + end if + + ! + ! Phase two: join the neighbours + ! + tmpaggr = ilaggr + step2: do ii=1,nr + i = idxs(ii) + + if (ilaggr(i) == -(nr+1)) then + ! + ! Find the most strongly connected neighbour that is + ! already aggregated, if any, and join its aggregate + ! + cpling = dzero + ip = 0 + do k=s_neigh%irp(i), s_neigh%irp(i+1)-1 + j = s_neigh%ja(k) + if ((1<=j).and.(j<=nr)) then + if ( (tmpaggr(j) > 0).and. (real(muij%val(k)) > cpling)& + & .and.(real(s_neigh%val(k))>0)) then + ip = k + cpling = muij%val(k) + end if + end if + enddo + if (ip > 0) then + ilaggr(i) = ilaggr(s_neigh%ja(ip)) + end if + end if + end do step2 + + + ! + ! Phase three: sweep over leftovers, if any + ! + step3: do ii=1,nr + i = idxs(ii) + + if (ilaggr(i) < 0) then + ! + ! Find its strongly connected neighbourhood not + ! already aggregated, and make it into a new aggregate. + ! + ip = 0 + do k=s_neigh%irp(i), s_neigh%irp(i+1)-1 + j = s_neigh%ja(k) + if ((1<=j).and.(j<=nr)) then + if (ilaggr(j) < 0) then + ip = ip + 1 + icol(ip) = j + end if + end if + enddo + if (ip > 0) then + icnt = icnt + 1 + naggr = naggr + 1 + ilaggr(i) = naggr + do k=1, ip + ilaggr(icol(k)) = naggr + end do + end if + end if + end do step3 + + ! Any leftovers? + do i=1, nr + if (ilaggr(i) <= 0) then + nz = (s_neigh%irp(i+1)-s_neigh%irp(i)) + if (nz <= 1) then + ! Mark explicitly as a singleton so that + ! it will be ignored in map_to_tprol. + ! Need to use -(nrglob+nr) to make sure + ! it's still negative when shifted and combined with + ! other processes. + ilaggr(i) = -(nrglob+nr) + else + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers') + goto 9999 + endif + end if + end do + + if (naggr > ncol) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Fatal error: naggr>ncol') + goto 9999 + end if + + call psb_realloc(ncol,ilaggr,info) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_realloc' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + allocate(nlaggr(np),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),& + & a_err='integer') + goto 9999 + end if + + nlaggr(:) = 0 + nlaggr(me+1) = naggr + call psb_sum(ictxt,nlaggr(1:np)) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_soc2_map_bld + diff --git a/mlprec/impl/aggregator/amg_z_symdec_aggregator_tprol.f90 b/mlprec/impl/aggregator/amg_z_symdec_aggregator_tprol.f90 new file mode 100644 index 00000000..74e0cecc --- /dev/null +++ b/mlprec/impl/aggregator/amg_z_symdec_aggregator_tprol.f90 @@ -0,0 +1,160 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_z_symdec_aggregator_tprol.f90 +! +! Subroutine: amg_z_symdec_aggregator_tprol +! Version: complex +! +! +! This routine is mainly an interface to soc_map_bld where the real work is performed. +! It takes care of some consistency checking, and calls map_to_tprol, which is +! refactored and shared among all the aggregation methods that produce a simple +! integer mapping. It also symmetrizes the pattern of the local matrix A. +! +! +! +! Arguments: +! Arguments: +! ag - type(amg_z_dec_aggregator_type), input/output. +! The aggregator object, carrying with itself the mapping algorithm. +! parms - The auxiliary parameters object +! ag_data - Auxiliary global aggregation parameters object +! +! a - type(psb_zspmat_type). +! The sparse matrix structure containing the local part of the +! fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! ilaggr - integer, dimension(:), allocatable, output +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that on exit the indices +! will be shifted so as to make sure the ranges on the various processes do not +! overlap. +! nlaggr - integer, dimension(:), allocatable, output +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_zspmat_type), output +! The tentative prolongator, based on ilaggr. +! +! info - integer, output. +! Error code. +! +subroutine amg_z_symdec_aggregator_build_tprol(ag,parms,ag_data,& + & a,desc_a,ilaggr,nlaggr,op_prol,info) + use psb_base_mod + use amg_z_prec_type + use amg_z_symdec_aggregator_mod, amg_protect_name => amg_z_symdec_aggregator_build_tprol + use amg_z_inner_mod + implicit none + class(amg_z_symdec_aggregator_type), target, intent(inout) :: ag + type(amg_dml_parms), intent(inout) :: parms + type(amg_daggr_data), intent(in) :: ag_data + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(in) :: desc_a + integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) + type(psb_lzspmat_type), intent(out) :: op_prol + integer(psb_ipk_), intent(out) :: info + + ! Local variables + type(psb_zspmat_type) :: atmp, atrans + character(len=20) :: name + integer(psb_mpk_) :: ictxt, np, me + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: nr + integer(psb_lpk_) :: ntaggr + integer(psb_ipk_) :: debug_level, debug_unit + logical :: clean_zeros + + name='amg_z_symdec_aggregator_tprol' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + call amg_check_def(parms%ml_cycle,'Multilevel cycle',& + & amg_mult_ml_,is_legal_ml_cycle) + call amg_check_def(parms%par_aggr_alg,'Aggregation',& + & amg_dec_aggr_,is_legal_ml_par_aggr_alg) + call amg_check_def(parms%aggr_ord,'Ordering',& + & amg_aggr_ord_nat_,is_legal_ml_aggr_ord) + call amg_check_def(parms%aggr_thresh,'Aggr_Thresh',dzero,is_legal_d_aggr_thrs) + + nr = a%get_nrows() + call a%csclip(atmp,info,imax=nr,jmax=nr,& + & rscale=.false.,cscale=.false.) + call atmp%set_nrows(nr) + call atmp%set_ncols(nr) + if (info == psb_success_) call atmp%transp(atrans) + if (info == psb_success_) call atrans%cscnv(info,type='COO') + if (info == psb_success_) call psb_rwextd(nr,atmp,info,b=atrans,rowscale=.false.) + call atmp%set_nrows(nr) + call atmp%set_ncols(nr) + if (info == psb_success_) call atrans%free() + if (info == psb_success_) call atmp%cscnv(info,type='CSR') + + ! + ! The decoupled aggregator based on SOC measures ignores + ! ag_data except for clean_zeros; soc_map_bld is a procedure pointer. + ! + clean_zeros = ag%do_clean_zeros + if (info == psb_success_) & + & call ag%soc_map_bld(parms%aggr_ord,parms%aggr_thresh,clean_zeros,atmp,& + & desc_a,nlaggr,ilaggr,info) + if (info == psb_success_) call atmp%free() + + if (info == psb_success_) call amg_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='soc_map_bld/map_to_tprol') + goto 9999 + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_z_symdec_aggregator_build_tprol diff --git a/mlprec/impl/aggregator/amg_zaggrmat_minnrg_bld.f90 b/mlprec/impl/aggregator/amg_zaggrmat_minnrg_bld.f90 new file mode 100644 index 00000000..c0b0bd60 --- /dev/null +++ b/mlprec/impl/aggregator/amg_zaggrmat_minnrg_bld.f90 @@ -0,0 +1,656 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_zaggrmat_minnrg_bld.F90 +! +! Subroutine: amg_zaggrmat_minnrg_bld +! Version: complex +! +! This routine builds a coarse-level matrix A_C from a fine-level matrix A +! by using the Galerkin approach, i.e. +! +! A_C = P_C^T A P_C, +! +! where P_C is a prolongator from the coarse level to the fine one. +! +! The prolongator P_C is built according to a smoothed aggregation algorithm, +! i.e. it is obtained by applying a damped Jacobi smoother to the piecewise +! constant interpolation operator P corresponding to the fine-to-coarse level +! mapping built by the amg_aggrmap_bld subroutine: +! +! P_C = (I - omega*D^(-1)A) * P, +! +! where D is the diagonal matrix with main diagonal equal to the main diagonal +! of A, and omega is a suitable smoothing parameter. An estimate of the spectral +! radius of D^(-1)A, to be used in the computation of omega, is provided, +! according to the value of p%parms%aggr_omega_alg, specified by the user +! through amg_zprecinit and amg_zprecset. +! 4. Minimum energy aggregation: +! M. Sala, R. Tuminaro: A new Petrov-Galerkin smoothed aggregation preconditioner +! for nonsymmetric linear systems, SIAM J. Sci. Comput., 31(1):143-166 (2008) +! +! On output from this routine the entries of AC, op_prol, op_restr +! are still in "global numbering" mode; this is fixed in the calling routine +! aggregator%mat_bld. +! +! +! Arguments: +! a - type(psb_zspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! p - type(amg_z_onelev_type), input/output. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! parms - type(amg_dml_parms), input +! Parameters controlling the choice of algorithm +! ac - type(psb_zspmat_type), output +! The coarse matrix on output +! +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_zspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_zspmat_type), output +! The restrictor operator; in this particular case, it is different +! from the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +! +subroutine amg_zaggrmat_minnrg_bld(a,desc_a,ilaggr,nlaggr,parms,& + & ac,desc_ac,op_prol,op_restr,info) + use psb_base_mod + use amg_base_prec_type + use amg_z_inner_mod, amg_protect_name => amg_zaggrmat_minnrg_bld + + implicit none + + ! Arguments + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(amg_dml_parms), intent(inout) :: parms + type(psb_lzspmat_type), intent(inout) :: op_prol + type(psb_lzspmat_type), intent(out) :: ac,op_restr + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nzac, ip, ndx,& + & naggr, nzl,naggrm1,naggrp1, i, j, k, jd, icolF, nrt + integer(psb_ipk_) :: ictxt,np,me, icomm + character(len=20) :: name + type(psb_lzspmat_type) :: la, af, ptilde, rtilde, atran, atp, atdatp + type(psb_lzspmat_type) :: am3,am4, ap, adap,atmp,rada, ra, atmp2, dap, dadap, da + type(psb_lzspmat_type) :: dat, datp, datdatp, atmp3, tmp_prol + type(psb_lz_coo_sparse_mat) :: tmpcoo + type(psb_lz_csr_sparse_mat) :: acsr1, acsr2, acsr3, acsr, acsrf + type(psb_lz_csc_sparse_mat) :: csc_dap, csc_dadap, csc_datp, csc_datdatp, acsc + complex(psb_dpk_), allocatable :: adiag(:), adinv(:) + complex(psb_dpk_), allocatable :: omf(:), omp(:), omi(:), oden(:) + logical :: filter_mat + integer(psb_ipk_) :: ierr(5) + integer(psb_ipk_) :: debug_level, debug_unit, err_act + integer(psb_ipk_), parameter :: ncmax=16 + real(psb_dpk_) :: anorm, theta + complex(psb_dpk_) :: tmp, alpha, beta, ommx + + name='amg_aggrmat_minnrg' + info=psb_success_ + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + ictxt = desc_a%get_context() + + call psb_info(ictxt, me, np) + + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + theta = parms%aggr_thresh + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + + filter_mat = (parms%aggr_filter == amg_filter_mat_) + + ! naggr: number of local aggregates + ! nrow: local rows. + ! + allocate(adinv(ncol),& + & omf(ncol),omp(ntaggr),oden(ntaggr),omi(ncol),stat=info) + + if (info /= psb_success_) then + info=psb_err_alloc_request_; ierr(1)=6*ncol+ntaggr; + call psb_errpush(info,name,i_err=ierr,a_err='complex(psb_dpk_)') + goto 9999 + end if + + ! Get the diagonal D + adiag = a%get_diag(info) + if (info == psb_success_) & + & call psb_realloc(ncol,adiag,info) + if (info == psb_success_) & + & call psb_halo(adiag,desc_a,info) + if (info == psb_success_) call a%cp_to_l(la) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_getdiag') + goto 9999 + end if + + do i=1,size(adiag) + if (adiag(i) /= zzero) then + adinv(i) = zone / adiag(i) + else + adinv(i) = zone + end if + end do + + + + ! 1. Allocate Ptilde in sparse matrix form + call op_prol%mv_to(tmpcoo) + call ptilde%mv_from(tmpcoo) + call ptilde%cscnv(info,type='csr') + + if (info == psb_success_) call la%cscnv(am3,info,type='csr',dupl=psb_dupl_add_) + if (info == psb_success_) call la%cscnv(da,info,type='csr',dupl=psb_dupl_add_) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Initial copies done.' + + call da%scal(adinv,info) + + call psb_spspmm(da,ptilde,dap,info) + + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 1') + goto 9999 + end if + + call dap%clone(atmp,info) + + call psb_sphalo(atmp,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.,outfmt='CSR ') + if (info == psb_success_) call psb_rwextd(ncol,atmp,info,b=am4) + if (info == psb_success_) call am4%free() + + call psb_spspmm(da,atmp,dadap,info) + call atmp%free() + + ! !$ write(0,*) 'Columns of AP',psb_sp_get_ncols(ap) + ! !$ write(0,*) 'Columns of ADAP',psb_sp_get_ncols(adap) + call dap%mv_to(csc_dap) + call dadap%mv_to(csc_dadap) + + call csc_mat_col_prod(csc_dap,csc_dadap,omp,info) + call csc_mat_col_prod(csc_dadap,csc_dadap,oden,info) + call psb_sum(ictxt,omp) + call psb_sum(ictxt,oden) + ! !$ write(0,*) trim(name),' OMP :',omp + ! !$ write(0,*) trim(name),' ODEN:',oden + + omp = omp/oden + + ! !$ write(0,*) 'Check on output prolongator ',omp(1:min(size(omp),10)) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done NUMBMM 1' + + call am3%mv_to(acsr3) + ! Compute omega_int + ommx = zzero + do i=1, ncol + if (ilaggr(i) >0) then + omi(i) = omp(ilaggr(i)) + else + omi(i) = zzero + end if + if(abs(omi(i)) .gt. abs(ommx)) ommx = omi(i) + end do + ! Compute omega_fine + do i=1, nrow + omf(i) = ommx + do j=acsr3%irp(i),acsr3%irp(i+1)-1 + if(abs(omi(acsr3%ja(j))) .lt. abs(omf(i))) omf(i)=omi(acsr3%ja(j)) + end do +!!$ if(min(real(omf(i)),aimag(omf(i))) < dzero) omf(i) = zzero + if(psb_minreal(omf(i)) < dzero) omf(i) = zzero + end do + + omf(1:nrow) = omf(1:nrow) * adinv(1:nrow) + + if (filter_mat) then + ! + ! Build the filtered matrix Af from A + ! + call la%cscnv(acsrf,info,dupl=psb_dupl_add_) + + do i=1,nrow + tmp = zzero + jd = -1 + do j=acsrf%irp(i),acsrf%irp(i+1)-1 + if (acsrf%ja(j) == i) jd = j + if (abs(acsrf%val(j)) < theta*sqrt(abs(adiag(i)*adiag(acsrf%ja(j))))) then + tmp=tmp+acsrf%val(j) + acsrf%val(j)=zzero + endif + enddo + if (jd == -1) then + write(0,*) 'Wrong input: we need the diagonal!!!!', i + else + acsrf%val(jd)=acsrf%val(jd)-tmp + end if + enddo + ! Take out zeroed terms + call acsrf%clean_zeros(info) + + ! + ! Build the smoothed prolongator using the filtered matrix + ! + do i=1,acsrf%get_nrows() + do j=acsrf%irp(i),acsrf%irp(i+1)-1 + if (acsrf%ja(j) == i) then + acsrf%val(j) = zone - omf(i)*acsrf%val(j) + else + acsrf%val(j) = - omf(i)*acsrf%val(j) + end if + end do + end do + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done gather, going for SYMBMM 1' + + call af%mv_from(acsrf) + ! + ! op_prol = (I-w*D*Af)Ptilde + ! Doing it this way means to consider diag(Af_i) + ! + ! + call psb_spspmm(af,ptilde,op_prol,info) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done SPSPMM 1' + else + ! + ! Build the smoothed prolongator using the original matrix + ! + do i=1,acsr3%get_nrows() + do j=acsr3%irp(i),acsr3%irp(i+1)-1 + if (acsr3%ja(j) == i) then + acsr3%val(j) = zone - omf(i)*acsr3%val(j) + else + acsr3%val(j) = - omf(i)*acsr3%val(j) + end if + end do + end do + + call am3%mv_from(acsr3) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done gather, going for SYMBMM 1' + ! + ! + ! op_prol = (I-w*D*A)Ptilde + ! + ! + call psb_spspmm(am3,ptilde,op_prol,info) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done NUMBMM 1' + + end if + + + ! + ! Ok, let's start over with the restrictor + ! + call ptilde%transc(rtilde) + call la%cscnv(atmp,info,type='csr') + call psb_sphalo(atmp,desc_a,am4,info,& + & colcnv=.true.,rowscale=.true.) + nrt = am4%get_nrows() + call am4%csclip(atmp2,info,lone,nrt,lone,ncol) + call atmp2%cscnv(info,type='CSR') + if (info == psb_success_) call psb_rwextd(ncol,atmp,info,b=atmp2) + call am4%free() + call atmp2%free() + + ! This is to compute the transpose. It ONLY works if the + ! original A has a symmetric pattern. + call atmp%transc(atmp2) + call atmp2%csclip(dat,info,lone,nrow,lone,ncol) + call dat%cscnv(info,type='csr') + call dat%scal(adinv,info) + + ! Now for the product. + call psb_spspmm(dat,ptilde,datp,info) + + call datp%clone(atmp2,info) + call psb_sphalo(atmp2,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.,outfmt='CSR ') + if (info == psb_success_) call psb_rwextd(ncol,atmp2,info,b=am4) + if (info == psb_success_) call am4%free() + + + call psb_symbmm(dat,atmp2,datdatp,info) + call psb_numbmm(dat,atmp2,datdatp) + call atmp2%free() + + call datp%mv_to(csc_datp) + call datdatp%mv_to(csc_datdatp) + + call csc_mat_col_prod(csc_datp,csc_datdatp,omp,info) + call csc_mat_col_prod(csc_datdatp,csc_datdatp,oden,info) + call psb_sum(ictxt,omp) + call psb_sum(ictxt,oden) + + + ! !$ write(debug_unit,*) trim(name),' OMP_R :',omp + ! ! $ write(debug_unit,*) trim(name),' ODEN_R:',oden + omp = omp/oden + ! !$ write(0,*) 'Check on output restrictor',omp(1:min(size(omp),10)) + ! Compute omega_int + ommx = zzero + do i=1, ncol + if (ilaggr(i) >0) then + omi(i) = omp(ilaggr(i)) + else + omi(i) = zzero + end if + if(abs(omi(i)) .gt. abs(ommx)) ommx = omi(i) + end do + ! Compute omega_fine + ! Going over the columns of atmp means going over the rows + ! of A^T. Hopefully ;-) + call atmp%cp_to(acsc) + + do i=1, nrow + omf(i) = ommx + do j= acsc%icp(i),acsc%icp(i+1)-1 + if(abs(omi(acsc%ia(j))) .lt. abs(omf(i))) omf(i)=omi(acsc%ia(j)) + end do +!!$ if(min(real(omf(i)),aimag(omf(i))) < dzero) omf(i) = zzero + if(psb_minreal(omf(i)) < dzero) omf(i) = zzero + end do + omf(1:nrow) = omf(1:nrow)*adinv(1:nrow) + call psb_halo(omf,desc_a,info) + call acsc%free() + + + call atmp%mv_to(acsr1) + + do i=1,acsr1%get_nrows() + do j=acsr1%irp(i),acsr1%irp(i+1)-1 + if (acsr1%ja(j) == i) then + acsr1%val(j) = zone - acsr1%val(j)*omf(acsr1%ja(j)) + else + acsr1%val(j) = - acsr1%val(j)*omf(acsr1%ja(j)) + end if + end do + end do + call atmp%mv_from(acsr1) + + call rtilde%mv_to(tmpcoo) + nzl = tmpcoo%get_nzeros() + i=0 + do k=1, nzl + if ((naggrm1 < tmpcoo%ia(k)) .and. (tmpcoo%ia(k) <= naggrp1)) then + i = i+1 + tmpcoo%val(i) = tmpcoo%val(k) + tmpcoo%ia(i) = tmpcoo%ia(k) + tmpcoo%ja(i) = tmpcoo%ja(k) + end if + end do + call tmpcoo%set_nzeros(i) + call rtilde%mv_from(tmpcoo) + call rtilde%cscnv(info,type='csr') + + call psb_spspmm(rtilde,atmp,op_restr,info) + + ! + ! Now we have to gather the halo of op_prol, and add it to itself + ! to multiply it by A, + ! + call op_prol%clone(tmp_prol,info) + if (info == psb_success_) call psb_sphalo(tmp_prol,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.) + if (info == psb_success_) call psb_rwextd(ncol,tmp_prol,info,b=am4) + if (info == psb_success_) call am4%free() + + if(info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Halo of op_prol') + goto 9999 + end if + + ! + ! Now we have to fix this. The only rows of B that are correct + ! are those corresponding to "local" aggregates, i.e. indices in ilaggr(:) + ! + call op_restr%mv_to(tmpcoo) + + nzl = tmpcoo%get_nzeros() + i=0 + do k=1, nzl + if ((naggrm1 < tmpcoo%ia(k)) .and. (tmpcoo%ia(k) <= naggrp1)) then + i = i+1 + tmpcoo%val(i) = tmpcoo%val(k) + tmpcoo%ia(i) = tmpcoo%ia(k) + tmpcoo%ja(i) = tmpcoo%ja(k) + end if + end do + call tmpcoo%set_nzeros(i) + call op_restr%mv_from(tmpcoo) + call op_restr%cscnv(info,type='csr') + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'starting sphalo/ rwxtd' + + call psb_spspmm(la,tmp_prol,am3,info) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done SPSPMM 2' + + call psb_sphalo(am3,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.) + if (info == psb_success_) call psb_rwextd(ncol,am3,info,b=am4) + if (info == psb_success_) call am4%free() + + if(info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Extend am3') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done sphalo/ rwxtd' + + call psb_spspmm(op_restr,am3,ac,info) + if (info == psb_success_) call am3%free() + if (info == psb_success_) call ac%cscnv(info,type='coo',dupl=psb_dupl_add_) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + &a_err='Build ac = op_restr x am3') + goto 9999 + end if + + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done smooth_aggregate ' + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_errpush(info,name) + call psb_error_handler(err_act) + return + + +contains + + subroutine csc_mat_col_prod(a,b,v,info) + implicit none + type(psb_lz_csc_sparse_mat), intent(in) :: a, b + complex(psb_dpk_), intent(out) :: v(:) + integer(psb_ipk_), intent(out) :: info + + integer(psb_lpk_) :: i,j,k, nr, nc,iap,nra,ibp,nrb + + info = psb_success_ + nc = a%get_ncols() + if (nc /= b%get_ncols()) then + write(0,*) 'Matrices A and B should have same columns' + info = -1 + return + end if + + do j=1, nc + iap = a%icp(j) + nra = a%icp(j+1)-iap + ibp = b%icp(j) + nrb = b%icp(j+1)-ibp + v(j) = sparse_srtd_dot(nra,a%ia(iap:iap+nra-1),a%val(iap:iap+nra-1),& + & nrb,b%ia(ibp:ibp+nrb-1),b%val(ibp:ibp+nrb-1)) + end do + + end subroutine csc_mat_col_prod + + + subroutine csr_mat_row_prod(a,b,v,info) + implicit none + type(psb_lz_csr_sparse_mat), intent(in) :: a, b + complex(psb_dpk_), intent(out) :: v(:) + integer(psb_ipk_), intent(out) :: info + + integer(psb_lpk_) :: i,j,k, nr, nc,iap,nca,ibp,ncb + + info = psb_success_ + nr = a%get_nrows() + if (nr /= b%get_nrows()) then + write(0,*) 'Matrices A and B should have same rows' + info = -1 + return + end if + + do j=1, nr + iap = a%irp(j) + nca = a%irp(j+1)-iap + ibp = b%irp(j) + ncb = b%irp(j+1)-ibp + v(j) = sparse_srtd_dot(nca,a%ja(iap:iap+nca-1),a%val(iap:iap+nca-1),& + & ncb,b%ja(ibp:ibp+ncb-1),b%val(ibp:ibp+ncb-1)) + end do + + end subroutine csr_mat_row_prod + + + function sparse_srtd_dot(nv1,iv1,v1,nv2,iv2,v2) result(dot) + implicit none + integer(psb_lpk_), intent(in) :: nv1,nv2 + integer(psb_lpk_), intent(in) :: iv1(:), iv2(:) + complex(psb_dpk_), intent(in) :: v1(:),v2(:) + complex(psb_dpk_) :: dot + + integer(psb_lpk_) :: i,j,k, ip1, ip2 + + dot = zzero + ip1 = 1 + ip2 = 1 + + do + if (ip1 > nv1) exit + if (ip2 > nv2) exit + if (iv1(ip1) == iv2(ip2)) then + dot = dot + conjg(v1(ip1))*v2(ip2) + ip1 = ip1 + 1 + ip2 = ip2 + 1 + else if (iv1(ip1) < iv2(ip2)) then + ip1 = ip1 + 1 + else + ip2 = ip2 + 1 + end if + end do + + end function sparse_srtd_dot + + subroutine local_dump(me,mat,name,header) + type(psb_lzspmat_type), intent(in) :: mat + integer(psb_ipk_), intent(in) :: me + character(len=*), intent(in) :: name + character(len=*), intent(in) :: header + character(len=80) :: filename + + write(filename,'(a,a,i0,a,i0,a)') trim(name),'.p',me + open(20+me,file=filename) + call mat%print(20+me,head=trim(header)) + close(20+me) + end subroutine local_dump + +end subroutine amg_zaggrmat_minnrg_bld diff --git a/mlprec/impl/aggregator/amg_zaggrmat_nosmth_bld.f90 b/mlprec/impl/aggregator/amg_zaggrmat_nosmth_bld.f90 new file mode 100644 index 00000000..496915fa --- /dev/null +++ b/mlprec/impl/aggregator/amg_zaggrmat_nosmth_bld.f90 @@ -0,0 +1,198 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_zaggrmat_nosmth_bld.F90 +! +! Subroutine: amg_zaggrmat_nosmth_bld +! Version: complex +! +! This routine builds a coarse-level matrix A_C from a fine-level matrix A +! by using the Galerkin approach, i.e. +! +! A_C = P_C^T A P_C, +! +! where P_C is the piecewise constant interpolation operator corresponding +! the fine-to-coarse level mapping built by amg_aggrmap_bld. +! +! The coarse-level matrix A_C is distributed among the parallel processes or +! replicated on each of them, according to the value of p%parms%coarse_mat +! specified by the user through amg_zprecinit and amg_zprecset. +! On output from this routine the entries of AC, op_prol, op_restr +! are still in "global numbering" mode; this is fixed in the calling routine +! aggregator%mat_bld. +! +! For details see +! P. D'Ambra, D. di Serafino and S. Filippone, On the development of +! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math., +! 57 (2007), 1181-1196. +! +! +! Arguments: +! a - type(psb_zspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! p - type(amg_z_onelev_type), input/output. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! parms - type(amg_dml_parms), input +! Parameters controlling the choice of algorithm +! ac - type(psb_zspmat_type), output +! The coarse matrix on output +! +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_zspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_zspmat_type), output +! The restrictor operator; normally, it is the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +! +subroutine amg_zaggrmat_nosmth_bld(a,desc_a,ilaggr,nlaggr,parms,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + use psb_base_mod + use amg_base_prec_type + use amg_z_inner_mod, amg_protect_name => amg_zaggrmat_nosmth_bld + use amg_z_base_aggregator_mod + implicit none + + ! Arguments + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(amg_dml_parms), intent(inout) :: parms + type(psb_zspmat_type), intent(inout) :: op_prol,ac,op_restr + type(psb_lzspmat_type), intent(inout) :: t_prol + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt, np, me, icomm, minfo + character(len=20) :: name + type(psb_lz_coo_sparse_mat) :: lcoo_prol + type(psb_z_coo_sparse_mat) :: coo_prol, coo_restr + type(psb_z_csr_sparse_mat) :: acsr + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nzl, ip, & + & naggr, nzt, naggrm1, naggrp1, i, k + integer(psb_ipk_) :: inaggr, nzlp + logical, parameter :: debug = .false. + + name = 'amg_aggrmat_nosmth_bld' + info = psb_success_ + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + + ictxt = desc_a%get_context() + icomm = desc_a%get_mpic() + call psb_info(ictxt, me, np) + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + + call a%cp_to(acsr) + call t_prol%mv_to(lcoo_prol) + inaggr = naggr + call psb_cdall(ictxt,desc_ac,info,nl=inaggr) + nzlp = lcoo_prol%get_nzeros() + call desc_ac%indxmap%g2lip_ins(lcoo_prol%ja(1:nzlp),info) + call lcoo_prol%set_ncols(desc_ac%get_local_cols()) + call lcoo_prol%cp_to_icoo(coo_prol,info) + + if (debug) call check_coo(me,trim(name)//' Check 1 on coo_prol:',coo_prol) + + call psb_cdasb(desc_ac,info) + call psb_cd_reinit(desc_ac,info) + + call amg_ptap(acsr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info) + + call coo_restr%set_nrows(desc_ac%get_local_rows()) + call coo_restr%set_ncols(desc_a%get_local_cols()) + call coo_prol%set_nrows(desc_a%get_local_rows()) + call coo_prol%set_ncols(desc_ac%get_local_cols()) + + if (debug) call check_coo(me,trim(name)//' Check 1 on coo_restr:',coo_restr) + + call op_prol%mv_from(coo_prol) + call op_restr%mv_from(coo_restr) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + subroutine check_coo(me,string,coo) + implicit none + integer(psb_ipk_) :: me + type(psb_z_coo_sparse_mat) :: coo + character(len=*) :: string + integer(psb_lpk_) :: nr,nc,nz + nr = coo%get_nrows() + nc = coo%get_ncols() + nz = coo%get_nzeros() + write(0,*) me,string,nr,nc,& + & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& + & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) + + end subroutine check_coo +end subroutine amg_zaggrmat_nosmth_bld diff --git a/mlprec/impl/aggregator/amg_zaggrmat_smth_bld.f90 b/mlprec/impl/aggregator/amg_zaggrmat_smth_bld.f90 new file mode 100644 index 00000000..0b5fe88e --- /dev/null +++ b/mlprec/impl/aggregator/amg_zaggrmat_smth_bld.f90 @@ -0,0 +1,325 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_zaggrmat_smth_bld.F90 +! +! Subroutine: amg_zaggrmat_smth_bld +! Version: complex +! +! This routine builds a coarse-level matrix A_C from a fine-level matrix A +! by using the Galerkin approach, i.e. +! +! A_C = P_C^T A P_C, +! +! where P_C is a prolongator from the coarse level to the fine one. +! +! The prolongator P_C is built according to a smoothed aggregation algorithm, +! i.e. it is obtained by applying a damped Jacobi smoother to the piecewise +! constant interpolation operator P corresponding to the fine-to-coarse level +! mapping built by the amg_aggrmap_bld subroutine: +! +! P_C = (I - omega*D^(-1)A) * P, +! +! where D is the diagonal matrix with main diagonal equal to the main diagonal +! of A, and omega is a suitable smoothing parameter. An estimate of the spectral +! radius of D^(-1)A, to be used in the computation of omega, is provided, +! according to the value of p%parms%aggr_omega_alg, specified by the user +! through amg_zprecinit and amg_zprecset. +! +! The coarse-level matrix A_C is distributed among the parallel processes or +! replicated on each of them, according to the value of p%parms%coarse_mat, +! specified by the user through amg_zprecinit and amg_zprecset. +! On output from this routine the entries of AC, op_prol, op_restr +! are still in "global numbering" mode; this is fixed in the calling routine +! aggregator%mat_bld. +! +! +! Arguments: +! a - type(psb_zspmat_type), input. +! The sparse matrix structure containing the local part of +! the fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of the fine-level matrix. +! p - type(amg_z_onelev_type), input/output. +! The 'one-level' data structure that will contain the local +! part of the matrix to be built as well as the information +! concerning the prolongator and its transpose. +! parms - type(amg_dml_parms), input +! Parameters controlling the choice of algorithm +! ac - type(psb_zspmat_type), output +! The coarse matrix on output +! +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_zspmat_type), input/output +! The tentative prolongator on input, the computed prolongator on output +! +! op_restr - type(psb_zspmat_type), output +! The restrictor operator; normally, it is the transpose of the prolongator. +! +! info - integer, output. +! Error code. +! +subroutine amg_zaggrmat_smth_bld(a,desc_a,ilaggr,nlaggr,parms,& + & ac,desc_ac,op_prol,op_restr,t_prol,info) + use psb_base_mod + use amg_base_prec_type + use amg_z_inner_mod, amg_protect_name => amg_zaggrmat_smth_bld + use amg_z_base_aggregator_mod + + implicit none + + ! Arguments + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) + type(amg_dml_parms), intent(inout) :: parms + type(psb_zspmat_type), intent(out) :: op_prol,ac,op_restr + type(psb_lzspmat_type), intent(inout) :: t_prol + type(psb_desc_type), intent(inout) :: desc_ac + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, ip, & + & naggr, nzl,naggrm1,naggrp1, i, j, k, jd, icolF, nrw + integer(psb_ipk_) :: inaggr, nzlp + integer(psb_ipk_) :: ictxt, np, me + character(len=20) :: name + type(psb_lz_coo_sparse_mat) :: tmpcoo + type(psb_z_coo_sparse_mat) :: coo_prol, coo_restr + type(psb_z_csr_sparse_mat) :: acsr1, acsrf, csr_prol, acsr + complex(psb_dpk_), allocatable :: adiag(:) + real(psb_dpk_), allocatable :: arwsum(:) + integer(psb_ipk_) :: ierr(5) + logical :: filter_mat + integer(psb_ipk_) :: debug_level, debug_unit, err_act + integer(psb_ipk_), parameter :: ncmax=16 + real(psb_dpk_) :: anorm, omega, tmp, dg, theta + logical, parameter :: debug_new=.false. + character(len=80) :: filename + + name='amg_aggrmat_smth_bld' + info=psb_success_ + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + ictxt = desc_a%get_context() + + call psb_info(ictxt, me, np) + + nglob = desc_a%get_global_rows() + nrow = desc_a%get_local_rows() + ncol = desc_a%get_local_cols() + + theta = parms%aggr_thresh + + naggr = nlaggr(me+1) + ntaggr = sum(nlaggr) + + naggrm1 = sum(nlaggr(1:me)) + naggrp1 = sum(nlaggr(1:me+1)) + filter_mat = (parms%aggr_filter == amg_filter_mat_) + + ! + ! naggr: number of local aggregates + ! nrow: local rows. + ! + + ! Get the diagonal D + adiag = a%get_diag(info) + if (info == psb_success_) & + & call psb_realloc(ncol,adiag,info) + if (info == psb_success_) & + & call psb_halo(adiag,desc_a,info) + if (info == psb_success_) call a%cp_to(acsr) + + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_getdiag') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Initial copies done.' + + call acsr%cp_to_fmt(acsrf,info) + + + if (filter_mat) then + ! + ! Build the filtered matrix Af from A + ! + + do i=1, nrow + tmp = zzero + jd = -1 + do j=acsrf%irp(i),acsrf%irp(i+1)-1 + if (acsrf%ja(j) == i) jd = j + if (abs(acsrf%val(j)) < theta*sqrt(abs(adiag(i)*adiag(acsrf%ja(j))))) then + tmp=tmp+acsrf%val(j) + acsrf%val(j)=zzero + endif + + enddo + if (jd == -1) then + write(0,*) 'Wrong input: we need the diagonal!!!!', i + else + acsrf%val(jd)=acsrf%val(jd)-tmp + end if + enddo + ! Take out zeroed terms + call acsrf%clean_zeros(info) + end if + + + do i=1,size(adiag) + if (adiag(i) /= zzero) then + adiag(i) = zone / adiag(i) + else + adiag(i) = zone + end if + end do + + if (parms%aggr_omega_alg == amg_eig_est_) then + + if (parms%aggr_eig == amg_max_norm_) then + allocate(arwsum(nrow)) + call acsr%arwsum(arwsum) + anorm = maxval(abs(adiag(1:nrow)*arwsum(1:nrow))) + call psb_amx(ictxt,anorm) + omega = 4.d0/(3.d0*anorm) + parms%aggr_omega_val = omega + + else + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_aggr_eig_') + goto 9999 + end if + + else if (parms%aggr_omega_alg == amg_user_choice_) then + + omega = parms%aggr_omega_val + + else if (parms%aggr_omega_alg /= amg_user_choice_) then + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_aggr_omega_alg_') + goto 9999 + end if + + + call acsrf%scal(adiag,info) + if (info /= psb_success_) goto 9999 + + call t_prol%mv_to(tmpcoo) + inaggr = naggr + call psb_cdall(ictxt,desc_ac,info,nl=inaggr) + nzlp = tmpcoo%get_nzeros() + call desc_ac%indxmap%g2lip_ins(tmpcoo%ja(1:nzlp),info) + call tmpcoo%set_ncols(desc_ac%get_local_cols()) + call tmpcoo%mv_to_ifmt(csr_prol,info) + + call psb_cdasb(desc_ac,info) + call psb_cd_reinit(desc_ac,info) + ! + ! Build the smoothed prolongator using either A or Af + ! acsr1 = (I-w*D*A) Prol acsr1 = (I-w*D*Af) Prol + ! This is always done through the variable acsrf which + ! is a bit less readable, but saves space and one matrix copy + ! + call omega_smooth(omega,acsrf) + call psb_par_spspmm(acsrf,desc_a,csr_prol,acsr1,desc_ac,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 1') + goto 9999 + end if + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done SPSPMM 1' + nzl = acsr1%get_nzeros() + call acsr1%mv_to_coo(coo_prol,info) + + call amg_ptap(acsr,desc_a,nlaggr,parms,ac,& + & coo_prol,desc_ac,coo_restr,info) + + call op_prol%mv_from(coo_prol) + call op_restr%mv_from(coo_restr) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done smooth_aggregate ' + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_errpush(info,name) + call psb_error_handler(err_act) + return + +contains + + subroutine omega_smooth(omega,acsr) + implicit none + real(psb_dpk_),intent(in) :: omega + type(psb_z_csr_sparse_mat), intent(inout) :: acsr + ! + integer(psb_lpk_) :: i,j + do i=1,acsr%get_nrows() + do j=acsr%irp(i),acsr%irp(i+1)-1 + if (acsr%ja(j) == i) then + acsr%val(j) = zone - omega*acsr%val(j) + else + acsr%val(j) = - omega*acsr%val(j) + end if + end do + end do + end subroutine omega_smooth + +end subroutine amg_zaggrmat_smth_bld diff --git a/mlprec/impl/aggregator/mld_c_dec_aggregator_mat_asb.f90 b/mlprec/impl/aggregator/mld_c_dec_aggregator_mat_asb.f90 deleted file mode 100644 index a98771e3..00000000 --- a/mlprec/impl/aggregator/mld_c_dec_aggregator_mat_asb.f90 +++ /dev/null @@ -1,195 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_c_dec_aggregator_mat_asb.f90 -! -! Subroutine: mld_c_dec_aggregator_mat_asb -! Version: complex -! -! -! From a given AC to final format, generating DESC_AC -! -! Arguments: -! ag - type(mld_c_dec_aggregator_type), input/output. -! The aggregator object -! parms - type(mld_sml_parms), input -! The aggregation parameters -! a - type(psb_cspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! ac - type(psb_cspmat_type), inout -! The coarse matrix -! desc_ac - type(psb_desc_type), output. -! The communication descriptor of the fine-level matrix. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! -! op_prol - type(psb_cspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_cspmat_type), input/output -! The restrictor operator; normally, it is the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -subroutine mld_c_dec_aggregator_mat_asb(ag,parms,a,desc_a,& - & ac,desc_ac, op_prol,op_restr,info) - use psb_base_mod - use mld_base_prec_type - use mld_c_dec_aggregator_mod, mld_protect_name => mld_c_dec_aggregator_mat_asb - implicit none - class(mld_c_dec_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - type(psb_cspmat_type), intent(inout) :: op_prol, ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: ictxt, np, me - type(psb_lc_coo_sparse_mat) :: tmpcoo - type(psb_lcspmat_type) :: tmp_ac - integer(psb_ipk_) :: i_nr, i_nc, i_nl, nzl - integer(psb_lpk_) :: ntaggr - integer(psb_ipk_) :: err_act, debug_level, debug_unit - character(len=20) :: name='c_dec_aggregator_mat_asb' - - - if (psb_get_errstatus().ne.0) return - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - select case(parms%coarse_mat) - - case(mld_distr_mat_) - - call ac%cscnv(info,type='csr') - call op_prol%cscnv(info,type='csr') - call op_restr%cscnv(info,type='csr') - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ac ' - - case(mld_repl_mat_) - ! - ! We are assuming here that an c matrix - ! can hold all entries - ! - if (desc_ac%get_global_rows() < huge(1_psb_ipk_) ) then - ntaggr = desc_ac%get_global_rows() - i_nr = ntaggr - else - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_coarse_mat_') - goto 9999 - end if - - call op_prol%mv_to(tmpcoo) - nzl = tmpcoo%get_nzeros() - call psb_loc_to_glob(tmpcoo%ja(1:nzl),desc_ac,info,'I') - call tmpcoo%set_ncols(i_nr) - call op_prol%mv_from(tmpcoo) - - call op_restr%mv_to(tmpcoo) - nzl = tmpcoo%get_nzeros() - call psb_loc_to_glob(tmpcoo%ia(1:nzl),desc_ac,info,'I') - call tmpcoo%set_nrows(i_nr) - call op_restr%mv_from(tmpcoo) - - - call psb_gather(tmp_ac,ac,desc_ac,info,root=-ione,& - & dupl=psb_dupl_add_,keeploc=.false.) - call tmp_ac%mv_to(tmpcoo) - call ac%mv_from(tmpcoo) - - call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) - if (info == psb_success_) call psb_cdasb(desc_ac,info) - - if (info /= psb_success_) goto 9999 - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_coarse_mat_') - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_lc_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo -end subroutine mld_c_dec_aggregator_mat_asb diff --git a/mlprec/impl/aggregator/mld_c_dec_aggregator_mat_bld.f90 b/mlprec/impl/aggregator/mld_c_dec_aggregator_mat_bld.f90 deleted file mode 100644 index 6a2e8f30..00000000 --- a/mlprec/impl/aggregator/mld_c_dec_aggregator_mat_bld.f90 +++ /dev/null @@ -1,216 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_c_dec_aggregator_mat_bld.f90 -! -! Subroutine: mld_c_dec_aggregator_mat_bld -! Version: complex -! -! This routine builds the matrix associated to the current level of the -! multilevel preconditioner from the matrix associated to the previous level, -! by using the user-specified aggregation technique (therefore, it also builds the -! prolongation and restriction operators mapping the current level to the -! previous one and vice versa). -! The current level is regarded as the coarse one, while the previous as -! the fine one. This is in agreement with the fact that the routine is called, -! by mld_mlprec_bld, only on levels >=2. -! The coarse-level matrix A_C is built from a fine-level matrix A -! by using the Galerkin approach, i.e. -! -! A_C = P_C^T A P_C, -! -! where P_C is a prolongator from the coarse level to the fine one. -! -! A mapping from the nodes of the adjacency graph of A to the nodes of the -! adjacency graph of A_C has been computed by the mld_aggrmap_bld subroutine. -! The prolongator P_C is built here from this mapping, according to the -! value of p%iprcparm(mld_aggr_kind_), specified by the user through -! mld_cprecinit and mld_zprecset. -! On output from this routine the entries of AC, op_prol, op_restr -! are still in "global numbering" mode; this is fixed in the calling routine -! mld_c_lev_aggrmat_bld. -! -! Currently four different prolongators are implemented, corresponding to -! four aggregation algorithms: -! 1. un-smoothed aggregation, -! 2. smoothed aggregation, -! 3. "bizarre" aggregation. -! 4. minimum energy -! 1. The non-smoothed aggregation uses as prolongator the piecewise constant -! interpolation operator corresponding to the fine-to-coarse level mapping built -! by p%aggr%bld_tprol. This is called tentative prolongator. -! 2. The smoothed aggregation uses as prolongator the operator obtained by applying -! a damped Jacobi smoother to the tentative prolongator. -! 3. The "bizarre" aggregation uses a prolongator proposed by the authors of MLD2P4. -! This prolongator still requires a deep analysis and testing and its use is -! not recommended. -! 4. Minimum energy aggregation -! -! For more details see -! M. Brezina and P. Vanek, A black-box iterative solver based on a two-level -! Schwarz method, Computing, 63 (1999), 233-263. -! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed -! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 -! (1996), 179-196. -! P. D'Ambra, D. di Serafino and S. Filippone, On the development of PSBLAS-based -! parallel two-level Schwarz preconditioners, Appl. Num. Math., 57 (2007), -! 1181-1196. -! M. Sala, R. Tuminaro: A new Petrov-Galerkin smoothed aggregation preconditioner -! for nonsymmetric linear systems, SIAM J. Sci. Comput., 31(1):143-166 (2008) -! -! -! The main structure is: -! 1. Perform sanity checks; -! 2. Compute prolongator/restrictor/AC -! -! -! Arguments: -! ag - type(mld_c_dec_aggregator_type), input/output. -! The aggregator object -! parms - type(mld_sml_parms), input -! The aggregation parameters -! a - type(psb_cspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! ac - type(psb_cspmat_type), output -! The coarse matrix on output -! -! op_prol - type(psb_cspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_cspmat_type), output -! The restrictor operator; normally, it is the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -subroutine mld_c_dec_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - use psb_base_mod - use mld_c_prec_type, mld_protect_name => mld_c_dec_aggregator_mat_bld - use mld_c_inner_mod - implicit none - - class(mld_c_dec_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(psb_lcspmat_type), intent(inout) :: t_prol - type(psb_cspmat_type), intent(out) :: op_prol,ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - - ! Local variables - character(len=20) :: name - integer(psb_mpk_) :: ictxt, np, me - integer(psb_lpk_) :: nzl,ntaggr - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: debug_level, debug_unit - - name='mld_c_dec_aggregator_mat_bld' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - ! - ! Build the coarse-level matrix from the fine-level one, starting from - ! the mapping defined by mld_aggrmap_bld and applying the aggregation - ! algorithm specified by - ! - select case (parms%aggr_prol) - case (mld_no_smooth_) - - call mld_caggrmat_nosmth_bld(a,desc_a,ilaggr,nlaggr,& - & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) - - case(mld_smooth_prol_) - - call mld_caggrmat_smth_bld(a,desc_a,ilaggr,nlaggr, & - & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) - -!!$ case(mld_biz_prol_) -!!$ -!!$ call mld_caggrmat_biz_bld(a,desc_a,ilaggr,nlaggr, & -!!$ & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) - - case(mld_min_energy_) - - call mld_caggrmat_minnrg_bld(a,desc_a,ilaggr,nlaggr, & - & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='Invalid aggr kind') - goto 9999 - - end select - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='Inner aggrmat bld') - goto 9999 - end if - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - -end subroutine mld_c_dec_aggregator_mat_bld diff --git a/mlprec/impl/aggregator/mld_c_dec_aggregator_tprol.f90 b/mlprec/impl/aggregator/mld_c_dec_aggregator_tprol.f90 deleted file mode 100644 index 6f82c5bc..00000000 --- a/mlprec/impl/aggregator/mld_c_dec_aggregator_tprol.f90 +++ /dev/null @@ -1,139 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_c_dec_aggregator_tprol.f90 -! -! Subroutine: mld_c_dec_aggregator_tprol -! Version: complex -! -! This routine is mainly an interface to soc_map_bld where the real work is performed. -! It takes care of some consistency checking, and calls map_to_tprol, which is -! refactored and shared among all the aggregation methods that produce a simple -! integer mapping. -! -! -! Arguments: -! ag - type(mld_c_dec_aggregator_type), input/output. -! The aggregator object, carrying with itself the mapping algorithm. -! parms - The auxiliary parameters object -! ag_data - Auxiliary global aggregation parameters object -! -! -! a - type(psb_cspmat_type). -! The sparse matrix structure containing the local part of the -! fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! ilaggr - integer, dimension(:), allocatable, output -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that on exit the indices -! will be shifted so as to make sure the ranges on the various processes do not -! overlap. -! nlaggr - integer, dimension(:), allocatable, output -! nlaggr(i) contains the aggregates held by process i. -! t_prol - type(psb_cspmat_type), output -! The tentative prolongator, based on ilaggr. -! -! info - integer, output. -! Error code. -! -subroutine mld_c_dec_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,t_prol,info) - use psb_base_mod - use mld_c_prec_type, mld_protect_name => mld_c_dec_aggregator_build_tprol - use mld_c_inner_mod - implicit none - class(mld_c_dec_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(mld_saggr_data), intent(in) :: ag_data - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lcspmat_type), intent(out) :: t_prol - integer(psb_ipk_), intent(out) :: info - - ! Local variables - character(len=20) :: name - integer(psb_mpk_) :: ictxt, np, me - integer(psb_ipk_) :: err_act - integer(psb_lpk_) :: ntaggr - integer(psb_ipk_) :: debug_level, debug_unit - logical :: clean_zeros - - name='mld_c_dec_aggregator_tprol' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - call mld_check_def(parms%ml_cycle,'Multilevel cycle',& - & mld_mult_ml_,is_legal_ml_cycle) - call mld_check_def(parms%par_aggr_alg,'Aggregation',& - & mld_dec_aggr_,is_legal_ml_par_aggr_alg) - call mld_check_def(parms%aggr_ord,'Ordering',& - & mld_aggr_ord_nat_,is_legal_ml_aggr_ord) - call mld_check_def(parms%aggr_thresh,'Aggr_Thresh',szero,is_legal_s_aggr_thrs) - - ! - ! The decoupled aggregator based on SOC measures ignores - ! ag_data except for clean_zeros; soc_map_bld is a procedure pointer. - ! - clean_zeros = ag%do_clean_zeros - call ag%soc_map_bld(parms%aggr_ord,parms%aggr_thresh,clean_zeros,a,desc_a,nlaggr,ilaggr,info) - - if (info==psb_success_) call mld_map_to_tprol(desc_a,ilaggr,nlaggr,t_prol,info) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='soc_map_bld/map_to_tprol') - goto 9999 - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_c_dec_aggregator_build_tprol diff --git a/mlprec/impl/aggregator/mld_c_map_to_tprol.f90 b/mlprec/impl/aggregator/mld_c_map_to_tprol.f90 deleted file mode 100644 index fb3e65d4..00000000 --- a/mlprec/impl/aggregator/mld_c_map_to_tprol.f90 +++ /dev/null @@ -1,154 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_c_map_to_tprol.f90 -! -! Subroutine: mld_c_map_to_tprol -! Version: complex -! -! This routine uses a mapping from the row indices of the fine-level matrix -! to the row indices of the coarse-level matrix to build a tentative -! prolongator, i.e. a piecewise constant operator. -! This is later used to build the final operator; the code has been refactored here -! to be shared among all the methods that provide the tentative prolongator -! through a simple integer mapping. -! -! The aggregation algorithm is a parallel version of that described in -! * M. Brezina and P. Vanek, A black-box iterative solver based on a -! two-level Schwarz method, Computing, 63 (1999), 233-263. -! * P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed -! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 -! (1996), 179-196. -! For more details see -! P. D'Ambra, D. di Serafino and S. Filippone, On the development of -! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math. -! 57 (2007), 1181-1196. -! -! -! Arguments: -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! ilaggr - integer, dimension(:), allocatable. -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that on exit the indices -! will be shifted so as to make sure the ranges on the various processes do not -! overlap. -! nlaggr - integer, dimension(:), allocatable. -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_cspmat_type). -! The tentative prolongator, based on ilaggr. -! -! info - integer, output. -! Error code. -! -subroutine mld_c_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) - - use psb_base_mod - use mld_c_inner_mod, mld_protect_name => mld_c_map_to_tprol - - implicit none - - ! Arguments - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), allocatable, intent(inout) :: ilaggr(:),nlaggr(:) - type(psb_lcspmat_type), intent(out) :: op_prol - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_lpk_) :: icnt,nlp,k,n,ia,isz,nr, naggr,i,j,m,naggrm1, naggrp1, ntaggr - type(psb_lc_coo_sparse_mat) :: tmpcoo - integer(psb_ipk_) :: debug_level, debug_unit,err_act - integer(psb_ipk_) :: ictxt,np,me - integer(psb_lpk_) :: nrow, ncol, n_ne - character(len=20) :: name, ch_err - - info=psb_success_ - name = 'mld_map_to_tprol' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ! - ictxt=desc_a%get_context() - call psb_info(ictxt,me,np) - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - ilaggr(1:nrow) = ilaggr(1:nrow) + naggrm1 - call psb_halo(ilaggr,desc_a,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_halo') - goto 9999 - end if - - call tmpcoo%allocate(nrow,ntaggr,ncol) - k = 0 - do i=1,nrow - ! - ! Note: at this point, a value ilaggr(i)<=0 - ! tags a "singleton" row, and it has to be - ! left alone. - ! - if (ilaggr(i)>0) then - k = k + 1 - tmpcoo%val(k) = cone - tmpcoo%ia(k) = i - tmpcoo%ja(k) = ilaggr(i) - end if - end do - call tmpcoo%set_nzeros(k) - call tmpcoo%set_dupl(psb_dupl_add_) - call tmpcoo%set_sorted() ! At this point this is in row-major - call op_prol%mv_from(tmpcoo) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_map_to_tprol diff --git a/mlprec/impl/aggregator/mld_c_ptap.f90 b/mlprec/impl/aggregator/mld_c_ptap.f90 deleted file mode 100644 index bc008cb8..00000000 --- a/mlprec/impl/aggregator/mld_c_ptap.f90 +++ /dev/null @@ -1,689 +0,0 @@ -! -! -! MLD2P4 Extensions -! -! (C) Copyright 2019 -! -! Salvatore Filippone Cranfield University -! Pasqua D'Ambra IAC-CNR, Naples, IT -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_daggrmat_nosmth_bld.F90 -! -! -subroutine mld_c_ptap(a_csr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info,desc_ax) - use psb_base_mod - use mld_c_inner_mod - use mld_c_base_aggregator_mod, mld_protect_name => mld_c_ptap - implicit none - - ! Arguments - type(psb_c_csr_sparse_mat), intent(inout) :: a_csr - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - type(mld_sml_parms), intent(inout) :: parms - type(psb_c_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr - type(psb_desc_type), intent(inout) :: desc_ac - type(psb_cspmat_type), intent(out) :: ac - integer(psb_ipk_), intent(out) :: info - type(psb_desc_type), intent(inout), optional :: desc_ax - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo - character(len=40) :: name - integer(psb_ipk_) :: ierr(5) - type(psb_lc_coo_sparse_mat) :: ac_coo, tmpcoo - type(psb_c_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr - integer(psb_ipk_) :: debug_level, debug_unit, naggr - integer(psb_lpk_) :: nglob, ntaggr, naggrm1, naggrp1 - integer(psb_ipk_) :: nrow, ncol, nrl, nzl, ip, nzt, i, k - integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza - logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. - integer(psb_ipk_), save :: idx_spspmm=-1 - - name='mld_ptap' - if(psb_get_errstatus().ne.0) return - info=psb_success_ - call psb_erractionsave(err_act) - - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - call psb_info(ictxt, me, np) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - if ((do_timings).and.(idx_spspmm==-1)) & - & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr - - ! - ! COO_PROL should arrive here with local numbering - ! - if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& - & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& - & nrow,ntaggr,naggr - - call coo_prol%cp_to_fmt(csr_prol,info) - - if (debug) write(0,*) me,trim(name),' Product AxPROL ',& - & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & - & desc_a%get_local_rows(),desc_a%get_local_cols(),& - & desc_ac%get_local_rows(),desc_a%get_local_cols() - if (debug) flush(0) - - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - - if (debug) write(0,*) me,trim(name),' Done AxPROL ',& - & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& - & desc_ac%get_local_rows(),desc_ac%get_local_cols() - - ! - ! Ok first product done. - - if (present(desc_ax)) then - block - call coo_prol%cp_to_coo(coo_restr,info) - call coo_restr%set_ncols(desc_ac%get_local_cols()) - call coo_restr%set_nrows(desc_a%get_local_rows()) - call psb_c_coo_glob_transpose(coo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_ax%get_local_cols()) -! !$ write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& -! !$ & desc_a%get_local_cols(),desc_ax%get_local_cols(),coo_restr%get_nzeros() -! !$ if (desc_a%get_local_cols()= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - - else - - ! - ! Remember that RESTR must be built from PROL after halo extension, - ! which is done above in psb_par_spspmm - if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& - & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() - call csr_prol%mv_to_coo(coo_restr,info) -!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& -!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() - if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) - - call coo_restr%transp() - nzl = coo_restr%get_nzeros() - nrl = desc_ac%get_local_rows() - i=0 - ! - ! Only keep local rows - ! - do k=1, nzl - if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then - i = i+1 - coo_restr%val(i) = coo_restr%val(k) - coo_restr%ia(i) = coo_restr%ia(k) - coo_restr%ja(i) = coo_restr%ja(k) - end if - end do - call coo_restr%set_nzeros(i) - call coo_restr%fix(info) - nzl = coo_restr%get_nzeros() - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_a%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) - call csr_restr%cp_from_coo(coo_restr,info) - -!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - end if - - call psb_cdasb(desc_ac,info) - - call ac_csr%set_nrows(desc_ac%get_local_rows()) - call ac_csr%set_ncols(desc_ac%get_local_cols()) - call ac%mv_from(ac_csr) - call ac%set_asb() - - if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() - if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr - ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() - - call coo_prol%set_ncols(desc_ac%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ptap ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_c_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo - -end subroutine mld_c_ptap - -subroutine mld_c_lc_ptap(a_csr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info,desc_ax) - use psb_base_mod - use mld_c_inner_mod - use mld_c_base_aggregator_mod !, mld_protect_name => mld_c_lc_ptap - implicit none - - ! Arguments - type(psb_c_csr_sparse_mat), intent(inout) :: a_csr - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - type(mld_sml_parms), intent(inout) :: parms - type(psb_lc_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr - type(psb_desc_type), intent(inout) :: desc_ac - type(psb_lcspmat_type), intent(out) :: ac - integer(psb_ipk_), intent(out) :: info - type(psb_desc_type), intent(inout), optional :: desc_ax - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo - character(len=40) :: name - integer(psb_ipk_) :: ierr(5) - type(psb_lc_coo_sparse_mat) :: ac_coo, tmpcoo - type(psb_c_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr - integer(psb_ipk_) :: debug_level, debug_unit, naggr - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nrl, nzl, ip, & - & nzt, naggrm1, naggrp1, i, k - integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza - logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. - integer(psb_ipk_), save :: idx_spspmm=-1 - - name='mld_ptap' - if(psb_get_errstatus().ne.0) return - info=psb_success_ - call psb_erractionsave(err_act) - - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - call psb_info(ictxt, me, np) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - if ((do_timings).and.(idx_spspmm==-1)) & - & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr - - ! - ! COO_PROL should arrive here with local numbering - ! - if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& - & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& - & nrow,ntaggr,naggr - - call coo_prol%cp_to_ifmt(csr_prol,info) - - if (debug) write(0,*) me,trim(name),' Product AxPROL ',& - & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & - & desc_a%get_local_rows(),desc_a%get_local_cols(),& - & desc_ac%get_local_rows(),desc_a%get_local_cols() - if (debug) flush(0) - - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - - if (debug) write(0,*) me,trim(name),' Done AxPROL ',& - & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& - & desc_ac%get_local_rows(),desc_ac%get_local_cols() - - ! - ! Ok first product done. - - if (present(desc_ax)) then - block - type(psb_c_coo_sparse_mat) :: icoo_restr - - call coo_prol%cp_to_icoo(icoo_restr,info) - call icoo_restr%set_ncols(desc_ac%get_local_cols()) - call icoo_restr%set_nrows(desc_a%get_local_rows()) - call psb_c_coo_glob_transpose(icoo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) - call icoo_restr%set_nrows(desc_ac%get_local_rows()) - call icoo_restr%set_ncols(desc_ax%get_local_cols()) -! !$ write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& -! !$ & desc_a%get_local_cols(),desc_ax%get_local_cols(),icoo_restr%get_nzeros() -! !$ if (desc_a%get_local_cols()= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - - else - - ! - ! Remember that RESTR must be built from PROL after halo extension, - ! which is done above in psb_par_spspmm - if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& - & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() - call csr_prol%mv_to_lcoo(coo_restr,info) -!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& -!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() - if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) - - call coo_restr%transp() - nzl = coo_restr%get_nzeros() - nrl = desc_ac%get_local_rows() - i=0 - ! - ! Only keep local rows - ! - do k=1, nzl - if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then - i = i+1 - coo_restr%val(i) = coo_restr%val(k) - coo_restr%ia(i) = coo_restr%ia(k) - coo_restr%ja(i) = coo_restr%ja(k) - end if - end do - call coo_restr%set_nzeros(i) - call coo_restr%fix(info) - nzl = coo_restr%get_nzeros() - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_a%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) - call csr_restr%cp_from_lcoo(coo_restr,info) - -!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - end if - - call psb_cdasb(desc_ac,info) - - call ac_csr%set_nrows(desc_ac%get_local_rows()) - call ac_csr%set_ncols(desc_ac%get_local_cols()) - call ac%mv_from(ac_csr) - call ac%set_asb() - - if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() - if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr - ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() - - call coo_prol%set_ncols(desc_ac%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ptap ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_lc_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo - -end subroutine mld_c_lc_ptap - -subroutine mld_lc_ptap(a_csr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info,desc_ax) - use psb_base_mod - use mld_c_inner_mod - use mld_c_base_aggregator_mod!, mld_protect_name => mld_lc_ptap - implicit none - - ! Arguments - type(psb_lc_csr_sparse_mat), intent(inout) :: a_csr - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - type(mld_sml_parms), intent(inout) :: parms - type(psb_lc_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr - type(psb_desc_type), intent(inout) :: desc_ac - type(psb_lcspmat_type), intent(out) :: ac - integer(psb_ipk_), intent(out) :: info - type(psb_desc_type), intent(inout), optional :: desc_ax - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo - character(len=40) :: name - integer(psb_ipk_) :: ierr(5) - type(psb_lc_coo_sparse_mat) :: ac_coo, tmpcoo - type(psb_lc_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr - integer(psb_ipk_) :: debug_level, debug_unit, naggr - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nrl, nzl, ip, & - & nzt, naggrm1, naggrp1, i, k - integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza - logical, parameter :: do_timings=.true., oldstyle=.false., debug=.false. - integer(psb_ipk_), save :: idx_spspmm=-1 - - name='mld_ptap' - if(psb_get_errstatus().ne.0) return - info=psb_success_ - call psb_erractionsave(err_act) - - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - call psb_info(ictxt, me, np) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - if ((do_timings).and.(idx_spspmm==-1)) & - & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr - - ! - ! COO_PROL should arrive here with local numbering - ! - if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& - & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& - & nrow,ntaggr,naggr - - call coo_prol%cp_to_fmt(csr_prol,info) - - if (debug) write(0,*) me,trim(name),' Product AxPROL ',& - & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & - & desc_a%get_local_rows(),desc_a%get_local_cols(),& - & desc_ac%get_local_rows(),desc_a%get_local_cols() - if (debug) flush(0) - - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - - if (debug) write(0,*) me,trim(name),' Done AxPROL ',& - & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& - & desc_ac%get_local_rows(),desc_ac%get_local_cols() - - ! - ! Ok first product done. - - if (present(desc_ax)) then - block - type(psb_c_coo_sparse_mat) :: icoo_restr - - call coo_prol%cp_to_icoo(icoo_restr,info) - call icoo_restr%set_ncols(desc_ac%get_local_cols()) - call icoo_restr%set_nrows(desc_a%get_local_rows()) - call psb_c_coo_glob_transpose(icoo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) - call icoo_restr%set_nrows(desc_ac%get_local_rows()) - call icoo_restr%set_ncols(desc_ax%get_local_cols()) - write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& - & desc_a%get_local_cols(),desc_ax%get_local_cols(),icoo_restr%get_nzeros() - if (desc_a%get_local_cols()= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - - else - - ! - ! Remember that RESTR must be built from PROL after halo extension, - ! which is done above in psb_par_spspmm - if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& - & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() - call csr_prol%mv_to_coo(coo_restr,info) -!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& -!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() - if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) - - call coo_restr%transp() - nzl = coo_restr%get_nzeros() - nrl = desc_ac%get_local_rows() - i=0 - ! - ! Only keep local rows - ! - do k=1, nzl - if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then - i = i+1 - coo_restr%val(i) = coo_restr%val(k) - coo_restr%ia(i) = coo_restr%ia(k) - coo_restr%ja(i) = coo_restr%ja(k) - end if - end do - call coo_restr%set_nzeros(i) - call coo_restr%fix(info) - nzl = coo_restr%get_nzeros() - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_a%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) - call csr_restr%cp_from_coo(coo_restr,info) - -!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - end if - - call psb_cdasb(desc_ac,info) - - call ac_csr%set_nrows(desc_ac%get_local_rows()) - call ac_csr%set_ncols(desc_ac%get_local_cols()) - call ac%mv_from(ac_csr) - call ac%set_asb() - - if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() - if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr - ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() - - call coo_prol%set_ncols(desc_ac%get_local_cols()) - !call coo_restr%mv_from_ifmt(csr_restr,info) -!!$ call coo_restr%set_nrows(desc_ac%get_local_rows()) -!!$ call coo_restr%set_ncols(desc_a%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ptap ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_lc_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo - -end subroutine mld_lc_ptap diff --git a/mlprec/impl/aggregator/mld_c_soc1_map_bld.f90 b/mlprec/impl/aggregator/mld_c_soc1_map_bld.f90 deleted file mode 100644 index 576df2d1..00000000 --- a/mlprec/impl/aggregator/mld_c_soc1_map_bld.f90 +++ /dev/null @@ -1,349 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_c_soc1_map__bld.f90 -! -! Subroutine: mld_c_soc1_map_bld -! Version: complex -! -! This routine builds the tentative prolongator based on the -! strength of connection aggregation algorithm presented in -! -! M. Brezina and P. Vanek, A black-box iterative solver based on a -! two-level Schwarz method, Computing, 63 (1999), 233-263. -! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed -! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 -! (1996), 179-196. -! -! Note: upon exit -! -! Arguments: -! a - type(psb_cspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_cprec_type), input/output. -! The preconditioner data structure; upon exit it contains -! the multilevel hierarchy of prolongators, restrictors -! and coarse matrices. -! info - integer, output. -! Error code. -! -! -! -subroutine mld_c_soc1_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) - - use psb_base_mod - use mld_base_prec_type - use mld_c_inner_mod - - implicit none - - ! Arguments - integer(psb_ipk_), intent(in) :: iorder - logical, intent(in) :: clean_zeros - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - real(psb_spk_), intent(in) :: theta - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),& - & ideg(:), idxs(:) - integer(psb_lpk_), allocatable :: tmpaggr(:) - complex(psb_spk_), allocatable :: val(:), diag(:) - integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr, nc, naggr,i,j,m, nz, ilg, ii, ip - type(psb_c_csr_sparse_mat) :: acsr - real(psb_spk_) :: cpling, tcl - logical :: disjoint - integer(psb_ipk_) :: debug_level, debug_unit,err_act - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: nrow, ncol, n_ne - integer(psb_lpk_) :: nrglob - character(len=20) :: name, ch_err - - info=psb_success_ - name = 'mld_soc1_map_bld' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ! - ictxt=desc_a%get_context() - call psb_info(ictxt,me,np) - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - nrglob = desc_a%get_global_rows() - - nr = a%get_nrows() - nc = a%get_ncols() - allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),& - & icol(nc),val(nc),stat=info) - if(info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),& - & a_err='integer') - goto 9999 - end if - - diag = a%get_diag(info) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='psb_sp_getdiag') - goto 9999 - end if - - call a%cp_to(acsr) - if (clean_zeros) call acsr%clean_zeros(info) - if (iorder == mld_aggr_ord_nat_) then - do i=1, nr - ilaggr(i) = -(nr+1) - idxs(i) = i - end do - else - do i=1, nr - ilaggr(i) = -(nr+1) - ideg(i) = acsr%irp(i+1) - acsr%irp(i) - end do - call psb_msort(ideg,ix=idxs,dir=psb_sort_down_) - end if - - - ! - ! Phase one: Start with disjoint groups. - ! - naggr = 0 - icnt = 0 - step1: do ii=1, nr - i = idxs(ii) - if ((i<1).or.(i>nr)) then - info=psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - if (ilaggr(i) == -(nr+1)) then - nz = (acsr%irp(i+1)-acsr%irp(i)) - if ((nz<0).or.(nz>size(icol))) then - info=psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) - val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) - - ! - ! Build the set of all strongly coupled nodes - ! - ip = 0 - do k=1, nz - j = icol(k) - if ((1<=j).and.(j<=nr)) then - if (abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j)))) then - ip = ip + 1 - icol(ip) = icol(k) - end if - end if - enddo - - ! - ! If the whole strongly coupled neighborhood of I is - ! as yet unconnected, turn it into the next aggregate. - ! Same if ip==0 (in which case, neighborhood only - ! contains I even if it does not look like it from matrix) - ! - disjoint = all(ilaggr(icol(1:ip)) == -(nr+1)).or.(ip==0) - if (disjoint) then - icnt = icnt + 1 - naggr = naggr + 1 - do k=1, ip - ilaggr(icol(k)) = naggr - end do - ilaggr(i) = naggr - end if - endif - enddo step1 - - if (debug_level >= psb_debug_outer_) then - write(debug_unit,*) me,' ',trim(name),& - & ' Check 1:',count(ilaggr == -(nr+1)) - end if - - ! - ! Phase two: join the neighbours - ! - tmpaggr = ilaggr - step2: do ii=1,nr - i = idxs(ii) - - if (ilaggr(i) == -(nr+1)) then - nz = (acsr%irp(i+1)-acsr%irp(i)) - if (nz == 1) cycle step2 - icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) - val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) - - ! - ! Find the most strongly connected neighbour that is - ! already aggregated, if any, and join its aggregate - ! - cpling = szero - ip = 0 - do k=1, nz - j = icol(k) - if ((1<=j).and.(j<=nr)) then - if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))& - & .and. (tmpaggr(j) > 0).and. (abs(val(k)) > cpling)) then - ip = k - cpling = abs(val(k)) - end if - end if - enddo - if (ip > 0) then - ilaggr(i) = ilaggr(icol(ip)) - end if - end if - end do step2 - - - ! - ! Phase three: sweep over leftovers, if any - ! - step3: do ii=1,nr - i = idxs(ii) - - if (ilaggr(i) < 0) then - nz = (acsr%irp(i+1)-acsr%irp(i)) - if (nz == 1) cycle step3 - icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) - val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) - ! - ! Find its strongly connected neighbourhood not - ! already aggregated, and make it into a new aggregate. - ! - cpling = szero - ip = 0 - do k=1, nz - j = icol(k) - if ((1<=j).and.(j<=nr)) then - if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))& - & .and. (ilaggr(j) < 0)) then - ip = ip + 1 - icol(ip) = icol(k) - end if - end if - enddo - if (ip > 0) then - icnt = icnt + 1 - naggr = naggr + 1 - ilaggr(i) = naggr - do k=1, ip - ilaggr(icol(k)) = naggr - end do - else - ! - ! This should not happen: we did not even connect with ourselves, - ! but it's not a singleton. - ! - naggr = naggr + 1 - ilaggr(i) = naggr - end if - end if - end do step3 - - ! Any leftovers? - do i=1, nr - if (ilaggr(i) < 0) then - nz = (acsr%irp(i+1)-acsr%irp(i)) - if (nz == 1) then - ! Mark explicitly as a singleton so that - ! it will be ignored in map_to_tprol. - ! Need to use -(nrglob+nr) to make sure - ! it's still negative when shifted and combined with - ! other processes. - ilaggr(i) = -(nrglob+nr) - else - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers') - goto 9999 - endif - end if - end do - - if (naggr > ncol) then - !write(0,*) name,'Error : naggr > ncol',naggr,ncol - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Fatal error: naggr>ncol') - goto 9999 - end if - - call psb_realloc(ncol,ilaggr,info) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_realloc' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - allocate(nlaggr(np),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),& - & a_err='integer') - goto 9999 - end if - - nlaggr(:) = 0 - nlaggr(me+1) = naggr - call psb_sum(ictxt,nlaggr(1:np)) - - call acsr%free() - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_soc1_map_bld - diff --git a/mlprec/impl/aggregator/mld_c_soc2_map_bld.f90 b/mlprec/impl/aggregator/mld_c_soc2_map_bld.f90 deleted file mode 100644 index 81b43da5..00000000 --- a/mlprec/impl/aggregator/mld_c_soc2_map_bld.f90 +++ /dev/null @@ -1,348 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_c_soc2_map__bld.f90 -! -! Subroutine: mld_c_soc2_map_bld -! Version: complex -! -! The aggregator object hosts the aggregation method for building -! the multilevel hierarchy. This variant is based on the method -! presented in -! -! S. Gratton, P. Henon, P. Jiranek and X. Vasseur: -! Reducing complexity of algebraic multigrid by aggregation -! Numerical Lin. Algebra with Applications, 2016, 23:501-518 -! -! Note: upon exit -! -! Arguments: -! a - type(psb_cspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_cprec_type), input/output. -! The preconditioner data structure; upon exit it contains -! the multilevel hierarchy of prolongators, restrictors -! and coarse matrices. -! info - integer, output. -! Error code. -! -! -! -subroutine mld_c_soc2_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) - - use psb_base_mod - use mld_base_prec_type - use mld_c_inner_mod - - implicit none - - ! Arguments - integer(psb_ipk_), intent(in) :: iorder - logical, intent(in) :: clean_zeros - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - real(psb_spk_), intent(in) :: theta - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),& - & ideg(:), idxs(:) - integer(psb_lpk_), allocatable :: tmpaggr(:) - complex(psb_spk_), allocatable :: val(:), diag(:) - integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr,nc,naggr,i,j,m, nz, ilg, ii, ip, ip1,nzcnt - integer(psb_lpk_) :: nrglob - type(psb_c_csr_sparse_mat) :: acsr, muij, s_neigh - type(psb_c_coo_sparse_mat) :: s_neigh_coo - real(psb_spk_) :: cpling, tcl - logical :: disjoint - integer(psb_ipk_) :: debug_level, debug_unit,err_act - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: nrow, ncol, n_ne - character(len=20) :: name, ch_err - - info=psb_success_ - name = 'mld_soc2_map_bld' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ! - ictxt=desc_a%get_context() - call psb_info(ictxt,me,np) - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - nrglob = desc_a%get_global_rows() - - nr = a%get_nrows() - nc = a%get_ncols() - allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),icol(nc),stat=info) - if(info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),& - & a_err='integer') - goto 9999 - end if - - diag = a%get_diag(info) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='psb_sp_getdiag') - goto 9999 - end if - - ! - ! Phase zero: compute muij - ! - call a%cp_to(muij) - if (clean_zeros) call muij%clean_zeros(info) - do i=1, nr - do k=muij%irp(i),muij%irp(i+1)-1 - j = muij%ja(k) - if (j<= nr) muij%val(k) = abs(muij%val(k))/sqrt(abs(diag(i)*diag(j))) - end do - end do - - ! - ! Compute the 1-neigbour; mark strong links with +1, weak links with -1 - ! - call s_neigh_coo%allocate(nr,nr,muij%get_nzeros()) - ip = 0 - do i=1, nr - do k=muij%irp(i),muij%irp(i+1)-1 - j = muij%ja(k) - if (j<=nr) then - ip = ip + 1 - s_neigh_coo%ia(ip) = i - s_neigh_coo%ja(ip) = j - if (real(muij%val(k)) >= theta) then - s_neigh_coo%val(ip) = sone - else - s_neigh_coo%val(ip) = -sone - end if - end if - end do - end do - !write(*,*) 'S_NEIGH: ',nr,ip - call s_neigh_coo%set_nzeros(ip) - call s_neigh%mv_from_coo(s_neigh_coo,info) - - if (iorder == mld_aggr_ord_nat_) then - do i=1, nr - ilaggr(i) = -(nr+1) - idxs(i) = i - end do - else - do i=1, nr - ilaggr(i) = -(nr+1) - ideg(i) = muij%irp(i+1) - muij%irp(i) - end do - call psb_msort(ideg,ix=idxs,dir=psb_sort_down_) - end if - - - ! - ! Phase one: Start with disjoint groups. - ! - naggr = 0 - icnt = 0 - step1: do ii=1, nr - i = idxs(ii) - - if (ilaggr(i) == -(nr+1)) then - ! - ! Get the 1-neighbourhood of I - ! - ip1 = s_neigh%irp(i) - nz = s_neigh%irp(i+1)-ip1 - ! - ! If the neighbourhood only contains I, skip it - ! - if (nz ==0) then - ilaggr(i) = 0 - cycle step1 - end if - if ((nz==1).and.(s_neigh%ja(ip1)==i)) then - ilaggr(i) = 0 - cycle step1 - end if - ! - ! If the whole strongly coupled neighborhood of I is - ! as yet unconnected, turn it into the next aggregate. - ! - nzcnt = count(real(s_neigh%val(ip1:ip1+nz-1)) > 0) - icol(1:nzcnt) = pack(s_neigh%ja(ip1:ip1+nz-1),(real(s_neigh%val(ip1:ip1+nz-1)) > 0)) - disjoint = all(ilaggr(icol(1:nzcnt)) == -(nr+1)) - if (disjoint) then - icnt = icnt + 1 - naggr = naggr + 1 - do k=1, nzcnt - ilaggr(icol(k)) = naggr - end do - ilaggr(i) = naggr - end if - endif - enddo step1 - - if (debug_level >= psb_debug_outer_) then - write(debug_unit,*) me,' ',trim(name),& - & ' Check 1:',count(ilaggr == -(nr+1)) - end if - - ! - ! Phase two: join the neighbours - ! - tmpaggr = ilaggr - step2: do ii=1,nr - i = idxs(ii) - - if (ilaggr(i) == -(nr+1)) then - ! - ! Find the most strongly connected neighbour that is - ! already aggregated, if any, and join its aggregate - ! - cpling = szero - ip = 0 - do k=s_neigh%irp(i), s_neigh%irp(i+1)-1 - j = s_neigh%ja(k) - if ((1<=j).and.(j<=nr)) then - if ( (tmpaggr(j) > 0).and. (real(muij%val(k)) > cpling)& - & .and.(real(s_neigh%val(k))>0)) then - ip = k - cpling = muij%val(k) - end if - end if - enddo - if (ip > 0) then - ilaggr(i) = ilaggr(s_neigh%ja(ip)) - end if - end if - end do step2 - - - ! - ! Phase three: sweep over leftovers, if any - ! - step3: do ii=1,nr - i = idxs(ii) - - if (ilaggr(i) < 0) then - ! - ! Find its strongly connected neighbourhood not - ! already aggregated, and make it into a new aggregate. - ! - ip = 0 - do k=s_neigh%irp(i), s_neigh%irp(i+1)-1 - j = s_neigh%ja(k) - if ((1<=j).and.(j<=nr)) then - if (ilaggr(j) < 0) then - ip = ip + 1 - icol(ip) = j - end if - end if - enddo - if (ip > 0) then - icnt = icnt + 1 - naggr = naggr + 1 - ilaggr(i) = naggr - do k=1, ip - ilaggr(icol(k)) = naggr - end do - end if - end if - end do step3 - - ! Any leftovers? - do i=1, nr - if (ilaggr(i) <= 0) then - nz = (s_neigh%irp(i+1)-s_neigh%irp(i)) - if (nz <= 1) then - ! Mark explicitly as a singleton so that - ! it will be ignored in map_to_tprol. - ! Need to use -(nrglob+nr) to make sure - ! it's still negative when shifted and combined with - ! other processes. - ilaggr(i) = -(nrglob+nr) - else - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers') - goto 9999 - endif - end if - end do - - if (naggr > ncol) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Fatal error: naggr>ncol') - goto 9999 - end if - - call psb_realloc(ncol,ilaggr,info) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_realloc' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - allocate(nlaggr(np),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),& - & a_err='integer') - goto 9999 - end if - - nlaggr(:) = 0 - nlaggr(me+1) = naggr - call psb_sum(ictxt,nlaggr(1:np)) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_soc2_map_bld - diff --git a/mlprec/impl/aggregator/mld_c_symdec_aggregator_tprol.f90 b/mlprec/impl/aggregator/mld_c_symdec_aggregator_tprol.f90 deleted file mode 100644 index 1ca19694..00000000 --- a/mlprec/impl/aggregator/mld_c_symdec_aggregator_tprol.f90 +++ /dev/null @@ -1,160 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_c_symdec_aggregator_tprol.f90 -! -! Subroutine: mld_c_symdec_aggregator_tprol -! Version: complex -! -! -! This routine is mainly an interface to soc_map_bld where the real work is performed. -! It takes care of some consistency checking, and calls map_to_tprol, which is -! refactored and shared among all the aggregation methods that produce a simple -! integer mapping. It also symmetrizes the pattern of the local matrix A. -! -! -! -! Arguments: -! Arguments: -! ag - type(mld_c_dec_aggregator_type), input/output. -! The aggregator object, carrying with itself the mapping algorithm. -! parms - The auxiliary parameters object -! ag_data - Auxiliary global aggregation parameters object -! -! a - type(psb_cspmat_type). -! The sparse matrix structure containing the local part of the -! fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! ilaggr - integer, dimension(:), allocatable, output -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that on exit the indices -! will be shifted so as to make sure the ranges on the various processes do not -! overlap. -! nlaggr - integer, dimension(:), allocatable, output -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_cspmat_type), output -! The tentative prolongator, based on ilaggr. -! -! info - integer, output. -! Error code. -! -subroutine mld_c_symdec_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,op_prol,info) - use psb_base_mod - use mld_c_prec_type - use mld_c_symdec_aggregator_mod, mld_protect_name => mld_c_symdec_aggregator_build_tprol - use mld_c_inner_mod - implicit none - class(mld_c_symdec_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(mld_saggr_data), intent(in) :: ag_data - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lcspmat_type), intent(out) :: op_prol - integer(psb_ipk_), intent(out) :: info - - ! Local variables - type(psb_cspmat_type) :: atmp, atrans - character(len=20) :: name - integer(psb_mpk_) :: ictxt, np, me - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: nr - integer(psb_lpk_) :: ntaggr - integer(psb_ipk_) :: debug_level, debug_unit - logical :: clean_zeros - - name='mld_c_symdec_aggregator_tprol' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - call mld_check_def(parms%ml_cycle,'Multilevel cycle',& - & mld_mult_ml_,is_legal_ml_cycle) - call mld_check_def(parms%par_aggr_alg,'Aggregation',& - & mld_dec_aggr_,is_legal_ml_par_aggr_alg) - call mld_check_def(parms%aggr_ord,'Ordering',& - & mld_aggr_ord_nat_,is_legal_ml_aggr_ord) - call mld_check_def(parms%aggr_thresh,'Aggr_Thresh',szero,is_legal_s_aggr_thrs) - - nr = a%get_nrows() - call a%csclip(atmp,info,imax=nr,jmax=nr,& - & rscale=.false.,cscale=.false.) - call atmp%set_nrows(nr) - call atmp%set_ncols(nr) - if (info == psb_success_) call atmp%transp(atrans) - if (info == psb_success_) call atrans%cscnv(info,type='COO') - if (info == psb_success_) call psb_rwextd(nr,atmp,info,b=atrans,rowscale=.false.) - call atmp%set_nrows(nr) - call atmp%set_ncols(nr) - if (info == psb_success_) call atrans%free() - if (info == psb_success_) call atmp%cscnv(info,type='CSR') - - ! - ! The decoupled aggregator based on SOC measures ignores - ! ag_data except for clean_zeros; soc_map_bld is a procedure pointer. - ! - clean_zeros = ag%do_clean_zeros - if (info == psb_success_) & - & call ag%soc_map_bld(parms%aggr_ord,parms%aggr_thresh,clean_zeros,atmp,& - & desc_a,nlaggr,ilaggr,info) - if (info == psb_success_) call atmp%free() - - if (info == psb_success_) call mld_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='soc_map_bld/map_to_tprol') - goto 9999 - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_c_symdec_aggregator_build_tprol diff --git a/mlprec/impl/aggregator/mld_caggrmat_minnrg_bld.f90 b/mlprec/impl/aggregator/mld_caggrmat_minnrg_bld.f90 deleted file mode 100644 index e33b955e..00000000 --- a/mlprec/impl/aggregator/mld_caggrmat_minnrg_bld.f90 +++ /dev/null @@ -1,656 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_caggrmat_minnrg_bld.F90 -! -! Subroutine: mld_caggrmat_minnrg_bld -! Version: complex -! -! This routine builds a coarse-level matrix A_C from a fine-level matrix A -! by using the Galerkin approach, i.e. -! -! A_C = P_C^T A P_C, -! -! where P_C is a prolongator from the coarse level to the fine one. -! -! The prolongator P_C is built according to a smoothed aggregation algorithm, -! i.e. it is obtained by applying a damped Jacobi smoother to the piecewise -! constant interpolation operator P corresponding to the fine-to-coarse level -! mapping built by the mld_aggrmap_bld subroutine: -! -! P_C = (I - omega*D^(-1)A) * P, -! -! where D is the diagonal matrix with main diagonal equal to the main diagonal -! of A, and omega is a suitable smoothing parameter. An estimate of the spectral -! radius of D^(-1)A, to be used in the computation of omega, is provided, -! according to the value of p%parms%aggr_omega_alg, specified by the user -! through mld_cprecinit and mld_cprecset. -! 4. Minimum energy aggregation: -! M. Sala, R. Tuminaro: A new Petrov-Galerkin smoothed aggregation preconditioner -! for nonsymmetric linear systems, SIAM J. Sci. Comput., 31(1):143-166 (2008) -! -! On output from this routine the entries of AC, op_prol, op_restr -! are still in "global numbering" mode; this is fixed in the calling routine -! aggregator%mat_bld. -! -! -! Arguments: -! a - type(psb_cspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! p - type(mld_c_onelev_type), input/output. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! parms - type(mld_sml_parms), input -! Parameters controlling the choice of algorithm -! ac - type(psb_cspmat_type), output -! The coarse matrix on output -! -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_cspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_cspmat_type), output -! The restrictor operator; in this particular case, it is different -! from the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -! -subroutine mld_caggrmat_minnrg_bld(a,desc_a,ilaggr,nlaggr,parms,& - & ac,desc_ac,op_prol,op_restr,info) - use psb_base_mod - use mld_base_prec_type - use mld_c_inner_mod, mld_protect_name => mld_caggrmat_minnrg_bld - - implicit none - - ! Arguments - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(mld_sml_parms), intent(inout) :: parms - type(psb_lcspmat_type), intent(inout) :: op_prol - type(psb_lcspmat_type), intent(out) :: ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nzac, ip, ndx,& - & naggr, nzl,naggrm1,naggrp1, i, j, k, jd, icolF, nrt - integer(psb_ipk_) :: ictxt,np,me, icomm - character(len=20) :: name - type(psb_lcspmat_type) :: la, af, ptilde, rtilde, atran, atp, atdatp - type(psb_lcspmat_type) :: am3,am4, ap, adap,atmp,rada, ra, atmp2, dap, dadap, da - type(psb_lcspmat_type) :: dat, datp, datdatp, atmp3, tmp_prol - type(psb_lc_coo_sparse_mat) :: tmpcoo - type(psb_lc_csr_sparse_mat) :: acsr1, acsr2, acsr3, acsr, acsrf - type(psb_lc_csc_sparse_mat) :: csc_dap, csc_dadap, csc_datp, csc_datdatp, acsc - complex(psb_spk_), allocatable :: adiag(:), adinv(:) - complex(psb_spk_), allocatable :: omf(:), omp(:), omi(:), oden(:) - logical :: filter_mat - integer(psb_ipk_) :: ierr(5) - integer(psb_ipk_) :: debug_level, debug_unit, err_act - integer(psb_ipk_), parameter :: ncmax=16 - real(psb_spk_) :: anorm, theta - complex(psb_spk_) :: tmp, alpha, beta, ommx - - name='mld_aggrmat_minnrg' - info=psb_success_ - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - ictxt = desc_a%get_context() - - call psb_info(ictxt, me, np) - - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - theta = parms%aggr_thresh - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - - filter_mat = (parms%aggr_filter == mld_filter_mat_) - - ! naggr: number of local aggregates - ! nrow: local rows. - ! - allocate(adinv(ncol),& - & omf(ncol),omp(ntaggr),oden(ntaggr),omi(ncol),stat=info) - - if (info /= psb_success_) then - info=psb_err_alloc_request_; ierr(1)=6*ncol+ntaggr; - call psb_errpush(info,name,i_err=ierr,a_err='complex(psb_spk_)') - goto 9999 - end if - - ! Get the diagonal D - adiag = a%get_diag(info) - if (info == psb_success_) & - & call psb_realloc(ncol,adiag,info) - if (info == psb_success_) & - & call psb_halo(adiag,desc_a,info) - if (info == psb_success_) call a%cp_to_l(la) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_getdiag') - goto 9999 - end if - - do i=1,size(adiag) - if (adiag(i) /= czero) then - adinv(i) = cone / adiag(i) - else - adinv(i) = cone - end if - end do - - - - ! 1. Allocate Ptilde in sparse matrix form - call op_prol%mv_to(tmpcoo) - call ptilde%mv_from(tmpcoo) - call ptilde%cscnv(info,type='csr') - - if (info == psb_success_) call la%cscnv(am3,info,type='csr',dupl=psb_dupl_add_) - if (info == psb_success_) call la%cscnv(da,info,type='csr',dupl=psb_dupl_add_) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' Initial copies done.' - - call da%scal(adinv,info) - - call psb_spspmm(da,ptilde,dap,info) - - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 1') - goto 9999 - end if - - call dap%clone(atmp,info) - - call psb_sphalo(atmp,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.,outfmt='CSR ') - if (info == psb_success_) call psb_rwextd(ncol,atmp,info,b=am4) - if (info == psb_success_) call am4%free() - - call psb_spspmm(da,atmp,dadap,info) - call atmp%free() - - ! !$ write(0,*) 'Columns of AP',psb_sp_get_ncols(ap) - ! !$ write(0,*) 'Columns of ADAP',psb_sp_get_ncols(adap) - call dap%mv_to(csc_dap) - call dadap%mv_to(csc_dadap) - - call csc_mat_col_prod(csc_dap,csc_dadap,omp,info) - call csc_mat_col_prod(csc_dadap,csc_dadap,oden,info) - call psb_sum(ictxt,omp) - call psb_sum(ictxt,oden) - ! !$ write(0,*) trim(name),' OMP :',omp - ! !$ write(0,*) trim(name),' ODEN:',oden - - omp = omp/oden - - ! !$ write(0,*) 'Check on output prolongator ',omp(1:min(size(omp),10)) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done NUMBMM 1' - - call am3%mv_to(acsr3) - ! Compute omega_int - ommx = czero - do i=1, ncol - if (ilaggr(i) >0) then - omi(i) = omp(ilaggr(i)) - else - omi(i) = czero - end if - if(abs(omi(i)) .gt. abs(ommx)) ommx = omi(i) - end do - ! Compute omega_fine - do i=1, nrow - omf(i) = ommx - do j=acsr3%irp(i),acsr3%irp(i+1)-1 - if(abs(omi(acsr3%ja(j))) .lt. abs(omf(i))) omf(i)=omi(acsr3%ja(j)) - end do -!!$ if(min(real(omf(i)),aimag(omf(i))) < szero) omf(i) = czero - if(psb_minreal(omf(i)) < szero) omf(i) = czero - end do - - omf(1:nrow) = omf(1:nrow) * adinv(1:nrow) - - if (filter_mat) then - ! - ! Build the filtered matrix Af from A - ! - call la%cscnv(acsrf,info,dupl=psb_dupl_add_) - - do i=1,nrow - tmp = czero - jd = -1 - do j=acsrf%irp(i),acsrf%irp(i+1)-1 - if (acsrf%ja(j) == i) jd = j - if (abs(acsrf%val(j)) < theta*sqrt(abs(adiag(i)*adiag(acsrf%ja(j))))) then - tmp=tmp+acsrf%val(j) - acsrf%val(j)=czero - endif - enddo - if (jd == -1) then - write(0,*) 'Wrong input: we need the diagonal!!!!', i - else - acsrf%val(jd)=acsrf%val(jd)-tmp - end if - enddo - ! Take out zeroed terms - call acsrf%clean_zeros(info) - - ! - ! Build the smoothed prolongator using the filtered matrix - ! - do i=1,acsrf%get_nrows() - do j=acsrf%irp(i),acsrf%irp(i+1)-1 - if (acsrf%ja(j) == i) then - acsrf%val(j) = cone - omf(i)*acsrf%val(j) - else - acsrf%val(j) = - omf(i)*acsrf%val(j) - end if - end do - end do - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done gather, going for SYMBMM 1' - - call af%mv_from(acsrf) - ! - ! op_prol = (I-w*D*Af)Ptilde - ! Doing it this way means to consider diag(Af_i) - ! - ! - call psb_spspmm(af,ptilde,op_prol,info) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done SPSPMM 1' - else - ! - ! Build the smoothed prolongator using the original matrix - ! - do i=1,acsr3%get_nrows() - do j=acsr3%irp(i),acsr3%irp(i+1)-1 - if (acsr3%ja(j) == i) then - acsr3%val(j) = cone - omf(i)*acsr3%val(j) - else - acsr3%val(j) = - omf(i)*acsr3%val(j) - end if - end do - end do - - call am3%mv_from(acsr3) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done gather, going for SYMBMM 1' - ! - ! - ! op_prol = (I-w*D*A)Ptilde - ! - ! - call psb_spspmm(am3,ptilde,op_prol,info) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done NUMBMM 1' - - end if - - - ! - ! Ok, let's start over with the restrictor - ! - call ptilde%transc(rtilde) - call la%cscnv(atmp,info,type='csr') - call psb_sphalo(atmp,desc_a,am4,info,& - & colcnv=.true.,rowscale=.true.) - nrt = am4%get_nrows() - call am4%csclip(atmp2,info,lone,nrt,lone,ncol) - call atmp2%cscnv(info,type='CSR') - if (info == psb_success_) call psb_rwextd(ncol,atmp,info,b=atmp2) - call am4%free() - call atmp2%free() - - ! This is to compute the transpose. It ONLY works if the - ! original A has a symmetric pattern. - call atmp%transc(atmp2) - call atmp2%csclip(dat,info,lone,nrow,lone,ncol) - call dat%cscnv(info,type='csr') - call dat%scal(adinv,info) - - ! Now for the product. - call psb_spspmm(dat,ptilde,datp,info) - - call datp%clone(atmp2,info) - call psb_sphalo(atmp2,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.,outfmt='CSR ') - if (info == psb_success_) call psb_rwextd(ncol,atmp2,info,b=am4) - if (info == psb_success_) call am4%free() - - - call psb_symbmm(dat,atmp2,datdatp,info) - call psb_numbmm(dat,atmp2,datdatp) - call atmp2%free() - - call datp%mv_to(csc_datp) - call datdatp%mv_to(csc_datdatp) - - call csc_mat_col_prod(csc_datp,csc_datdatp,omp,info) - call csc_mat_col_prod(csc_datdatp,csc_datdatp,oden,info) - call psb_sum(ictxt,omp) - call psb_sum(ictxt,oden) - - - ! !$ write(debug_unit,*) trim(name),' OMP_R :',omp - ! ! $ write(debug_unit,*) trim(name),' ODEN_R:',oden - omp = omp/oden - ! !$ write(0,*) 'Check on output restrictor',omp(1:min(size(omp),10)) - ! Compute omega_int - ommx = czero - do i=1, ncol - if (ilaggr(i) >0) then - omi(i) = omp(ilaggr(i)) - else - omi(i) = czero - end if - if(abs(omi(i)) .gt. abs(ommx)) ommx = omi(i) - end do - ! Compute omega_fine - ! Going over the columns of atmp means going over the rows - ! of A^T. Hopefully ;-) - call atmp%cp_to(acsc) - - do i=1, nrow - omf(i) = ommx - do j= acsc%icp(i),acsc%icp(i+1)-1 - if(abs(omi(acsc%ia(j))) .lt. abs(omf(i))) omf(i)=omi(acsc%ia(j)) - end do -!!$ if(min(real(omf(i)),aimag(omf(i))) < szero) omf(i) = czero - if(psb_minreal(omf(i)) < szero) omf(i) = czero - end do - omf(1:nrow) = omf(1:nrow)*adinv(1:nrow) - call psb_halo(omf,desc_a,info) - call acsc%free() - - - call atmp%mv_to(acsr1) - - do i=1,acsr1%get_nrows() - do j=acsr1%irp(i),acsr1%irp(i+1)-1 - if (acsr1%ja(j) == i) then - acsr1%val(j) = cone - acsr1%val(j)*omf(acsr1%ja(j)) - else - acsr1%val(j) = - acsr1%val(j)*omf(acsr1%ja(j)) - end if - end do - end do - call atmp%mv_from(acsr1) - - call rtilde%mv_to(tmpcoo) - nzl = tmpcoo%get_nzeros() - i=0 - do k=1, nzl - if ((naggrm1 < tmpcoo%ia(k)) .and. (tmpcoo%ia(k) <= naggrp1)) then - i = i+1 - tmpcoo%val(i) = tmpcoo%val(k) - tmpcoo%ia(i) = tmpcoo%ia(k) - tmpcoo%ja(i) = tmpcoo%ja(k) - end if - end do - call tmpcoo%set_nzeros(i) - call rtilde%mv_from(tmpcoo) - call rtilde%cscnv(info,type='csr') - - call psb_spspmm(rtilde,atmp,op_restr,info) - - ! - ! Now we have to gather the halo of op_prol, and add it to itself - ! to multiply it by A, - ! - call op_prol%clone(tmp_prol,info) - if (info == psb_success_) call psb_sphalo(tmp_prol,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.) - if (info == psb_success_) call psb_rwextd(ncol,tmp_prol,info,b=am4) - if (info == psb_success_) call am4%free() - - if(info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Halo of op_prol') - goto 9999 - end if - - ! - ! Now we have to fix this. The only rows of B that are correct - ! are those corresponding to "local" aggregates, i.e. indices in ilaggr(:) - ! - call op_restr%mv_to(tmpcoo) - - nzl = tmpcoo%get_nzeros() - i=0 - do k=1, nzl - if ((naggrm1 < tmpcoo%ia(k)) .and. (tmpcoo%ia(k) <= naggrp1)) then - i = i+1 - tmpcoo%val(i) = tmpcoo%val(k) - tmpcoo%ia(i) = tmpcoo%ia(k) - tmpcoo%ja(i) = tmpcoo%ja(k) - end if - end do - call tmpcoo%set_nzeros(i) - call op_restr%mv_from(tmpcoo) - call op_restr%cscnv(info,type='csr') - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - call psb_spspmm(la,tmp_prol,am3,info) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done SPSPMM 2' - - call psb_sphalo(am3,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.) - if (info == psb_success_) call psb_rwextd(ncol,am3,info,b=am4) - if (info == psb_success_) call am4%free() - - if(info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Extend am3') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done sphalo/ rwxtd' - - call psb_spspmm(op_restr,am3,ac,info) - if (info == psb_success_) call am3%free() - if (info == psb_success_) call ac%cscnv(info,type='coo',dupl=psb_dupl_add_) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - &a_err='Build ac = op_restr x am3') - goto 9999 - end if - - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done smooth_aggregate ' - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_errpush(info,name) - call psb_error_handler(err_act) - return - - -contains - - subroutine csc_mat_col_prod(a,b,v,info) - implicit none - type(psb_lc_csc_sparse_mat), intent(in) :: a, b - complex(psb_spk_), intent(out) :: v(:) - integer(psb_ipk_), intent(out) :: info - - integer(psb_lpk_) :: i,j,k, nr, nc,iap,nra,ibp,nrb - - info = psb_success_ - nc = a%get_ncols() - if (nc /= b%get_ncols()) then - write(0,*) 'Matrices A and B should have same columns' - info = -1 - return - end if - - do j=1, nc - iap = a%icp(j) - nra = a%icp(j+1)-iap - ibp = b%icp(j) - nrb = b%icp(j+1)-ibp - v(j) = sparse_srtd_dot(nra,a%ia(iap:iap+nra-1),a%val(iap:iap+nra-1),& - & nrb,b%ia(ibp:ibp+nrb-1),b%val(ibp:ibp+nrb-1)) - end do - - end subroutine csc_mat_col_prod - - - subroutine csr_mat_row_prod(a,b,v,info) - implicit none - type(psb_lc_csr_sparse_mat), intent(in) :: a, b - complex(psb_spk_), intent(out) :: v(:) - integer(psb_ipk_), intent(out) :: info - - integer(psb_lpk_) :: i,j,k, nr, nc,iap,nca,ibp,ncb - - info = psb_success_ - nr = a%get_nrows() - if (nr /= b%get_nrows()) then - write(0,*) 'Matrices A and B should have same rows' - info = -1 - return - end if - - do j=1, nr - iap = a%irp(j) - nca = a%irp(j+1)-iap - ibp = b%irp(j) - ncb = b%irp(j+1)-ibp - v(j) = sparse_srtd_dot(nca,a%ja(iap:iap+nca-1),a%val(iap:iap+nca-1),& - & ncb,b%ja(ibp:ibp+ncb-1),b%val(ibp:ibp+ncb-1)) - end do - - end subroutine csr_mat_row_prod - - - function sparse_srtd_dot(nv1,iv1,v1,nv2,iv2,v2) result(dot) - implicit none - integer(psb_lpk_), intent(in) :: nv1,nv2 - integer(psb_lpk_), intent(in) :: iv1(:), iv2(:) - complex(psb_spk_), intent(in) :: v1(:),v2(:) - complex(psb_spk_) :: dot - - integer(psb_lpk_) :: i,j,k, ip1, ip2 - - dot = czero - ip1 = 1 - ip2 = 1 - - do - if (ip1 > nv1) exit - if (ip2 > nv2) exit - if (iv1(ip1) == iv2(ip2)) then - dot = dot + conjg(v1(ip1))*v2(ip2) - ip1 = ip1 + 1 - ip2 = ip2 + 1 - else if (iv1(ip1) < iv2(ip2)) then - ip1 = ip1 + 1 - else - ip2 = ip2 + 1 - end if - end do - - end function sparse_srtd_dot - - subroutine local_dump(me,mat,name,header) - type(psb_lcspmat_type), intent(in) :: mat - integer(psb_ipk_), intent(in) :: me - character(len=*), intent(in) :: name - character(len=*), intent(in) :: header - character(len=80) :: filename - - write(filename,'(a,a,i0,a,i0,a)') trim(name),'.p',me - open(20+me,file=filename) - call mat%print(20+me,head=trim(header)) - close(20+me) - end subroutine local_dump - -end subroutine mld_caggrmat_minnrg_bld diff --git a/mlprec/impl/aggregator/mld_caggrmat_nosmth_bld.f90 b/mlprec/impl/aggregator/mld_caggrmat_nosmth_bld.f90 deleted file mode 100644 index 896cdcae..00000000 --- a/mlprec/impl/aggregator/mld_caggrmat_nosmth_bld.f90 +++ /dev/null @@ -1,198 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_caggrmat_nosmth_bld.F90 -! -! Subroutine: mld_caggrmat_nosmth_bld -! Version: complex -! -! This routine builds a coarse-level matrix A_C from a fine-level matrix A -! by using the Galerkin approach, i.e. -! -! A_C = P_C^T A P_C, -! -! where P_C is the piecewise constant interpolation operator corresponding -! the fine-to-coarse level mapping built by mld_aggrmap_bld. -! -! The coarse-level matrix A_C is distributed among the parallel processes or -! replicated on each of them, according to the value of p%parms%coarse_mat -! specified by the user through mld_cprecinit and mld_zprecset. -! On output from this routine the entries of AC, op_prol, op_restr -! are still in "global numbering" mode; this is fixed in the calling routine -! aggregator%mat_bld. -! -! For details see -! P. D'Ambra, D. di Serafino and S. Filippone, On the development of -! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math., -! 57 (2007), 1181-1196. -! -! -! Arguments: -! a - type(psb_cspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! p - type(mld_c_onelev_type), input/output. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! parms - type(mld_sml_parms), input -! Parameters controlling the choice of algorithm -! ac - type(psb_cspmat_type), output -! The coarse matrix on output -! -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_cspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_cspmat_type), output -! The restrictor operator; normally, it is the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -! -subroutine mld_caggrmat_nosmth_bld(a,desc_a,ilaggr,nlaggr,parms,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - use psb_base_mod - use mld_base_prec_type - use mld_c_inner_mod, mld_protect_name => mld_caggrmat_nosmth_bld - use mld_c_base_aggregator_mod - implicit none - - ! Arguments - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(mld_sml_parms), intent(inout) :: parms - type(psb_cspmat_type), intent(inout) :: op_prol,ac,op_restr - type(psb_lcspmat_type), intent(inout) :: t_prol - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt, np, me, icomm, minfo - character(len=20) :: name - type(psb_lc_coo_sparse_mat) :: lcoo_prol - type(psb_c_coo_sparse_mat) :: coo_prol, coo_restr - type(psb_c_csr_sparse_mat) :: acsr - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nzl, ip, & - & naggr, nzt, naggrm1, naggrp1, i, k - integer(psb_ipk_) :: inaggr, nzlp - logical, parameter :: debug = .false. - - name = 'mld_aggrmat_nosmth_bld' - info = psb_success_ - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - call psb_info(ictxt, me, np) - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - - call a%cp_to(acsr) - call t_prol%mv_to(lcoo_prol) - inaggr = naggr - call psb_cdall(ictxt,desc_ac,info,nl=inaggr) - nzlp = lcoo_prol%get_nzeros() - call desc_ac%indxmap%g2lip_ins(lcoo_prol%ja(1:nzlp),info) - call lcoo_prol%set_ncols(desc_ac%get_local_cols()) - call lcoo_prol%cp_to_icoo(coo_prol,info) - - if (debug) call check_coo(me,trim(name)//' Check 1 on coo_prol:',coo_prol) - - call psb_cdasb(desc_ac,info) - call psb_cd_reinit(desc_ac,info) - - call mld_ptap(acsr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info) - - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_a%get_local_cols()) - call coo_prol%set_nrows(desc_a%get_local_rows()) - call coo_prol%set_ncols(desc_ac%get_local_cols()) - - if (debug) call check_coo(me,trim(name)//' Check 1 on coo_restr:',coo_restr) - - call op_prol%mv_from(coo_prol) - call op_restr%mv_from(coo_restr) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_c_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo -end subroutine mld_caggrmat_nosmth_bld diff --git a/mlprec/impl/aggregator/mld_caggrmat_smth_bld.f90 b/mlprec/impl/aggregator/mld_caggrmat_smth_bld.f90 deleted file mode 100644 index 4497ba41..00000000 --- a/mlprec/impl/aggregator/mld_caggrmat_smth_bld.f90 +++ /dev/null @@ -1,325 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_caggrmat_smth_bld.F90 -! -! Subroutine: mld_caggrmat_smth_bld -! Version: complex -! -! This routine builds a coarse-level matrix A_C from a fine-level matrix A -! by using the Galerkin approach, i.e. -! -! A_C = P_C^T A P_C, -! -! where P_C is a prolongator from the coarse level to the fine one. -! -! The prolongator P_C is built according to a smoothed aggregation algorithm, -! i.e. it is obtained by applying a damped Jacobi smoother to the piecewise -! constant interpolation operator P corresponding to the fine-to-coarse level -! mapping built by the mld_aggrmap_bld subroutine: -! -! P_C = (I - omega*D^(-1)A) * P, -! -! where D is the diagonal matrix with main diagonal equal to the main diagonal -! of A, and omega is a suitable smoothing parameter. An estimate of the spectral -! radius of D^(-1)A, to be used in the computation of omega, is provided, -! according to the value of p%parms%aggr_omega_alg, specified by the user -! through mld_cprecinit and mld_zprecset. -! -! The coarse-level matrix A_C is distributed among the parallel processes or -! replicated on each of them, according to the value of p%parms%coarse_mat, -! specified by the user through mld_cprecinit and mld_zprecset. -! On output from this routine the entries of AC, op_prol, op_restr -! are still in "global numbering" mode; this is fixed in the calling routine -! aggregator%mat_bld. -! -! -! Arguments: -! a - type(psb_cspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! p - type(mld_c_onelev_type), input/output. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! parms - type(mld_sml_parms), input -! Parameters controlling the choice of algorithm -! ac - type(psb_cspmat_type), output -! The coarse matrix on output -! -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_cspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_cspmat_type), output -! The restrictor operator; normally, it is the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -subroutine mld_caggrmat_smth_bld(a,desc_a,ilaggr,nlaggr,parms,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - use psb_base_mod - use mld_base_prec_type - use mld_c_inner_mod, mld_protect_name => mld_caggrmat_smth_bld - use mld_c_base_aggregator_mod - - implicit none - - ! Arguments - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(mld_sml_parms), intent(inout) :: parms - type(psb_cspmat_type), intent(out) :: op_prol,ac,op_restr - type(psb_lcspmat_type), intent(inout) :: t_prol - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, ip, & - & naggr, nzl,naggrm1,naggrp1, i, j, k, jd, icolF, nrw - integer(psb_ipk_) :: inaggr, nzlp - integer(psb_ipk_) :: ictxt, np, me - character(len=20) :: name - type(psb_lc_coo_sparse_mat) :: tmpcoo - type(psb_c_coo_sparse_mat) :: coo_prol, coo_restr - type(psb_c_csr_sparse_mat) :: acsr1, acsrf, csr_prol, acsr - complex(psb_spk_), allocatable :: adiag(:) - real(psb_spk_), allocatable :: arwsum(:) - integer(psb_ipk_) :: ierr(5) - logical :: filter_mat - integer(psb_ipk_) :: debug_level, debug_unit, err_act - integer(psb_ipk_), parameter :: ncmax=16 - real(psb_spk_) :: anorm, omega, tmp, dg, theta - logical, parameter :: debug_new=.false. - character(len=80) :: filename - - name='mld_aggrmat_smth_bld' - info=psb_success_ - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - ictxt = desc_a%get_context() - - call psb_info(ictxt, me, np) - - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - theta = parms%aggr_thresh - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - filter_mat = (parms%aggr_filter == mld_filter_mat_) - - ! - ! naggr: number of local aggregates - ! nrow: local rows. - ! - - ! Get the diagonal D - adiag = a%get_diag(info) - if (info == psb_success_) & - & call psb_realloc(ncol,adiag,info) - if (info == psb_success_) & - & call psb_halo(adiag,desc_a,info) - if (info == psb_success_) call a%cp_to(acsr) - - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_getdiag') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' Initial copies done.' - - call acsr%cp_to_fmt(acsrf,info) - - - if (filter_mat) then - ! - ! Build the filtered matrix Af from A - ! - - do i=1, nrow - tmp = czero - jd = -1 - do j=acsrf%irp(i),acsrf%irp(i+1)-1 - if (acsrf%ja(j) == i) jd = j - if (abs(acsrf%val(j)) < theta*sqrt(abs(adiag(i)*adiag(acsrf%ja(j))))) then - tmp=tmp+acsrf%val(j) - acsrf%val(j)=czero - endif - - enddo - if (jd == -1) then - write(0,*) 'Wrong input: we need the diagonal!!!!', i - else - acsrf%val(jd)=acsrf%val(jd)-tmp - end if - enddo - ! Take out zeroed terms - call acsrf%clean_zeros(info) - end if - - - do i=1,size(adiag) - if (adiag(i) /= czero) then - adiag(i) = cone / adiag(i) - else - adiag(i) = cone - end if - end do - - if (parms%aggr_omega_alg == mld_eig_est_) then - - if (parms%aggr_eig == mld_max_norm_) then - allocate(arwsum(nrow)) - call acsr%arwsum(arwsum) - anorm = maxval(abs(adiag(1:nrow)*arwsum(1:nrow))) - call psb_amx(ictxt,anorm) - omega = 4.d0/(3.d0*anorm) - parms%aggr_omega_val = omega - - else - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_aggr_eig_') - goto 9999 - end if - - else if (parms%aggr_omega_alg == mld_user_choice_) then - - omega = parms%aggr_omega_val - - else if (parms%aggr_omega_alg /= mld_user_choice_) then - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_aggr_omega_alg_') - goto 9999 - end if - - - call acsrf%scal(adiag,info) - if (info /= psb_success_) goto 9999 - - call t_prol%mv_to(tmpcoo) - inaggr = naggr - call psb_cdall(ictxt,desc_ac,info,nl=inaggr) - nzlp = tmpcoo%get_nzeros() - call desc_ac%indxmap%g2lip_ins(tmpcoo%ja(1:nzlp),info) - call tmpcoo%set_ncols(desc_ac%get_local_cols()) - call tmpcoo%mv_to_ifmt(csr_prol,info) - - call psb_cdasb(desc_ac,info) - call psb_cd_reinit(desc_ac,info) - ! - ! Build the smoothed prolongator using either A or Af - ! acsr1 = (I-w*D*A) Prol acsr1 = (I-w*D*Af) Prol - ! This is always done through the variable acsrf which - ! is a bit less readable, but saves space and one matrix copy - ! - call omega_smooth(omega,acsrf) - call psb_par_spspmm(acsrf,desc_a,csr_prol,acsr1,desc_ac,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 1') - goto 9999 - end if - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done SPSPMM 1' - nzl = acsr1%get_nzeros() - call acsr1%mv_to_coo(coo_prol,info) - - call mld_ptap(acsr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info) - - call op_prol%mv_from(coo_prol) - call op_restr%mv_from(coo_restr) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done smooth_aggregate ' - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_errpush(info,name) - call psb_error_handler(err_act) - return - -contains - - subroutine omega_smooth(omega,acsr) - implicit none - real(psb_spk_),intent(in) :: omega - type(psb_c_csr_sparse_mat), intent(inout) :: acsr - ! - integer(psb_lpk_) :: i,j - do i=1,acsr%get_nrows() - do j=acsr%irp(i),acsr%irp(i+1)-1 - if (acsr%ja(j) == i) then - acsr%val(j) = cone - omega*acsr%val(j) - else - acsr%val(j) = - omega*acsr%val(j) - end if - end do - end do - end subroutine omega_smooth - -end subroutine mld_caggrmat_smth_bld diff --git a/mlprec/impl/aggregator/mld_d_dec_aggregator_mat_asb.f90 b/mlprec/impl/aggregator/mld_d_dec_aggregator_mat_asb.f90 deleted file mode 100644 index 61c2a1c3..00000000 --- a/mlprec/impl/aggregator/mld_d_dec_aggregator_mat_asb.f90 +++ /dev/null @@ -1,195 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_d_dec_aggregator_mat_asb.f90 -! -! Subroutine: mld_d_dec_aggregator_mat_asb -! Version: real -! -! -! From a given AC to final format, generating DESC_AC -! -! Arguments: -! ag - type(mld_d_dec_aggregator_type), input/output. -! The aggregator object -! parms - type(mld_dml_parms), input -! The aggregation parameters -! a - type(psb_dspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! ac - type(psb_dspmat_type), inout -! The coarse matrix -! desc_ac - type(psb_desc_type), output. -! The communication descriptor of the fine-level matrix. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! -! op_prol - type(psb_dspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_dspmat_type), input/output -! The restrictor operator; normally, it is the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -subroutine mld_d_dec_aggregator_mat_asb(ag,parms,a,desc_a,& - & ac,desc_ac, op_prol,op_restr,info) - use psb_base_mod - use mld_base_prec_type - use mld_d_dec_aggregator_mod, mld_protect_name => mld_d_dec_aggregator_mat_asb - implicit none - class(mld_d_dec_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - type(psb_dspmat_type), intent(inout) :: op_prol, ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: ictxt, np, me - type(psb_ld_coo_sparse_mat) :: tmpcoo - type(psb_ldspmat_type) :: tmp_ac - integer(psb_ipk_) :: i_nr, i_nc, i_nl, nzl - integer(psb_lpk_) :: ntaggr - integer(psb_ipk_) :: err_act, debug_level, debug_unit - character(len=20) :: name='d_dec_aggregator_mat_asb' - - - if (psb_get_errstatus().ne.0) return - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - select case(parms%coarse_mat) - - case(mld_distr_mat_) - - call ac%cscnv(info,type='csr') - call op_prol%cscnv(info,type='csr') - call op_restr%cscnv(info,type='csr') - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ac ' - - case(mld_repl_mat_) - ! - ! We are assuming here that an d matrix - ! can hold all entries - ! - if (desc_ac%get_global_rows() < huge(1_psb_ipk_) ) then - ntaggr = desc_ac%get_global_rows() - i_nr = ntaggr - else - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_coarse_mat_') - goto 9999 - end if - - call op_prol%mv_to(tmpcoo) - nzl = tmpcoo%get_nzeros() - call psb_loc_to_glob(tmpcoo%ja(1:nzl),desc_ac,info,'I') - call tmpcoo%set_ncols(i_nr) - call op_prol%mv_from(tmpcoo) - - call op_restr%mv_to(tmpcoo) - nzl = tmpcoo%get_nzeros() - call psb_loc_to_glob(tmpcoo%ia(1:nzl),desc_ac,info,'I') - call tmpcoo%set_nrows(i_nr) - call op_restr%mv_from(tmpcoo) - - - call psb_gather(tmp_ac,ac,desc_ac,info,root=-ione,& - & dupl=psb_dupl_add_,keeploc=.false.) - call tmp_ac%mv_to(tmpcoo) - call ac%mv_from(tmpcoo) - - call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) - if (info == psb_success_) call psb_cdasb(desc_ac,info) - - if (info /= psb_success_) goto 9999 - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_coarse_mat_') - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_ld_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo -end subroutine mld_d_dec_aggregator_mat_asb diff --git a/mlprec/impl/aggregator/mld_d_dec_aggregator_mat_bld.f90 b/mlprec/impl/aggregator/mld_d_dec_aggregator_mat_bld.f90 deleted file mode 100644 index a312a6d9..00000000 --- a/mlprec/impl/aggregator/mld_d_dec_aggregator_mat_bld.f90 +++ /dev/null @@ -1,216 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_d_dec_aggregator_mat_bld.f90 -! -! Subroutine: mld_d_dec_aggregator_mat_bld -! Version: real -! -! This routine builds the matrix associated to the current level of the -! multilevel preconditioner from the matrix associated to the previous level, -! by using the user-specified aggregation technique (therefore, it also builds the -! prolongation and restriction operators mapping the current level to the -! previous one and vice versa). -! The current level is regarded as the coarse one, while the previous as -! the fine one. This is in agreement with the fact that the routine is called, -! by mld_mlprec_bld, only on levels >=2. -! The coarse-level matrix A_C is built from a fine-level matrix A -! by using the Galerkin approach, i.e. -! -! A_C = P_C^T A P_C, -! -! where P_C is a prolongator from the coarse level to the fine one. -! -! A mapping from the nodes of the adjacency graph of A to the nodes of the -! adjacency graph of A_C has been computed by the mld_aggrmap_bld subroutine. -! The prolongator P_C is built here from this mapping, according to the -! value of p%iprcparm(mld_aggr_kind_), specified by the user through -! mld_dprecinit and mld_zprecset. -! On output from this routine the entries of AC, op_prol, op_restr -! are still in "global numbering" mode; this is fixed in the calling routine -! mld_d_lev_aggrmat_bld. -! -! Currently four different prolongators are implemented, corresponding to -! four aggregation algorithms: -! 1. un-smoothed aggregation, -! 2. smoothed aggregation, -! 3. "bizarre" aggregation. -! 4. minimum energy -! 1. The non-smoothed aggregation uses as prolongator the piecewise constant -! interpolation operator corresponding to the fine-to-coarse level mapping built -! by p%aggr%bld_tprol. This is called tentative prolongator. -! 2. The smoothed aggregation uses as prolongator the operator obtained by applying -! a damped Jacobi smoother to the tentative prolongator. -! 3. The "bizarre" aggregation uses a prolongator proposed by the authors of MLD2P4. -! This prolongator still requires a deep analysis and testing and its use is -! not recommended. -! 4. Minimum energy aggregation -! -! For more details see -! M. Brezina and P. Vanek, A black-box iterative solver based on a two-level -! Schwarz method, Computing, 63 (1999), 233-263. -! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed -! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 -! (1996), 179-196. -! P. D'Ambra, D. di Serafino and S. Filippone, On the development of PSBLAS-based -! parallel two-level Schwarz preconditioners, Appl. Num. Math., 57 (2007), -! 1181-1196. -! M. Sala, R. Tuminaro: A new Petrov-Galerkin smoothed aggregation preconditioner -! for nonsymmetric linear systems, SIAM J. Sci. Comput., 31(1):143-166 (2008) -! -! -! The main structure is: -! 1. Perform sanity checks; -! 2. Compute prolongator/restrictor/AC -! -! -! Arguments: -! ag - type(mld_d_dec_aggregator_type), input/output. -! The aggregator object -! parms - type(mld_dml_parms), input -! The aggregation parameters -! a - type(psb_dspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! ac - type(psb_dspmat_type), output -! The coarse matrix on output -! -! op_prol - type(psb_dspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_dspmat_type), output -! The restrictor operator; normally, it is the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -subroutine mld_d_dec_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - use psb_base_mod - use mld_d_prec_type, mld_protect_name => mld_d_dec_aggregator_mat_bld - use mld_d_inner_mod - implicit none - - class(mld_d_dec_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(psb_ldspmat_type), intent(inout) :: t_prol - type(psb_dspmat_type), intent(out) :: op_prol,ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - - ! Local variables - character(len=20) :: name - integer(psb_mpk_) :: ictxt, np, me - integer(psb_lpk_) :: nzl,ntaggr - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: debug_level, debug_unit - - name='mld_d_dec_aggregator_mat_bld' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - ! - ! Build the coarse-level matrix from the fine-level one, starting from - ! the mapping defined by mld_aggrmap_bld and applying the aggregation - ! algorithm specified by - ! - select case (parms%aggr_prol) - case (mld_no_smooth_) - - call mld_daggrmat_nosmth_bld(a,desc_a,ilaggr,nlaggr,& - & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) - - case(mld_smooth_prol_) - - call mld_daggrmat_smth_bld(a,desc_a,ilaggr,nlaggr, & - & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) - -!!$ case(mld_biz_prol_) -!!$ -!!$ call mld_daggrmat_biz_bld(a,desc_a,ilaggr,nlaggr, & -!!$ & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) - - case(mld_min_energy_) - - call mld_daggrmat_minnrg_bld(a,desc_a,ilaggr,nlaggr, & - & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='Invalid aggr kind') - goto 9999 - - end select - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='Inner aggrmat bld') - goto 9999 - end if - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - -end subroutine mld_d_dec_aggregator_mat_bld diff --git a/mlprec/impl/aggregator/mld_d_dec_aggregator_tprol.f90 b/mlprec/impl/aggregator/mld_d_dec_aggregator_tprol.f90 deleted file mode 100644 index 0f8eaca5..00000000 --- a/mlprec/impl/aggregator/mld_d_dec_aggregator_tprol.f90 +++ /dev/null @@ -1,139 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_d_dec_aggregator_tprol.f90 -! -! Subroutine: mld_d_dec_aggregator_tprol -! Version: real -! -! This routine is mainly an interface to soc_map_bld where the real work is performed. -! It takes care of some consistency checking, and calls map_to_tprol, which is -! refactored and shared among all the aggregation methods that produce a simple -! integer mapping. -! -! -! Arguments: -! ag - type(mld_d_dec_aggregator_type), input/output. -! The aggregator object, carrying with itself the mapping algorithm. -! parms - The auxiliary parameters object -! ag_data - Auxiliary global aggregation parameters object -! -! -! a - type(psb_dspmat_type). -! The sparse matrix structure containing the local part of the -! fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! ilaggr - integer, dimension(:), allocatable, output -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that on exit the indices -! will be shifted so as to make sure the ranges on the various processes do not -! overlap. -! nlaggr - integer, dimension(:), allocatable, output -! nlaggr(i) contains the aggregates held by process i. -! t_prol - type(psb_dspmat_type), output -! The tentative prolongator, based on ilaggr. -! -! info - integer, output. -! Error code. -! -subroutine mld_d_dec_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,t_prol,info) - use psb_base_mod - use mld_d_prec_type, mld_protect_name => mld_d_dec_aggregator_build_tprol - use mld_d_inner_mod - implicit none - class(mld_d_dec_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(mld_daggr_data), intent(in) :: ag_data - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_ldspmat_type), intent(out) :: t_prol - integer(psb_ipk_), intent(out) :: info - - ! Local variables - character(len=20) :: name - integer(psb_mpk_) :: ictxt, np, me - integer(psb_ipk_) :: err_act - integer(psb_lpk_) :: ntaggr - integer(psb_ipk_) :: debug_level, debug_unit - logical :: clean_zeros - - name='mld_d_dec_aggregator_tprol' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - call mld_check_def(parms%ml_cycle,'Multilevel cycle',& - & mld_mult_ml_,is_legal_ml_cycle) - call mld_check_def(parms%par_aggr_alg,'Aggregation',& - & mld_dec_aggr_,is_legal_ml_par_aggr_alg) - call mld_check_def(parms%aggr_ord,'Ordering',& - & mld_aggr_ord_nat_,is_legal_ml_aggr_ord) - call mld_check_def(parms%aggr_thresh,'Aggr_Thresh',dzero,is_legal_d_aggr_thrs) - - ! - ! The decoupled aggregator based on SOC measures ignores - ! ag_data except for clean_zeros; soc_map_bld is a procedure pointer. - ! - clean_zeros = ag%do_clean_zeros - call ag%soc_map_bld(parms%aggr_ord,parms%aggr_thresh,clean_zeros,a,desc_a,nlaggr,ilaggr,info) - - if (info==psb_success_) call mld_map_to_tprol(desc_a,ilaggr,nlaggr,t_prol,info) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='soc_map_bld/map_to_tprol') - goto 9999 - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_d_dec_aggregator_build_tprol diff --git a/mlprec/impl/aggregator/mld_d_map_to_tprol.f90 b/mlprec/impl/aggregator/mld_d_map_to_tprol.f90 deleted file mode 100644 index 8e59d76c..00000000 --- a/mlprec/impl/aggregator/mld_d_map_to_tprol.f90 +++ /dev/null @@ -1,154 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_d_map_to_tprol.f90 -! -! Subroutine: mld_d_map_to_tprol -! Version: real -! -! This routine uses a mapping from the row indices of the fine-level matrix -! to the row indices of the coarse-level matrix to build a tentative -! prolongator, i.e. a piecewise constant operator. -! This is later used to build the final operator; the code has been refactored here -! to be shared among all the methods that provide the tentative prolongator -! through a simple integer mapping. -! -! The aggregation algorithm is a parallel version of that described in -! * M. Brezina and P. Vanek, A black-box iterative solver based on a -! two-level Schwarz method, Computing, 63 (1999), 233-263. -! * P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed -! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 -! (1996), 179-196. -! For more details see -! P. D'Ambra, D. di Serafino and S. Filippone, On the development of -! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math. -! 57 (2007), 1181-1196. -! -! -! Arguments: -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! ilaggr - integer, dimension(:), allocatable. -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that on exit the indices -! will be shifted so as to make sure the ranges on the various processes do not -! overlap. -! nlaggr - integer, dimension(:), allocatable. -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_dspmat_type). -! The tentative prolongator, based on ilaggr. -! -! info - integer, output. -! Error code. -! -subroutine mld_d_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) - - use psb_base_mod - use mld_d_inner_mod, mld_protect_name => mld_d_map_to_tprol - - implicit none - - ! Arguments - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), allocatable, intent(inout) :: ilaggr(:),nlaggr(:) - type(psb_ldspmat_type), intent(out) :: op_prol - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_lpk_) :: icnt,nlp,k,n,ia,isz,nr, naggr,i,j,m,naggrm1, naggrp1, ntaggr - type(psb_ld_coo_sparse_mat) :: tmpcoo - integer(psb_ipk_) :: debug_level, debug_unit,err_act - integer(psb_ipk_) :: ictxt,np,me - integer(psb_lpk_) :: nrow, ncol, n_ne - character(len=20) :: name, ch_err - - info=psb_success_ - name = 'mld_map_to_tprol' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ! - ictxt=desc_a%get_context() - call psb_info(ictxt,me,np) - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - ilaggr(1:nrow) = ilaggr(1:nrow) + naggrm1 - call psb_halo(ilaggr,desc_a,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_halo') - goto 9999 - end if - - call tmpcoo%allocate(nrow,ntaggr,ncol) - k = 0 - do i=1,nrow - ! - ! Note: at this point, a value ilaggr(i)<=0 - ! tags a "singleton" row, and it has to be - ! left alone. - ! - if (ilaggr(i)>0) then - k = k + 1 - tmpcoo%val(k) = done - tmpcoo%ia(k) = i - tmpcoo%ja(k) = ilaggr(i) - end if - end do - call tmpcoo%set_nzeros(k) - call tmpcoo%set_dupl(psb_dupl_add_) - call tmpcoo%set_sorted() ! At this point this is in row-major - call op_prol%mv_from(tmpcoo) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_map_to_tprol diff --git a/mlprec/impl/aggregator/mld_d_ptap.f90 b/mlprec/impl/aggregator/mld_d_ptap.f90 deleted file mode 100644 index e10fa86c..00000000 --- a/mlprec/impl/aggregator/mld_d_ptap.f90 +++ /dev/null @@ -1,689 +0,0 @@ -! -! -! MLD2P4 Extensions -! -! (C) Copyright 2019 -! -! Salvatore Filippone Cranfield University -! Pasqua D'Ambra IAC-CNR, Naples, IT -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_daggrmat_nosmth_bld.F90 -! -! -subroutine mld_d_ptap(a_csr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info,desc_ax) - use psb_base_mod - use mld_d_inner_mod - use mld_d_base_aggregator_mod, mld_protect_name => mld_d_ptap - implicit none - - ! Arguments - type(psb_d_csr_sparse_mat), intent(inout) :: a_csr - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - type(mld_dml_parms), intent(inout) :: parms - type(psb_d_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr - type(psb_desc_type), intent(inout) :: desc_ac - type(psb_dspmat_type), intent(out) :: ac - integer(psb_ipk_), intent(out) :: info - type(psb_desc_type), intent(inout), optional :: desc_ax - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo - character(len=40) :: name - integer(psb_ipk_) :: ierr(5) - type(psb_ld_coo_sparse_mat) :: ac_coo, tmpcoo - type(psb_d_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr - integer(psb_ipk_) :: debug_level, debug_unit, naggr - integer(psb_lpk_) :: nglob, ntaggr, naggrm1, naggrp1 - integer(psb_ipk_) :: nrow, ncol, nrl, nzl, ip, nzt, i, k - integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza - logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. - integer(psb_ipk_), save :: idx_spspmm=-1 - - name='mld_ptap' - if(psb_get_errstatus().ne.0) return - info=psb_success_ - call psb_erractionsave(err_act) - - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - call psb_info(ictxt, me, np) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - if ((do_timings).and.(idx_spspmm==-1)) & - & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr - - ! - ! COO_PROL should arrive here with local numbering - ! - if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& - & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& - & nrow,ntaggr,naggr - - call coo_prol%cp_to_fmt(csr_prol,info) - - if (debug) write(0,*) me,trim(name),' Product AxPROL ',& - & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & - & desc_a%get_local_rows(),desc_a%get_local_cols(),& - & desc_ac%get_local_rows(),desc_a%get_local_cols() - if (debug) flush(0) - - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - - if (debug) write(0,*) me,trim(name),' Done AxPROL ',& - & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& - & desc_ac%get_local_rows(),desc_ac%get_local_cols() - - ! - ! Ok first product done. - - if (present(desc_ax)) then - block - call coo_prol%cp_to_coo(coo_restr,info) - call coo_restr%set_ncols(desc_ac%get_local_cols()) - call coo_restr%set_nrows(desc_a%get_local_rows()) - call psb_d_coo_glob_transpose(coo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_ax%get_local_cols()) -! !$ write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& -! !$ & desc_a%get_local_cols(),desc_ax%get_local_cols(),coo_restr%get_nzeros() -! !$ if (desc_a%get_local_cols()= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - - else - - ! - ! Remember that RESTR must be built from PROL after halo extension, - ! which is done above in psb_par_spspmm - if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& - & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() - call csr_prol%mv_to_coo(coo_restr,info) -!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& -!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() - if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) - - call coo_restr%transp() - nzl = coo_restr%get_nzeros() - nrl = desc_ac%get_local_rows() - i=0 - ! - ! Only keep local rows - ! - do k=1, nzl - if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then - i = i+1 - coo_restr%val(i) = coo_restr%val(k) - coo_restr%ia(i) = coo_restr%ia(k) - coo_restr%ja(i) = coo_restr%ja(k) - end if - end do - call coo_restr%set_nzeros(i) - call coo_restr%fix(info) - nzl = coo_restr%get_nzeros() - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_a%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) - call csr_restr%cp_from_coo(coo_restr,info) - -!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - end if - - call psb_cdasb(desc_ac,info) - - call ac_csr%set_nrows(desc_ac%get_local_rows()) - call ac_csr%set_ncols(desc_ac%get_local_cols()) - call ac%mv_from(ac_csr) - call ac%set_asb() - - if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() - if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr - ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() - - call coo_prol%set_ncols(desc_ac%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ptap ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_d_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo - -end subroutine mld_d_ptap - -subroutine mld_d_ld_ptap(a_csr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info,desc_ax) - use psb_base_mod - use mld_d_inner_mod - use mld_d_base_aggregator_mod !, mld_protect_name => mld_d_ld_ptap - implicit none - - ! Arguments - type(psb_d_csr_sparse_mat), intent(inout) :: a_csr - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - type(mld_dml_parms), intent(inout) :: parms - type(psb_ld_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr - type(psb_desc_type), intent(inout) :: desc_ac - type(psb_ldspmat_type), intent(out) :: ac - integer(psb_ipk_), intent(out) :: info - type(psb_desc_type), intent(inout), optional :: desc_ax - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo - character(len=40) :: name - integer(psb_ipk_) :: ierr(5) - type(psb_ld_coo_sparse_mat) :: ac_coo, tmpcoo - type(psb_d_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr - integer(psb_ipk_) :: debug_level, debug_unit, naggr - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nrl, nzl, ip, & - & nzt, naggrm1, naggrp1, i, k - integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza - logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. - integer(psb_ipk_), save :: idx_spspmm=-1 - - name='mld_ptap' - if(psb_get_errstatus().ne.0) return - info=psb_success_ - call psb_erractionsave(err_act) - - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - call psb_info(ictxt, me, np) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - if ((do_timings).and.(idx_spspmm==-1)) & - & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr - - ! - ! COO_PROL should arrive here with local numbering - ! - if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& - & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& - & nrow,ntaggr,naggr - - call coo_prol%cp_to_ifmt(csr_prol,info) - - if (debug) write(0,*) me,trim(name),' Product AxPROL ',& - & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & - & desc_a%get_local_rows(),desc_a%get_local_cols(),& - & desc_ac%get_local_rows(),desc_a%get_local_cols() - if (debug) flush(0) - - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - - if (debug) write(0,*) me,trim(name),' Done AxPROL ',& - & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& - & desc_ac%get_local_rows(),desc_ac%get_local_cols() - - ! - ! Ok first product done. - - if (present(desc_ax)) then - block - type(psb_d_coo_sparse_mat) :: icoo_restr - - call coo_prol%cp_to_icoo(icoo_restr,info) - call icoo_restr%set_ncols(desc_ac%get_local_cols()) - call icoo_restr%set_nrows(desc_a%get_local_rows()) - call psb_d_coo_glob_transpose(icoo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) - call icoo_restr%set_nrows(desc_ac%get_local_rows()) - call icoo_restr%set_ncols(desc_ax%get_local_cols()) -! !$ write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& -! !$ & desc_a%get_local_cols(),desc_ax%get_local_cols(),icoo_restr%get_nzeros() -! !$ if (desc_a%get_local_cols()= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - - else - - ! - ! Remember that RESTR must be built from PROL after halo extension, - ! which is done above in psb_par_spspmm - if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& - & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() - call csr_prol%mv_to_lcoo(coo_restr,info) -!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& -!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() - if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) - - call coo_restr%transp() - nzl = coo_restr%get_nzeros() - nrl = desc_ac%get_local_rows() - i=0 - ! - ! Only keep local rows - ! - do k=1, nzl - if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then - i = i+1 - coo_restr%val(i) = coo_restr%val(k) - coo_restr%ia(i) = coo_restr%ia(k) - coo_restr%ja(i) = coo_restr%ja(k) - end if - end do - call coo_restr%set_nzeros(i) - call coo_restr%fix(info) - nzl = coo_restr%get_nzeros() - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_a%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) - call csr_restr%cp_from_lcoo(coo_restr,info) - -!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - end if - - call psb_cdasb(desc_ac,info) - - call ac_csr%set_nrows(desc_ac%get_local_rows()) - call ac_csr%set_ncols(desc_ac%get_local_cols()) - call ac%mv_from(ac_csr) - call ac%set_asb() - - if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() - if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr - ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() - - call coo_prol%set_ncols(desc_ac%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ptap ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_ld_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo - -end subroutine mld_d_ld_ptap - -subroutine mld_ld_ptap(a_csr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info,desc_ax) - use psb_base_mod - use mld_d_inner_mod - use mld_d_base_aggregator_mod!, mld_protect_name => mld_ld_ptap - implicit none - - ! Arguments - type(psb_ld_csr_sparse_mat), intent(inout) :: a_csr - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - type(mld_dml_parms), intent(inout) :: parms - type(psb_ld_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr - type(psb_desc_type), intent(inout) :: desc_ac - type(psb_ldspmat_type), intent(out) :: ac - integer(psb_ipk_), intent(out) :: info - type(psb_desc_type), intent(inout), optional :: desc_ax - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo - character(len=40) :: name - integer(psb_ipk_) :: ierr(5) - type(psb_ld_coo_sparse_mat) :: ac_coo, tmpcoo - type(psb_ld_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr - integer(psb_ipk_) :: debug_level, debug_unit, naggr - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nrl, nzl, ip, & - & nzt, naggrm1, naggrp1, i, k - integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza - logical, parameter :: do_timings=.true., oldstyle=.false., debug=.false. - integer(psb_ipk_), save :: idx_spspmm=-1 - - name='mld_ptap' - if(psb_get_errstatus().ne.0) return - info=psb_success_ - call psb_erractionsave(err_act) - - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - call psb_info(ictxt, me, np) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - if ((do_timings).and.(idx_spspmm==-1)) & - & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr - - ! - ! COO_PROL should arrive here with local numbering - ! - if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& - & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& - & nrow,ntaggr,naggr - - call coo_prol%cp_to_fmt(csr_prol,info) - - if (debug) write(0,*) me,trim(name),' Product AxPROL ',& - & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & - & desc_a%get_local_rows(),desc_a%get_local_cols(),& - & desc_ac%get_local_rows(),desc_a%get_local_cols() - if (debug) flush(0) - - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - - if (debug) write(0,*) me,trim(name),' Done AxPROL ',& - & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& - & desc_ac%get_local_rows(),desc_ac%get_local_cols() - - ! - ! Ok first product done. - - if (present(desc_ax)) then - block - type(psb_d_coo_sparse_mat) :: icoo_restr - - call coo_prol%cp_to_icoo(icoo_restr,info) - call icoo_restr%set_ncols(desc_ac%get_local_cols()) - call icoo_restr%set_nrows(desc_a%get_local_rows()) - call psb_d_coo_glob_transpose(icoo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) - call icoo_restr%set_nrows(desc_ac%get_local_rows()) - call icoo_restr%set_ncols(desc_ax%get_local_cols()) - write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& - & desc_a%get_local_cols(),desc_ax%get_local_cols(),icoo_restr%get_nzeros() - if (desc_a%get_local_cols()= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - - else - - ! - ! Remember that RESTR must be built from PROL after halo extension, - ! which is done above in psb_par_spspmm - if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& - & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() - call csr_prol%mv_to_coo(coo_restr,info) -!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& -!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() - if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) - - call coo_restr%transp() - nzl = coo_restr%get_nzeros() - nrl = desc_ac%get_local_rows() - i=0 - ! - ! Only keep local rows - ! - do k=1, nzl - if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then - i = i+1 - coo_restr%val(i) = coo_restr%val(k) - coo_restr%ia(i) = coo_restr%ia(k) - coo_restr%ja(i) = coo_restr%ja(k) - end if - end do - call coo_restr%set_nzeros(i) - call coo_restr%fix(info) - nzl = coo_restr%get_nzeros() - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_a%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) - call csr_restr%cp_from_coo(coo_restr,info) - -!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - end if - - call psb_cdasb(desc_ac,info) - - call ac_csr%set_nrows(desc_ac%get_local_rows()) - call ac_csr%set_ncols(desc_ac%get_local_cols()) - call ac%mv_from(ac_csr) - call ac%set_asb() - - if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() - if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr - ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() - - call coo_prol%set_ncols(desc_ac%get_local_cols()) - !call coo_restr%mv_from_ifmt(csr_restr,info) -!!$ call coo_restr%set_nrows(desc_ac%get_local_rows()) -!!$ call coo_restr%set_ncols(desc_a%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ptap ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_ld_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo - -end subroutine mld_ld_ptap diff --git a/mlprec/impl/aggregator/mld_d_soc1_map_bld.f90 b/mlprec/impl/aggregator/mld_d_soc1_map_bld.f90 deleted file mode 100644 index 4da28284..00000000 --- a/mlprec/impl/aggregator/mld_d_soc1_map_bld.f90 +++ /dev/null @@ -1,349 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_d_soc1_map__bld.f90 -! -! Subroutine: mld_d_soc1_map_bld -! Version: real -! -! This routine builds the tentative prolongator based on the -! strength of connection aggregation algorithm presented in -! -! M. Brezina and P. Vanek, A black-box iterative solver based on a -! two-level Schwarz method, Computing, 63 (1999), 233-263. -! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed -! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 -! (1996), 179-196. -! -! Note: upon exit -! -! Arguments: -! a - type(psb_dspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_dprec_type), input/output. -! The preconditioner data structure; upon exit it contains -! the multilevel hierarchy of prolongators, restrictors -! and coarse matrices. -! info - integer, output. -! Error code. -! -! -! -subroutine mld_d_soc1_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) - - use psb_base_mod - use mld_base_prec_type - use mld_d_inner_mod - - implicit none - - ! Arguments - integer(psb_ipk_), intent(in) :: iorder - logical, intent(in) :: clean_zeros - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - real(psb_dpk_), intent(in) :: theta - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),& - & ideg(:), idxs(:) - integer(psb_lpk_), allocatable :: tmpaggr(:) - real(psb_dpk_), allocatable :: val(:), diag(:) - integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr, nc, naggr,i,j,m, nz, ilg, ii, ip - type(psb_d_csr_sparse_mat) :: acsr - real(psb_dpk_) :: cpling, tcl - logical :: disjoint - integer(psb_ipk_) :: debug_level, debug_unit,err_act - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: nrow, ncol, n_ne - integer(psb_lpk_) :: nrglob - character(len=20) :: name, ch_err - - info=psb_success_ - name = 'mld_soc1_map_bld' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ! - ictxt=desc_a%get_context() - call psb_info(ictxt,me,np) - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - nrglob = desc_a%get_global_rows() - - nr = a%get_nrows() - nc = a%get_ncols() - allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),& - & icol(nc),val(nc),stat=info) - if(info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),& - & a_err='integer') - goto 9999 - end if - - diag = a%get_diag(info) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='psb_sp_getdiag') - goto 9999 - end if - - call a%cp_to(acsr) - if (clean_zeros) call acsr%clean_zeros(info) - if (iorder == mld_aggr_ord_nat_) then - do i=1, nr - ilaggr(i) = -(nr+1) - idxs(i) = i - end do - else - do i=1, nr - ilaggr(i) = -(nr+1) - ideg(i) = acsr%irp(i+1) - acsr%irp(i) - end do - call psb_msort(ideg,ix=idxs,dir=psb_sort_down_) - end if - - - ! - ! Phase one: Start with disjoint groups. - ! - naggr = 0 - icnt = 0 - step1: do ii=1, nr - i = idxs(ii) - if ((i<1).or.(i>nr)) then - info=psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - if (ilaggr(i) == -(nr+1)) then - nz = (acsr%irp(i+1)-acsr%irp(i)) - if ((nz<0).or.(nz>size(icol))) then - info=psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) - val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) - - ! - ! Build the set of all strongly coupled nodes - ! - ip = 0 - do k=1, nz - j = icol(k) - if ((1<=j).and.(j<=nr)) then - if (abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j)))) then - ip = ip + 1 - icol(ip) = icol(k) - end if - end if - enddo - - ! - ! If the whole strongly coupled neighborhood of I is - ! as yet unconnected, turn it into the next aggregate. - ! Same if ip==0 (in which case, neighborhood only - ! contains I even if it does not look like it from matrix) - ! - disjoint = all(ilaggr(icol(1:ip)) == -(nr+1)).or.(ip==0) - if (disjoint) then - icnt = icnt + 1 - naggr = naggr + 1 - do k=1, ip - ilaggr(icol(k)) = naggr - end do - ilaggr(i) = naggr - end if - endif - enddo step1 - - if (debug_level >= psb_debug_outer_) then - write(debug_unit,*) me,' ',trim(name),& - & ' Check 1:',count(ilaggr == -(nr+1)) - end if - - ! - ! Phase two: join the neighbours - ! - tmpaggr = ilaggr - step2: do ii=1,nr - i = idxs(ii) - - if (ilaggr(i) == -(nr+1)) then - nz = (acsr%irp(i+1)-acsr%irp(i)) - if (nz == 1) cycle step2 - icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) - val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) - - ! - ! Find the most strongly connected neighbour that is - ! already aggregated, if any, and join its aggregate - ! - cpling = dzero - ip = 0 - do k=1, nz - j = icol(k) - if ((1<=j).and.(j<=nr)) then - if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))& - & .and. (tmpaggr(j) > 0).and. (abs(val(k)) > cpling)) then - ip = k - cpling = abs(val(k)) - end if - end if - enddo - if (ip > 0) then - ilaggr(i) = ilaggr(icol(ip)) - end if - end if - end do step2 - - - ! - ! Phase three: sweep over leftovers, if any - ! - step3: do ii=1,nr - i = idxs(ii) - - if (ilaggr(i) < 0) then - nz = (acsr%irp(i+1)-acsr%irp(i)) - if (nz == 1) cycle step3 - icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) - val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) - ! - ! Find its strongly connected neighbourhood not - ! already aggregated, and make it into a new aggregate. - ! - cpling = dzero - ip = 0 - do k=1, nz - j = icol(k) - if ((1<=j).and.(j<=nr)) then - if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))& - & .and. (ilaggr(j) < 0)) then - ip = ip + 1 - icol(ip) = icol(k) - end if - end if - enddo - if (ip > 0) then - icnt = icnt + 1 - naggr = naggr + 1 - ilaggr(i) = naggr - do k=1, ip - ilaggr(icol(k)) = naggr - end do - else - ! - ! This should not happen: we did not even connect with ourselves, - ! but it's not a singleton. - ! - naggr = naggr + 1 - ilaggr(i) = naggr - end if - end if - end do step3 - - ! Any leftovers? - do i=1, nr - if (ilaggr(i) < 0) then - nz = (acsr%irp(i+1)-acsr%irp(i)) - if (nz == 1) then - ! Mark explicitly as a singleton so that - ! it will be ignored in map_to_tprol. - ! Need to use -(nrglob+nr) to make sure - ! it's still negative when shifted and combined with - ! other processes. - ilaggr(i) = -(nrglob+nr) - else - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers') - goto 9999 - endif - end if - end do - - if (naggr > ncol) then - !write(0,*) name,'Error : naggr > ncol',naggr,ncol - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Fatal error: naggr>ncol') - goto 9999 - end if - - call psb_realloc(ncol,ilaggr,info) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_realloc' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - allocate(nlaggr(np),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),& - & a_err='integer') - goto 9999 - end if - - nlaggr(:) = 0 - nlaggr(me+1) = naggr - call psb_sum(ictxt,nlaggr(1:np)) - - call acsr%free() - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_soc1_map_bld - diff --git a/mlprec/impl/aggregator/mld_d_soc2_map_bld.f90 b/mlprec/impl/aggregator/mld_d_soc2_map_bld.f90 deleted file mode 100644 index ae8ceedc..00000000 --- a/mlprec/impl/aggregator/mld_d_soc2_map_bld.f90 +++ /dev/null @@ -1,348 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_d_soc2_map__bld.f90 -! -! Subroutine: mld_d_soc2_map_bld -! Version: real -! -! The aggregator object hosts the aggregation method for building -! the multilevel hierarchy. This variant is based on the method -! presented in -! -! S. Gratton, P. Henon, P. Jiranek and X. Vasseur: -! Reducing complexity of algebraic multigrid by aggregation -! Numerical Lin. Algebra with Applications, 2016, 23:501-518 -! -! Note: upon exit -! -! Arguments: -! a - type(psb_dspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_dprec_type), input/output. -! The preconditioner data structure; upon exit it contains -! the multilevel hierarchy of prolongators, restrictors -! and coarse matrices. -! info - integer, output. -! Error code. -! -! -! -subroutine mld_d_soc2_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) - - use psb_base_mod - use mld_base_prec_type - use mld_d_inner_mod - - implicit none - - ! Arguments - integer(psb_ipk_), intent(in) :: iorder - logical, intent(in) :: clean_zeros - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - real(psb_dpk_), intent(in) :: theta - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),& - & ideg(:), idxs(:) - integer(psb_lpk_), allocatable :: tmpaggr(:) - real(psb_dpk_), allocatable :: val(:), diag(:) - integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr,nc,naggr,i,j,m, nz, ilg, ii, ip, ip1,nzcnt - integer(psb_lpk_) :: nrglob - type(psb_d_csr_sparse_mat) :: acsr, muij, s_neigh - type(psb_d_coo_sparse_mat) :: s_neigh_coo - real(psb_dpk_) :: cpling, tcl - logical :: disjoint - integer(psb_ipk_) :: debug_level, debug_unit,err_act - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: nrow, ncol, n_ne - character(len=20) :: name, ch_err - - info=psb_success_ - name = 'mld_soc2_map_bld' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ! - ictxt=desc_a%get_context() - call psb_info(ictxt,me,np) - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - nrglob = desc_a%get_global_rows() - - nr = a%get_nrows() - nc = a%get_ncols() - allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),icol(nc),stat=info) - if(info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),& - & a_err='integer') - goto 9999 - end if - - diag = a%get_diag(info) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='psb_sp_getdiag') - goto 9999 - end if - - ! - ! Phase zero: compute muij - ! - call a%cp_to(muij) - if (clean_zeros) call muij%clean_zeros(info) - do i=1, nr - do k=muij%irp(i),muij%irp(i+1)-1 - j = muij%ja(k) - if (j<= nr) muij%val(k) = abs(muij%val(k))/sqrt(abs(diag(i)*diag(j))) - end do - end do - - ! - ! Compute the 1-neigbour; mark strong links with +1, weak links with -1 - ! - call s_neigh_coo%allocate(nr,nr,muij%get_nzeros()) - ip = 0 - do i=1, nr - do k=muij%irp(i),muij%irp(i+1)-1 - j = muij%ja(k) - if (j<=nr) then - ip = ip + 1 - s_neigh_coo%ia(ip) = i - s_neigh_coo%ja(ip) = j - if (real(muij%val(k)) >= theta) then - s_neigh_coo%val(ip) = done - else - s_neigh_coo%val(ip) = -done - end if - end if - end do - end do - !write(*,*) 'S_NEIGH: ',nr,ip - call s_neigh_coo%set_nzeros(ip) - call s_neigh%mv_from_coo(s_neigh_coo,info) - - if (iorder == mld_aggr_ord_nat_) then - do i=1, nr - ilaggr(i) = -(nr+1) - idxs(i) = i - end do - else - do i=1, nr - ilaggr(i) = -(nr+1) - ideg(i) = muij%irp(i+1) - muij%irp(i) - end do - call psb_msort(ideg,ix=idxs,dir=psb_sort_down_) - end if - - - ! - ! Phase one: Start with disjoint groups. - ! - naggr = 0 - icnt = 0 - step1: do ii=1, nr - i = idxs(ii) - - if (ilaggr(i) == -(nr+1)) then - ! - ! Get the 1-neighbourhood of I - ! - ip1 = s_neigh%irp(i) - nz = s_neigh%irp(i+1)-ip1 - ! - ! If the neighbourhood only contains I, skip it - ! - if (nz ==0) then - ilaggr(i) = 0 - cycle step1 - end if - if ((nz==1).and.(s_neigh%ja(ip1)==i)) then - ilaggr(i) = 0 - cycle step1 - end if - ! - ! If the whole strongly coupled neighborhood of I is - ! as yet unconnected, turn it into the next aggregate. - ! - nzcnt = count(real(s_neigh%val(ip1:ip1+nz-1)) > 0) - icol(1:nzcnt) = pack(s_neigh%ja(ip1:ip1+nz-1),(real(s_neigh%val(ip1:ip1+nz-1)) > 0)) - disjoint = all(ilaggr(icol(1:nzcnt)) == -(nr+1)) - if (disjoint) then - icnt = icnt + 1 - naggr = naggr + 1 - do k=1, nzcnt - ilaggr(icol(k)) = naggr - end do - ilaggr(i) = naggr - end if - endif - enddo step1 - - if (debug_level >= psb_debug_outer_) then - write(debug_unit,*) me,' ',trim(name),& - & ' Check 1:',count(ilaggr == -(nr+1)) - end if - - ! - ! Phase two: join the neighbours - ! - tmpaggr = ilaggr - step2: do ii=1,nr - i = idxs(ii) - - if (ilaggr(i) == -(nr+1)) then - ! - ! Find the most strongly connected neighbour that is - ! already aggregated, if any, and join its aggregate - ! - cpling = dzero - ip = 0 - do k=s_neigh%irp(i), s_neigh%irp(i+1)-1 - j = s_neigh%ja(k) - if ((1<=j).and.(j<=nr)) then - if ( (tmpaggr(j) > 0).and. (real(muij%val(k)) > cpling)& - & .and.(real(s_neigh%val(k))>0)) then - ip = k - cpling = muij%val(k) - end if - end if - enddo - if (ip > 0) then - ilaggr(i) = ilaggr(s_neigh%ja(ip)) - end if - end if - end do step2 - - - ! - ! Phase three: sweep over leftovers, if any - ! - step3: do ii=1,nr - i = idxs(ii) - - if (ilaggr(i) < 0) then - ! - ! Find its strongly connected neighbourhood not - ! already aggregated, and make it into a new aggregate. - ! - ip = 0 - do k=s_neigh%irp(i), s_neigh%irp(i+1)-1 - j = s_neigh%ja(k) - if ((1<=j).and.(j<=nr)) then - if (ilaggr(j) < 0) then - ip = ip + 1 - icol(ip) = j - end if - end if - enddo - if (ip > 0) then - icnt = icnt + 1 - naggr = naggr + 1 - ilaggr(i) = naggr - do k=1, ip - ilaggr(icol(k)) = naggr - end do - end if - end if - end do step3 - - ! Any leftovers? - do i=1, nr - if (ilaggr(i) <= 0) then - nz = (s_neigh%irp(i+1)-s_neigh%irp(i)) - if (nz <= 1) then - ! Mark explicitly as a singleton so that - ! it will be ignored in map_to_tprol. - ! Need to use -(nrglob+nr) to make sure - ! it's still negative when shifted and combined with - ! other processes. - ilaggr(i) = -(nrglob+nr) - else - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers') - goto 9999 - endif - end if - end do - - if (naggr > ncol) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Fatal error: naggr>ncol') - goto 9999 - end if - - call psb_realloc(ncol,ilaggr,info) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_realloc' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - allocate(nlaggr(np),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),& - & a_err='integer') - goto 9999 - end if - - nlaggr(:) = 0 - nlaggr(me+1) = naggr - call psb_sum(ictxt,nlaggr(1:np)) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_soc2_map_bld - diff --git a/mlprec/impl/aggregator/mld_d_symdec_aggregator_tprol.f90 b/mlprec/impl/aggregator/mld_d_symdec_aggregator_tprol.f90 deleted file mode 100644 index f9f80452..00000000 --- a/mlprec/impl/aggregator/mld_d_symdec_aggregator_tprol.f90 +++ /dev/null @@ -1,160 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_d_symdec_aggregator_tprol.f90 -! -! Subroutine: mld_d_symdec_aggregator_tprol -! Version: real -! -! -! This routine is mainly an interface to soc_map_bld where the real work is performed. -! It takes care of some consistency checking, and calls map_to_tprol, which is -! refactored and shared among all the aggregation methods that produce a simple -! integer mapping. It also symmetrizes the pattern of the local matrix A. -! -! -! -! Arguments: -! Arguments: -! ag - type(mld_d_dec_aggregator_type), input/output. -! The aggregator object, carrying with itself the mapping algorithm. -! parms - The auxiliary parameters object -! ag_data - Auxiliary global aggregation parameters object -! -! a - type(psb_dspmat_type). -! The sparse matrix structure containing the local part of the -! fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! ilaggr - integer, dimension(:), allocatable, output -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that on exit the indices -! will be shifted so as to make sure the ranges on the various processes do not -! overlap. -! nlaggr - integer, dimension(:), allocatable, output -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_dspmat_type), output -! The tentative prolongator, based on ilaggr. -! -! info - integer, output. -! Error code. -! -subroutine mld_d_symdec_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,op_prol,info) - use psb_base_mod - use mld_d_prec_type - use mld_d_symdec_aggregator_mod, mld_protect_name => mld_d_symdec_aggregator_build_tprol - use mld_d_inner_mod - implicit none - class(mld_d_symdec_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(mld_daggr_data), intent(in) :: ag_data - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_ldspmat_type), intent(out) :: op_prol - integer(psb_ipk_), intent(out) :: info - - ! Local variables - type(psb_dspmat_type) :: atmp, atrans - character(len=20) :: name - integer(psb_mpk_) :: ictxt, np, me - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: nr - integer(psb_lpk_) :: ntaggr - integer(psb_ipk_) :: debug_level, debug_unit - logical :: clean_zeros - - name='mld_d_symdec_aggregator_tprol' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - call mld_check_def(parms%ml_cycle,'Multilevel cycle',& - & mld_mult_ml_,is_legal_ml_cycle) - call mld_check_def(parms%par_aggr_alg,'Aggregation',& - & mld_dec_aggr_,is_legal_ml_par_aggr_alg) - call mld_check_def(parms%aggr_ord,'Ordering',& - & mld_aggr_ord_nat_,is_legal_ml_aggr_ord) - call mld_check_def(parms%aggr_thresh,'Aggr_Thresh',dzero,is_legal_d_aggr_thrs) - - nr = a%get_nrows() - call a%csclip(atmp,info,imax=nr,jmax=nr,& - & rscale=.false.,cscale=.false.) - call atmp%set_nrows(nr) - call atmp%set_ncols(nr) - if (info == psb_success_) call atmp%transp(atrans) - if (info == psb_success_) call atrans%cscnv(info,type='COO') - if (info == psb_success_) call psb_rwextd(nr,atmp,info,b=atrans,rowscale=.false.) - call atmp%set_nrows(nr) - call atmp%set_ncols(nr) - if (info == psb_success_) call atrans%free() - if (info == psb_success_) call atmp%cscnv(info,type='CSR') - - ! - ! The decoupled aggregator based on SOC measures ignores - ! ag_data except for clean_zeros; soc_map_bld is a procedure pointer. - ! - clean_zeros = ag%do_clean_zeros - if (info == psb_success_) & - & call ag%soc_map_bld(parms%aggr_ord,parms%aggr_thresh,clean_zeros,atmp,& - & desc_a,nlaggr,ilaggr,info) - if (info == psb_success_) call atmp%free() - - if (info == psb_success_) call mld_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='soc_map_bld/map_to_tprol') - goto 9999 - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_d_symdec_aggregator_build_tprol diff --git a/mlprec/impl/aggregator/mld_daggrmat_minnrg_bld.f90 b/mlprec/impl/aggregator/mld_daggrmat_minnrg_bld.f90 deleted file mode 100644 index 468dacb1..00000000 --- a/mlprec/impl/aggregator/mld_daggrmat_minnrg_bld.f90 +++ /dev/null @@ -1,656 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_daggrmat_minnrg_bld.F90 -! -! Subroutine: mld_daggrmat_minnrg_bld -! Version: real -! -! This routine builds a coarse-level matrix A_C from a fine-level matrix A -! by using the Galerkin approach, i.e. -! -! A_C = P_C^T A P_C, -! -! where P_C is a prolongator from the coarse level to the fine one. -! -! The prolongator P_C is built according to a smoothed aggregation algorithm, -! i.e. it is obtained by applying a damped Jacobi smoother to the piecewise -! constant interpolation operator P corresponding to the fine-to-coarse level -! mapping built by the mld_aggrmap_bld subroutine: -! -! P_C = (I - omega*D^(-1)A) * P, -! -! where D is the diagonal matrix with main diagonal equal to the main diagonal -! of A, and omega is a suitable smoothing parameter. An estimate of the spectral -! radius of D^(-1)A, to be used in the computation of omega, is provided, -! according to the value of p%parms%aggr_omega_alg, specified by the user -! through mld_dprecinit and mld_dprecset. -! 4. Minimum energy aggregation: -! M. Sala, R. Tuminaro: A new Petrov-Galerkin smoothed aggregation preconditioner -! for nonsymmetric linear systems, SIAM J. Sci. Comput., 31(1):143-166 (2008) -! -! On output from this routine the entries of AC, op_prol, op_restr -! are still in "global numbering" mode; this is fixed in the calling routine -! aggregator%mat_bld. -! -! -! Arguments: -! a - type(psb_dspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! p - type(mld_d_onelev_type), input/output. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! parms - type(mld_dml_parms), input -! Parameters controlling the choice of algorithm -! ac - type(psb_dspmat_type), output -! The coarse matrix on output -! -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_dspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_dspmat_type), output -! The restrictor operator; in this particular case, it is different -! from the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -! -subroutine mld_daggrmat_minnrg_bld(a,desc_a,ilaggr,nlaggr,parms,& - & ac,desc_ac,op_prol,op_restr,info) - use psb_base_mod - use mld_base_prec_type - use mld_d_inner_mod, mld_protect_name => mld_daggrmat_minnrg_bld - - implicit none - - ! Arguments - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(mld_dml_parms), intent(inout) :: parms - type(psb_ldspmat_type), intent(inout) :: op_prol - type(psb_ldspmat_type), intent(out) :: ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nzac, ip, ndx,& - & naggr, nzl,naggrm1,naggrp1, i, j, k, jd, icolF, nrt - integer(psb_ipk_) :: ictxt,np,me, icomm - character(len=20) :: name - type(psb_ldspmat_type) :: la, af, ptilde, rtilde, atran, atp, atdatp - type(psb_ldspmat_type) :: am3,am4, ap, adap,atmp,rada, ra, atmp2, dap, dadap, da - type(psb_ldspmat_type) :: dat, datp, datdatp, atmp3, tmp_prol - type(psb_ld_coo_sparse_mat) :: tmpcoo - type(psb_ld_csr_sparse_mat) :: acsr1, acsr2, acsr3, acsr, acsrf - type(psb_ld_csc_sparse_mat) :: csc_dap, csc_dadap, csc_datp, csc_datdatp, acsc - real(psb_dpk_), allocatable :: adiag(:), adinv(:) - real(psb_dpk_), allocatable :: omf(:), omp(:), omi(:), oden(:) - logical :: filter_mat - integer(psb_ipk_) :: ierr(5) - integer(psb_ipk_) :: debug_level, debug_unit, err_act - integer(psb_ipk_), parameter :: ncmax=16 - real(psb_dpk_) :: anorm, theta - real(psb_dpk_) :: tmp, alpha, beta, ommx - - name='mld_aggrmat_minnrg' - info=psb_success_ - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - ictxt = desc_a%get_context() - - call psb_info(ictxt, me, np) - - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - theta = parms%aggr_thresh - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - - filter_mat = (parms%aggr_filter == mld_filter_mat_) - - ! naggr: number of local aggregates - ! nrow: local rows. - ! - allocate(adinv(ncol),& - & omf(ncol),omp(ntaggr),oden(ntaggr),omi(ncol),stat=info) - - if (info /= psb_success_) then - info=psb_err_alloc_request_; ierr(1)=6*ncol+ntaggr; - call psb_errpush(info,name,i_err=ierr,a_err='real(psb_dpk_)') - goto 9999 - end if - - ! Get the diagonal D - adiag = a%get_diag(info) - if (info == psb_success_) & - & call psb_realloc(ncol,adiag,info) - if (info == psb_success_) & - & call psb_halo(adiag,desc_a,info) - if (info == psb_success_) call a%cp_to_l(la) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_getdiag') - goto 9999 - end if - - do i=1,size(adiag) - if (adiag(i) /= dzero) then - adinv(i) = done / adiag(i) - else - adinv(i) = done - end if - end do - - - - ! 1. Allocate Ptilde in sparse matrix form - call op_prol%mv_to(tmpcoo) - call ptilde%mv_from(tmpcoo) - call ptilde%cscnv(info,type='csr') - - if (info == psb_success_) call la%cscnv(am3,info,type='csr',dupl=psb_dupl_add_) - if (info == psb_success_) call la%cscnv(da,info,type='csr',dupl=psb_dupl_add_) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' Initial copies done.' - - call da%scal(adinv,info) - - call psb_spspmm(da,ptilde,dap,info) - - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 1') - goto 9999 - end if - - call dap%clone(atmp,info) - - call psb_sphalo(atmp,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.,outfmt='CSR ') - if (info == psb_success_) call psb_rwextd(ncol,atmp,info,b=am4) - if (info == psb_success_) call am4%free() - - call psb_spspmm(da,atmp,dadap,info) - call atmp%free() - - ! !$ write(0,*) 'Columns of AP',psb_sp_get_ncols(ap) - ! !$ write(0,*) 'Columns of ADAP',psb_sp_get_ncols(adap) - call dap%mv_to(csc_dap) - call dadap%mv_to(csc_dadap) - - call csc_mat_col_prod(csc_dap,csc_dadap,omp,info) - call csc_mat_col_prod(csc_dadap,csc_dadap,oden,info) - call psb_sum(ictxt,omp) - call psb_sum(ictxt,oden) - ! !$ write(0,*) trim(name),' OMP :',omp - ! !$ write(0,*) trim(name),' ODEN:',oden - - omp = omp/oden - - ! !$ write(0,*) 'Check on output prolongator ',omp(1:min(size(omp),10)) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done NUMBMM 1' - - call am3%mv_to(acsr3) - ! Compute omega_int - ommx = dzero - do i=1, ncol - if (ilaggr(i) >0) then - omi(i) = omp(ilaggr(i)) - else - omi(i) = dzero - end if - if(abs(omi(i)) .gt. abs(ommx)) ommx = omi(i) - end do - ! Compute omega_fine - do i=1, nrow - omf(i) = ommx - do j=acsr3%irp(i),acsr3%irp(i+1)-1 - if(abs(omi(acsr3%ja(j))) .lt. abs(omf(i))) omf(i)=omi(acsr3%ja(j)) - end do -!!$ if(min(real(omf(i)),aimag(omf(i))) < dzero) omf(i) = dzero - if(psb_minreal(omf(i)) < dzero) omf(i) = dzero - end do - - omf(1:nrow) = omf(1:nrow) * adinv(1:nrow) - - if (filter_mat) then - ! - ! Build the filtered matrix Af from A - ! - call la%cscnv(acsrf,info,dupl=psb_dupl_add_) - - do i=1,nrow - tmp = dzero - jd = -1 - do j=acsrf%irp(i),acsrf%irp(i+1)-1 - if (acsrf%ja(j) == i) jd = j - if (abs(acsrf%val(j)) < theta*sqrt(abs(adiag(i)*adiag(acsrf%ja(j))))) then - tmp=tmp+acsrf%val(j) - acsrf%val(j)=dzero - endif - enddo - if (jd == -1) then - write(0,*) 'Wrong input: we need the diagonal!!!!', i - else - acsrf%val(jd)=acsrf%val(jd)-tmp - end if - enddo - ! Take out zeroed terms - call acsrf%clean_zeros(info) - - ! - ! Build the smoothed prolongator using the filtered matrix - ! - do i=1,acsrf%get_nrows() - do j=acsrf%irp(i),acsrf%irp(i+1)-1 - if (acsrf%ja(j) == i) then - acsrf%val(j) = done - omf(i)*acsrf%val(j) - else - acsrf%val(j) = - omf(i)*acsrf%val(j) - end if - end do - end do - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done gather, going for SYMBMM 1' - - call af%mv_from(acsrf) - ! - ! op_prol = (I-w*D*Af)Ptilde - ! Doing it this way means to consider diag(Af_i) - ! - ! - call psb_spspmm(af,ptilde,op_prol,info) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done SPSPMM 1' - else - ! - ! Build the smoothed prolongator using the original matrix - ! - do i=1,acsr3%get_nrows() - do j=acsr3%irp(i),acsr3%irp(i+1)-1 - if (acsr3%ja(j) == i) then - acsr3%val(j) = done - omf(i)*acsr3%val(j) - else - acsr3%val(j) = - omf(i)*acsr3%val(j) - end if - end do - end do - - call am3%mv_from(acsr3) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done gather, going for SYMBMM 1' - ! - ! - ! op_prol = (I-w*D*A)Ptilde - ! - ! - call psb_spspmm(am3,ptilde,op_prol,info) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done NUMBMM 1' - - end if - - - ! - ! Ok, let's start over with the restrictor - ! - call ptilde%transc(rtilde) - call la%cscnv(atmp,info,type='csr') - call psb_sphalo(atmp,desc_a,am4,info,& - & colcnv=.true.,rowscale=.true.) - nrt = am4%get_nrows() - call am4%csclip(atmp2,info,lone,nrt,lone,ncol) - call atmp2%cscnv(info,type='CSR') - if (info == psb_success_) call psb_rwextd(ncol,atmp,info,b=atmp2) - call am4%free() - call atmp2%free() - - ! This is to compute the transpose. It ONLY works if the - ! original A has a symmetric pattern. - call atmp%transc(atmp2) - call atmp2%csclip(dat,info,lone,nrow,lone,ncol) - call dat%cscnv(info,type='csr') - call dat%scal(adinv,info) - - ! Now for the product. - call psb_spspmm(dat,ptilde,datp,info) - - call datp%clone(atmp2,info) - call psb_sphalo(atmp2,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.,outfmt='CSR ') - if (info == psb_success_) call psb_rwextd(ncol,atmp2,info,b=am4) - if (info == psb_success_) call am4%free() - - - call psb_symbmm(dat,atmp2,datdatp,info) - call psb_numbmm(dat,atmp2,datdatp) - call atmp2%free() - - call datp%mv_to(csc_datp) - call datdatp%mv_to(csc_datdatp) - - call csc_mat_col_prod(csc_datp,csc_datdatp,omp,info) - call csc_mat_col_prod(csc_datdatp,csc_datdatp,oden,info) - call psb_sum(ictxt,omp) - call psb_sum(ictxt,oden) - - - ! !$ write(debug_unit,*) trim(name),' OMP_R :',omp - ! ! $ write(debug_unit,*) trim(name),' ODEN_R:',oden - omp = omp/oden - ! !$ write(0,*) 'Check on output restrictor',omp(1:min(size(omp),10)) - ! Compute omega_int - ommx = dzero - do i=1, ncol - if (ilaggr(i) >0) then - omi(i) = omp(ilaggr(i)) - else - omi(i) = dzero - end if - if(abs(omi(i)) .gt. abs(ommx)) ommx = omi(i) - end do - ! Compute omega_fine - ! Going over the columns of atmp means going over the rows - ! of A^T. Hopefully ;-) - call atmp%cp_to(acsc) - - do i=1, nrow - omf(i) = ommx - do j= acsc%icp(i),acsc%icp(i+1)-1 - if(abs(omi(acsc%ia(j))) .lt. abs(omf(i))) omf(i)=omi(acsc%ia(j)) - end do -!!$ if(min(real(omf(i)),aimag(omf(i))) < dzero) omf(i) = dzero - if(psb_minreal(omf(i)) < dzero) omf(i) = dzero - end do - omf(1:nrow) = omf(1:nrow)*adinv(1:nrow) - call psb_halo(omf,desc_a,info) - call acsc%free() - - - call atmp%mv_to(acsr1) - - do i=1,acsr1%get_nrows() - do j=acsr1%irp(i),acsr1%irp(i+1)-1 - if (acsr1%ja(j) == i) then - acsr1%val(j) = done - acsr1%val(j)*omf(acsr1%ja(j)) - else - acsr1%val(j) = - acsr1%val(j)*omf(acsr1%ja(j)) - end if - end do - end do - call atmp%mv_from(acsr1) - - call rtilde%mv_to(tmpcoo) - nzl = tmpcoo%get_nzeros() - i=0 - do k=1, nzl - if ((naggrm1 < tmpcoo%ia(k)) .and. (tmpcoo%ia(k) <= naggrp1)) then - i = i+1 - tmpcoo%val(i) = tmpcoo%val(k) - tmpcoo%ia(i) = tmpcoo%ia(k) - tmpcoo%ja(i) = tmpcoo%ja(k) - end if - end do - call tmpcoo%set_nzeros(i) - call rtilde%mv_from(tmpcoo) - call rtilde%cscnv(info,type='csr') - - call psb_spspmm(rtilde,atmp,op_restr,info) - - ! - ! Now we have to gather the halo of op_prol, and add it to itself - ! to multiply it by A, - ! - call op_prol%clone(tmp_prol,info) - if (info == psb_success_) call psb_sphalo(tmp_prol,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.) - if (info == psb_success_) call psb_rwextd(ncol,tmp_prol,info,b=am4) - if (info == psb_success_) call am4%free() - - if(info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Halo of op_prol') - goto 9999 - end if - - ! - ! Now we have to fix this. The only rows of B that are correct - ! are those corresponding to "local" aggregates, i.e. indices in ilaggr(:) - ! - call op_restr%mv_to(tmpcoo) - - nzl = tmpcoo%get_nzeros() - i=0 - do k=1, nzl - if ((naggrm1 < tmpcoo%ia(k)) .and. (tmpcoo%ia(k) <= naggrp1)) then - i = i+1 - tmpcoo%val(i) = tmpcoo%val(k) - tmpcoo%ia(i) = tmpcoo%ia(k) - tmpcoo%ja(i) = tmpcoo%ja(k) - end if - end do - call tmpcoo%set_nzeros(i) - call op_restr%mv_from(tmpcoo) - call op_restr%cscnv(info,type='csr') - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - call psb_spspmm(la,tmp_prol,am3,info) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done SPSPMM 2' - - call psb_sphalo(am3,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.) - if (info == psb_success_) call psb_rwextd(ncol,am3,info,b=am4) - if (info == psb_success_) call am4%free() - - if(info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Extend am3') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done sphalo/ rwxtd' - - call psb_spspmm(op_restr,am3,ac,info) - if (info == psb_success_) call am3%free() - if (info == psb_success_) call ac%cscnv(info,type='coo',dupl=psb_dupl_add_) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - &a_err='Build ac = op_restr x am3') - goto 9999 - end if - - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done smooth_aggregate ' - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_errpush(info,name) - call psb_error_handler(err_act) - return - - -contains - - subroutine csc_mat_col_prod(a,b,v,info) - implicit none - type(psb_ld_csc_sparse_mat), intent(in) :: a, b - real(psb_dpk_), intent(out) :: v(:) - integer(psb_ipk_), intent(out) :: info - - integer(psb_lpk_) :: i,j,k, nr, nc,iap,nra,ibp,nrb - - info = psb_success_ - nc = a%get_ncols() - if (nc /= b%get_ncols()) then - write(0,*) 'Matrices A and B should have same columns' - info = -1 - return - end if - - do j=1, nc - iap = a%icp(j) - nra = a%icp(j+1)-iap - ibp = b%icp(j) - nrb = b%icp(j+1)-ibp - v(j) = sparse_srtd_dot(nra,a%ia(iap:iap+nra-1),a%val(iap:iap+nra-1),& - & nrb,b%ia(ibp:ibp+nrb-1),b%val(ibp:ibp+nrb-1)) - end do - - end subroutine csc_mat_col_prod - - - subroutine csr_mat_row_prod(a,b,v,info) - implicit none - type(psb_ld_csr_sparse_mat), intent(in) :: a, b - real(psb_dpk_), intent(out) :: v(:) - integer(psb_ipk_), intent(out) :: info - - integer(psb_lpk_) :: i,j,k, nr, nc,iap,nca,ibp,ncb - - info = psb_success_ - nr = a%get_nrows() - if (nr /= b%get_nrows()) then - write(0,*) 'Matrices A and B should have same rows' - info = -1 - return - end if - - do j=1, nr - iap = a%irp(j) - nca = a%irp(j+1)-iap - ibp = b%irp(j) - ncb = b%irp(j+1)-ibp - v(j) = sparse_srtd_dot(nca,a%ja(iap:iap+nca-1),a%val(iap:iap+nca-1),& - & ncb,b%ja(ibp:ibp+ncb-1),b%val(ibp:ibp+ncb-1)) - end do - - end subroutine csr_mat_row_prod - - - function sparse_srtd_dot(nv1,iv1,v1,nv2,iv2,v2) result(dot) - implicit none - integer(psb_lpk_), intent(in) :: nv1,nv2 - integer(psb_lpk_), intent(in) :: iv1(:), iv2(:) - real(psb_dpk_), intent(in) :: v1(:),v2(:) - real(psb_dpk_) :: dot - - integer(psb_lpk_) :: i,j,k, ip1, ip2 - - dot = dzero - ip1 = 1 - ip2 = 1 - - do - if (ip1 > nv1) exit - if (ip2 > nv2) exit - if (iv1(ip1) == iv2(ip2)) then - dot = dot + (v1(ip1))*v2(ip2) - ip1 = ip1 + 1 - ip2 = ip2 + 1 - else if (iv1(ip1) < iv2(ip2)) then - ip1 = ip1 + 1 - else - ip2 = ip2 + 1 - end if - end do - - end function sparse_srtd_dot - - subroutine local_dump(me,mat,name,header) - type(psb_ldspmat_type), intent(in) :: mat - integer(psb_ipk_), intent(in) :: me - character(len=*), intent(in) :: name - character(len=*), intent(in) :: header - character(len=80) :: filename - - write(filename,'(a,a,i0,a,i0,a)') trim(name),'.p',me - open(20+me,file=filename) - call mat%print(20+me,head=trim(header)) - close(20+me) - end subroutine local_dump - -end subroutine mld_daggrmat_minnrg_bld diff --git a/mlprec/impl/aggregator/mld_daggrmat_nosmth_bld.f90 b/mlprec/impl/aggregator/mld_daggrmat_nosmth_bld.f90 deleted file mode 100644 index 63fb2a44..00000000 --- a/mlprec/impl/aggregator/mld_daggrmat_nosmth_bld.f90 +++ /dev/null @@ -1,198 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_daggrmat_nosmth_bld.F90 -! -! Subroutine: mld_daggrmat_nosmth_bld -! Version: real -! -! This routine builds a coarse-level matrix A_C from a fine-level matrix A -! by using the Galerkin approach, i.e. -! -! A_C = P_C^T A P_C, -! -! where P_C is the piecewise constant interpolation operator corresponding -! the fine-to-coarse level mapping built by mld_aggrmap_bld. -! -! The coarse-level matrix A_C is distributed among the parallel processes or -! replicated on each of them, according to the value of p%parms%coarse_mat -! specified by the user through mld_dprecinit and mld_zprecset. -! On output from this routine the entries of AC, op_prol, op_restr -! are still in "global numbering" mode; this is fixed in the calling routine -! aggregator%mat_bld. -! -! For details see -! P. D'Ambra, D. di Serafino and S. Filippone, On the development of -! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math., -! 57 (2007), 1181-1196. -! -! -! Arguments: -! a - type(psb_dspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! p - type(mld_d_onelev_type), input/output. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! parms - type(mld_dml_parms), input -! Parameters controlling the choice of algorithm -! ac - type(psb_dspmat_type), output -! The coarse matrix on output -! -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_dspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_dspmat_type), output -! The restrictor operator; normally, it is the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -! -subroutine mld_daggrmat_nosmth_bld(a,desc_a,ilaggr,nlaggr,parms,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - use psb_base_mod - use mld_base_prec_type - use mld_d_inner_mod, mld_protect_name => mld_daggrmat_nosmth_bld - use mld_d_base_aggregator_mod - implicit none - - ! Arguments - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(mld_dml_parms), intent(inout) :: parms - type(psb_dspmat_type), intent(inout) :: op_prol,ac,op_restr - type(psb_ldspmat_type), intent(inout) :: t_prol - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt, np, me, icomm, minfo - character(len=20) :: name - type(psb_ld_coo_sparse_mat) :: lcoo_prol - type(psb_d_coo_sparse_mat) :: coo_prol, coo_restr - type(psb_d_csr_sparse_mat) :: acsr - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nzl, ip, & - & naggr, nzt, naggrm1, naggrp1, i, k - integer(psb_ipk_) :: inaggr, nzlp - logical, parameter :: debug = .false. - - name = 'mld_aggrmat_nosmth_bld' - info = psb_success_ - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - call psb_info(ictxt, me, np) - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - - call a%cp_to(acsr) - call t_prol%mv_to(lcoo_prol) - inaggr = naggr - call psb_cdall(ictxt,desc_ac,info,nl=inaggr) - nzlp = lcoo_prol%get_nzeros() - call desc_ac%indxmap%g2lip_ins(lcoo_prol%ja(1:nzlp),info) - call lcoo_prol%set_ncols(desc_ac%get_local_cols()) - call lcoo_prol%cp_to_icoo(coo_prol,info) - - if (debug) call check_coo(me,trim(name)//' Check 1 on coo_prol:',coo_prol) - - call psb_cdasb(desc_ac,info) - call psb_cd_reinit(desc_ac,info) - - call mld_ptap(acsr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info) - - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_a%get_local_cols()) - call coo_prol%set_nrows(desc_a%get_local_rows()) - call coo_prol%set_ncols(desc_ac%get_local_cols()) - - if (debug) call check_coo(me,trim(name)//' Check 1 on coo_restr:',coo_restr) - - call op_prol%mv_from(coo_prol) - call op_restr%mv_from(coo_restr) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_d_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo -end subroutine mld_daggrmat_nosmth_bld diff --git a/mlprec/impl/aggregator/mld_daggrmat_smth_bld.f90 b/mlprec/impl/aggregator/mld_daggrmat_smth_bld.f90 deleted file mode 100644 index bf17e911..00000000 --- a/mlprec/impl/aggregator/mld_daggrmat_smth_bld.f90 +++ /dev/null @@ -1,325 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_daggrmat_smth_bld.F90 -! -! Subroutine: mld_daggrmat_smth_bld -! Version: real -! -! This routine builds a coarse-level matrix A_C from a fine-level matrix A -! by using the Galerkin approach, i.e. -! -! A_C = P_C^T A P_C, -! -! where P_C is a prolongator from the coarse level to the fine one. -! -! The prolongator P_C is built according to a smoothed aggregation algorithm, -! i.e. it is obtained by applying a damped Jacobi smoother to the piecewise -! constant interpolation operator P corresponding to the fine-to-coarse level -! mapping built by the mld_aggrmap_bld subroutine: -! -! P_C = (I - omega*D^(-1)A) * P, -! -! where D is the diagonal matrix with main diagonal equal to the main diagonal -! of A, and omega is a suitable smoothing parameter. An estimate of the spectral -! radius of D^(-1)A, to be used in the computation of omega, is provided, -! according to the value of p%parms%aggr_omega_alg, specified by the user -! through mld_dprecinit and mld_zprecset. -! -! The coarse-level matrix A_C is distributed among the parallel processes or -! replicated on each of them, according to the value of p%parms%coarse_mat, -! specified by the user through mld_dprecinit and mld_zprecset. -! On output from this routine the entries of AC, op_prol, op_restr -! are still in "global numbering" mode; this is fixed in the calling routine -! aggregator%mat_bld. -! -! -! Arguments: -! a - type(psb_dspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! p - type(mld_d_onelev_type), input/output. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! parms - type(mld_dml_parms), input -! Parameters controlling the choice of algorithm -! ac - type(psb_dspmat_type), output -! The coarse matrix on output -! -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_dspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_dspmat_type), output -! The restrictor operator; normally, it is the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -subroutine mld_daggrmat_smth_bld(a,desc_a,ilaggr,nlaggr,parms,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - use psb_base_mod - use mld_base_prec_type - use mld_d_inner_mod, mld_protect_name => mld_daggrmat_smth_bld - use mld_d_base_aggregator_mod - - implicit none - - ! Arguments - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(mld_dml_parms), intent(inout) :: parms - type(psb_dspmat_type), intent(out) :: op_prol,ac,op_restr - type(psb_ldspmat_type), intent(inout) :: t_prol - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, ip, & - & naggr, nzl,naggrm1,naggrp1, i, j, k, jd, icolF, nrw - integer(psb_ipk_) :: inaggr, nzlp - integer(psb_ipk_) :: ictxt, np, me - character(len=20) :: name - type(psb_ld_coo_sparse_mat) :: tmpcoo - type(psb_d_coo_sparse_mat) :: coo_prol, coo_restr - type(psb_d_csr_sparse_mat) :: acsr1, acsrf, csr_prol, acsr - real(psb_dpk_), allocatable :: adiag(:) - real(psb_dpk_), allocatable :: arwsum(:) - integer(psb_ipk_) :: ierr(5) - logical :: filter_mat - integer(psb_ipk_) :: debug_level, debug_unit, err_act - integer(psb_ipk_), parameter :: ncmax=16 - real(psb_dpk_) :: anorm, omega, tmp, dg, theta - logical, parameter :: debug_new=.false. - character(len=80) :: filename - - name='mld_aggrmat_smth_bld' - info=psb_success_ - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - ictxt = desc_a%get_context() - - call psb_info(ictxt, me, np) - - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - theta = parms%aggr_thresh - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - filter_mat = (parms%aggr_filter == mld_filter_mat_) - - ! - ! naggr: number of local aggregates - ! nrow: local rows. - ! - - ! Get the diagonal D - adiag = a%get_diag(info) - if (info == psb_success_) & - & call psb_realloc(ncol,adiag,info) - if (info == psb_success_) & - & call psb_halo(adiag,desc_a,info) - if (info == psb_success_) call a%cp_to(acsr) - - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_getdiag') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' Initial copies done.' - - call acsr%cp_to_fmt(acsrf,info) - - - if (filter_mat) then - ! - ! Build the filtered matrix Af from A - ! - - do i=1, nrow - tmp = dzero - jd = -1 - do j=acsrf%irp(i),acsrf%irp(i+1)-1 - if (acsrf%ja(j) == i) jd = j - if (abs(acsrf%val(j)) < theta*sqrt(abs(adiag(i)*adiag(acsrf%ja(j))))) then - tmp=tmp+acsrf%val(j) - acsrf%val(j)=dzero - endif - - enddo - if (jd == -1) then - write(0,*) 'Wrong input: we need the diagonal!!!!', i - else - acsrf%val(jd)=acsrf%val(jd)-tmp - end if - enddo - ! Take out zeroed terms - call acsrf%clean_zeros(info) - end if - - - do i=1,size(adiag) - if (adiag(i) /= dzero) then - adiag(i) = done / adiag(i) - else - adiag(i) = done - end if - end do - - if (parms%aggr_omega_alg == mld_eig_est_) then - - if (parms%aggr_eig == mld_max_norm_) then - allocate(arwsum(nrow)) - call acsr%arwsum(arwsum) - anorm = maxval(abs(adiag(1:nrow)*arwsum(1:nrow))) - call psb_amx(ictxt,anorm) - omega = 4.d0/(3.d0*anorm) - parms%aggr_omega_val = omega - - else - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_aggr_eig_') - goto 9999 - end if - - else if (parms%aggr_omega_alg == mld_user_choice_) then - - omega = parms%aggr_omega_val - - else if (parms%aggr_omega_alg /= mld_user_choice_) then - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_aggr_omega_alg_') - goto 9999 - end if - - - call acsrf%scal(adiag,info) - if (info /= psb_success_) goto 9999 - - call t_prol%mv_to(tmpcoo) - inaggr = naggr - call psb_cdall(ictxt,desc_ac,info,nl=inaggr) - nzlp = tmpcoo%get_nzeros() - call desc_ac%indxmap%g2lip_ins(tmpcoo%ja(1:nzlp),info) - call tmpcoo%set_ncols(desc_ac%get_local_cols()) - call tmpcoo%mv_to_ifmt(csr_prol,info) - - call psb_cdasb(desc_ac,info) - call psb_cd_reinit(desc_ac,info) - ! - ! Build the smoothed prolongator using either A or Af - ! acsr1 = (I-w*D*A) Prol acsr1 = (I-w*D*Af) Prol - ! This is always done through the variable acsrf which - ! is a bit less readable, but saves space and one matrix copy - ! - call omega_smooth(omega,acsrf) - call psb_par_spspmm(acsrf,desc_a,csr_prol,acsr1,desc_ac,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 1') - goto 9999 - end if - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done SPSPMM 1' - nzl = acsr1%get_nzeros() - call acsr1%mv_to_coo(coo_prol,info) - - call mld_ptap(acsr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info) - - call op_prol%mv_from(coo_prol) - call op_restr%mv_from(coo_restr) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done smooth_aggregate ' - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_errpush(info,name) - call psb_error_handler(err_act) - return - -contains - - subroutine omega_smooth(omega,acsr) - implicit none - real(psb_dpk_),intent(in) :: omega - type(psb_d_csr_sparse_mat), intent(inout) :: acsr - ! - integer(psb_lpk_) :: i,j - do i=1,acsr%get_nrows() - do j=acsr%irp(i),acsr%irp(i+1)-1 - if (acsr%ja(j) == i) then - acsr%val(j) = done - omega*acsr%val(j) - else - acsr%val(j) = - omega*acsr%val(j) - end if - end do - end do - end subroutine omega_smooth - -end subroutine mld_daggrmat_smth_bld diff --git a/mlprec/impl/aggregator/mld_s_dec_aggregator_mat_asb.f90 b/mlprec/impl/aggregator/mld_s_dec_aggregator_mat_asb.f90 deleted file mode 100644 index 8a7dab3e..00000000 --- a/mlprec/impl/aggregator/mld_s_dec_aggregator_mat_asb.f90 +++ /dev/null @@ -1,195 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_s_dec_aggregator_mat_asb.f90 -! -! Subroutine: mld_s_dec_aggregator_mat_asb -! Version: real -! -! -! From a given AC to final format, generating DESC_AC -! -! Arguments: -! ag - type(mld_s_dec_aggregator_type), input/output. -! The aggregator object -! parms - type(mld_sml_parms), input -! The aggregation parameters -! a - type(psb_sspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! ac - type(psb_sspmat_type), inout -! The coarse matrix -! desc_ac - type(psb_desc_type), output. -! The communication descriptor of the fine-level matrix. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! -! op_prol - type(psb_sspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_sspmat_type), input/output -! The restrictor operator; normally, it is the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -subroutine mld_s_dec_aggregator_mat_asb(ag,parms,a,desc_a,& - & ac,desc_ac, op_prol,op_restr,info) - use psb_base_mod - use mld_base_prec_type - use mld_s_dec_aggregator_mod, mld_protect_name => mld_s_dec_aggregator_mat_asb - implicit none - class(mld_s_dec_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - type(psb_sspmat_type), intent(inout) :: op_prol, ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: ictxt, np, me - type(psb_ls_coo_sparse_mat) :: tmpcoo - type(psb_lsspmat_type) :: tmp_ac - integer(psb_ipk_) :: i_nr, i_nc, i_nl, nzl - integer(psb_lpk_) :: ntaggr - integer(psb_ipk_) :: err_act, debug_level, debug_unit - character(len=20) :: name='s_dec_aggregator_mat_asb' - - - if (psb_get_errstatus().ne.0) return - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - select case(parms%coarse_mat) - - case(mld_distr_mat_) - - call ac%cscnv(info,type='csr') - call op_prol%cscnv(info,type='csr') - call op_restr%cscnv(info,type='csr') - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ac ' - - case(mld_repl_mat_) - ! - ! We are assuming here that an s matrix - ! can hold all entries - ! - if (desc_ac%get_global_rows() < huge(1_psb_ipk_) ) then - ntaggr = desc_ac%get_global_rows() - i_nr = ntaggr - else - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_coarse_mat_') - goto 9999 - end if - - call op_prol%mv_to(tmpcoo) - nzl = tmpcoo%get_nzeros() - call psb_loc_to_glob(tmpcoo%ja(1:nzl),desc_ac,info,'I') - call tmpcoo%set_ncols(i_nr) - call op_prol%mv_from(tmpcoo) - - call op_restr%mv_to(tmpcoo) - nzl = tmpcoo%get_nzeros() - call psb_loc_to_glob(tmpcoo%ia(1:nzl),desc_ac,info,'I') - call tmpcoo%set_nrows(i_nr) - call op_restr%mv_from(tmpcoo) - - - call psb_gather(tmp_ac,ac,desc_ac,info,root=-ione,& - & dupl=psb_dupl_add_,keeploc=.false.) - call tmp_ac%mv_to(tmpcoo) - call ac%mv_from(tmpcoo) - - call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) - if (info == psb_success_) call psb_cdasb(desc_ac,info) - - if (info /= psb_success_) goto 9999 - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_coarse_mat_') - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_ls_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo -end subroutine mld_s_dec_aggregator_mat_asb diff --git a/mlprec/impl/aggregator/mld_s_dec_aggregator_mat_bld.f90 b/mlprec/impl/aggregator/mld_s_dec_aggregator_mat_bld.f90 deleted file mode 100644 index a9b62c0a..00000000 --- a/mlprec/impl/aggregator/mld_s_dec_aggregator_mat_bld.f90 +++ /dev/null @@ -1,216 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_s_dec_aggregator_mat_bld.f90 -! -! Subroutine: mld_s_dec_aggregator_mat_bld -! Version: real -! -! This routine builds the matrix associated to the current level of the -! multilevel preconditioner from the matrix associated to the previous level, -! by using the user-specified aggregation technique (therefore, it also builds the -! prolongation and restriction operators mapping the current level to the -! previous one and vice versa). -! The current level is regarded as the coarse one, while the previous as -! the fine one. This is in agreement with the fact that the routine is called, -! by mld_mlprec_bld, only on levels >=2. -! The coarse-level matrix A_C is built from a fine-level matrix A -! by using the Galerkin approach, i.e. -! -! A_C = P_C^T A P_C, -! -! where P_C is a prolongator from the coarse level to the fine one. -! -! A mapping from the nodes of the adjacency graph of A to the nodes of the -! adjacency graph of A_C has been computed by the mld_aggrmap_bld subroutine. -! The prolongator P_C is built here from this mapping, according to the -! value of p%iprcparm(mld_aggr_kind_), specified by the user through -! mld_sprecinit and mld_zprecset. -! On output from this routine the entries of AC, op_prol, op_restr -! are still in "global numbering" mode; this is fixed in the calling routine -! mld_s_lev_aggrmat_bld. -! -! Currently four different prolongators are implemented, corresponding to -! four aggregation algorithms: -! 1. un-smoothed aggregation, -! 2. smoothed aggregation, -! 3. "bizarre" aggregation. -! 4. minimum energy -! 1. The non-smoothed aggregation uses as prolongator the piecewise constant -! interpolation operator corresponding to the fine-to-coarse level mapping built -! by p%aggr%bld_tprol. This is called tentative prolongator. -! 2. The smoothed aggregation uses as prolongator the operator obtained by applying -! a damped Jacobi smoother to the tentative prolongator. -! 3. The "bizarre" aggregation uses a prolongator proposed by the authors of MLD2P4. -! This prolongator still requires a deep analysis and testing and its use is -! not recommended. -! 4. Minimum energy aggregation -! -! For more details see -! M. Brezina and P. Vanek, A black-box iterative solver based on a two-level -! Schwarz method, Computing, 63 (1999), 233-263. -! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed -! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 -! (1996), 179-196. -! P. D'Ambra, D. di Serafino and S. Filippone, On the development of PSBLAS-based -! parallel two-level Schwarz preconditioners, Appl. Num. Math., 57 (2007), -! 1181-1196. -! M. Sala, R. Tuminaro: A new Petrov-Galerkin smoothed aggregation preconditioner -! for nonsymmetric linear systems, SIAM J. Sci. Comput., 31(1):143-166 (2008) -! -! -! The main structure is: -! 1. Perform sanity checks; -! 2. Compute prolongator/restrictor/AC -! -! -! Arguments: -! ag - type(mld_s_dec_aggregator_type), input/output. -! The aggregator object -! parms - type(mld_sml_parms), input -! The aggregation parameters -! a - type(psb_sspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! ac - type(psb_sspmat_type), output -! The coarse matrix on output -! -! op_prol - type(psb_sspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_sspmat_type), output -! The restrictor operator; normally, it is the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -subroutine mld_s_dec_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - use psb_base_mod - use mld_s_prec_type, mld_protect_name => mld_s_dec_aggregator_mat_bld - use mld_s_inner_mod - implicit none - - class(mld_s_dec_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(psb_lsspmat_type), intent(inout) :: t_prol - type(psb_sspmat_type), intent(out) :: op_prol,ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - - ! Local variables - character(len=20) :: name - integer(psb_mpk_) :: ictxt, np, me - integer(psb_lpk_) :: nzl,ntaggr - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: debug_level, debug_unit - - name='mld_s_dec_aggregator_mat_bld' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - ! - ! Build the coarse-level matrix from the fine-level one, starting from - ! the mapping defined by mld_aggrmap_bld and applying the aggregation - ! algorithm specified by - ! - select case (parms%aggr_prol) - case (mld_no_smooth_) - - call mld_saggrmat_nosmth_bld(a,desc_a,ilaggr,nlaggr,& - & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) - - case(mld_smooth_prol_) - - call mld_saggrmat_smth_bld(a,desc_a,ilaggr,nlaggr, & - & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) - -!!$ case(mld_biz_prol_) -!!$ -!!$ call mld_saggrmat_biz_bld(a,desc_a,ilaggr,nlaggr, & -!!$ & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) - - case(mld_min_energy_) - - call mld_saggrmat_minnrg_bld(a,desc_a,ilaggr,nlaggr, & - & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='Invalid aggr kind') - goto 9999 - - end select - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='Inner aggrmat bld') - goto 9999 - end if - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - -end subroutine mld_s_dec_aggregator_mat_bld diff --git a/mlprec/impl/aggregator/mld_s_dec_aggregator_tprol.f90 b/mlprec/impl/aggregator/mld_s_dec_aggregator_tprol.f90 deleted file mode 100644 index ca5e8422..00000000 --- a/mlprec/impl/aggregator/mld_s_dec_aggregator_tprol.f90 +++ /dev/null @@ -1,139 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_s_dec_aggregator_tprol.f90 -! -! Subroutine: mld_s_dec_aggregator_tprol -! Version: real -! -! This routine is mainly an interface to soc_map_bld where the real work is performed. -! It takes care of some consistency checking, and calls map_to_tprol, which is -! refactored and shared among all the aggregation methods that produce a simple -! integer mapping. -! -! -! Arguments: -! ag - type(mld_s_dec_aggregator_type), input/output. -! The aggregator object, carrying with itself the mapping algorithm. -! parms - The auxiliary parameters object -! ag_data - Auxiliary global aggregation parameters object -! -! -! a - type(psb_sspmat_type). -! The sparse matrix structure containing the local part of the -! fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! ilaggr - integer, dimension(:), allocatable, output -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that on exit the indices -! will be shifted so as to make sure the ranges on the various processes do not -! overlap. -! nlaggr - integer, dimension(:), allocatable, output -! nlaggr(i) contains the aggregates held by process i. -! t_prol - type(psb_sspmat_type), output -! The tentative prolongator, based on ilaggr. -! -! info - integer, output. -! Error code. -! -subroutine mld_s_dec_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,t_prol,info) - use psb_base_mod - use mld_s_prec_type, mld_protect_name => mld_s_dec_aggregator_build_tprol - use mld_s_inner_mod - implicit none - class(mld_s_dec_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(mld_saggr_data), intent(in) :: ag_data - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lsspmat_type), intent(out) :: t_prol - integer(psb_ipk_), intent(out) :: info - - ! Local variables - character(len=20) :: name - integer(psb_mpk_) :: ictxt, np, me - integer(psb_ipk_) :: err_act - integer(psb_lpk_) :: ntaggr - integer(psb_ipk_) :: debug_level, debug_unit - logical :: clean_zeros - - name='mld_s_dec_aggregator_tprol' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - call mld_check_def(parms%ml_cycle,'Multilevel cycle',& - & mld_mult_ml_,is_legal_ml_cycle) - call mld_check_def(parms%par_aggr_alg,'Aggregation',& - & mld_dec_aggr_,is_legal_ml_par_aggr_alg) - call mld_check_def(parms%aggr_ord,'Ordering',& - & mld_aggr_ord_nat_,is_legal_ml_aggr_ord) - call mld_check_def(parms%aggr_thresh,'Aggr_Thresh',szero,is_legal_s_aggr_thrs) - - ! - ! The decoupled aggregator based on SOC measures ignores - ! ag_data except for clean_zeros; soc_map_bld is a procedure pointer. - ! - clean_zeros = ag%do_clean_zeros - call ag%soc_map_bld(parms%aggr_ord,parms%aggr_thresh,clean_zeros,a,desc_a,nlaggr,ilaggr,info) - - if (info==psb_success_) call mld_map_to_tprol(desc_a,ilaggr,nlaggr,t_prol,info) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='soc_map_bld/map_to_tprol') - goto 9999 - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_s_dec_aggregator_build_tprol diff --git a/mlprec/impl/aggregator/mld_s_map_to_tprol.f90 b/mlprec/impl/aggregator/mld_s_map_to_tprol.f90 deleted file mode 100644 index 0de193c2..00000000 --- a/mlprec/impl/aggregator/mld_s_map_to_tprol.f90 +++ /dev/null @@ -1,154 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_s_map_to_tprol.f90 -! -! Subroutine: mld_s_map_to_tprol -! Version: real -! -! This routine uses a mapping from the row indices of the fine-level matrix -! to the row indices of the coarse-level matrix to build a tentative -! prolongator, i.e. a piecewise constant operator. -! This is later used to build the final operator; the code has been refactored here -! to be shared among all the methods that provide the tentative prolongator -! through a simple integer mapping. -! -! The aggregation algorithm is a parallel version of that described in -! * M. Brezina and P. Vanek, A black-box iterative solver based on a -! two-level Schwarz method, Computing, 63 (1999), 233-263. -! * P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed -! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 -! (1996), 179-196. -! For more details see -! P. D'Ambra, D. di Serafino and S. Filippone, On the development of -! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math. -! 57 (2007), 1181-1196. -! -! -! Arguments: -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! ilaggr - integer, dimension(:), allocatable. -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that on exit the indices -! will be shifted so as to make sure the ranges on the various processes do not -! overlap. -! nlaggr - integer, dimension(:), allocatable. -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_sspmat_type). -! The tentative prolongator, based on ilaggr. -! -! info - integer, output. -! Error code. -! -subroutine mld_s_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) - - use psb_base_mod - use mld_s_inner_mod, mld_protect_name => mld_s_map_to_tprol - - implicit none - - ! Arguments - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), allocatable, intent(inout) :: ilaggr(:),nlaggr(:) - type(psb_lsspmat_type), intent(out) :: op_prol - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_lpk_) :: icnt,nlp,k,n,ia,isz,nr, naggr,i,j,m,naggrm1, naggrp1, ntaggr - type(psb_ls_coo_sparse_mat) :: tmpcoo - integer(psb_ipk_) :: debug_level, debug_unit,err_act - integer(psb_ipk_) :: ictxt,np,me - integer(psb_lpk_) :: nrow, ncol, n_ne - character(len=20) :: name, ch_err - - info=psb_success_ - name = 'mld_map_to_tprol' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ! - ictxt=desc_a%get_context() - call psb_info(ictxt,me,np) - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - ilaggr(1:nrow) = ilaggr(1:nrow) + naggrm1 - call psb_halo(ilaggr,desc_a,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_halo') - goto 9999 - end if - - call tmpcoo%allocate(nrow,ntaggr,ncol) - k = 0 - do i=1,nrow - ! - ! Note: at this point, a value ilaggr(i)<=0 - ! tags a "singleton" row, and it has to be - ! left alone. - ! - if (ilaggr(i)>0) then - k = k + 1 - tmpcoo%val(k) = sone - tmpcoo%ia(k) = i - tmpcoo%ja(k) = ilaggr(i) - end if - end do - call tmpcoo%set_nzeros(k) - call tmpcoo%set_dupl(psb_dupl_add_) - call tmpcoo%set_sorted() ! At this point this is in row-major - call op_prol%mv_from(tmpcoo) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_map_to_tprol diff --git a/mlprec/impl/aggregator/mld_s_ptap.f90 b/mlprec/impl/aggregator/mld_s_ptap.f90 deleted file mode 100644 index c18dbc51..00000000 --- a/mlprec/impl/aggregator/mld_s_ptap.f90 +++ /dev/null @@ -1,689 +0,0 @@ -! -! -! MLD2P4 Extensions -! -! (C) Copyright 2019 -! -! Salvatore Filippone Cranfield University -! Pasqua D'Ambra IAC-CNR, Naples, IT -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_daggrmat_nosmth_bld.F90 -! -! -subroutine mld_s_ptap(a_csr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info,desc_ax) - use psb_base_mod - use mld_s_inner_mod - use mld_s_base_aggregator_mod, mld_protect_name => mld_s_ptap - implicit none - - ! Arguments - type(psb_s_csr_sparse_mat), intent(inout) :: a_csr - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - type(mld_sml_parms), intent(inout) :: parms - type(psb_s_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr - type(psb_desc_type), intent(inout) :: desc_ac - type(psb_sspmat_type), intent(out) :: ac - integer(psb_ipk_), intent(out) :: info - type(psb_desc_type), intent(inout), optional :: desc_ax - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo - character(len=40) :: name - integer(psb_ipk_) :: ierr(5) - type(psb_ls_coo_sparse_mat) :: ac_coo, tmpcoo - type(psb_s_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr - integer(psb_ipk_) :: debug_level, debug_unit, naggr - integer(psb_lpk_) :: nglob, ntaggr, naggrm1, naggrp1 - integer(psb_ipk_) :: nrow, ncol, nrl, nzl, ip, nzt, i, k - integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza - logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. - integer(psb_ipk_), save :: idx_spspmm=-1 - - name='mld_ptap' - if(psb_get_errstatus().ne.0) return - info=psb_success_ - call psb_erractionsave(err_act) - - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - call psb_info(ictxt, me, np) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - if ((do_timings).and.(idx_spspmm==-1)) & - & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr - - ! - ! COO_PROL should arrive here with local numbering - ! - if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& - & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& - & nrow,ntaggr,naggr - - call coo_prol%cp_to_fmt(csr_prol,info) - - if (debug) write(0,*) me,trim(name),' Product AxPROL ',& - & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & - & desc_a%get_local_rows(),desc_a%get_local_cols(),& - & desc_ac%get_local_rows(),desc_a%get_local_cols() - if (debug) flush(0) - - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - - if (debug) write(0,*) me,trim(name),' Done AxPROL ',& - & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& - & desc_ac%get_local_rows(),desc_ac%get_local_cols() - - ! - ! Ok first product done. - - if (present(desc_ax)) then - block - call coo_prol%cp_to_coo(coo_restr,info) - call coo_restr%set_ncols(desc_ac%get_local_cols()) - call coo_restr%set_nrows(desc_a%get_local_rows()) - call psb_s_coo_glob_transpose(coo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_ax%get_local_cols()) -! !$ write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& -! !$ & desc_a%get_local_cols(),desc_ax%get_local_cols(),coo_restr%get_nzeros() -! !$ if (desc_a%get_local_cols()= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - - else - - ! - ! Remember that RESTR must be built from PROL after halo extension, - ! which is done above in psb_par_spspmm - if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& - & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() - call csr_prol%mv_to_coo(coo_restr,info) -!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& -!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() - if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) - - call coo_restr%transp() - nzl = coo_restr%get_nzeros() - nrl = desc_ac%get_local_rows() - i=0 - ! - ! Only keep local rows - ! - do k=1, nzl - if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then - i = i+1 - coo_restr%val(i) = coo_restr%val(k) - coo_restr%ia(i) = coo_restr%ia(k) - coo_restr%ja(i) = coo_restr%ja(k) - end if - end do - call coo_restr%set_nzeros(i) - call coo_restr%fix(info) - nzl = coo_restr%get_nzeros() - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_a%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) - call csr_restr%cp_from_coo(coo_restr,info) - -!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - end if - - call psb_cdasb(desc_ac,info) - - call ac_csr%set_nrows(desc_ac%get_local_rows()) - call ac_csr%set_ncols(desc_ac%get_local_cols()) - call ac%mv_from(ac_csr) - call ac%set_asb() - - if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() - if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr - ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() - - call coo_prol%set_ncols(desc_ac%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ptap ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_s_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo - -end subroutine mld_s_ptap - -subroutine mld_s_ls_ptap(a_csr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info,desc_ax) - use psb_base_mod - use mld_s_inner_mod - use mld_s_base_aggregator_mod !, mld_protect_name => mld_s_ls_ptap - implicit none - - ! Arguments - type(psb_s_csr_sparse_mat), intent(inout) :: a_csr - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - type(mld_sml_parms), intent(inout) :: parms - type(psb_ls_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr - type(psb_desc_type), intent(inout) :: desc_ac - type(psb_lsspmat_type), intent(out) :: ac - integer(psb_ipk_), intent(out) :: info - type(psb_desc_type), intent(inout), optional :: desc_ax - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo - character(len=40) :: name - integer(psb_ipk_) :: ierr(5) - type(psb_ls_coo_sparse_mat) :: ac_coo, tmpcoo - type(psb_s_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr - integer(psb_ipk_) :: debug_level, debug_unit, naggr - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nrl, nzl, ip, & - & nzt, naggrm1, naggrp1, i, k - integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza - logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. - integer(psb_ipk_), save :: idx_spspmm=-1 - - name='mld_ptap' - if(psb_get_errstatus().ne.0) return - info=psb_success_ - call psb_erractionsave(err_act) - - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - call psb_info(ictxt, me, np) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - if ((do_timings).and.(idx_spspmm==-1)) & - & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr - - ! - ! COO_PROL should arrive here with local numbering - ! - if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& - & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& - & nrow,ntaggr,naggr - - call coo_prol%cp_to_ifmt(csr_prol,info) - - if (debug) write(0,*) me,trim(name),' Product AxPROL ',& - & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & - & desc_a%get_local_rows(),desc_a%get_local_cols(),& - & desc_ac%get_local_rows(),desc_a%get_local_cols() - if (debug) flush(0) - - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - - if (debug) write(0,*) me,trim(name),' Done AxPROL ',& - & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& - & desc_ac%get_local_rows(),desc_ac%get_local_cols() - - ! - ! Ok first product done. - - if (present(desc_ax)) then - block - type(psb_s_coo_sparse_mat) :: icoo_restr - - call coo_prol%cp_to_icoo(icoo_restr,info) - call icoo_restr%set_ncols(desc_ac%get_local_cols()) - call icoo_restr%set_nrows(desc_a%get_local_rows()) - call psb_s_coo_glob_transpose(icoo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) - call icoo_restr%set_nrows(desc_ac%get_local_rows()) - call icoo_restr%set_ncols(desc_ax%get_local_cols()) -! !$ write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& -! !$ & desc_a%get_local_cols(),desc_ax%get_local_cols(),icoo_restr%get_nzeros() -! !$ if (desc_a%get_local_cols()= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - - else - - ! - ! Remember that RESTR must be built from PROL after halo extension, - ! which is done above in psb_par_spspmm - if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& - & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() - call csr_prol%mv_to_lcoo(coo_restr,info) -!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& -!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() - if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) - - call coo_restr%transp() - nzl = coo_restr%get_nzeros() - nrl = desc_ac%get_local_rows() - i=0 - ! - ! Only keep local rows - ! - do k=1, nzl - if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then - i = i+1 - coo_restr%val(i) = coo_restr%val(k) - coo_restr%ia(i) = coo_restr%ia(k) - coo_restr%ja(i) = coo_restr%ja(k) - end if - end do - call coo_restr%set_nzeros(i) - call coo_restr%fix(info) - nzl = coo_restr%get_nzeros() - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_a%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) - call csr_restr%cp_from_lcoo(coo_restr,info) - -!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - end if - - call psb_cdasb(desc_ac,info) - - call ac_csr%set_nrows(desc_ac%get_local_rows()) - call ac_csr%set_ncols(desc_ac%get_local_cols()) - call ac%mv_from(ac_csr) - call ac%set_asb() - - if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() - if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr - ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() - - call coo_prol%set_ncols(desc_ac%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ptap ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_ls_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo - -end subroutine mld_s_ls_ptap - -subroutine mld_ls_ptap(a_csr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info,desc_ax) - use psb_base_mod - use mld_s_inner_mod - use mld_s_base_aggregator_mod!, mld_protect_name => mld_ls_ptap - implicit none - - ! Arguments - type(psb_ls_csr_sparse_mat), intent(inout) :: a_csr - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - type(mld_sml_parms), intent(inout) :: parms - type(psb_ls_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr - type(psb_desc_type), intent(inout) :: desc_ac - type(psb_lsspmat_type), intent(out) :: ac - integer(psb_ipk_), intent(out) :: info - type(psb_desc_type), intent(inout), optional :: desc_ax - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo - character(len=40) :: name - integer(psb_ipk_) :: ierr(5) - type(psb_ls_coo_sparse_mat) :: ac_coo, tmpcoo - type(psb_ls_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr - integer(psb_ipk_) :: debug_level, debug_unit, naggr - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nrl, nzl, ip, & - & nzt, naggrm1, naggrp1, i, k - integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza - logical, parameter :: do_timings=.true., oldstyle=.false., debug=.false. - integer(psb_ipk_), save :: idx_spspmm=-1 - - name='mld_ptap' - if(psb_get_errstatus().ne.0) return - info=psb_success_ - call psb_erractionsave(err_act) - - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - call psb_info(ictxt, me, np) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - if ((do_timings).and.(idx_spspmm==-1)) & - & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr - - ! - ! COO_PROL should arrive here with local numbering - ! - if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& - & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& - & nrow,ntaggr,naggr - - call coo_prol%cp_to_fmt(csr_prol,info) - - if (debug) write(0,*) me,trim(name),' Product AxPROL ',& - & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & - & desc_a%get_local_rows(),desc_a%get_local_cols(),& - & desc_ac%get_local_rows(),desc_a%get_local_cols() - if (debug) flush(0) - - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - - if (debug) write(0,*) me,trim(name),' Done AxPROL ',& - & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& - & desc_ac%get_local_rows(),desc_ac%get_local_cols() - - ! - ! Ok first product done. - - if (present(desc_ax)) then - block - type(psb_s_coo_sparse_mat) :: icoo_restr - - call coo_prol%cp_to_icoo(icoo_restr,info) - call icoo_restr%set_ncols(desc_ac%get_local_cols()) - call icoo_restr%set_nrows(desc_a%get_local_rows()) - call psb_s_coo_glob_transpose(icoo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) - call icoo_restr%set_nrows(desc_ac%get_local_rows()) - call icoo_restr%set_ncols(desc_ax%get_local_cols()) - write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& - & desc_a%get_local_cols(),desc_ax%get_local_cols(),icoo_restr%get_nzeros() - if (desc_a%get_local_cols()= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - - else - - ! - ! Remember that RESTR must be built from PROL after halo extension, - ! which is done above in psb_par_spspmm - if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& - & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() - call csr_prol%mv_to_coo(coo_restr,info) -!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& -!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() - if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) - - call coo_restr%transp() - nzl = coo_restr%get_nzeros() - nrl = desc_ac%get_local_rows() - i=0 - ! - ! Only keep local rows - ! - do k=1, nzl - if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then - i = i+1 - coo_restr%val(i) = coo_restr%val(k) - coo_restr%ia(i) = coo_restr%ia(k) - coo_restr%ja(i) = coo_restr%ja(k) - end if - end do - call coo_restr%set_nzeros(i) - call coo_restr%fix(info) - nzl = coo_restr%get_nzeros() - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_a%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) - call csr_restr%cp_from_coo(coo_restr,info) - -!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - end if - - call psb_cdasb(desc_ac,info) - - call ac_csr%set_nrows(desc_ac%get_local_rows()) - call ac_csr%set_ncols(desc_ac%get_local_cols()) - call ac%mv_from(ac_csr) - call ac%set_asb() - - if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() - if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr - ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() - - call coo_prol%set_ncols(desc_ac%get_local_cols()) - !call coo_restr%mv_from_ifmt(csr_restr,info) -!!$ call coo_restr%set_nrows(desc_ac%get_local_rows()) -!!$ call coo_restr%set_ncols(desc_a%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ptap ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_ls_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo - -end subroutine mld_ls_ptap diff --git a/mlprec/impl/aggregator/mld_s_soc1_map_bld.f90 b/mlprec/impl/aggregator/mld_s_soc1_map_bld.f90 deleted file mode 100644 index 7992b425..00000000 --- a/mlprec/impl/aggregator/mld_s_soc1_map_bld.f90 +++ /dev/null @@ -1,349 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_s_soc1_map__bld.f90 -! -! Subroutine: mld_s_soc1_map_bld -! Version: real -! -! This routine builds the tentative prolongator based on the -! strength of connection aggregation algorithm presented in -! -! M. Brezina and P. Vanek, A black-box iterative solver based on a -! two-level Schwarz method, Computing, 63 (1999), 233-263. -! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed -! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 -! (1996), 179-196. -! -! Note: upon exit -! -! Arguments: -! a - type(psb_sspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_sprec_type), input/output. -! The preconditioner data structure; upon exit it contains -! the multilevel hierarchy of prolongators, restrictors -! and coarse matrices. -! info - integer, output. -! Error code. -! -! -! -subroutine mld_s_soc1_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) - - use psb_base_mod - use mld_base_prec_type - use mld_s_inner_mod - - implicit none - - ! Arguments - integer(psb_ipk_), intent(in) :: iorder - logical, intent(in) :: clean_zeros - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - real(psb_spk_), intent(in) :: theta - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),& - & ideg(:), idxs(:) - integer(psb_lpk_), allocatable :: tmpaggr(:) - real(psb_spk_), allocatable :: val(:), diag(:) - integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr, nc, naggr,i,j,m, nz, ilg, ii, ip - type(psb_s_csr_sparse_mat) :: acsr - real(psb_spk_) :: cpling, tcl - logical :: disjoint - integer(psb_ipk_) :: debug_level, debug_unit,err_act - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: nrow, ncol, n_ne - integer(psb_lpk_) :: nrglob - character(len=20) :: name, ch_err - - info=psb_success_ - name = 'mld_soc1_map_bld' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ! - ictxt=desc_a%get_context() - call psb_info(ictxt,me,np) - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - nrglob = desc_a%get_global_rows() - - nr = a%get_nrows() - nc = a%get_ncols() - allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),& - & icol(nc),val(nc),stat=info) - if(info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),& - & a_err='integer') - goto 9999 - end if - - diag = a%get_diag(info) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='psb_sp_getdiag') - goto 9999 - end if - - call a%cp_to(acsr) - if (clean_zeros) call acsr%clean_zeros(info) - if (iorder == mld_aggr_ord_nat_) then - do i=1, nr - ilaggr(i) = -(nr+1) - idxs(i) = i - end do - else - do i=1, nr - ilaggr(i) = -(nr+1) - ideg(i) = acsr%irp(i+1) - acsr%irp(i) - end do - call psb_msort(ideg,ix=idxs,dir=psb_sort_down_) - end if - - - ! - ! Phase one: Start with disjoint groups. - ! - naggr = 0 - icnt = 0 - step1: do ii=1, nr - i = idxs(ii) - if ((i<1).or.(i>nr)) then - info=psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - if (ilaggr(i) == -(nr+1)) then - nz = (acsr%irp(i+1)-acsr%irp(i)) - if ((nz<0).or.(nz>size(icol))) then - info=psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) - val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) - - ! - ! Build the set of all strongly coupled nodes - ! - ip = 0 - do k=1, nz - j = icol(k) - if ((1<=j).and.(j<=nr)) then - if (abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j)))) then - ip = ip + 1 - icol(ip) = icol(k) - end if - end if - enddo - - ! - ! If the whole strongly coupled neighborhood of I is - ! as yet unconnected, turn it into the next aggregate. - ! Same if ip==0 (in which case, neighborhood only - ! contains I even if it does not look like it from matrix) - ! - disjoint = all(ilaggr(icol(1:ip)) == -(nr+1)).or.(ip==0) - if (disjoint) then - icnt = icnt + 1 - naggr = naggr + 1 - do k=1, ip - ilaggr(icol(k)) = naggr - end do - ilaggr(i) = naggr - end if - endif - enddo step1 - - if (debug_level >= psb_debug_outer_) then - write(debug_unit,*) me,' ',trim(name),& - & ' Check 1:',count(ilaggr == -(nr+1)) - end if - - ! - ! Phase two: join the neighbours - ! - tmpaggr = ilaggr - step2: do ii=1,nr - i = idxs(ii) - - if (ilaggr(i) == -(nr+1)) then - nz = (acsr%irp(i+1)-acsr%irp(i)) - if (nz == 1) cycle step2 - icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) - val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) - - ! - ! Find the most strongly connected neighbour that is - ! already aggregated, if any, and join its aggregate - ! - cpling = szero - ip = 0 - do k=1, nz - j = icol(k) - if ((1<=j).and.(j<=nr)) then - if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))& - & .and. (tmpaggr(j) > 0).and. (abs(val(k)) > cpling)) then - ip = k - cpling = abs(val(k)) - end if - end if - enddo - if (ip > 0) then - ilaggr(i) = ilaggr(icol(ip)) - end if - end if - end do step2 - - - ! - ! Phase three: sweep over leftovers, if any - ! - step3: do ii=1,nr - i = idxs(ii) - - if (ilaggr(i) < 0) then - nz = (acsr%irp(i+1)-acsr%irp(i)) - if (nz == 1) cycle step3 - icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) - val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) - ! - ! Find its strongly connected neighbourhood not - ! already aggregated, and make it into a new aggregate. - ! - cpling = szero - ip = 0 - do k=1, nz - j = icol(k) - if ((1<=j).and.(j<=nr)) then - if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))& - & .and. (ilaggr(j) < 0)) then - ip = ip + 1 - icol(ip) = icol(k) - end if - end if - enddo - if (ip > 0) then - icnt = icnt + 1 - naggr = naggr + 1 - ilaggr(i) = naggr - do k=1, ip - ilaggr(icol(k)) = naggr - end do - else - ! - ! This should not happen: we did not even connect with ourselves, - ! but it's not a singleton. - ! - naggr = naggr + 1 - ilaggr(i) = naggr - end if - end if - end do step3 - - ! Any leftovers? - do i=1, nr - if (ilaggr(i) < 0) then - nz = (acsr%irp(i+1)-acsr%irp(i)) - if (nz == 1) then - ! Mark explicitly as a singleton so that - ! it will be ignored in map_to_tprol. - ! Need to use -(nrglob+nr) to make sure - ! it's still negative when shifted and combined with - ! other processes. - ilaggr(i) = -(nrglob+nr) - else - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers') - goto 9999 - endif - end if - end do - - if (naggr > ncol) then - !write(0,*) name,'Error : naggr > ncol',naggr,ncol - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Fatal error: naggr>ncol') - goto 9999 - end if - - call psb_realloc(ncol,ilaggr,info) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_realloc' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - allocate(nlaggr(np),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),& - & a_err='integer') - goto 9999 - end if - - nlaggr(:) = 0 - nlaggr(me+1) = naggr - call psb_sum(ictxt,nlaggr(1:np)) - - call acsr%free() - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_soc1_map_bld - diff --git a/mlprec/impl/aggregator/mld_s_soc2_map_bld.f90 b/mlprec/impl/aggregator/mld_s_soc2_map_bld.f90 deleted file mode 100644 index 7fcce613..00000000 --- a/mlprec/impl/aggregator/mld_s_soc2_map_bld.f90 +++ /dev/null @@ -1,348 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_s_soc2_map__bld.f90 -! -! Subroutine: mld_s_soc2_map_bld -! Version: real -! -! The aggregator object hosts the aggregation method for building -! the multilevel hierarchy. This variant is based on the method -! presented in -! -! S. Gratton, P. Henon, P. Jiranek and X. Vasseur: -! Reducing complexity of algebraic multigrid by aggregation -! Numerical Lin. Algebra with Applications, 2016, 23:501-518 -! -! Note: upon exit -! -! Arguments: -! a - type(psb_sspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_sprec_type), input/output. -! The preconditioner data structure; upon exit it contains -! the multilevel hierarchy of prolongators, restrictors -! and coarse matrices. -! info - integer, output. -! Error code. -! -! -! -subroutine mld_s_soc2_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) - - use psb_base_mod - use mld_base_prec_type - use mld_s_inner_mod - - implicit none - - ! Arguments - integer(psb_ipk_), intent(in) :: iorder - logical, intent(in) :: clean_zeros - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - real(psb_spk_), intent(in) :: theta - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),& - & ideg(:), idxs(:) - integer(psb_lpk_), allocatable :: tmpaggr(:) - real(psb_spk_), allocatable :: val(:), diag(:) - integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr,nc,naggr,i,j,m, nz, ilg, ii, ip, ip1,nzcnt - integer(psb_lpk_) :: nrglob - type(psb_s_csr_sparse_mat) :: acsr, muij, s_neigh - type(psb_s_coo_sparse_mat) :: s_neigh_coo - real(psb_spk_) :: cpling, tcl - logical :: disjoint - integer(psb_ipk_) :: debug_level, debug_unit,err_act - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: nrow, ncol, n_ne - character(len=20) :: name, ch_err - - info=psb_success_ - name = 'mld_soc2_map_bld' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ! - ictxt=desc_a%get_context() - call psb_info(ictxt,me,np) - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - nrglob = desc_a%get_global_rows() - - nr = a%get_nrows() - nc = a%get_ncols() - allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),icol(nc),stat=info) - if(info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),& - & a_err='integer') - goto 9999 - end if - - diag = a%get_diag(info) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='psb_sp_getdiag') - goto 9999 - end if - - ! - ! Phase zero: compute muij - ! - call a%cp_to(muij) - if (clean_zeros) call muij%clean_zeros(info) - do i=1, nr - do k=muij%irp(i),muij%irp(i+1)-1 - j = muij%ja(k) - if (j<= nr) muij%val(k) = abs(muij%val(k))/sqrt(abs(diag(i)*diag(j))) - end do - end do - - ! - ! Compute the 1-neigbour; mark strong links with +1, weak links with -1 - ! - call s_neigh_coo%allocate(nr,nr,muij%get_nzeros()) - ip = 0 - do i=1, nr - do k=muij%irp(i),muij%irp(i+1)-1 - j = muij%ja(k) - if (j<=nr) then - ip = ip + 1 - s_neigh_coo%ia(ip) = i - s_neigh_coo%ja(ip) = j - if (real(muij%val(k)) >= theta) then - s_neigh_coo%val(ip) = sone - else - s_neigh_coo%val(ip) = -sone - end if - end if - end do - end do - !write(*,*) 'S_NEIGH: ',nr,ip - call s_neigh_coo%set_nzeros(ip) - call s_neigh%mv_from_coo(s_neigh_coo,info) - - if (iorder == mld_aggr_ord_nat_) then - do i=1, nr - ilaggr(i) = -(nr+1) - idxs(i) = i - end do - else - do i=1, nr - ilaggr(i) = -(nr+1) - ideg(i) = muij%irp(i+1) - muij%irp(i) - end do - call psb_msort(ideg,ix=idxs,dir=psb_sort_down_) - end if - - - ! - ! Phase one: Start with disjoint groups. - ! - naggr = 0 - icnt = 0 - step1: do ii=1, nr - i = idxs(ii) - - if (ilaggr(i) == -(nr+1)) then - ! - ! Get the 1-neighbourhood of I - ! - ip1 = s_neigh%irp(i) - nz = s_neigh%irp(i+1)-ip1 - ! - ! If the neighbourhood only contains I, skip it - ! - if (nz ==0) then - ilaggr(i) = 0 - cycle step1 - end if - if ((nz==1).and.(s_neigh%ja(ip1)==i)) then - ilaggr(i) = 0 - cycle step1 - end if - ! - ! If the whole strongly coupled neighborhood of I is - ! as yet unconnected, turn it into the next aggregate. - ! - nzcnt = count(real(s_neigh%val(ip1:ip1+nz-1)) > 0) - icol(1:nzcnt) = pack(s_neigh%ja(ip1:ip1+nz-1),(real(s_neigh%val(ip1:ip1+nz-1)) > 0)) - disjoint = all(ilaggr(icol(1:nzcnt)) == -(nr+1)) - if (disjoint) then - icnt = icnt + 1 - naggr = naggr + 1 - do k=1, nzcnt - ilaggr(icol(k)) = naggr - end do - ilaggr(i) = naggr - end if - endif - enddo step1 - - if (debug_level >= psb_debug_outer_) then - write(debug_unit,*) me,' ',trim(name),& - & ' Check 1:',count(ilaggr == -(nr+1)) - end if - - ! - ! Phase two: join the neighbours - ! - tmpaggr = ilaggr - step2: do ii=1,nr - i = idxs(ii) - - if (ilaggr(i) == -(nr+1)) then - ! - ! Find the most strongly connected neighbour that is - ! already aggregated, if any, and join its aggregate - ! - cpling = szero - ip = 0 - do k=s_neigh%irp(i), s_neigh%irp(i+1)-1 - j = s_neigh%ja(k) - if ((1<=j).and.(j<=nr)) then - if ( (tmpaggr(j) > 0).and. (real(muij%val(k)) > cpling)& - & .and.(real(s_neigh%val(k))>0)) then - ip = k - cpling = muij%val(k) - end if - end if - enddo - if (ip > 0) then - ilaggr(i) = ilaggr(s_neigh%ja(ip)) - end if - end if - end do step2 - - - ! - ! Phase three: sweep over leftovers, if any - ! - step3: do ii=1,nr - i = idxs(ii) - - if (ilaggr(i) < 0) then - ! - ! Find its strongly connected neighbourhood not - ! already aggregated, and make it into a new aggregate. - ! - ip = 0 - do k=s_neigh%irp(i), s_neigh%irp(i+1)-1 - j = s_neigh%ja(k) - if ((1<=j).and.(j<=nr)) then - if (ilaggr(j) < 0) then - ip = ip + 1 - icol(ip) = j - end if - end if - enddo - if (ip > 0) then - icnt = icnt + 1 - naggr = naggr + 1 - ilaggr(i) = naggr - do k=1, ip - ilaggr(icol(k)) = naggr - end do - end if - end if - end do step3 - - ! Any leftovers? - do i=1, nr - if (ilaggr(i) <= 0) then - nz = (s_neigh%irp(i+1)-s_neigh%irp(i)) - if (nz <= 1) then - ! Mark explicitly as a singleton so that - ! it will be ignored in map_to_tprol. - ! Need to use -(nrglob+nr) to make sure - ! it's still negative when shifted and combined with - ! other processes. - ilaggr(i) = -(nrglob+nr) - else - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers') - goto 9999 - endif - end if - end do - - if (naggr > ncol) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Fatal error: naggr>ncol') - goto 9999 - end if - - call psb_realloc(ncol,ilaggr,info) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_realloc' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - allocate(nlaggr(np),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),& - & a_err='integer') - goto 9999 - end if - - nlaggr(:) = 0 - nlaggr(me+1) = naggr - call psb_sum(ictxt,nlaggr(1:np)) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_soc2_map_bld - diff --git a/mlprec/impl/aggregator/mld_s_symdec_aggregator_tprol.f90 b/mlprec/impl/aggregator/mld_s_symdec_aggregator_tprol.f90 deleted file mode 100644 index 007250e9..00000000 --- a/mlprec/impl/aggregator/mld_s_symdec_aggregator_tprol.f90 +++ /dev/null @@ -1,160 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_s_symdec_aggregator_tprol.f90 -! -! Subroutine: mld_s_symdec_aggregator_tprol -! Version: real -! -! -! This routine is mainly an interface to soc_map_bld where the real work is performed. -! It takes care of some consistency checking, and calls map_to_tprol, which is -! refactored and shared among all the aggregation methods that produce a simple -! integer mapping. It also symmetrizes the pattern of the local matrix A. -! -! -! -! Arguments: -! Arguments: -! ag - type(mld_s_dec_aggregator_type), input/output. -! The aggregator object, carrying with itself the mapping algorithm. -! parms - The auxiliary parameters object -! ag_data - Auxiliary global aggregation parameters object -! -! a - type(psb_sspmat_type). -! The sparse matrix structure containing the local part of the -! fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! ilaggr - integer, dimension(:), allocatable, output -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that on exit the indices -! will be shifted so as to make sure the ranges on the various processes do not -! overlap. -! nlaggr - integer, dimension(:), allocatable, output -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_sspmat_type), output -! The tentative prolongator, based on ilaggr. -! -! info - integer, output. -! Error code. -! -subroutine mld_s_symdec_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,op_prol,info) - use psb_base_mod - use mld_s_prec_type - use mld_s_symdec_aggregator_mod, mld_protect_name => mld_s_symdec_aggregator_build_tprol - use mld_s_inner_mod - implicit none - class(mld_s_symdec_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(mld_saggr_data), intent(in) :: ag_data - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lsspmat_type), intent(out) :: op_prol - integer(psb_ipk_), intent(out) :: info - - ! Local variables - type(psb_sspmat_type) :: atmp, atrans - character(len=20) :: name - integer(psb_mpk_) :: ictxt, np, me - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: nr - integer(psb_lpk_) :: ntaggr - integer(psb_ipk_) :: debug_level, debug_unit - logical :: clean_zeros - - name='mld_s_symdec_aggregator_tprol' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - call mld_check_def(parms%ml_cycle,'Multilevel cycle',& - & mld_mult_ml_,is_legal_ml_cycle) - call mld_check_def(parms%par_aggr_alg,'Aggregation',& - & mld_dec_aggr_,is_legal_ml_par_aggr_alg) - call mld_check_def(parms%aggr_ord,'Ordering',& - & mld_aggr_ord_nat_,is_legal_ml_aggr_ord) - call mld_check_def(parms%aggr_thresh,'Aggr_Thresh',szero,is_legal_s_aggr_thrs) - - nr = a%get_nrows() - call a%csclip(atmp,info,imax=nr,jmax=nr,& - & rscale=.false.,cscale=.false.) - call atmp%set_nrows(nr) - call atmp%set_ncols(nr) - if (info == psb_success_) call atmp%transp(atrans) - if (info == psb_success_) call atrans%cscnv(info,type='COO') - if (info == psb_success_) call psb_rwextd(nr,atmp,info,b=atrans,rowscale=.false.) - call atmp%set_nrows(nr) - call atmp%set_ncols(nr) - if (info == psb_success_) call atrans%free() - if (info == psb_success_) call atmp%cscnv(info,type='CSR') - - ! - ! The decoupled aggregator based on SOC measures ignores - ! ag_data except for clean_zeros; soc_map_bld is a procedure pointer. - ! - clean_zeros = ag%do_clean_zeros - if (info == psb_success_) & - & call ag%soc_map_bld(parms%aggr_ord,parms%aggr_thresh,clean_zeros,atmp,& - & desc_a,nlaggr,ilaggr,info) - if (info == psb_success_) call atmp%free() - - if (info == psb_success_) call mld_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='soc_map_bld/map_to_tprol') - goto 9999 - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_s_symdec_aggregator_build_tprol diff --git a/mlprec/impl/aggregator/mld_saggrmat_minnrg_bld.f90 b/mlprec/impl/aggregator/mld_saggrmat_minnrg_bld.f90 deleted file mode 100644 index ce7a4e68..00000000 --- a/mlprec/impl/aggregator/mld_saggrmat_minnrg_bld.f90 +++ /dev/null @@ -1,656 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_saggrmat_minnrg_bld.F90 -! -! Subroutine: mld_saggrmat_minnrg_bld -! Version: real -! -! This routine builds a coarse-level matrix A_C from a fine-level matrix A -! by using the Galerkin approach, i.e. -! -! A_C = P_C^T A P_C, -! -! where P_C is a prolongator from the coarse level to the fine one. -! -! The prolongator P_C is built according to a smoothed aggregation algorithm, -! i.e. it is obtained by applying a damped Jacobi smoother to the piecewise -! constant interpolation operator P corresponding to the fine-to-coarse level -! mapping built by the mld_aggrmap_bld subroutine: -! -! P_C = (I - omega*D^(-1)A) * P, -! -! where D is the diagonal matrix with main diagonal equal to the main diagonal -! of A, and omega is a suitable smoothing parameter. An estimate of the spectral -! radius of D^(-1)A, to be used in the computation of omega, is provided, -! according to the value of p%parms%aggr_omega_alg, specified by the user -! through mld_sprecinit and mld_sprecset. -! 4. Minimum energy aggregation: -! M. Sala, R. Tuminaro: A new Petrov-Galerkin smoothed aggregation preconditioner -! for nonsymmetric linear systems, SIAM J. Sci. Comput., 31(1):143-166 (2008) -! -! On output from this routine the entries of AC, op_prol, op_restr -! are still in "global numbering" mode; this is fixed in the calling routine -! aggregator%mat_bld. -! -! -! Arguments: -! a - type(psb_sspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! p - type(mld_s_onelev_type), input/output. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! parms - type(mld_sml_parms), input -! Parameters controlling the choice of algorithm -! ac - type(psb_sspmat_type), output -! The coarse matrix on output -! -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_sspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_sspmat_type), output -! The restrictor operator; in this particular case, it is different -! from the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -! -subroutine mld_saggrmat_minnrg_bld(a,desc_a,ilaggr,nlaggr,parms,& - & ac,desc_ac,op_prol,op_restr,info) - use psb_base_mod - use mld_base_prec_type - use mld_s_inner_mod, mld_protect_name => mld_saggrmat_minnrg_bld - - implicit none - - ! Arguments - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(mld_sml_parms), intent(inout) :: parms - type(psb_lsspmat_type), intent(inout) :: op_prol - type(psb_lsspmat_type), intent(out) :: ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nzac, ip, ndx,& - & naggr, nzl,naggrm1,naggrp1, i, j, k, jd, icolF, nrt - integer(psb_ipk_) :: ictxt,np,me, icomm - character(len=20) :: name - type(psb_lsspmat_type) :: la, af, ptilde, rtilde, atran, atp, atdatp - type(psb_lsspmat_type) :: am3,am4, ap, adap,atmp,rada, ra, atmp2, dap, dadap, da - type(psb_lsspmat_type) :: dat, datp, datdatp, atmp3, tmp_prol - type(psb_ls_coo_sparse_mat) :: tmpcoo - type(psb_ls_csr_sparse_mat) :: acsr1, acsr2, acsr3, acsr, acsrf - type(psb_ls_csc_sparse_mat) :: csc_dap, csc_dadap, csc_datp, csc_datdatp, acsc - real(psb_spk_), allocatable :: adiag(:), adinv(:) - real(psb_spk_), allocatable :: omf(:), omp(:), omi(:), oden(:) - logical :: filter_mat - integer(psb_ipk_) :: ierr(5) - integer(psb_ipk_) :: debug_level, debug_unit, err_act - integer(psb_ipk_), parameter :: ncmax=16 - real(psb_spk_) :: anorm, theta - real(psb_spk_) :: tmp, alpha, beta, ommx - - name='mld_aggrmat_minnrg' - info=psb_success_ - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - ictxt = desc_a%get_context() - - call psb_info(ictxt, me, np) - - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - theta = parms%aggr_thresh - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - - filter_mat = (parms%aggr_filter == mld_filter_mat_) - - ! naggr: number of local aggregates - ! nrow: local rows. - ! - allocate(adinv(ncol),& - & omf(ncol),omp(ntaggr),oden(ntaggr),omi(ncol),stat=info) - - if (info /= psb_success_) then - info=psb_err_alloc_request_; ierr(1)=6*ncol+ntaggr; - call psb_errpush(info,name,i_err=ierr,a_err='real(psb_spk_)') - goto 9999 - end if - - ! Get the diagonal D - adiag = a%get_diag(info) - if (info == psb_success_) & - & call psb_realloc(ncol,adiag,info) - if (info == psb_success_) & - & call psb_halo(adiag,desc_a,info) - if (info == psb_success_) call a%cp_to_l(la) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_getdiag') - goto 9999 - end if - - do i=1,size(adiag) - if (adiag(i) /= szero) then - adinv(i) = sone / adiag(i) - else - adinv(i) = sone - end if - end do - - - - ! 1. Allocate Ptilde in sparse matrix form - call op_prol%mv_to(tmpcoo) - call ptilde%mv_from(tmpcoo) - call ptilde%cscnv(info,type='csr') - - if (info == psb_success_) call la%cscnv(am3,info,type='csr',dupl=psb_dupl_add_) - if (info == psb_success_) call la%cscnv(da,info,type='csr',dupl=psb_dupl_add_) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' Initial copies done.' - - call da%scal(adinv,info) - - call psb_spspmm(da,ptilde,dap,info) - - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 1') - goto 9999 - end if - - call dap%clone(atmp,info) - - call psb_sphalo(atmp,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.,outfmt='CSR ') - if (info == psb_success_) call psb_rwextd(ncol,atmp,info,b=am4) - if (info == psb_success_) call am4%free() - - call psb_spspmm(da,atmp,dadap,info) - call atmp%free() - - ! !$ write(0,*) 'Columns of AP',psb_sp_get_ncols(ap) - ! !$ write(0,*) 'Columns of ADAP',psb_sp_get_ncols(adap) - call dap%mv_to(csc_dap) - call dadap%mv_to(csc_dadap) - - call csc_mat_col_prod(csc_dap,csc_dadap,omp,info) - call csc_mat_col_prod(csc_dadap,csc_dadap,oden,info) - call psb_sum(ictxt,omp) - call psb_sum(ictxt,oden) - ! !$ write(0,*) trim(name),' OMP :',omp - ! !$ write(0,*) trim(name),' ODEN:',oden - - omp = omp/oden - - ! !$ write(0,*) 'Check on output prolongator ',omp(1:min(size(omp),10)) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done NUMBMM 1' - - call am3%mv_to(acsr3) - ! Compute omega_int - ommx = szero - do i=1, ncol - if (ilaggr(i) >0) then - omi(i) = omp(ilaggr(i)) - else - omi(i) = szero - end if - if(abs(omi(i)) .gt. abs(ommx)) ommx = omi(i) - end do - ! Compute omega_fine - do i=1, nrow - omf(i) = ommx - do j=acsr3%irp(i),acsr3%irp(i+1)-1 - if(abs(omi(acsr3%ja(j))) .lt. abs(omf(i))) omf(i)=omi(acsr3%ja(j)) - end do -!!$ if(min(real(omf(i)),aimag(omf(i))) < szero) omf(i) = szero - if(psb_minreal(omf(i)) < szero) omf(i) = szero - end do - - omf(1:nrow) = omf(1:nrow) * adinv(1:nrow) - - if (filter_mat) then - ! - ! Build the filtered matrix Af from A - ! - call la%cscnv(acsrf,info,dupl=psb_dupl_add_) - - do i=1,nrow - tmp = szero - jd = -1 - do j=acsrf%irp(i),acsrf%irp(i+1)-1 - if (acsrf%ja(j) == i) jd = j - if (abs(acsrf%val(j)) < theta*sqrt(abs(adiag(i)*adiag(acsrf%ja(j))))) then - tmp=tmp+acsrf%val(j) - acsrf%val(j)=szero - endif - enddo - if (jd == -1) then - write(0,*) 'Wrong input: we need the diagonal!!!!', i - else - acsrf%val(jd)=acsrf%val(jd)-tmp - end if - enddo - ! Take out zeroed terms - call acsrf%clean_zeros(info) - - ! - ! Build the smoothed prolongator using the filtered matrix - ! - do i=1,acsrf%get_nrows() - do j=acsrf%irp(i),acsrf%irp(i+1)-1 - if (acsrf%ja(j) == i) then - acsrf%val(j) = sone - omf(i)*acsrf%val(j) - else - acsrf%val(j) = - omf(i)*acsrf%val(j) - end if - end do - end do - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done gather, going for SYMBMM 1' - - call af%mv_from(acsrf) - ! - ! op_prol = (I-w*D*Af)Ptilde - ! Doing it this way means to consider diag(Af_i) - ! - ! - call psb_spspmm(af,ptilde,op_prol,info) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done SPSPMM 1' - else - ! - ! Build the smoothed prolongator using the original matrix - ! - do i=1,acsr3%get_nrows() - do j=acsr3%irp(i),acsr3%irp(i+1)-1 - if (acsr3%ja(j) == i) then - acsr3%val(j) = sone - omf(i)*acsr3%val(j) - else - acsr3%val(j) = - omf(i)*acsr3%val(j) - end if - end do - end do - - call am3%mv_from(acsr3) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done gather, going for SYMBMM 1' - ! - ! - ! op_prol = (I-w*D*A)Ptilde - ! - ! - call psb_spspmm(am3,ptilde,op_prol,info) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done NUMBMM 1' - - end if - - - ! - ! Ok, let's start over with the restrictor - ! - call ptilde%transc(rtilde) - call la%cscnv(atmp,info,type='csr') - call psb_sphalo(atmp,desc_a,am4,info,& - & colcnv=.true.,rowscale=.true.) - nrt = am4%get_nrows() - call am4%csclip(atmp2,info,lone,nrt,lone,ncol) - call atmp2%cscnv(info,type='CSR') - if (info == psb_success_) call psb_rwextd(ncol,atmp,info,b=atmp2) - call am4%free() - call atmp2%free() - - ! This is to compute the transpose. It ONLY works if the - ! original A has a symmetric pattern. - call atmp%transc(atmp2) - call atmp2%csclip(dat,info,lone,nrow,lone,ncol) - call dat%cscnv(info,type='csr') - call dat%scal(adinv,info) - - ! Now for the product. - call psb_spspmm(dat,ptilde,datp,info) - - call datp%clone(atmp2,info) - call psb_sphalo(atmp2,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.,outfmt='CSR ') - if (info == psb_success_) call psb_rwextd(ncol,atmp2,info,b=am4) - if (info == psb_success_) call am4%free() - - - call psb_symbmm(dat,atmp2,datdatp,info) - call psb_numbmm(dat,atmp2,datdatp) - call atmp2%free() - - call datp%mv_to(csc_datp) - call datdatp%mv_to(csc_datdatp) - - call csc_mat_col_prod(csc_datp,csc_datdatp,omp,info) - call csc_mat_col_prod(csc_datdatp,csc_datdatp,oden,info) - call psb_sum(ictxt,omp) - call psb_sum(ictxt,oden) - - - ! !$ write(debug_unit,*) trim(name),' OMP_R :',omp - ! ! $ write(debug_unit,*) trim(name),' ODEN_R:',oden - omp = omp/oden - ! !$ write(0,*) 'Check on output restrictor',omp(1:min(size(omp),10)) - ! Compute omega_int - ommx = szero - do i=1, ncol - if (ilaggr(i) >0) then - omi(i) = omp(ilaggr(i)) - else - omi(i) = szero - end if - if(abs(omi(i)) .gt. abs(ommx)) ommx = omi(i) - end do - ! Compute omega_fine - ! Going over the columns of atmp means going over the rows - ! of A^T. Hopefully ;-) - call atmp%cp_to(acsc) - - do i=1, nrow - omf(i) = ommx - do j= acsc%icp(i),acsc%icp(i+1)-1 - if(abs(omi(acsc%ia(j))) .lt. abs(omf(i))) omf(i)=omi(acsc%ia(j)) - end do -!!$ if(min(real(omf(i)),aimag(omf(i))) < szero) omf(i) = szero - if(psb_minreal(omf(i)) < szero) omf(i) = szero - end do - omf(1:nrow) = omf(1:nrow)*adinv(1:nrow) - call psb_halo(omf,desc_a,info) - call acsc%free() - - - call atmp%mv_to(acsr1) - - do i=1,acsr1%get_nrows() - do j=acsr1%irp(i),acsr1%irp(i+1)-1 - if (acsr1%ja(j) == i) then - acsr1%val(j) = sone - acsr1%val(j)*omf(acsr1%ja(j)) - else - acsr1%val(j) = - acsr1%val(j)*omf(acsr1%ja(j)) - end if - end do - end do - call atmp%mv_from(acsr1) - - call rtilde%mv_to(tmpcoo) - nzl = tmpcoo%get_nzeros() - i=0 - do k=1, nzl - if ((naggrm1 < tmpcoo%ia(k)) .and. (tmpcoo%ia(k) <= naggrp1)) then - i = i+1 - tmpcoo%val(i) = tmpcoo%val(k) - tmpcoo%ia(i) = tmpcoo%ia(k) - tmpcoo%ja(i) = tmpcoo%ja(k) - end if - end do - call tmpcoo%set_nzeros(i) - call rtilde%mv_from(tmpcoo) - call rtilde%cscnv(info,type='csr') - - call psb_spspmm(rtilde,atmp,op_restr,info) - - ! - ! Now we have to gather the halo of op_prol, and add it to itself - ! to multiply it by A, - ! - call op_prol%clone(tmp_prol,info) - if (info == psb_success_) call psb_sphalo(tmp_prol,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.) - if (info == psb_success_) call psb_rwextd(ncol,tmp_prol,info,b=am4) - if (info == psb_success_) call am4%free() - - if(info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Halo of op_prol') - goto 9999 - end if - - ! - ! Now we have to fix this. The only rows of B that are correct - ! are those corresponding to "local" aggregates, i.e. indices in ilaggr(:) - ! - call op_restr%mv_to(tmpcoo) - - nzl = tmpcoo%get_nzeros() - i=0 - do k=1, nzl - if ((naggrm1 < tmpcoo%ia(k)) .and. (tmpcoo%ia(k) <= naggrp1)) then - i = i+1 - tmpcoo%val(i) = tmpcoo%val(k) - tmpcoo%ia(i) = tmpcoo%ia(k) - tmpcoo%ja(i) = tmpcoo%ja(k) - end if - end do - call tmpcoo%set_nzeros(i) - call op_restr%mv_from(tmpcoo) - call op_restr%cscnv(info,type='csr') - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - call psb_spspmm(la,tmp_prol,am3,info) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done SPSPMM 2' - - call psb_sphalo(am3,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.) - if (info == psb_success_) call psb_rwextd(ncol,am3,info,b=am4) - if (info == psb_success_) call am4%free() - - if(info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Extend am3') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done sphalo/ rwxtd' - - call psb_spspmm(op_restr,am3,ac,info) - if (info == psb_success_) call am3%free() - if (info == psb_success_) call ac%cscnv(info,type='coo',dupl=psb_dupl_add_) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - &a_err='Build ac = op_restr x am3') - goto 9999 - end if - - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done smooth_aggregate ' - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_errpush(info,name) - call psb_error_handler(err_act) - return - - -contains - - subroutine csc_mat_col_prod(a,b,v,info) - implicit none - type(psb_ls_csc_sparse_mat), intent(in) :: a, b - real(psb_spk_), intent(out) :: v(:) - integer(psb_ipk_), intent(out) :: info - - integer(psb_lpk_) :: i,j,k, nr, nc,iap,nra,ibp,nrb - - info = psb_success_ - nc = a%get_ncols() - if (nc /= b%get_ncols()) then - write(0,*) 'Matrices A and B should have same columns' - info = -1 - return - end if - - do j=1, nc - iap = a%icp(j) - nra = a%icp(j+1)-iap - ibp = b%icp(j) - nrb = b%icp(j+1)-ibp - v(j) = sparse_srtd_dot(nra,a%ia(iap:iap+nra-1),a%val(iap:iap+nra-1),& - & nrb,b%ia(ibp:ibp+nrb-1),b%val(ibp:ibp+nrb-1)) - end do - - end subroutine csc_mat_col_prod - - - subroutine csr_mat_row_prod(a,b,v,info) - implicit none - type(psb_ls_csr_sparse_mat), intent(in) :: a, b - real(psb_spk_), intent(out) :: v(:) - integer(psb_ipk_), intent(out) :: info - - integer(psb_lpk_) :: i,j,k, nr, nc,iap,nca,ibp,ncb - - info = psb_success_ - nr = a%get_nrows() - if (nr /= b%get_nrows()) then - write(0,*) 'Matrices A and B should have same rows' - info = -1 - return - end if - - do j=1, nr - iap = a%irp(j) - nca = a%irp(j+1)-iap - ibp = b%irp(j) - ncb = b%irp(j+1)-ibp - v(j) = sparse_srtd_dot(nca,a%ja(iap:iap+nca-1),a%val(iap:iap+nca-1),& - & ncb,b%ja(ibp:ibp+ncb-1),b%val(ibp:ibp+ncb-1)) - end do - - end subroutine csr_mat_row_prod - - - function sparse_srtd_dot(nv1,iv1,v1,nv2,iv2,v2) result(dot) - implicit none - integer(psb_lpk_), intent(in) :: nv1,nv2 - integer(psb_lpk_), intent(in) :: iv1(:), iv2(:) - real(psb_spk_), intent(in) :: v1(:),v2(:) - real(psb_spk_) :: dot - - integer(psb_lpk_) :: i,j,k, ip1, ip2 - - dot = szero - ip1 = 1 - ip2 = 1 - - do - if (ip1 > nv1) exit - if (ip2 > nv2) exit - if (iv1(ip1) == iv2(ip2)) then - dot = dot + (v1(ip1))*v2(ip2) - ip1 = ip1 + 1 - ip2 = ip2 + 1 - else if (iv1(ip1) < iv2(ip2)) then - ip1 = ip1 + 1 - else - ip2 = ip2 + 1 - end if - end do - - end function sparse_srtd_dot - - subroutine local_dump(me,mat,name,header) - type(psb_lsspmat_type), intent(in) :: mat - integer(psb_ipk_), intent(in) :: me - character(len=*), intent(in) :: name - character(len=*), intent(in) :: header - character(len=80) :: filename - - write(filename,'(a,a,i0,a,i0,a)') trim(name),'.p',me - open(20+me,file=filename) - call mat%print(20+me,head=trim(header)) - close(20+me) - end subroutine local_dump - -end subroutine mld_saggrmat_minnrg_bld diff --git a/mlprec/impl/aggregator/mld_saggrmat_nosmth_bld.f90 b/mlprec/impl/aggregator/mld_saggrmat_nosmth_bld.f90 deleted file mode 100644 index 9b8db96a..00000000 --- a/mlprec/impl/aggregator/mld_saggrmat_nosmth_bld.f90 +++ /dev/null @@ -1,198 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_saggrmat_nosmth_bld.F90 -! -! Subroutine: mld_saggrmat_nosmth_bld -! Version: real -! -! This routine builds a coarse-level matrix A_C from a fine-level matrix A -! by using the Galerkin approach, i.e. -! -! A_C = P_C^T A P_C, -! -! where P_C is the piecewise constant interpolation operator corresponding -! the fine-to-coarse level mapping built by mld_aggrmap_bld. -! -! The coarse-level matrix A_C is distributed among the parallel processes or -! replicated on each of them, according to the value of p%parms%coarse_mat -! specified by the user through mld_sprecinit and mld_zprecset. -! On output from this routine the entries of AC, op_prol, op_restr -! are still in "global numbering" mode; this is fixed in the calling routine -! aggregator%mat_bld. -! -! For details see -! P. D'Ambra, D. di Serafino and S. Filippone, On the development of -! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math., -! 57 (2007), 1181-1196. -! -! -! Arguments: -! a - type(psb_sspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! p - type(mld_s_onelev_type), input/output. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! parms - type(mld_sml_parms), input -! Parameters controlling the choice of algorithm -! ac - type(psb_sspmat_type), output -! The coarse matrix on output -! -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_sspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_sspmat_type), output -! The restrictor operator; normally, it is the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -! -subroutine mld_saggrmat_nosmth_bld(a,desc_a,ilaggr,nlaggr,parms,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - use psb_base_mod - use mld_base_prec_type - use mld_s_inner_mod, mld_protect_name => mld_saggrmat_nosmth_bld - use mld_s_base_aggregator_mod - implicit none - - ! Arguments - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(mld_sml_parms), intent(inout) :: parms - type(psb_sspmat_type), intent(inout) :: op_prol,ac,op_restr - type(psb_lsspmat_type), intent(inout) :: t_prol - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt, np, me, icomm, minfo - character(len=20) :: name - type(psb_ls_coo_sparse_mat) :: lcoo_prol - type(psb_s_coo_sparse_mat) :: coo_prol, coo_restr - type(psb_s_csr_sparse_mat) :: acsr - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nzl, ip, & - & naggr, nzt, naggrm1, naggrp1, i, k - integer(psb_ipk_) :: inaggr, nzlp - logical, parameter :: debug = .false. - - name = 'mld_aggrmat_nosmth_bld' - info = psb_success_ - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - call psb_info(ictxt, me, np) - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - - call a%cp_to(acsr) - call t_prol%mv_to(lcoo_prol) - inaggr = naggr - call psb_cdall(ictxt,desc_ac,info,nl=inaggr) - nzlp = lcoo_prol%get_nzeros() - call desc_ac%indxmap%g2lip_ins(lcoo_prol%ja(1:nzlp),info) - call lcoo_prol%set_ncols(desc_ac%get_local_cols()) - call lcoo_prol%cp_to_icoo(coo_prol,info) - - if (debug) call check_coo(me,trim(name)//' Check 1 on coo_prol:',coo_prol) - - call psb_cdasb(desc_ac,info) - call psb_cd_reinit(desc_ac,info) - - call mld_ptap(acsr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info) - - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_a%get_local_cols()) - call coo_prol%set_nrows(desc_a%get_local_rows()) - call coo_prol%set_ncols(desc_ac%get_local_cols()) - - if (debug) call check_coo(me,trim(name)//' Check 1 on coo_restr:',coo_restr) - - call op_prol%mv_from(coo_prol) - call op_restr%mv_from(coo_restr) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_s_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo -end subroutine mld_saggrmat_nosmth_bld diff --git a/mlprec/impl/aggregator/mld_saggrmat_smth_bld.f90 b/mlprec/impl/aggregator/mld_saggrmat_smth_bld.f90 deleted file mode 100644 index fb967d50..00000000 --- a/mlprec/impl/aggregator/mld_saggrmat_smth_bld.f90 +++ /dev/null @@ -1,325 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_saggrmat_smth_bld.F90 -! -! Subroutine: mld_saggrmat_smth_bld -! Version: real -! -! This routine builds a coarse-level matrix A_C from a fine-level matrix A -! by using the Galerkin approach, i.e. -! -! A_C = P_C^T A P_C, -! -! where P_C is a prolongator from the coarse level to the fine one. -! -! The prolongator P_C is built according to a smoothed aggregation algorithm, -! i.e. it is obtained by applying a damped Jacobi smoother to the piecewise -! constant interpolation operator P corresponding to the fine-to-coarse level -! mapping built by the mld_aggrmap_bld subroutine: -! -! P_C = (I - omega*D^(-1)A) * P, -! -! where D is the diagonal matrix with main diagonal equal to the main diagonal -! of A, and omega is a suitable smoothing parameter. An estimate of the spectral -! radius of D^(-1)A, to be used in the computation of omega, is provided, -! according to the value of p%parms%aggr_omega_alg, specified by the user -! through mld_sprecinit and mld_zprecset. -! -! The coarse-level matrix A_C is distributed among the parallel processes or -! replicated on each of them, according to the value of p%parms%coarse_mat, -! specified by the user through mld_sprecinit and mld_zprecset. -! On output from this routine the entries of AC, op_prol, op_restr -! are still in "global numbering" mode; this is fixed in the calling routine -! aggregator%mat_bld. -! -! -! Arguments: -! a - type(psb_sspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! p - type(mld_s_onelev_type), input/output. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! parms - type(mld_sml_parms), input -! Parameters controlling the choice of algorithm -! ac - type(psb_sspmat_type), output -! The coarse matrix on output -! -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_sspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_sspmat_type), output -! The restrictor operator; normally, it is the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -subroutine mld_saggrmat_smth_bld(a,desc_a,ilaggr,nlaggr,parms,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - use psb_base_mod - use mld_base_prec_type - use mld_s_inner_mod, mld_protect_name => mld_saggrmat_smth_bld - use mld_s_base_aggregator_mod - - implicit none - - ! Arguments - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(mld_sml_parms), intent(inout) :: parms - type(psb_sspmat_type), intent(out) :: op_prol,ac,op_restr - type(psb_lsspmat_type), intent(inout) :: t_prol - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, ip, & - & naggr, nzl,naggrm1,naggrp1, i, j, k, jd, icolF, nrw - integer(psb_ipk_) :: inaggr, nzlp - integer(psb_ipk_) :: ictxt, np, me - character(len=20) :: name - type(psb_ls_coo_sparse_mat) :: tmpcoo - type(psb_s_coo_sparse_mat) :: coo_prol, coo_restr - type(psb_s_csr_sparse_mat) :: acsr1, acsrf, csr_prol, acsr - real(psb_spk_), allocatable :: adiag(:) - real(psb_spk_), allocatable :: arwsum(:) - integer(psb_ipk_) :: ierr(5) - logical :: filter_mat - integer(psb_ipk_) :: debug_level, debug_unit, err_act - integer(psb_ipk_), parameter :: ncmax=16 - real(psb_spk_) :: anorm, omega, tmp, dg, theta - logical, parameter :: debug_new=.false. - character(len=80) :: filename - - name='mld_aggrmat_smth_bld' - info=psb_success_ - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - ictxt = desc_a%get_context() - - call psb_info(ictxt, me, np) - - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - theta = parms%aggr_thresh - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - filter_mat = (parms%aggr_filter == mld_filter_mat_) - - ! - ! naggr: number of local aggregates - ! nrow: local rows. - ! - - ! Get the diagonal D - adiag = a%get_diag(info) - if (info == psb_success_) & - & call psb_realloc(ncol,adiag,info) - if (info == psb_success_) & - & call psb_halo(adiag,desc_a,info) - if (info == psb_success_) call a%cp_to(acsr) - - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_getdiag') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' Initial copies done.' - - call acsr%cp_to_fmt(acsrf,info) - - - if (filter_mat) then - ! - ! Build the filtered matrix Af from A - ! - - do i=1, nrow - tmp = szero - jd = -1 - do j=acsrf%irp(i),acsrf%irp(i+1)-1 - if (acsrf%ja(j) == i) jd = j - if (abs(acsrf%val(j)) < theta*sqrt(abs(adiag(i)*adiag(acsrf%ja(j))))) then - tmp=tmp+acsrf%val(j) - acsrf%val(j)=szero - endif - - enddo - if (jd == -1) then - write(0,*) 'Wrong input: we need the diagonal!!!!', i - else - acsrf%val(jd)=acsrf%val(jd)-tmp - end if - enddo - ! Take out zeroed terms - call acsrf%clean_zeros(info) - end if - - - do i=1,size(adiag) - if (adiag(i) /= szero) then - adiag(i) = sone / adiag(i) - else - adiag(i) = sone - end if - end do - - if (parms%aggr_omega_alg == mld_eig_est_) then - - if (parms%aggr_eig == mld_max_norm_) then - allocate(arwsum(nrow)) - call acsr%arwsum(arwsum) - anorm = maxval(abs(adiag(1:nrow)*arwsum(1:nrow))) - call psb_amx(ictxt,anorm) - omega = 4.d0/(3.d0*anorm) - parms%aggr_omega_val = omega - - else - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_aggr_eig_') - goto 9999 - end if - - else if (parms%aggr_omega_alg == mld_user_choice_) then - - omega = parms%aggr_omega_val - - else if (parms%aggr_omega_alg /= mld_user_choice_) then - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_aggr_omega_alg_') - goto 9999 - end if - - - call acsrf%scal(adiag,info) - if (info /= psb_success_) goto 9999 - - call t_prol%mv_to(tmpcoo) - inaggr = naggr - call psb_cdall(ictxt,desc_ac,info,nl=inaggr) - nzlp = tmpcoo%get_nzeros() - call desc_ac%indxmap%g2lip_ins(tmpcoo%ja(1:nzlp),info) - call tmpcoo%set_ncols(desc_ac%get_local_cols()) - call tmpcoo%mv_to_ifmt(csr_prol,info) - - call psb_cdasb(desc_ac,info) - call psb_cd_reinit(desc_ac,info) - ! - ! Build the smoothed prolongator using either A or Af - ! acsr1 = (I-w*D*A) Prol acsr1 = (I-w*D*Af) Prol - ! This is always done through the variable acsrf which - ! is a bit less readable, but saves space and one matrix copy - ! - call omega_smooth(omega,acsrf) - call psb_par_spspmm(acsrf,desc_a,csr_prol,acsr1,desc_ac,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 1') - goto 9999 - end if - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done SPSPMM 1' - nzl = acsr1%get_nzeros() - call acsr1%mv_to_coo(coo_prol,info) - - call mld_ptap(acsr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info) - - call op_prol%mv_from(coo_prol) - call op_restr%mv_from(coo_restr) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done smooth_aggregate ' - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_errpush(info,name) - call psb_error_handler(err_act) - return - -contains - - subroutine omega_smooth(omega,acsr) - implicit none - real(psb_spk_),intent(in) :: omega - type(psb_s_csr_sparse_mat), intent(inout) :: acsr - ! - integer(psb_lpk_) :: i,j - do i=1,acsr%get_nrows() - do j=acsr%irp(i),acsr%irp(i+1)-1 - if (acsr%ja(j) == i) then - acsr%val(j) = sone - omega*acsr%val(j) - else - acsr%val(j) = - omega*acsr%val(j) - end if - end do - end do - end subroutine omega_smooth - -end subroutine mld_saggrmat_smth_bld diff --git a/mlprec/impl/aggregator/mld_z_dec_aggregator_mat_asb.f90 b/mlprec/impl/aggregator/mld_z_dec_aggregator_mat_asb.f90 deleted file mode 100644 index 133fe8a0..00000000 --- a/mlprec/impl/aggregator/mld_z_dec_aggregator_mat_asb.f90 +++ /dev/null @@ -1,195 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_z_dec_aggregator_mat_asb.f90 -! -! Subroutine: mld_z_dec_aggregator_mat_asb -! Version: complex -! -! -! From a given AC to final format, generating DESC_AC -! -! Arguments: -! ag - type(mld_z_dec_aggregator_type), input/output. -! The aggregator object -! parms - type(mld_dml_parms), input -! The aggregation parameters -! a - type(psb_zspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! ac - type(psb_zspmat_type), inout -! The coarse matrix -! desc_ac - type(psb_desc_type), output. -! The communication descriptor of the fine-level matrix. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! -! op_prol - type(psb_zspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_zspmat_type), input/output -! The restrictor operator; normally, it is the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -subroutine mld_z_dec_aggregator_mat_asb(ag,parms,a,desc_a,& - & ac,desc_ac, op_prol,op_restr,info) - use psb_base_mod - use mld_base_prec_type - use mld_z_dec_aggregator_mod, mld_protect_name => mld_z_dec_aggregator_mat_asb - implicit none - class(mld_z_dec_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - type(psb_zspmat_type), intent(inout) :: op_prol, ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: ictxt, np, me - type(psb_lz_coo_sparse_mat) :: tmpcoo - type(psb_lzspmat_type) :: tmp_ac - integer(psb_ipk_) :: i_nr, i_nc, i_nl, nzl - integer(psb_lpk_) :: ntaggr - integer(psb_ipk_) :: err_act, debug_level, debug_unit - character(len=20) :: name='z_dec_aggregator_mat_asb' - - - if (psb_get_errstatus().ne.0) return - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - select case(parms%coarse_mat) - - case(mld_distr_mat_) - - call ac%cscnv(info,type='csr') - call op_prol%cscnv(info,type='csr') - call op_restr%cscnv(info,type='csr') - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ac ' - - case(mld_repl_mat_) - ! - ! We are assuming here that an z matrix - ! can hold all entries - ! - if (desc_ac%get_global_rows() < huge(1_psb_ipk_) ) then - ntaggr = desc_ac%get_global_rows() - i_nr = ntaggr - else - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_coarse_mat_') - goto 9999 - end if - - call op_prol%mv_to(tmpcoo) - nzl = tmpcoo%get_nzeros() - call psb_loc_to_glob(tmpcoo%ja(1:nzl),desc_ac,info,'I') - call tmpcoo%set_ncols(i_nr) - call op_prol%mv_from(tmpcoo) - - call op_restr%mv_to(tmpcoo) - nzl = tmpcoo%get_nzeros() - call psb_loc_to_glob(tmpcoo%ia(1:nzl),desc_ac,info,'I') - call tmpcoo%set_nrows(i_nr) - call op_restr%mv_from(tmpcoo) - - - call psb_gather(tmp_ac,ac,desc_ac,info,root=-ione,& - & dupl=psb_dupl_add_,keeploc=.false.) - call tmp_ac%mv_to(tmpcoo) - call ac%mv_from(tmpcoo) - - call psb_cdall(ictxt,desc_ac,info,mg=ntaggr,repl=.true.) - if (info == psb_success_) call psb_cdasb(desc_ac,info) - - if (info /= psb_success_) goto 9999 - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_coarse_mat_') - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_lz_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo -end subroutine mld_z_dec_aggregator_mat_asb diff --git a/mlprec/impl/aggregator/mld_z_dec_aggregator_mat_bld.f90 b/mlprec/impl/aggregator/mld_z_dec_aggregator_mat_bld.f90 deleted file mode 100644 index 780b1e3b..00000000 --- a/mlprec/impl/aggregator/mld_z_dec_aggregator_mat_bld.f90 +++ /dev/null @@ -1,216 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_z_dec_aggregator_mat_bld.f90 -! -! Subroutine: mld_z_dec_aggregator_mat_bld -! Version: complex -! -! This routine builds the matrix associated to the current level of the -! multilevel preconditioner from the matrix associated to the previous level, -! by using the user-specified aggregation technique (therefore, it also builds the -! prolongation and restriction operators mapping the current level to the -! previous one and vice versa). -! The current level is regarded as the coarse one, while the previous as -! the fine one. This is in agreement with the fact that the routine is called, -! by mld_mlprec_bld, only on levels >=2. -! The coarse-level matrix A_C is built from a fine-level matrix A -! by using the Galerkin approach, i.e. -! -! A_C = P_C^T A P_C, -! -! where P_C is a prolongator from the coarse level to the fine one. -! -! A mapping from the nodes of the adjacency graph of A to the nodes of the -! adjacency graph of A_C has been computed by the mld_aggrmap_bld subroutine. -! The prolongator P_C is built here from this mapping, according to the -! value of p%iprcparm(mld_aggr_kind_), specified by the user through -! mld_zprecinit and mld_zprecset. -! On output from this routine the entries of AC, op_prol, op_restr -! are still in "global numbering" mode; this is fixed in the calling routine -! mld_z_lev_aggrmat_bld. -! -! Currently four different prolongators are implemented, corresponding to -! four aggregation algorithms: -! 1. un-smoothed aggregation, -! 2. smoothed aggregation, -! 3. "bizarre" aggregation. -! 4. minimum energy -! 1. The non-smoothed aggregation uses as prolongator the piecewise constant -! interpolation operator corresponding to the fine-to-coarse level mapping built -! by p%aggr%bld_tprol. This is called tentative prolongator. -! 2. The smoothed aggregation uses as prolongator the operator obtained by applying -! a damped Jacobi smoother to the tentative prolongator. -! 3. The "bizarre" aggregation uses a prolongator proposed by the authors of MLD2P4. -! This prolongator still requires a deep analysis and testing and its use is -! not recommended. -! 4. Minimum energy aggregation -! -! For more details see -! M. Brezina and P. Vanek, A black-box iterative solver based on a two-level -! Schwarz method, Computing, 63 (1999), 233-263. -! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed -! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 -! (1996), 179-196. -! P. D'Ambra, D. di Serafino and S. Filippone, On the development of PSBLAS-based -! parallel two-level Schwarz preconditioners, Appl. Num. Math., 57 (2007), -! 1181-1196. -! M. Sala, R. Tuminaro: A new Petrov-Galerkin smoothed aggregation preconditioner -! for nonsymmetric linear systems, SIAM J. Sci. Comput., 31(1):143-166 (2008) -! -! -! The main structure is: -! 1. Perform sanity checks; -! 2. Compute prolongator/restrictor/AC -! -! -! Arguments: -! ag - type(mld_z_dec_aggregator_type), input/output. -! The aggregator object -! parms - type(mld_dml_parms), input -! The aggregation parameters -! a - type(psb_zspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! ac - type(psb_zspmat_type), output -! The coarse matrix on output -! -! op_prol - type(psb_zspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_zspmat_type), output -! The restrictor operator; normally, it is the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -subroutine mld_z_dec_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - use psb_base_mod - use mld_z_prec_type, mld_protect_name => mld_z_dec_aggregator_mat_bld - use mld_z_inner_mod - implicit none - - class(mld_z_dec_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(psb_lzspmat_type), intent(inout) :: t_prol - type(psb_zspmat_type), intent(out) :: op_prol,ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - - ! Local variables - character(len=20) :: name - integer(psb_mpk_) :: ictxt, np, me - integer(psb_lpk_) :: nzl,ntaggr - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: debug_level, debug_unit - - name='mld_z_dec_aggregator_mat_bld' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - ! - ! Build the coarse-level matrix from the fine-level one, starting from - ! the mapping defined by mld_aggrmap_bld and applying the aggregation - ! algorithm specified by - ! - select case (parms%aggr_prol) - case (mld_no_smooth_) - - call mld_zaggrmat_nosmth_bld(a,desc_a,ilaggr,nlaggr,& - & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) - - case(mld_smooth_prol_) - - call mld_zaggrmat_smth_bld(a,desc_a,ilaggr,nlaggr, & - & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) - -!!$ case(mld_biz_prol_) -!!$ -!!$ call mld_zaggrmat_biz_bld(a,desc_a,ilaggr,nlaggr, & -!!$ & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) - - case(mld_min_energy_) - - call mld_zaggrmat_minnrg_bld(a,desc_a,ilaggr,nlaggr, & - & parms,ac,desc_ac,op_prol,op_restr,t_prol,info) - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='Invalid aggr kind') - goto 9999 - - end select - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='Inner aggrmat bld') - goto 9999 - end if - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - -end subroutine mld_z_dec_aggregator_mat_bld diff --git a/mlprec/impl/aggregator/mld_z_dec_aggregator_tprol.f90 b/mlprec/impl/aggregator/mld_z_dec_aggregator_tprol.f90 deleted file mode 100644 index 2434674a..00000000 --- a/mlprec/impl/aggregator/mld_z_dec_aggregator_tprol.f90 +++ /dev/null @@ -1,139 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_z_dec_aggregator_tprol.f90 -! -! Subroutine: mld_z_dec_aggregator_tprol -! Version: complex -! -! This routine is mainly an interface to soc_map_bld where the real work is performed. -! It takes care of some consistency checking, and calls map_to_tprol, which is -! refactored and shared among all the aggregation methods that produce a simple -! integer mapping. -! -! -! Arguments: -! ag - type(mld_z_dec_aggregator_type), input/output. -! The aggregator object, carrying with itself the mapping algorithm. -! parms - The auxiliary parameters object -! ag_data - Auxiliary global aggregation parameters object -! -! -! a - type(psb_zspmat_type). -! The sparse matrix structure containing the local part of the -! fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! ilaggr - integer, dimension(:), allocatable, output -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that on exit the indices -! will be shifted so as to make sure the ranges on the various processes do not -! overlap. -! nlaggr - integer, dimension(:), allocatable, output -! nlaggr(i) contains the aggregates held by process i. -! t_prol - type(psb_zspmat_type), output -! The tentative prolongator, based on ilaggr. -! -! info - integer, output. -! Error code. -! -subroutine mld_z_dec_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,t_prol,info) - use psb_base_mod - use mld_z_prec_type, mld_protect_name => mld_z_dec_aggregator_build_tprol - use mld_z_inner_mod - implicit none - class(mld_z_dec_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(mld_daggr_data), intent(in) :: ag_data - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lzspmat_type), intent(out) :: t_prol - integer(psb_ipk_), intent(out) :: info - - ! Local variables - character(len=20) :: name - integer(psb_mpk_) :: ictxt, np, me - integer(psb_ipk_) :: err_act - integer(psb_lpk_) :: ntaggr - integer(psb_ipk_) :: debug_level, debug_unit - logical :: clean_zeros - - name='mld_z_dec_aggregator_tprol' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - call mld_check_def(parms%ml_cycle,'Multilevel cycle',& - & mld_mult_ml_,is_legal_ml_cycle) - call mld_check_def(parms%par_aggr_alg,'Aggregation',& - & mld_dec_aggr_,is_legal_ml_par_aggr_alg) - call mld_check_def(parms%aggr_ord,'Ordering',& - & mld_aggr_ord_nat_,is_legal_ml_aggr_ord) - call mld_check_def(parms%aggr_thresh,'Aggr_Thresh',dzero,is_legal_d_aggr_thrs) - - ! - ! The decoupled aggregator based on SOC measures ignores - ! ag_data except for clean_zeros; soc_map_bld is a procedure pointer. - ! - clean_zeros = ag%do_clean_zeros - call ag%soc_map_bld(parms%aggr_ord,parms%aggr_thresh,clean_zeros,a,desc_a,nlaggr,ilaggr,info) - - if (info==psb_success_) call mld_map_to_tprol(desc_a,ilaggr,nlaggr,t_prol,info) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='soc_map_bld/map_to_tprol') - goto 9999 - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_z_dec_aggregator_build_tprol diff --git a/mlprec/impl/aggregator/mld_z_map_to_tprol.f90 b/mlprec/impl/aggregator/mld_z_map_to_tprol.f90 deleted file mode 100644 index 2f8e16d7..00000000 --- a/mlprec/impl/aggregator/mld_z_map_to_tprol.f90 +++ /dev/null @@ -1,154 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_z_map_to_tprol.f90 -! -! Subroutine: mld_z_map_to_tprol -! Version: complex -! -! This routine uses a mapping from the row indices of the fine-level matrix -! to the row indices of the coarse-level matrix to build a tentative -! prolongator, i.e. a piecewise constant operator. -! This is later used to build the final operator; the code has been refactored here -! to be shared among all the methods that provide the tentative prolongator -! through a simple integer mapping. -! -! The aggregation algorithm is a parallel version of that described in -! * M. Brezina and P. Vanek, A black-box iterative solver based on a -! two-level Schwarz method, Computing, 63 (1999), 233-263. -! * P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed -! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 -! (1996), 179-196. -! For more details see -! P. D'Ambra, D. di Serafino and S. Filippone, On the development of -! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math. -! 57 (2007), 1181-1196. -! -! -! Arguments: -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! ilaggr - integer, dimension(:), allocatable. -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that on exit the indices -! will be shifted so as to make sure the ranges on the various processes do not -! overlap. -! nlaggr - integer, dimension(:), allocatable. -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_zspmat_type). -! The tentative prolongator, based on ilaggr. -! -! info - integer, output. -! Error code. -! -subroutine mld_z_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) - - use psb_base_mod - use mld_z_inner_mod, mld_protect_name => mld_z_map_to_tprol - - implicit none - - ! Arguments - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), allocatable, intent(inout) :: ilaggr(:),nlaggr(:) - type(psb_lzspmat_type), intent(out) :: op_prol - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_lpk_) :: icnt,nlp,k,n,ia,isz,nr, naggr,i,j,m,naggrm1, naggrp1, ntaggr - type(psb_lz_coo_sparse_mat) :: tmpcoo - integer(psb_ipk_) :: debug_level, debug_unit,err_act - integer(psb_ipk_) :: ictxt,np,me - integer(psb_lpk_) :: nrow, ncol, n_ne - character(len=20) :: name, ch_err - - info=psb_success_ - name = 'mld_map_to_tprol' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ! - ictxt=desc_a%get_context() - call psb_info(ictxt,me,np) - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - ilaggr(1:nrow) = ilaggr(1:nrow) + naggrm1 - call psb_halo(ilaggr,desc_a,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_halo') - goto 9999 - end if - - call tmpcoo%allocate(nrow,ntaggr,ncol) - k = 0 - do i=1,nrow - ! - ! Note: at this point, a value ilaggr(i)<=0 - ! tags a "singleton" row, and it has to be - ! left alone. - ! - if (ilaggr(i)>0) then - k = k + 1 - tmpcoo%val(k) = zone - tmpcoo%ia(k) = i - tmpcoo%ja(k) = ilaggr(i) - end if - end do - call tmpcoo%set_nzeros(k) - call tmpcoo%set_dupl(psb_dupl_add_) - call tmpcoo%set_sorted() ! At this point this is in row-major - call op_prol%mv_from(tmpcoo) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_map_to_tprol diff --git a/mlprec/impl/aggregator/mld_z_ptap.f90 b/mlprec/impl/aggregator/mld_z_ptap.f90 deleted file mode 100644 index 41dd1aca..00000000 --- a/mlprec/impl/aggregator/mld_z_ptap.f90 +++ /dev/null @@ -1,689 +0,0 @@ -! -! -! MLD2P4 Extensions -! -! (C) Copyright 2019 -! -! Salvatore Filippone Cranfield University -! Pasqua D'Ambra IAC-CNR, Naples, IT -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_daggrmat_nosmth_bld.F90 -! -! -subroutine mld_z_ptap(a_csr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info,desc_ax) - use psb_base_mod - use mld_z_inner_mod - use mld_z_base_aggregator_mod, mld_protect_name => mld_z_ptap - implicit none - - ! Arguments - type(psb_z_csr_sparse_mat), intent(inout) :: a_csr - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - type(mld_dml_parms), intent(inout) :: parms - type(psb_z_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr - type(psb_desc_type), intent(inout) :: desc_ac - type(psb_zspmat_type), intent(out) :: ac - integer(psb_ipk_), intent(out) :: info - type(psb_desc_type), intent(inout), optional :: desc_ax - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo - character(len=40) :: name - integer(psb_ipk_) :: ierr(5) - type(psb_lz_coo_sparse_mat) :: ac_coo, tmpcoo - type(psb_z_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr - integer(psb_ipk_) :: debug_level, debug_unit, naggr - integer(psb_lpk_) :: nglob, ntaggr, naggrm1, naggrp1 - integer(psb_ipk_) :: nrow, ncol, nrl, nzl, ip, nzt, i, k - integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza - logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. - integer(psb_ipk_), save :: idx_spspmm=-1 - - name='mld_ptap' - if(psb_get_errstatus().ne.0) return - info=psb_success_ - call psb_erractionsave(err_act) - - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - call psb_info(ictxt, me, np) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - if ((do_timings).and.(idx_spspmm==-1)) & - & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr - - ! - ! COO_PROL should arrive here with local numbering - ! - if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& - & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& - & nrow,ntaggr,naggr - - call coo_prol%cp_to_fmt(csr_prol,info) - - if (debug) write(0,*) me,trim(name),' Product AxPROL ',& - & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & - & desc_a%get_local_rows(),desc_a%get_local_cols(),& - & desc_ac%get_local_rows(),desc_a%get_local_cols() - if (debug) flush(0) - - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - - if (debug) write(0,*) me,trim(name),' Done AxPROL ',& - & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& - & desc_ac%get_local_rows(),desc_ac%get_local_cols() - - ! - ! Ok first product done. - - if (present(desc_ax)) then - block - call coo_prol%cp_to_coo(coo_restr,info) - call coo_restr%set_ncols(desc_ac%get_local_cols()) - call coo_restr%set_nrows(desc_a%get_local_rows()) - call psb_z_coo_glob_transpose(coo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_ax%get_local_cols()) -! !$ write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& -! !$ & desc_a%get_local_cols(),desc_ax%get_local_cols(),coo_restr%get_nzeros() -! !$ if (desc_a%get_local_cols()= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - - else - - ! - ! Remember that RESTR must be built from PROL after halo extension, - ! which is done above in psb_par_spspmm - if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& - & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() - call csr_prol%mv_to_coo(coo_restr,info) -!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& -!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() - if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) - - call coo_restr%transp() - nzl = coo_restr%get_nzeros() - nrl = desc_ac%get_local_rows() - i=0 - ! - ! Only keep local rows - ! - do k=1, nzl - if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then - i = i+1 - coo_restr%val(i) = coo_restr%val(k) - coo_restr%ia(i) = coo_restr%ia(k) - coo_restr%ja(i) = coo_restr%ja(k) - end if - end do - call coo_restr%set_nzeros(i) - call coo_restr%fix(info) - nzl = coo_restr%get_nzeros() - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_a%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) - call csr_restr%cp_from_coo(coo_restr,info) - -!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - end if - - call psb_cdasb(desc_ac,info) - - call ac_csr%set_nrows(desc_ac%get_local_rows()) - call ac_csr%set_ncols(desc_ac%get_local_cols()) - call ac%mv_from(ac_csr) - call ac%set_asb() - - if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() - if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr - ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() - - call coo_prol%set_ncols(desc_ac%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ptap ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_z_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo - -end subroutine mld_z_ptap - -subroutine mld_z_lz_ptap(a_csr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info,desc_ax) - use psb_base_mod - use mld_z_inner_mod - use mld_z_base_aggregator_mod !, mld_protect_name => mld_z_lz_ptap - implicit none - - ! Arguments - type(psb_z_csr_sparse_mat), intent(inout) :: a_csr - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - type(mld_dml_parms), intent(inout) :: parms - type(psb_lz_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr - type(psb_desc_type), intent(inout) :: desc_ac - type(psb_lzspmat_type), intent(out) :: ac - integer(psb_ipk_), intent(out) :: info - type(psb_desc_type), intent(inout), optional :: desc_ax - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo - character(len=40) :: name - integer(psb_ipk_) :: ierr(5) - type(psb_lz_coo_sparse_mat) :: ac_coo, tmpcoo - type(psb_z_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr - integer(psb_ipk_) :: debug_level, debug_unit, naggr - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nrl, nzl, ip, & - & nzt, naggrm1, naggrp1, i, k - integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza - logical, parameter :: do_timings=.false., oldstyle=.false., debug=.false. - integer(psb_ipk_), save :: idx_spspmm=-1 - - name='mld_ptap' - if(psb_get_errstatus().ne.0) return - info=psb_success_ - call psb_erractionsave(err_act) - - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - call psb_info(ictxt, me, np) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - if ((do_timings).and.(idx_spspmm==-1)) & - & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr - - ! - ! COO_PROL should arrive here with local numbering - ! - if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& - & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& - & nrow,ntaggr,naggr - - call coo_prol%cp_to_ifmt(csr_prol,info) - - if (debug) write(0,*) me,trim(name),' Product AxPROL ',& - & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & - & desc_a%get_local_rows(),desc_a%get_local_cols(),& - & desc_ac%get_local_rows(),desc_a%get_local_cols() - if (debug) flush(0) - - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - - if (debug) write(0,*) me,trim(name),' Done AxPROL ',& - & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& - & desc_ac%get_local_rows(),desc_ac%get_local_cols() - - ! - ! Ok first product done. - - if (present(desc_ax)) then - block - type(psb_z_coo_sparse_mat) :: icoo_restr - - call coo_prol%cp_to_icoo(icoo_restr,info) - call icoo_restr%set_ncols(desc_ac%get_local_cols()) - call icoo_restr%set_nrows(desc_a%get_local_rows()) - call psb_z_coo_glob_transpose(icoo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) - call icoo_restr%set_nrows(desc_ac%get_local_rows()) - call icoo_restr%set_ncols(desc_ax%get_local_cols()) -! !$ write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& -! !$ & desc_a%get_local_cols(),desc_ax%get_local_cols(),icoo_restr%get_nzeros() -! !$ if (desc_a%get_local_cols()= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - - else - - ! - ! Remember that RESTR must be built from PROL after halo extension, - ! which is done above in psb_par_spspmm - if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& - & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() - call csr_prol%mv_to_lcoo(coo_restr,info) -!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& -!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() - if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) - - call coo_restr%transp() - nzl = coo_restr%get_nzeros() - nrl = desc_ac%get_local_rows() - i=0 - ! - ! Only keep local rows - ! - do k=1, nzl - if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then - i = i+1 - coo_restr%val(i) = coo_restr%val(k) - coo_restr%ia(i) = coo_restr%ia(k) - coo_restr%ja(i) = coo_restr%ja(k) - end if - end do - call coo_restr%set_nzeros(i) - call coo_restr%fix(info) - nzl = coo_restr%get_nzeros() - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_a%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) - call csr_restr%cp_from_lcoo(coo_restr,info) - -!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - end if - - call psb_cdasb(desc_ac,info) - - call ac_csr%set_nrows(desc_ac%get_local_rows()) - call ac_csr%set_ncols(desc_ac%get_local_cols()) - call ac%mv_from(ac_csr) - call ac%set_asb() - - if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() - if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr - ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() - - call coo_prol%set_ncols(desc_ac%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ptap ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_lz_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo - -end subroutine mld_z_lz_ptap - -subroutine mld_lz_ptap(a_csr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info,desc_ax) - use psb_base_mod - use mld_z_inner_mod - use mld_z_base_aggregator_mod!, mld_protect_name => mld_lz_ptap - implicit none - - ! Arguments - type(psb_lz_csr_sparse_mat), intent(inout) :: a_csr - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - type(mld_dml_parms), intent(inout) :: parms - type(psb_lz_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr - type(psb_desc_type), intent(inout) :: desc_ac - type(psb_lzspmat_type), intent(out) :: ac - integer(psb_ipk_), intent(out) :: info - type(psb_desc_type), intent(inout), optional :: desc_ax - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt,np,me, icomm, ndx, minfo - character(len=40) :: name - integer(psb_ipk_) :: ierr(5) - type(psb_lz_coo_sparse_mat) :: ac_coo, tmpcoo - type(psb_lz_csr_sparse_mat) :: acsr3, csr_prol, ac_csr, csr_restr - integer(psb_ipk_) :: debug_level, debug_unit, naggr - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nrl, nzl, ip, & - & nzt, naggrm1, naggrp1, i, k - integer(psb_lpk_) :: nrsave, ncsave, nzsave, nza - logical, parameter :: do_timings=.true., oldstyle=.false., debug=.false. - integer(psb_ipk_), save :: idx_spspmm=-1 - - name='mld_ptap' - if(psb_get_errstatus().ne.0) return - info=psb_success_ - call psb_erractionsave(err_act) - - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - call psb_info(ictxt, me, np) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - if ((do_timings).and.(idx_spspmm==-1)) & - & idx_spspmm = psb_get_timer_idx("SPMM_BLD: par_spspmm") - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - !write(0,*)me,' ',name,' input sizes',nlaggr(:),':',naggr - - ! - ! COO_PROL should arrive here with local numbering - ! - if (debug) write(0,*) me,' ',trim(name),' Size check on entry New: ',& - & coo_prol%get_fmt(),coo_prol%get_nrows(),coo_prol%get_ncols(),coo_prol%get_nzeros(),& - & nrow,ntaggr,naggr - - call coo_prol%cp_to_fmt(csr_prol,info) - - if (debug) write(0,*) me,trim(name),' Product AxPROL ',& - & a_csr%get_nrows(),a_csr%get_ncols(), csr_prol%get_nrows(), & - & desc_a%get_local_rows(),desc_a%get_local_cols(),& - & desc_ac%get_local_rows(),desc_a%get_local_cols() - if (debug) flush(0) - - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(a_csr,desc_a,csr_prol,acsr3,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - - if (debug) write(0,*) me,trim(name),' Done AxPROL ',& - & acsr3%get_nrows(),acsr3%get_ncols(), acsr3%get_nzeros(),& - & desc_ac%get_local_rows(),desc_ac%get_local_cols() - - ! - ! Ok first product done. - - if (present(desc_ax)) then - block - type(psb_z_coo_sparse_mat) :: icoo_restr - - call coo_prol%cp_to_icoo(icoo_restr,info) - call icoo_restr%set_ncols(desc_ac%get_local_cols()) - call icoo_restr%set_nrows(desc_a%get_local_rows()) - call psb_z_coo_glob_transpose(icoo_restr,desc_a,info,desc_c=desc_ac,desc_rx=desc_ax) - call icoo_restr%set_nrows(desc_ac%get_local_rows()) - call icoo_restr%set_ncols(desc_ax%get_local_cols()) - write(0,*) me,' ',trim(name),' check on glob_transpose 1: ',& - & desc_a%get_local_cols(),desc_ax%get_local_cols(),icoo_restr%get_nzeros() - if (desc_a%get_local_cols()= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_ax,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - - else - - ! - ! Remember that RESTR must be built from PROL after halo extension, - ! which is done above in psb_par_spspmm - if (debug) write(0,*)me,' ',name,' No inp_restr, transposing prol ',& - & csr_prol%get_nrows(),csr_prol%get_ncols(),csr_prol%get_nzeros() - call csr_prol%mv_to_coo(coo_restr,info) -!!$ write(0,*)me,' ',name,' new into transposition ',coo_restr%get_nrows(),& -!!$ & coo_restr%get_ncols(),coo_restr%get_nzeros() - if (debug) call check_coo(me,trim(name)//' Check 1 (before transp) on coo_restr:',coo_restr) - - call coo_restr%transp() - nzl = coo_restr%get_nzeros() - nrl = desc_ac%get_local_rows() - i=0 - ! - ! Only keep local rows - ! - do k=1, nzl - if ((1 <= coo_restr%ia(k)) .and.(coo_restr%ia(k) <= nrl)) then - i = i+1 - coo_restr%val(i) = coo_restr%val(k) - coo_restr%ia(i) = coo_restr%ia(k) - coo_restr%ja(i) = coo_restr%ja(k) - end if - end do - call coo_restr%set_nzeros(i) - call coo_restr%fix(info) - nzl = coo_restr%get_nzeros() - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_a%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 2 on coo_restr:',coo_restr) - call csr_restr%cp_from_coo(coo_restr,info) - -!!$ write(0,*)me,' ',name,' after transposition ',coo_restr%get_nrows(),coo_restr%get_ncols(),coo_restr%get_nzeros() - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv coo_restr') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - if (debug) write(0,*) me,trim(name),' Product RESTRxAP ',& - & csr_restr%get_nrows(),csr_restr%get_ncols(), & - & desc_ac%get_local_rows(),desc_a%get_local_cols(),& - & acsr3%get_nrows(),acsr3%get_ncols() - if (do_timings) call psb_tic(idx_spspmm) - call psb_par_spspmm(csr_restr,desc_a,acsr3,ac_csr,desc_ac,info) - if (do_timings) call psb_toc(idx_spspmm) - call acsr3%free() - end if - - call psb_cdasb(desc_ac,info) - - call ac_csr%set_nrows(desc_ac%get_local_rows()) - call ac_csr%set_ncols(desc_ac%get_local_cols()) - call ac%mv_from(ac_csr) - call ac%set_asb() - - if (debug) write(0,*) me,' ',trim(name),' After mv_from',psb_get_errstatus() - if (debug) write(0,*) me,' ',trim(name),' ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros(),naggr,ntaggr - ! write(0,*) me,' ',trim(name),' Final AC newstyle ',ac%get_fmt(),ac%get_nrows(),ac%get_ncols(),ac%get_nzeros() - - call coo_prol%set_ncols(desc_ac%get_local_cols()) - !call coo_restr%mv_from_ifmt(csr_restr,info) -!!$ call coo_restr%set_nrows(desc_ac%get_local_rows()) -!!$ call coo_restr%set_ncols(desc_a%get_local_cols()) - if (debug) call check_coo(me,trim(name)//' Check 3 on coo_restr:',coo_restr) - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ptap ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_lz_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo - -end subroutine mld_lz_ptap diff --git a/mlprec/impl/aggregator/mld_z_soc1_map_bld.f90 b/mlprec/impl/aggregator/mld_z_soc1_map_bld.f90 deleted file mode 100644 index 48e44213..00000000 --- a/mlprec/impl/aggregator/mld_z_soc1_map_bld.f90 +++ /dev/null @@ -1,349 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_z_soc1_map__bld.f90 -! -! Subroutine: mld_z_soc1_map_bld -! Version: complex -! -! This routine builds the tentative prolongator based on the -! strength of connection aggregation algorithm presented in -! -! M. Brezina and P. Vanek, A black-box iterative solver based on a -! two-level Schwarz method, Computing, 63 (1999), 233-263. -! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed -! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 -! (1996), 179-196. -! -! Note: upon exit -! -! Arguments: -! a - type(psb_zspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_zprec_type), input/output. -! The preconditioner data structure; upon exit it contains -! the multilevel hierarchy of prolongators, restrictors -! and coarse matrices. -! info - integer, output. -! Error code. -! -! -! -subroutine mld_z_soc1_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) - - use psb_base_mod - use mld_base_prec_type - use mld_z_inner_mod - - implicit none - - ! Arguments - integer(psb_ipk_), intent(in) :: iorder - logical, intent(in) :: clean_zeros - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - real(psb_dpk_), intent(in) :: theta - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),& - & ideg(:), idxs(:) - integer(psb_lpk_), allocatable :: tmpaggr(:) - complex(psb_dpk_), allocatable :: val(:), diag(:) - integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr, nc, naggr,i,j,m, nz, ilg, ii, ip - type(psb_z_csr_sparse_mat) :: acsr - real(psb_dpk_) :: cpling, tcl - logical :: disjoint - integer(psb_ipk_) :: debug_level, debug_unit,err_act - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: nrow, ncol, n_ne - integer(psb_lpk_) :: nrglob - character(len=20) :: name, ch_err - - info=psb_success_ - name = 'mld_soc1_map_bld' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ! - ictxt=desc_a%get_context() - call psb_info(ictxt,me,np) - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - nrglob = desc_a%get_global_rows() - - nr = a%get_nrows() - nc = a%get_ncols() - allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),& - & icol(nc),val(nc),stat=info) - if(info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),& - & a_err='integer') - goto 9999 - end if - - diag = a%get_diag(info) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='psb_sp_getdiag') - goto 9999 - end if - - call a%cp_to(acsr) - if (clean_zeros) call acsr%clean_zeros(info) - if (iorder == mld_aggr_ord_nat_) then - do i=1, nr - ilaggr(i) = -(nr+1) - idxs(i) = i - end do - else - do i=1, nr - ilaggr(i) = -(nr+1) - ideg(i) = acsr%irp(i+1) - acsr%irp(i) - end do - call psb_msort(ideg,ix=idxs,dir=psb_sort_down_) - end if - - - ! - ! Phase one: Start with disjoint groups. - ! - naggr = 0 - icnt = 0 - step1: do ii=1, nr - i = idxs(ii) - if ((i<1).or.(i>nr)) then - info=psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - if (ilaggr(i) == -(nr+1)) then - nz = (acsr%irp(i+1)-acsr%irp(i)) - if ((nz<0).or.(nz>size(icol))) then - info=psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) - val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) - - ! - ! Build the set of all strongly coupled nodes - ! - ip = 0 - do k=1, nz - j = icol(k) - if ((1<=j).and.(j<=nr)) then - if (abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j)))) then - ip = ip + 1 - icol(ip) = icol(k) - end if - end if - enddo - - ! - ! If the whole strongly coupled neighborhood of I is - ! as yet unconnected, turn it into the next aggregate. - ! Same if ip==0 (in which case, neighborhood only - ! contains I even if it does not look like it from matrix) - ! - disjoint = all(ilaggr(icol(1:ip)) == -(nr+1)).or.(ip==0) - if (disjoint) then - icnt = icnt + 1 - naggr = naggr + 1 - do k=1, ip - ilaggr(icol(k)) = naggr - end do - ilaggr(i) = naggr - end if - endif - enddo step1 - - if (debug_level >= psb_debug_outer_) then - write(debug_unit,*) me,' ',trim(name),& - & ' Check 1:',count(ilaggr == -(nr+1)) - end if - - ! - ! Phase two: join the neighbours - ! - tmpaggr = ilaggr - step2: do ii=1,nr - i = idxs(ii) - - if (ilaggr(i) == -(nr+1)) then - nz = (acsr%irp(i+1)-acsr%irp(i)) - if (nz == 1) cycle step2 - icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) - val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) - - ! - ! Find the most strongly connected neighbour that is - ! already aggregated, if any, and join its aggregate - ! - cpling = dzero - ip = 0 - do k=1, nz - j = icol(k) - if ((1<=j).and.(j<=nr)) then - if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))& - & .and. (tmpaggr(j) > 0).and. (abs(val(k)) > cpling)) then - ip = k - cpling = abs(val(k)) - end if - end if - enddo - if (ip > 0) then - ilaggr(i) = ilaggr(icol(ip)) - end if - end if - end do step2 - - - ! - ! Phase three: sweep over leftovers, if any - ! - step3: do ii=1,nr - i = idxs(ii) - - if (ilaggr(i) < 0) then - nz = (acsr%irp(i+1)-acsr%irp(i)) - if (nz == 1) cycle step3 - icol(1:nz) = acsr%ja(acsr%irp(i):acsr%irp(i+1)-1) - val(1:nz) = acsr%val(acsr%irp(i):acsr%irp(i+1)-1) - ! - ! Find its strongly connected neighbourhood not - ! already aggregated, and make it into a new aggregate. - ! - cpling = dzero - ip = 0 - do k=1, nz - j = icol(k) - if ((1<=j).and.(j<=nr)) then - if ((abs(val(k)) > theta*sqrt(abs(diag(i)*diag(j))))& - & .and. (ilaggr(j) < 0)) then - ip = ip + 1 - icol(ip) = icol(k) - end if - end if - enddo - if (ip > 0) then - icnt = icnt + 1 - naggr = naggr + 1 - ilaggr(i) = naggr - do k=1, ip - ilaggr(icol(k)) = naggr - end do - else - ! - ! This should not happen: we did not even connect with ourselves, - ! but it's not a singleton. - ! - naggr = naggr + 1 - ilaggr(i) = naggr - end if - end if - end do step3 - - ! Any leftovers? - do i=1, nr - if (ilaggr(i) < 0) then - nz = (acsr%irp(i+1)-acsr%irp(i)) - if (nz == 1) then - ! Mark explicitly as a singleton so that - ! it will be ignored in map_to_tprol. - ! Need to use -(nrglob+nr) to make sure - ! it's still negative when shifted and combined with - ! other processes. - ilaggr(i) = -(nrglob+nr) - else - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers') - goto 9999 - endif - end if - end do - - if (naggr > ncol) then - !write(0,*) name,'Error : naggr > ncol',naggr,ncol - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Fatal error: naggr>ncol') - goto 9999 - end if - - call psb_realloc(ncol,ilaggr,info) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_realloc' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - allocate(nlaggr(np),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),& - & a_err='integer') - goto 9999 - end if - - nlaggr(:) = 0 - nlaggr(me+1) = naggr - call psb_sum(ictxt,nlaggr(1:np)) - - call acsr%free() - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_soc1_map_bld - diff --git a/mlprec/impl/aggregator/mld_z_soc2_map_bld.f90 b/mlprec/impl/aggregator/mld_z_soc2_map_bld.f90 deleted file mode 100644 index 7e1538e2..00000000 --- a/mlprec/impl/aggregator/mld_z_soc2_map_bld.f90 +++ /dev/null @@ -1,348 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_z_soc2_map__bld.f90 -! -! Subroutine: mld_z_soc2_map_bld -! Version: complex -! -! The aggregator object hosts the aggregation method for building -! the multilevel hierarchy. This variant is based on the method -! presented in -! -! S. Gratton, P. Henon, P. Jiranek and X. Vasseur: -! Reducing complexity of algebraic multigrid by aggregation -! Numerical Lin. Algebra with Applications, 2016, 23:501-518 -! -! Note: upon exit -! -! Arguments: -! a - type(psb_zspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_zprec_type), input/output. -! The preconditioner data structure; upon exit it contains -! the multilevel hierarchy of prolongators, restrictors -! and coarse matrices. -! info - integer, output. -! Error code. -! -! -! -subroutine mld_z_soc2_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) - - use psb_base_mod - use mld_base_prec_type - use mld_z_inner_mod - - implicit none - - ! Arguments - integer(psb_ipk_), intent(in) :: iorder - logical, intent(in) :: clean_zeros - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - real(psb_dpk_), intent(in) :: theta - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_), allocatable :: ils(:), neigh(:), irow(:), icol(:),& - & ideg(:), idxs(:) - integer(psb_lpk_), allocatable :: tmpaggr(:) - complex(psb_dpk_), allocatable :: val(:), diag(:) - integer(psb_ipk_) :: icnt,nlp,k,n,ia,isz,nr,nc,naggr,i,j,m, nz, ilg, ii, ip, ip1,nzcnt - integer(psb_lpk_) :: nrglob - type(psb_z_csr_sparse_mat) :: acsr, muij, s_neigh - type(psb_z_coo_sparse_mat) :: s_neigh_coo - real(psb_dpk_) :: cpling, tcl - logical :: disjoint - integer(psb_ipk_) :: debug_level, debug_unit,err_act - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: nrow, ncol, n_ne - character(len=20) :: name, ch_err - - info=psb_success_ - name = 'mld_soc2_map_bld' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ! - ictxt=desc_a%get_context() - call psb_info(ictxt,me,np) - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - nrglob = desc_a%get_global_rows() - - nr = a%get_nrows() - nc = a%get_ncols() - allocate(ilaggr(nr),neigh(nr),ideg(nr),idxs(nr),icol(nc),stat=info) - if(info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nr,izero,izero,izero,izero/),& - & a_err='integer') - goto 9999 - end if - - diag = a%get_diag(info) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='psb_sp_getdiag') - goto 9999 - end if - - ! - ! Phase zero: compute muij - ! - call a%cp_to(muij) - if (clean_zeros) call muij%clean_zeros(info) - do i=1, nr - do k=muij%irp(i),muij%irp(i+1)-1 - j = muij%ja(k) - if (j<= nr) muij%val(k) = abs(muij%val(k))/sqrt(abs(diag(i)*diag(j))) - end do - end do - - ! - ! Compute the 1-neigbour; mark strong links with +1, weak links with -1 - ! - call s_neigh_coo%allocate(nr,nr,muij%get_nzeros()) - ip = 0 - do i=1, nr - do k=muij%irp(i),muij%irp(i+1)-1 - j = muij%ja(k) - if (j<=nr) then - ip = ip + 1 - s_neigh_coo%ia(ip) = i - s_neigh_coo%ja(ip) = j - if (real(muij%val(k)) >= theta) then - s_neigh_coo%val(ip) = done - else - s_neigh_coo%val(ip) = -done - end if - end if - end do - end do - !write(*,*) 'S_NEIGH: ',nr,ip - call s_neigh_coo%set_nzeros(ip) - call s_neigh%mv_from_coo(s_neigh_coo,info) - - if (iorder == mld_aggr_ord_nat_) then - do i=1, nr - ilaggr(i) = -(nr+1) - idxs(i) = i - end do - else - do i=1, nr - ilaggr(i) = -(nr+1) - ideg(i) = muij%irp(i+1) - muij%irp(i) - end do - call psb_msort(ideg,ix=idxs,dir=psb_sort_down_) - end if - - - ! - ! Phase one: Start with disjoint groups. - ! - naggr = 0 - icnt = 0 - step1: do ii=1, nr - i = idxs(ii) - - if (ilaggr(i) == -(nr+1)) then - ! - ! Get the 1-neighbourhood of I - ! - ip1 = s_neigh%irp(i) - nz = s_neigh%irp(i+1)-ip1 - ! - ! If the neighbourhood only contains I, skip it - ! - if (nz ==0) then - ilaggr(i) = 0 - cycle step1 - end if - if ((nz==1).and.(s_neigh%ja(ip1)==i)) then - ilaggr(i) = 0 - cycle step1 - end if - ! - ! If the whole strongly coupled neighborhood of I is - ! as yet unconnected, turn it into the next aggregate. - ! - nzcnt = count(real(s_neigh%val(ip1:ip1+nz-1)) > 0) - icol(1:nzcnt) = pack(s_neigh%ja(ip1:ip1+nz-1),(real(s_neigh%val(ip1:ip1+nz-1)) > 0)) - disjoint = all(ilaggr(icol(1:nzcnt)) == -(nr+1)) - if (disjoint) then - icnt = icnt + 1 - naggr = naggr + 1 - do k=1, nzcnt - ilaggr(icol(k)) = naggr - end do - ilaggr(i) = naggr - end if - endif - enddo step1 - - if (debug_level >= psb_debug_outer_) then - write(debug_unit,*) me,' ',trim(name),& - & ' Check 1:',count(ilaggr == -(nr+1)) - end if - - ! - ! Phase two: join the neighbours - ! - tmpaggr = ilaggr - step2: do ii=1,nr - i = idxs(ii) - - if (ilaggr(i) == -(nr+1)) then - ! - ! Find the most strongly connected neighbour that is - ! already aggregated, if any, and join its aggregate - ! - cpling = dzero - ip = 0 - do k=s_neigh%irp(i), s_neigh%irp(i+1)-1 - j = s_neigh%ja(k) - if ((1<=j).and.(j<=nr)) then - if ( (tmpaggr(j) > 0).and. (real(muij%val(k)) > cpling)& - & .and.(real(s_neigh%val(k))>0)) then - ip = k - cpling = muij%val(k) - end if - end if - enddo - if (ip > 0) then - ilaggr(i) = ilaggr(s_neigh%ja(ip)) - end if - end if - end do step2 - - - ! - ! Phase three: sweep over leftovers, if any - ! - step3: do ii=1,nr - i = idxs(ii) - - if (ilaggr(i) < 0) then - ! - ! Find its strongly connected neighbourhood not - ! already aggregated, and make it into a new aggregate. - ! - ip = 0 - do k=s_neigh%irp(i), s_neigh%irp(i+1)-1 - j = s_neigh%ja(k) - if ((1<=j).and.(j<=nr)) then - if (ilaggr(j) < 0) then - ip = ip + 1 - icol(ip) = j - end if - end if - enddo - if (ip > 0) then - icnt = icnt + 1 - naggr = naggr + 1 - ilaggr(i) = naggr - do k=1, ip - ilaggr(icol(k)) = naggr - end do - end if - end if - end do step3 - - ! Any leftovers? - do i=1, nr - if (ilaggr(i) <= 0) then - nz = (s_neigh%irp(i+1)-s_neigh%irp(i)) - if (nz <= 1) then - ! Mark explicitly as a singleton so that - ! it will be ignored in map_to_tprol. - ! Need to use -(nrglob+nr) to make sure - ! it's still negative when shifted and combined with - ! other processes. - ilaggr(i) = -(nrglob+nr) - else - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Fatal error: non-singleton leftovers') - goto 9999 - endif - end if - end do - - if (naggr > ncol) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Fatal error: naggr>ncol') - goto 9999 - end if - - call psb_realloc(ncol,ilaggr,info) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_realloc' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - allocate(nlaggr(np),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/np,izero,izero,izero,izero/),& - & a_err='integer') - goto 9999 - end if - - nlaggr(:) = 0 - nlaggr(me+1) = naggr - call psb_sum(ictxt,nlaggr(1:np)) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_soc2_map_bld - diff --git a/mlprec/impl/aggregator/mld_z_symdec_aggregator_tprol.f90 b/mlprec/impl/aggregator/mld_z_symdec_aggregator_tprol.f90 deleted file mode 100644 index dbf11de1..00000000 --- a/mlprec/impl/aggregator/mld_z_symdec_aggregator_tprol.f90 +++ /dev/null @@ -1,160 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_z_symdec_aggregator_tprol.f90 -! -! Subroutine: mld_z_symdec_aggregator_tprol -! Version: complex -! -! -! This routine is mainly an interface to soc_map_bld where the real work is performed. -! It takes care of some consistency checking, and calls map_to_tprol, which is -! refactored and shared among all the aggregation methods that produce a simple -! integer mapping. It also symmetrizes the pattern of the local matrix A. -! -! -! -! Arguments: -! Arguments: -! ag - type(mld_z_dec_aggregator_type), input/output. -! The aggregator object, carrying with itself the mapping algorithm. -! parms - The auxiliary parameters object -! ag_data - Auxiliary global aggregation parameters object -! -! a - type(psb_zspmat_type). -! The sparse matrix structure containing the local part of the -! fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! ilaggr - integer, dimension(:), allocatable, output -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that on exit the indices -! will be shifted so as to make sure the ranges on the various processes do not -! overlap. -! nlaggr - integer, dimension(:), allocatable, output -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_zspmat_type), output -! The tentative prolongator, based on ilaggr. -! -! info - integer, output. -! Error code. -! -subroutine mld_z_symdec_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,op_prol,info) - use psb_base_mod - use mld_z_prec_type - use mld_z_symdec_aggregator_mod, mld_protect_name => mld_z_symdec_aggregator_build_tprol - use mld_z_inner_mod - implicit none - class(mld_z_symdec_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(mld_daggr_data), intent(in) :: ag_data - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lzspmat_type), intent(out) :: op_prol - integer(psb_ipk_), intent(out) :: info - - ! Local variables - type(psb_zspmat_type) :: atmp, atrans - character(len=20) :: name - integer(psb_mpk_) :: ictxt, np, me - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: nr - integer(psb_lpk_) :: ntaggr - integer(psb_ipk_) :: debug_level, debug_unit - logical :: clean_zeros - - name='mld_z_symdec_aggregator_tprol' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - call mld_check_def(parms%ml_cycle,'Multilevel cycle',& - & mld_mult_ml_,is_legal_ml_cycle) - call mld_check_def(parms%par_aggr_alg,'Aggregation',& - & mld_dec_aggr_,is_legal_ml_par_aggr_alg) - call mld_check_def(parms%aggr_ord,'Ordering',& - & mld_aggr_ord_nat_,is_legal_ml_aggr_ord) - call mld_check_def(parms%aggr_thresh,'Aggr_Thresh',dzero,is_legal_d_aggr_thrs) - - nr = a%get_nrows() - call a%csclip(atmp,info,imax=nr,jmax=nr,& - & rscale=.false.,cscale=.false.) - call atmp%set_nrows(nr) - call atmp%set_ncols(nr) - if (info == psb_success_) call atmp%transp(atrans) - if (info == psb_success_) call atrans%cscnv(info,type='COO') - if (info == psb_success_) call psb_rwextd(nr,atmp,info,b=atrans,rowscale=.false.) - call atmp%set_nrows(nr) - call atmp%set_ncols(nr) - if (info == psb_success_) call atrans%free() - if (info == psb_success_) call atmp%cscnv(info,type='CSR') - - ! - ! The decoupled aggregator based on SOC measures ignores - ! ag_data except for clean_zeros; soc_map_bld is a procedure pointer. - ! - clean_zeros = ag%do_clean_zeros - if (info == psb_success_) & - & call ag%soc_map_bld(parms%aggr_ord,parms%aggr_thresh,clean_zeros,atmp,& - & desc_a,nlaggr,ilaggr,info) - if (info == psb_success_) call atmp%free() - - if (info == psb_success_) call mld_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='soc_map_bld/map_to_tprol') - goto 9999 - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_z_symdec_aggregator_build_tprol diff --git a/mlprec/impl/aggregator/mld_zaggrmat_minnrg_bld.f90 b/mlprec/impl/aggregator/mld_zaggrmat_minnrg_bld.f90 deleted file mode 100644 index c7dc4b5b..00000000 --- a/mlprec/impl/aggregator/mld_zaggrmat_minnrg_bld.f90 +++ /dev/null @@ -1,656 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_zaggrmat_minnrg_bld.F90 -! -! Subroutine: mld_zaggrmat_minnrg_bld -! Version: complex -! -! This routine builds a coarse-level matrix A_C from a fine-level matrix A -! by using the Galerkin approach, i.e. -! -! A_C = P_C^T A P_C, -! -! where P_C is a prolongator from the coarse level to the fine one. -! -! The prolongator P_C is built according to a smoothed aggregation algorithm, -! i.e. it is obtained by applying a damped Jacobi smoother to the piecewise -! constant interpolation operator P corresponding to the fine-to-coarse level -! mapping built by the mld_aggrmap_bld subroutine: -! -! P_C = (I - omega*D^(-1)A) * P, -! -! where D is the diagonal matrix with main diagonal equal to the main diagonal -! of A, and omega is a suitable smoothing parameter. An estimate of the spectral -! radius of D^(-1)A, to be used in the computation of omega, is provided, -! according to the value of p%parms%aggr_omega_alg, specified by the user -! through mld_zprecinit and mld_zprecset. -! 4. Minimum energy aggregation: -! M. Sala, R. Tuminaro: A new Petrov-Galerkin smoothed aggregation preconditioner -! for nonsymmetric linear systems, SIAM J. Sci. Comput., 31(1):143-166 (2008) -! -! On output from this routine the entries of AC, op_prol, op_restr -! are still in "global numbering" mode; this is fixed in the calling routine -! aggregator%mat_bld. -! -! -! Arguments: -! a - type(psb_zspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! p - type(mld_z_onelev_type), input/output. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! parms - type(mld_dml_parms), input -! Parameters controlling the choice of algorithm -! ac - type(psb_zspmat_type), output -! The coarse matrix on output -! -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_zspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_zspmat_type), output -! The restrictor operator; in this particular case, it is different -! from the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -! -subroutine mld_zaggrmat_minnrg_bld(a,desc_a,ilaggr,nlaggr,parms,& - & ac,desc_ac,op_prol,op_restr,info) - use psb_base_mod - use mld_base_prec_type - use mld_z_inner_mod, mld_protect_name => mld_zaggrmat_minnrg_bld - - implicit none - - ! Arguments - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(mld_dml_parms), intent(inout) :: parms - type(psb_lzspmat_type), intent(inout) :: op_prol - type(psb_lzspmat_type), intent(out) :: ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nzac, ip, ndx,& - & naggr, nzl,naggrm1,naggrp1, i, j, k, jd, icolF, nrt - integer(psb_ipk_) :: ictxt,np,me, icomm - character(len=20) :: name - type(psb_lzspmat_type) :: la, af, ptilde, rtilde, atran, atp, atdatp - type(psb_lzspmat_type) :: am3,am4, ap, adap,atmp,rada, ra, atmp2, dap, dadap, da - type(psb_lzspmat_type) :: dat, datp, datdatp, atmp3, tmp_prol - type(psb_lz_coo_sparse_mat) :: tmpcoo - type(psb_lz_csr_sparse_mat) :: acsr1, acsr2, acsr3, acsr, acsrf - type(psb_lz_csc_sparse_mat) :: csc_dap, csc_dadap, csc_datp, csc_datdatp, acsc - complex(psb_dpk_), allocatable :: adiag(:), adinv(:) - complex(psb_dpk_), allocatable :: omf(:), omp(:), omi(:), oden(:) - logical :: filter_mat - integer(psb_ipk_) :: ierr(5) - integer(psb_ipk_) :: debug_level, debug_unit, err_act - integer(psb_ipk_), parameter :: ncmax=16 - real(psb_dpk_) :: anorm, theta - complex(psb_dpk_) :: tmp, alpha, beta, ommx - - name='mld_aggrmat_minnrg' - info=psb_success_ - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - ictxt = desc_a%get_context() - - call psb_info(ictxt, me, np) - - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - theta = parms%aggr_thresh - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - - filter_mat = (parms%aggr_filter == mld_filter_mat_) - - ! naggr: number of local aggregates - ! nrow: local rows. - ! - allocate(adinv(ncol),& - & omf(ncol),omp(ntaggr),oden(ntaggr),omi(ncol),stat=info) - - if (info /= psb_success_) then - info=psb_err_alloc_request_; ierr(1)=6*ncol+ntaggr; - call psb_errpush(info,name,i_err=ierr,a_err='complex(psb_dpk_)') - goto 9999 - end if - - ! Get the diagonal D - adiag = a%get_diag(info) - if (info == psb_success_) & - & call psb_realloc(ncol,adiag,info) - if (info == psb_success_) & - & call psb_halo(adiag,desc_a,info) - if (info == psb_success_) call a%cp_to_l(la) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_getdiag') - goto 9999 - end if - - do i=1,size(adiag) - if (adiag(i) /= zzero) then - adinv(i) = zone / adiag(i) - else - adinv(i) = zone - end if - end do - - - - ! 1. Allocate Ptilde in sparse matrix form - call op_prol%mv_to(tmpcoo) - call ptilde%mv_from(tmpcoo) - call ptilde%cscnv(info,type='csr') - - if (info == psb_success_) call la%cscnv(am3,info,type='csr',dupl=psb_dupl_add_) - if (info == psb_success_) call la%cscnv(da,info,type='csr',dupl=psb_dupl_add_) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' Initial copies done.' - - call da%scal(adinv,info) - - call psb_spspmm(da,ptilde,dap,info) - - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 1') - goto 9999 - end if - - call dap%clone(atmp,info) - - call psb_sphalo(atmp,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.,outfmt='CSR ') - if (info == psb_success_) call psb_rwextd(ncol,atmp,info,b=am4) - if (info == psb_success_) call am4%free() - - call psb_spspmm(da,atmp,dadap,info) - call atmp%free() - - ! !$ write(0,*) 'Columns of AP',psb_sp_get_ncols(ap) - ! !$ write(0,*) 'Columns of ADAP',psb_sp_get_ncols(adap) - call dap%mv_to(csc_dap) - call dadap%mv_to(csc_dadap) - - call csc_mat_col_prod(csc_dap,csc_dadap,omp,info) - call csc_mat_col_prod(csc_dadap,csc_dadap,oden,info) - call psb_sum(ictxt,omp) - call psb_sum(ictxt,oden) - ! !$ write(0,*) trim(name),' OMP :',omp - ! !$ write(0,*) trim(name),' ODEN:',oden - - omp = omp/oden - - ! !$ write(0,*) 'Check on output prolongator ',omp(1:min(size(omp),10)) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done NUMBMM 1' - - call am3%mv_to(acsr3) - ! Compute omega_int - ommx = zzero - do i=1, ncol - if (ilaggr(i) >0) then - omi(i) = omp(ilaggr(i)) - else - omi(i) = zzero - end if - if(abs(omi(i)) .gt. abs(ommx)) ommx = omi(i) - end do - ! Compute omega_fine - do i=1, nrow - omf(i) = ommx - do j=acsr3%irp(i),acsr3%irp(i+1)-1 - if(abs(omi(acsr3%ja(j))) .lt. abs(omf(i))) omf(i)=omi(acsr3%ja(j)) - end do -!!$ if(min(real(omf(i)),aimag(omf(i))) < dzero) omf(i) = zzero - if(psb_minreal(omf(i)) < dzero) omf(i) = zzero - end do - - omf(1:nrow) = omf(1:nrow) * adinv(1:nrow) - - if (filter_mat) then - ! - ! Build the filtered matrix Af from A - ! - call la%cscnv(acsrf,info,dupl=psb_dupl_add_) - - do i=1,nrow - tmp = zzero - jd = -1 - do j=acsrf%irp(i),acsrf%irp(i+1)-1 - if (acsrf%ja(j) == i) jd = j - if (abs(acsrf%val(j)) < theta*sqrt(abs(adiag(i)*adiag(acsrf%ja(j))))) then - tmp=tmp+acsrf%val(j) - acsrf%val(j)=zzero - endif - enddo - if (jd == -1) then - write(0,*) 'Wrong input: we need the diagonal!!!!', i - else - acsrf%val(jd)=acsrf%val(jd)-tmp - end if - enddo - ! Take out zeroed terms - call acsrf%clean_zeros(info) - - ! - ! Build the smoothed prolongator using the filtered matrix - ! - do i=1,acsrf%get_nrows() - do j=acsrf%irp(i),acsrf%irp(i+1)-1 - if (acsrf%ja(j) == i) then - acsrf%val(j) = zone - omf(i)*acsrf%val(j) - else - acsrf%val(j) = - omf(i)*acsrf%val(j) - end if - end do - end do - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done gather, going for SYMBMM 1' - - call af%mv_from(acsrf) - ! - ! op_prol = (I-w*D*Af)Ptilde - ! Doing it this way means to consider diag(Af_i) - ! - ! - call psb_spspmm(af,ptilde,op_prol,info) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done SPSPMM 1' - else - ! - ! Build the smoothed prolongator using the original matrix - ! - do i=1,acsr3%get_nrows() - do j=acsr3%irp(i),acsr3%irp(i+1)-1 - if (acsr3%ja(j) == i) then - acsr3%val(j) = zone - omf(i)*acsr3%val(j) - else - acsr3%val(j) = - omf(i)*acsr3%val(j) - end if - end do - end do - - call am3%mv_from(acsr3) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done gather, going for SYMBMM 1' - ! - ! - ! op_prol = (I-w*D*A)Ptilde - ! - ! - call psb_spspmm(am3,ptilde,op_prol,info) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done NUMBMM 1' - - end if - - - ! - ! Ok, let's start over with the restrictor - ! - call ptilde%transc(rtilde) - call la%cscnv(atmp,info,type='csr') - call psb_sphalo(atmp,desc_a,am4,info,& - & colcnv=.true.,rowscale=.true.) - nrt = am4%get_nrows() - call am4%csclip(atmp2,info,lone,nrt,lone,ncol) - call atmp2%cscnv(info,type='CSR') - if (info == psb_success_) call psb_rwextd(ncol,atmp,info,b=atmp2) - call am4%free() - call atmp2%free() - - ! This is to compute the transpose. It ONLY works if the - ! original A has a symmetric pattern. - call atmp%transc(atmp2) - call atmp2%csclip(dat,info,lone,nrow,lone,ncol) - call dat%cscnv(info,type='csr') - call dat%scal(adinv,info) - - ! Now for the product. - call psb_spspmm(dat,ptilde,datp,info) - - call datp%clone(atmp2,info) - call psb_sphalo(atmp2,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.,outfmt='CSR ') - if (info == psb_success_) call psb_rwextd(ncol,atmp2,info,b=am4) - if (info == psb_success_) call am4%free() - - - call psb_symbmm(dat,atmp2,datdatp,info) - call psb_numbmm(dat,atmp2,datdatp) - call atmp2%free() - - call datp%mv_to(csc_datp) - call datdatp%mv_to(csc_datdatp) - - call csc_mat_col_prod(csc_datp,csc_datdatp,omp,info) - call csc_mat_col_prod(csc_datdatp,csc_datdatp,oden,info) - call psb_sum(ictxt,omp) - call psb_sum(ictxt,oden) - - - ! !$ write(debug_unit,*) trim(name),' OMP_R :',omp - ! ! $ write(debug_unit,*) trim(name),' ODEN_R:',oden - omp = omp/oden - ! !$ write(0,*) 'Check on output restrictor',omp(1:min(size(omp),10)) - ! Compute omega_int - ommx = zzero - do i=1, ncol - if (ilaggr(i) >0) then - omi(i) = omp(ilaggr(i)) - else - omi(i) = zzero - end if - if(abs(omi(i)) .gt. abs(ommx)) ommx = omi(i) - end do - ! Compute omega_fine - ! Going over the columns of atmp means going over the rows - ! of A^T. Hopefully ;-) - call atmp%cp_to(acsc) - - do i=1, nrow - omf(i) = ommx - do j= acsc%icp(i),acsc%icp(i+1)-1 - if(abs(omi(acsc%ia(j))) .lt. abs(omf(i))) omf(i)=omi(acsc%ia(j)) - end do -!!$ if(min(real(omf(i)),aimag(omf(i))) < dzero) omf(i) = zzero - if(psb_minreal(omf(i)) < dzero) omf(i) = zzero - end do - omf(1:nrow) = omf(1:nrow)*adinv(1:nrow) - call psb_halo(omf,desc_a,info) - call acsc%free() - - - call atmp%mv_to(acsr1) - - do i=1,acsr1%get_nrows() - do j=acsr1%irp(i),acsr1%irp(i+1)-1 - if (acsr1%ja(j) == i) then - acsr1%val(j) = zone - acsr1%val(j)*omf(acsr1%ja(j)) - else - acsr1%val(j) = - acsr1%val(j)*omf(acsr1%ja(j)) - end if - end do - end do - call atmp%mv_from(acsr1) - - call rtilde%mv_to(tmpcoo) - nzl = tmpcoo%get_nzeros() - i=0 - do k=1, nzl - if ((naggrm1 < tmpcoo%ia(k)) .and. (tmpcoo%ia(k) <= naggrp1)) then - i = i+1 - tmpcoo%val(i) = tmpcoo%val(k) - tmpcoo%ia(i) = tmpcoo%ia(k) - tmpcoo%ja(i) = tmpcoo%ja(k) - end if - end do - call tmpcoo%set_nzeros(i) - call rtilde%mv_from(tmpcoo) - call rtilde%cscnv(info,type='csr') - - call psb_spspmm(rtilde,atmp,op_restr,info) - - ! - ! Now we have to gather the halo of op_prol, and add it to itself - ! to multiply it by A, - ! - call op_prol%clone(tmp_prol,info) - if (info == psb_success_) call psb_sphalo(tmp_prol,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.) - if (info == psb_success_) call psb_rwextd(ncol,tmp_prol,info,b=am4) - if (info == psb_success_) call am4%free() - - if(info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Halo of op_prol') - goto 9999 - end if - - ! - ! Now we have to fix this. The only rows of B that are correct - ! are those corresponding to "local" aggregates, i.e. indices in ilaggr(:) - ! - call op_restr%mv_to(tmpcoo) - - nzl = tmpcoo%get_nzeros() - i=0 - do k=1, nzl - if ((naggrm1 < tmpcoo%ia(k)) .and. (tmpcoo%ia(k) <= naggrp1)) then - i = i+1 - tmpcoo%val(i) = tmpcoo%val(k) - tmpcoo%ia(i) = tmpcoo%ia(k) - tmpcoo%ja(i) = tmpcoo%ja(k) - end if - end do - call tmpcoo%set_nzeros(i) - call op_restr%mv_from(tmpcoo) - call op_restr%cscnv(info,type='csr') - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'starting sphalo/ rwxtd' - - call psb_spspmm(la,tmp_prol,am3,info) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done SPSPMM 2' - - call psb_sphalo(am3,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.) - if (info == psb_success_) call psb_rwextd(ncol,am3,info,b=am4) - if (info == psb_success_) call am4%free() - - if(info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Extend am3') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done sphalo/ rwxtd' - - call psb_spspmm(op_restr,am3,ac,info) - if (info == psb_success_) call am3%free() - if (info == psb_success_) call ac%cscnv(info,type='coo',dupl=psb_dupl_add_) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - &a_err='Build ac = op_restr x am3') - goto 9999 - end if - - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done smooth_aggregate ' - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_errpush(info,name) - call psb_error_handler(err_act) - return - - -contains - - subroutine csc_mat_col_prod(a,b,v,info) - implicit none - type(psb_lz_csc_sparse_mat), intent(in) :: a, b - complex(psb_dpk_), intent(out) :: v(:) - integer(psb_ipk_), intent(out) :: info - - integer(psb_lpk_) :: i,j,k, nr, nc,iap,nra,ibp,nrb - - info = psb_success_ - nc = a%get_ncols() - if (nc /= b%get_ncols()) then - write(0,*) 'Matrices A and B should have same columns' - info = -1 - return - end if - - do j=1, nc - iap = a%icp(j) - nra = a%icp(j+1)-iap - ibp = b%icp(j) - nrb = b%icp(j+1)-ibp - v(j) = sparse_srtd_dot(nra,a%ia(iap:iap+nra-1),a%val(iap:iap+nra-1),& - & nrb,b%ia(ibp:ibp+nrb-1),b%val(ibp:ibp+nrb-1)) - end do - - end subroutine csc_mat_col_prod - - - subroutine csr_mat_row_prod(a,b,v,info) - implicit none - type(psb_lz_csr_sparse_mat), intent(in) :: a, b - complex(psb_dpk_), intent(out) :: v(:) - integer(psb_ipk_), intent(out) :: info - - integer(psb_lpk_) :: i,j,k, nr, nc,iap,nca,ibp,ncb - - info = psb_success_ - nr = a%get_nrows() - if (nr /= b%get_nrows()) then - write(0,*) 'Matrices A and B should have same rows' - info = -1 - return - end if - - do j=1, nr - iap = a%irp(j) - nca = a%irp(j+1)-iap - ibp = b%irp(j) - ncb = b%irp(j+1)-ibp - v(j) = sparse_srtd_dot(nca,a%ja(iap:iap+nca-1),a%val(iap:iap+nca-1),& - & ncb,b%ja(ibp:ibp+ncb-1),b%val(ibp:ibp+ncb-1)) - end do - - end subroutine csr_mat_row_prod - - - function sparse_srtd_dot(nv1,iv1,v1,nv2,iv2,v2) result(dot) - implicit none - integer(psb_lpk_), intent(in) :: nv1,nv2 - integer(psb_lpk_), intent(in) :: iv1(:), iv2(:) - complex(psb_dpk_), intent(in) :: v1(:),v2(:) - complex(psb_dpk_) :: dot - - integer(psb_lpk_) :: i,j,k, ip1, ip2 - - dot = zzero - ip1 = 1 - ip2 = 1 - - do - if (ip1 > nv1) exit - if (ip2 > nv2) exit - if (iv1(ip1) == iv2(ip2)) then - dot = dot + conjg(v1(ip1))*v2(ip2) - ip1 = ip1 + 1 - ip2 = ip2 + 1 - else if (iv1(ip1) < iv2(ip2)) then - ip1 = ip1 + 1 - else - ip2 = ip2 + 1 - end if - end do - - end function sparse_srtd_dot - - subroutine local_dump(me,mat,name,header) - type(psb_lzspmat_type), intent(in) :: mat - integer(psb_ipk_), intent(in) :: me - character(len=*), intent(in) :: name - character(len=*), intent(in) :: header - character(len=80) :: filename - - write(filename,'(a,a,i0,a,i0,a)') trim(name),'.p',me - open(20+me,file=filename) - call mat%print(20+me,head=trim(header)) - close(20+me) - end subroutine local_dump - -end subroutine mld_zaggrmat_minnrg_bld diff --git a/mlprec/impl/aggregator/mld_zaggrmat_nosmth_bld.f90 b/mlprec/impl/aggregator/mld_zaggrmat_nosmth_bld.f90 deleted file mode 100644 index a4a82cb1..00000000 --- a/mlprec/impl/aggregator/mld_zaggrmat_nosmth_bld.f90 +++ /dev/null @@ -1,198 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_zaggrmat_nosmth_bld.F90 -! -! Subroutine: mld_zaggrmat_nosmth_bld -! Version: complex -! -! This routine builds a coarse-level matrix A_C from a fine-level matrix A -! by using the Galerkin approach, i.e. -! -! A_C = P_C^T A P_C, -! -! where P_C is the piecewise constant interpolation operator corresponding -! the fine-to-coarse level mapping built by mld_aggrmap_bld. -! -! The coarse-level matrix A_C is distributed among the parallel processes or -! replicated on each of them, according to the value of p%parms%coarse_mat -! specified by the user through mld_zprecinit and mld_zprecset. -! On output from this routine the entries of AC, op_prol, op_restr -! are still in "global numbering" mode; this is fixed in the calling routine -! aggregator%mat_bld. -! -! For details see -! P. D'Ambra, D. di Serafino and S. Filippone, On the development of -! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math., -! 57 (2007), 1181-1196. -! -! -! Arguments: -! a - type(psb_zspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! p - type(mld_z_onelev_type), input/output. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! parms - type(mld_dml_parms), input -! Parameters controlling the choice of algorithm -! ac - type(psb_zspmat_type), output -! The coarse matrix on output -! -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_zspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_zspmat_type), output -! The restrictor operator; normally, it is the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -! -subroutine mld_zaggrmat_nosmth_bld(a,desc_a,ilaggr,nlaggr,parms,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - use psb_base_mod - use mld_base_prec_type - use mld_z_inner_mod, mld_protect_name => mld_zaggrmat_nosmth_bld - use mld_z_base_aggregator_mod - implicit none - - ! Arguments - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(mld_dml_parms), intent(inout) :: parms - type(psb_zspmat_type), intent(inout) :: op_prol,ac,op_restr - type(psb_lzspmat_type), intent(inout) :: t_prol - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt, np, me, icomm, minfo - character(len=20) :: name - type(psb_lz_coo_sparse_mat) :: lcoo_prol - type(psb_z_coo_sparse_mat) :: coo_prol, coo_restr - type(psb_z_csr_sparse_mat) :: acsr - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, nzl, ip, & - & naggr, nzt, naggrm1, naggrp1, i, k - integer(psb_ipk_) :: inaggr, nzlp - logical, parameter :: debug = .false. - - name = 'mld_aggrmat_nosmth_bld' - info = psb_success_ - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - - ictxt = desc_a%get_context() - icomm = desc_a%get_mpic() - call psb_info(ictxt, me, np) - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - - call a%cp_to(acsr) - call t_prol%mv_to(lcoo_prol) - inaggr = naggr - call psb_cdall(ictxt,desc_ac,info,nl=inaggr) - nzlp = lcoo_prol%get_nzeros() - call desc_ac%indxmap%g2lip_ins(lcoo_prol%ja(1:nzlp),info) - call lcoo_prol%set_ncols(desc_ac%get_local_cols()) - call lcoo_prol%cp_to_icoo(coo_prol,info) - - if (debug) call check_coo(me,trim(name)//' Check 1 on coo_prol:',coo_prol) - - call psb_cdasb(desc_ac,info) - call psb_cd_reinit(desc_ac,info) - - call mld_ptap(acsr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info) - - call coo_restr%set_nrows(desc_ac%get_local_rows()) - call coo_restr%set_ncols(desc_a%get_local_cols()) - call coo_prol%set_nrows(desc_a%get_local_rows()) - call coo_prol%set_ncols(desc_ac%get_local_cols()) - - if (debug) call check_coo(me,trim(name)//' Check 1 on coo_restr:',coo_restr) - - call op_prol%mv_from(coo_prol) - call op_restr%mv_from(coo_restr) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - subroutine check_coo(me,string,coo) - implicit none - integer(psb_ipk_) :: me - type(psb_z_coo_sparse_mat) :: coo - character(len=*) :: string - integer(psb_lpk_) :: nr,nc,nz - nr = coo%get_nrows() - nc = coo%get_ncols() - nz = coo%get_nzeros() - write(0,*) me,string,nr,nc,& - & minval(coo%ia(1:nz)),maxval(coo%ia(1:nz)),& - & minval(coo%ja(1:nz)),maxval(coo%ja(1:nz)) - - end subroutine check_coo -end subroutine mld_zaggrmat_nosmth_bld diff --git a/mlprec/impl/aggregator/mld_zaggrmat_smth_bld.f90 b/mlprec/impl/aggregator/mld_zaggrmat_smth_bld.f90 deleted file mode 100644 index 45d3fc7d..00000000 --- a/mlprec/impl/aggregator/mld_zaggrmat_smth_bld.f90 +++ /dev/null @@ -1,325 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_zaggrmat_smth_bld.F90 -! -! Subroutine: mld_zaggrmat_smth_bld -! Version: complex -! -! This routine builds a coarse-level matrix A_C from a fine-level matrix A -! by using the Galerkin approach, i.e. -! -! A_C = P_C^T A P_C, -! -! where P_C is a prolongator from the coarse level to the fine one. -! -! The prolongator P_C is built according to a smoothed aggregation algorithm, -! i.e. it is obtained by applying a damped Jacobi smoother to the piecewise -! constant interpolation operator P corresponding to the fine-to-coarse level -! mapping built by the mld_aggrmap_bld subroutine: -! -! P_C = (I - omega*D^(-1)A) * P, -! -! where D is the diagonal matrix with main diagonal equal to the main diagonal -! of A, and omega is a suitable smoothing parameter. An estimate of the spectral -! radius of D^(-1)A, to be used in the computation of omega, is provided, -! according to the value of p%parms%aggr_omega_alg, specified by the user -! through mld_zprecinit and mld_zprecset. -! -! The coarse-level matrix A_C is distributed among the parallel processes or -! replicated on each of them, according to the value of p%parms%coarse_mat, -! specified by the user through mld_zprecinit and mld_zprecset. -! On output from this routine the entries of AC, op_prol, op_restr -! are still in "global numbering" mode; this is fixed in the calling routine -! aggregator%mat_bld. -! -! -! Arguments: -! a - type(psb_zspmat_type), input. -! The sparse matrix structure containing the local part of -! the fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of the fine-level matrix. -! p - type(mld_z_onelev_type), input/output. -! The 'one-level' data structure that will contain the local -! part of the matrix to be built as well as the information -! concerning the prolongator and its transpose. -! parms - type(mld_dml_parms), input -! Parameters controlling the choice of algorithm -! ac - type(psb_zspmat_type), output -! The coarse matrix on output -! -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_zspmat_type), input/output -! The tentative prolongator on input, the computed prolongator on output -! -! op_restr - type(psb_zspmat_type), output -! The restrictor operator; normally, it is the transpose of the prolongator. -! -! info - integer, output. -! Error code. -! -subroutine mld_zaggrmat_smth_bld(a,desc_a,ilaggr,nlaggr,parms,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - use psb_base_mod - use mld_base_prec_type - use mld_z_inner_mod, mld_protect_name => mld_zaggrmat_smth_bld - use mld_z_base_aggregator_mod - - implicit none - - ! Arguments - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(mld_dml_parms), intent(inout) :: parms - type(psb_zspmat_type), intent(out) :: op_prol,ac,op_restr - type(psb_lzspmat_type), intent(inout) :: t_prol - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_lpk_) :: nrow, nglob, ncol, ntaggr, ip, & - & naggr, nzl,naggrm1,naggrp1, i, j, k, jd, icolF, nrw - integer(psb_ipk_) :: inaggr, nzlp - integer(psb_ipk_) :: ictxt, np, me - character(len=20) :: name - type(psb_lz_coo_sparse_mat) :: tmpcoo - type(psb_z_coo_sparse_mat) :: coo_prol, coo_restr - type(psb_z_csr_sparse_mat) :: acsr1, acsrf, csr_prol, acsr - complex(psb_dpk_), allocatable :: adiag(:) - real(psb_dpk_), allocatable :: arwsum(:) - integer(psb_ipk_) :: ierr(5) - logical :: filter_mat - integer(psb_ipk_) :: debug_level, debug_unit, err_act - integer(psb_ipk_), parameter :: ncmax=16 - real(psb_dpk_) :: anorm, omega, tmp, dg, theta - logical, parameter :: debug_new=.false. - character(len=80) :: filename - - name='mld_aggrmat_smth_bld' - info=psb_success_ - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - ictxt = desc_a%get_context() - - call psb_info(ictxt, me, np) - - nglob = desc_a%get_global_rows() - nrow = desc_a%get_local_rows() - ncol = desc_a%get_local_cols() - - theta = parms%aggr_thresh - - naggr = nlaggr(me+1) - ntaggr = sum(nlaggr) - - naggrm1 = sum(nlaggr(1:me)) - naggrp1 = sum(nlaggr(1:me+1)) - filter_mat = (parms%aggr_filter == mld_filter_mat_) - - ! - ! naggr: number of local aggregates - ! nrow: local rows. - ! - - ! Get the diagonal D - adiag = a%get_diag(info) - if (info == psb_success_) & - & call psb_realloc(ncol,adiag,info) - if (info == psb_success_) & - & call psb_halo(adiag,desc_a,info) - if (info == psb_success_) call a%cp_to(acsr) - - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_getdiag') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' Initial copies done.' - - call acsr%cp_to_fmt(acsrf,info) - - - if (filter_mat) then - ! - ! Build the filtered matrix Af from A - ! - - do i=1, nrow - tmp = zzero - jd = -1 - do j=acsrf%irp(i),acsrf%irp(i+1)-1 - if (acsrf%ja(j) == i) jd = j - if (abs(acsrf%val(j)) < theta*sqrt(abs(adiag(i)*adiag(acsrf%ja(j))))) then - tmp=tmp+acsrf%val(j) - acsrf%val(j)=zzero - endif - - enddo - if (jd == -1) then - write(0,*) 'Wrong input: we need the diagonal!!!!', i - else - acsrf%val(jd)=acsrf%val(jd)-tmp - end if - enddo - ! Take out zeroed terms - call acsrf%clean_zeros(info) - end if - - - do i=1,size(adiag) - if (adiag(i) /= zzero) then - adiag(i) = zone / adiag(i) - else - adiag(i) = zone - end if - end do - - if (parms%aggr_omega_alg == mld_eig_est_) then - - if (parms%aggr_eig == mld_max_norm_) then - allocate(arwsum(nrow)) - call acsr%arwsum(arwsum) - anorm = maxval(abs(adiag(1:nrow)*arwsum(1:nrow))) - call psb_amx(ictxt,anorm) - omega = 4.d0/(3.d0*anorm) - parms%aggr_omega_val = omega - - else - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_aggr_eig_') - goto 9999 - end if - - else if (parms%aggr_omega_alg == mld_user_choice_) then - - omega = parms%aggr_omega_val - - else if (parms%aggr_omega_alg /= mld_user_choice_) then - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_aggr_omega_alg_') - goto 9999 - end if - - - call acsrf%scal(adiag,info) - if (info /= psb_success_) goto 9999 - - call t_prol%mv_to(tmpcoo) - inaggr = naggr - call psb_cdall(ictxt,desc_ac,info,nl=inaggr) - nzlp = tmpcoo%get_nzeros() - call desc_ac%indxmap%g2lip_ins(tmpcoo%ja(1:nzlp),info) - call tmpcoo%set_ncols(desc_ac%get_local_cols()) - call tmpcoo%mv_to_ifmt(csr_prol,info) - - call psb_cdasb(desc_ac,info) - call psb_cd_reinit(desc_ac,info) - ! - ! Build the smoothed prolongator using either A or Af - ! acsr1 = (I-w*D*A) Prol acsr1 = (I-w*D*Af) Prol - ! This is always done through the variable acsrf which - ! is a bit less readable, but saves space and one matrix copy - ! - call omega_smooth(omega,acsrf) - call psb_par_spspmm(acsrf,desc_a,csr_prol,acsr1,desc_ac,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 1') - goto 9999 - end if - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done SPSPMM 1' - nzl = acsr1%get_nzeros() - call acsr1%mv_to_coo(coo_prol,info) - - call mld_ptap(acsr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_ac,coo_restr,info) - - call op_prol%mv_from(coo_prol) - call op_restr%mv_from(coo_restr) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done smooth_aggregate ' - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_errpush(info,name) - call psb_error_handler(err_act) - return - -contains - - subroutine omega_smooth(omega,acsr) - implicit none - real(psb_dpk_),intent(in) :: omega - type(psb_z_csr_sparse_mat), intent(inout) :: acsr - ! - integer(psb_lpk_) :: i,j - do i=1,acsr%get_nrows() - do j=acsr%irp(i),acsr%irp(i+1)-1 - if (acsr%ja(j) == i) then - acsr%val(j) = zone - omega*acsr%val(j) - else - acsr%val(j) = - omega*acsr%val(j) - end if - end do - end do - end subroutine omega_smooth - -end subroutine mld_zaggrmat_smth_bld diff --git a/mlprec/impl/amg_c_extprol_bld.F90 b/mlprec/impl/amg_c_extprol_bld.F90 new file mode 100644 index 00000000..b1e343b2 --- /dev/null +++ b/mlprec/impl/amg_c_extprol_bld.F90 @@ -0,0 +1,534 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_c_extprol_bld.f90 +! +! Subroutine: amg_c_extprol_bld +! Version: real +! +! This routine builds the preconditioner according to the requirements made by +! the user trough the subroutines amg_precinit and amg_precset. +! +! A multilevel preconditioner is regarded as an array of 'one-level' data structures, +! each containing the part of the preconditioner associated to a certain level, +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level. No transfer operators are associated to level 1. +! +! +! Arguments: +! a - type(psb_cspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_cprec_type), input/output. +! The preconditioner data structure containing the local part +! of the preconditioner to be built. +! info - integer, output. +! Error code. +! +! amold - class(psb_c_base_sparse_mat), input, optional +! Mold for the inner format of matrices contained in the +! preconditioner +! +! +! vmold - class(psb_c_base_vect_type), input, optional +! Mold for the inner format of vectors contained in the +! preconditioner +! +! +! +subroutine amg_c_extprol_bld(a,desc_a,p,prolv,restrv,info,amold,vmold,imold) + + use psb_base_mod + use amg_c_inner_mod + use amg_c_prec_mod, amg_protect_name => amg_c_extprol_bld + + Implicit None + + ! Arguments + type(psb_cspmat_type),intent(in), target :: a + type(psb_cspmat_type),intent(inout), target :: prolv(:) + type(psb_cspmat_type),intent(inout), target :: restrv(:) + type(psb_desc_type), intent(inout), target :: desc_a + type(amg_cprec_type),intent(inout),target :: p + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! !$ character, intent(in), optional :: upd + + ! Local Variables + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, casize, nplevs, mxplevs + integer(psb_ipk_) :: nprolv, nrestrv + real(psb_spk_) :: mnaggratio + integer(psb_ipk_) :: ipv(amg_ifpsz_), val + class(amg_c_base_smoother_type), allocatable :: coarse_sm, base_sm, med_sm + type(amg_sml_parms) :: baseparms, medparms, coarseparms + type(amg_c_onelev_type), allocatable :: tprecv(:) + integer(psb_ipk_) :: int_err(5) + character :: upd_ + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + logical, parameter :: debug=.false. + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_c_extprol_bld' + info = psb_success_ + int_err(1) = 0 + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + p%ictxt = ictxt + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' +#if defined(LPK8) + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Need fix for LPK8') + goto 9999 +#else + + ! + ! For the time being we are commenting out the UPDATE argument + ! we plan to resurrect it later. + ! !$ if (present(upd)) then + ! !$ if (debug_level >= psb_debug_outer_) & + ! !$ & write(debug_unit,*) me,' ',trim(name),'UPD ', upd + ! !$ + ! !$ if ((psb_toupper(upd).eq.'F').or.(psb_toupper(upd).eq.'T')) then + ! !$ upd_=psb_toupper(upd) + ! !$ else + ! !$ upd_='F' + ! !$ endif + ! !$ else + ! !$ upd_='F' + ! !$ endif + upd_ = 'F' + + if (.not.allocated(p%precv)) then + !! Error: should have called amg_cprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + ! + ! Check to ensure all procs have the same + ! + newsz = -1 + mxplevs = p%ag_data%max_levs + mnaggratio = p%ag_data%min_cr_ratio + casize = p%ag_data%min_coarse_size + iszv = size(p%precv) + nprolv = size(prolv) + nrestrv = size(restrv) + call psb_bcast(ictxt,iszv) + call psb_bcast(ictxt,casize) + call psb_bcast(ictxt,mxplevs) + call psb_bcast(ictxt,mnaggratio) + call psb_bcast(ictxt,nprolv) + call psb_bcast(ictxt,nrestrv) + if (casize /= p%ag_data%min_coarse_size) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent min_coarse_size') + goto 9999 + end if + if (mxplevs /= p%ag_data%max_levs) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent max_levs') + goto 9999 + end if + if (mnaggratio /= p%ag_data%min_cr_ratio) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent min_cr_ratio') + goto 9999 + end if + if (iszv /= size(p%precv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of precv') + goto 9999 + end if + if (nprolv /= size(prolv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of prolv') + goto 9999 + end if + if (nrestrv /= size(restrv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of restrv') + goto 9999 + end if + if (nrestrv /= nprolv) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size prolv vs restrv') + goto 9999 + end if + + if (iszv <= 1) then + ! We should only ever get here for multilevel. + info=psb_err_from_subroutine_ + ch_err='size bpv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + endif + + if (nrestrv < 1) then + ! We should only ever get here for multilevel. + info=psb_err_from_subroutine_ + ch_err='size restrv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + endif + + ! + nplevs = nrestrv + 1 + p%ag_data%max_levs = nplevs + + ! + ! Fixed number of levels. + ! + nplevs = max(itwo,mxplevs) + + coarseparms = p%precv(iszv)%parms + baseparms = p%precv(1)%parms + medparms = p%precv(2)%parms + + allocate(coarse_sm, source=p%precv(iszv)%sm,stat=info) + if (info == psb_success_) & + & allocate(med_sm, source=p%precv(2)%sm,stat=info) + if (info == psb_success_) & + & allocate(base_sm, source=p%precv(1)%sm,stat=info) + if (info /= psb_success_) then + write(0,*) 'Error in saving smoothers',info + call psb_errpush(psb_err_internal_error_,name,a_err='Base level precbuild.') + goto 9999 + end if + + if (iszv /= nplevs) then + allocate(tprecv(nplevs),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + tprecv(1)%parms = baseparms + allocate(tprecv(1)%sm,source=base_sm,stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + do i=2,nplevs-1 + tprecv(i)%parms = medparms + allocate(tprecv(i)%sm,source=med_sm,stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + end do + tprecv(nplevs)%parms = coarseparms + allocate(tprecv(nplevs)%sm,source=coarse_sm,stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + do i=1,iszv + call p%precv(i)%free(info) + end do + call move_alloc(tprecv,p%precv) + iszv = size(p%precv) + end if + ! + ! Finest level first; remember to fix base_a and base_desc + ! + p%precv(1)%base_a => a + p%precv(1)%base_desc => desc_a + newsz = 0 + array_build_loop: do i=2, iszv + + ! + ! Sanity checks on the parameters + ! + if (i p%precv(i)%ac + p%precv(i)%base_desc => p%precv(i)%desc_ac + + + if (i>2) then + if (all(p%precv(i)%map%naggr == p%precv(i-1)%map%naggr)) then + newsz=i-1 + end if + call psb_bcast(ictxt,newsz) + if (newsz > 0) exit array_build_loop + end if + end do array_build_loop + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Internal extprol build' ) + goto 9999 + endif + + iszv = size(p%precv) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Exiting with',iszv,' levels' +#endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + + subroutine amg_c_extaggr_bld(a,desc_a,p,op_restr,op_prol,info) + use psb_base_mod + use amg_c_inner_mod + + implicit none + + ! Arguments + type(psb_cspmat_type), intent(in), target :: a + type(psb_cspmat_type), intent(inout) :: op_restr,op_prol + type(psb_desc_type), intent(in), target :: desc_a + type(amg_c_onelev_type), intent(inout),target :: p + integer(psb_ipk_), intent(out) :: info + + ! Local variables + character(len=20) :: name + integer(psb_mpk_) :: ictxt, np, me, ncol + integer(psb_ipk_) :: err_act,ntaggr,nzl + integer(psb_ipk_), allocatable :: ilaggr(:), nlaggr(:) + type(psb_cspmat_type) :: ac, am2, am3, am4 + type(psb_c_coo_sparse_mat) :: acoo, bcoo + type(psb_c_csr_sparse_mat) :: acsr1 + logical, parameter :: debug=.false. + + name='amg_c_extaggr_bld' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) +#if defined(LPK8) + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Need fix for LPK8') + goto 9999 +#else + allocate(nlaggr(np),ilaggr(1)) + nlaggr = 0 + ilaggr = 0 + p%parms%par_aggr_alg = amg_ext_aggr_ + call amg_check_def(p%parms%ml_cycle,'Multilevel cycle',& + & amg_mult_ml_,is_legal_ml_cycle) + call amg_check_def(p%parms%coarse_mat,'Coarse matrix',& + & amg_distr_mat_,is_legal_ml_coarse_mat) + + nlaggr(me+1) = op_restr%get_nrows() + if (op_restr%get_nrows() /= op_prol%get_ncols()) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent restr/prol sizes') + goto 9999 + end if + call psb_sum(ictxt,nlaggr) + ntaggr = sum(nlaggr) + ncol = desc_a%get_local_cols() + if (debug) write(0,*)me,' Sizes:',op_restr%get_nrows(),op_restr%get_ncols(),& + & op_prol%get_nrows(),op_prol%get_ncols(), a%get_nrows(),a%get_ncols() + ! + ! Compute local part of AC + ! + call op_prol%clone(am2,info) + if (info == psb_success_) call psb_sphalo(am2,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.) + if (info == psb_success_) call psb_rwextd(ncol,am2,info,b=am4) + if (info == psb_success_) call am4%free() + call psb_spspmm(a,am2,am3,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 2') + goto 9999 + end if + call psb_sphalo(am3,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.) + if (info == psb_success_) call psb_rwextd(ncol,am3,info,b=am4) + if (info == psb_success_) call am4%free() + if(info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Extend am3') + goto 9999 + end if + call psb_spspmm(op_restr,am3,ac,info) + if (info == psb_success_) call am3%free() + if (info == psb_success_) call ac%cscnv(info,type='csr',dupl=psb_dupl_add_) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Build ac = op_restr x am3') + goto 9999 + end if + + select case(p%parms%coarse_mat) + + case(amg_distr_mat_) + + call ac%mv_to(bcoo) + nzl = bcoo%get_nzeros() + + if (info == psb_success_) call psb_cdall(ictxt,p%desc_ac,info,nl=nlaggr(me+1)) + if (info == psb_success_) call psb_cdins(nzl,bcoo%ia,bcoo%ja,p%desc_ac,info) + if (info == psb_success_) call psb_cdasb(p%desc_ac,info) + if (info == psb_success_) call psb_glob_to_loc(bcoo%ia(1:nzl),p%desc_ac,info,iact='I') + if (info == psb_success_) call psb_glob_to_loc(bcoo%ja(1:nzl),p%desc_ac,info,iact='I') + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Creating p%desc_ac and converting ac') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Assembld aux descr. distr.' + call p%ac%mv_from(bcoo) + + call p%ac%set_nrows(p%desc_ac%get_local_rows()) + call p%ac%set_ncols(p%desc_ac%get_local_cols()) + call p%ac%set_asb() + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_sp_free') + goto 9999 + end if + + if (np>1) then + call op_prol%mv_to(acsr1) + nzl = acsr1%get_nzeros() + call psb_glob_to_loc(acsr1%ja(1:nzl),p%desc_ac,info,'I') + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_glob_to_loc') + goto 9999 + end if + call op_prol%mv_from(acsr1) + endif + call op_prol%set_ncols(p%desc_ac%get_local_cols()) + + if (np>1) then + call op_restr%cscnv(info,type='coo',dupl=psb_dupl_add_) + call op_restr%mv_to(acoo) + nzl = acoo%get_nzeros() + if (info == psb_success_) call psb_glob_to_loc(acoo%ia(1:nzl),p%desc_ac,info,'I') + call acoo%set_dupl(psb_dupl_add_) + if (info == psb_success_) call op_restr%mv_from(acoo) + if (info == psb_success_) call op_restr%cscnv(info,type='csr') + if(info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Converting op_restr to local') + goto 9999 + end if + end if + call op_restr%set_nrows(p%desc_ac%get_local_cols()) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ac ' + + case(amg_repl_mat_) + ! + ! + call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) + if (info == psb_success_) call psb_cdasb(p%desc_ac,info) + if (info == psb_success_) & + & call psb_gather(p%ac,ac,p%desc_ac,info,dupl=psb_dupl_add_,keeploc=.false.) + + if (info /= psb_success_) goto 9999 + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_coarse_mat_') + goto 9999 + end select + + call p%ac%cscnv(info,type='csr',dupl=psb_dupl_add_) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv') + goto 9999 + end if + + ! + ! Copy the prolongation/restriction matrices into the descriptor map. + ! op_restr => PR^T i.e. restriction operator + ! op_prol => PR i.e. prolongation operator + ! + + p%map = psb_linmap(psb_map_aggr_,desc_a,& + & p%desc_ac,op_restr,op_prol,ilaggr,nlaggr) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_Free') + goto 9999 + end if +#endif + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + end subroutine amg_c_extaggr_bld + +end subroutine amg_c_extprol_bld diff --git a/mlprec/impl/amg_c_hierarchy_bld.f90 b/mlprec/impl/amg_c_hierarchy_bld.f90 new file mode 100644 index 00000000..57392d6e --- /dev/null +++ b/mlprec/impl/amg_c_hierarchy_bld.f90 @@ -0,0 +1,539 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_c_hierarchy_bld.f90 +! +! Subroutine: amg_c_hierarchy_bld +! Version: complex +! +! This routine builds the preconditioner according to the requirements made by +! the user trough the subroutines amg_precinit and amg_precset. +! +! A multilevel preconditioner is regarded as an array of 'one-level' data structures, +! each containing the part of the preconditioner associated to a certain level, +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level. No transfer operators are associated to level 1. +! +! +! Arguments: +! a - type(psb_cspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_cprec_type), input/output. +! The preconditioner data structure; upon exit it contains +! the multilevel hierarchy of prolongators, restrictors +! and coarse matrices. +! info - integer, output. +! Error code. +! +subroutine amg_c_hierarchy_bld(a,desc_a,prec,info) + + use psb_base_mod + use amg_c_inner_mod + use amg_c_prec_mod, amg_protect_name => amg_c_hierarchy_bld + + Implicit None + + ! Arguments + type(psb_cspmat_type),intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_cprec_type),intent(inout),target :: prec + integer(psb_ipk_), intent(out) :: info + + ! Local Variables + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz,& + & nplevs, mxplevs + integer(psb_lpk_) :: iaggsize, casize + real(psb_spk_) :: mnaggratio, sizeratio, athresh, aomega + class(amg_c_base_smoother_type), allocatable :: coarse_sm, med_sm, & + & med_sm2, coarse_sm2 + class(amg_c_base_aggregator_type), allocatable :: tmp_aggr + type(amg_sml_parms) :: medparms, coarseparms + integer(psb_lpk_), allocatable :: ilaggr(:), nlaggr(:) + type(psb_lcspmat_type) :: op_prol + type(amg_c_onelev_type), allocatable :: tprecv(:) + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + integer(psb_ipk_), save :: idx_bldtp=-1, idx_matasb=-1 + logical, parameter :: do_timings=.false. + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_c_hierarchy_bld' + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + prec%ictxt = ictxt + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' + if ((do_timings).and.(idx_bldtp==-1)) & + & idx_bldtp = psb_get_timer_idx("BLD_HIER: bld_tprol") + if ((do_timings).and.(idx_matasb==-1)) & + & idx_matasb = psb_get_timer_idx("BLD_HIER: mmat_asb") + ! + + if (.not.allocated(prec%precv)) then + !! Error: should have called amg_cprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + ! + ! Check to ensure all procs have the same + ! + newsz = -1 + mxplevs = prec%ag_data%max_levs + mnaggratio = prec%ag_data%min_cr_ratio + casize = prec%ag_data%min_coarse_size + iszv = size(prec%precv) + call psb_bcast(ictxt,iszv) + call psb_bcast(ictxt,casize) + call psb_bcast(ictxt,mxplevs) + call psb_bcast(ictxt,mnaggratio) + if (casize /= prec%ag_data%min_coarse_size) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent min_coarse_size') + goto 9999 + end if + if (mxplevs /= prec%ag_data%max_levs) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent max_levs') + goto 9999 + end if + if (mnaggratio /= prec%ag_data%min_cr_ratio) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent min_cr_ratio') + goto 9999 + end if + if (iszv /= size(prec%precv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of precv') + goto 9999 + end if + + if (iszv < 1) then + ! + ! This is wrong, cannot be size <1 + ! + info=psb_err_from_subroutine_ + ch_err='size bpv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + endif + if (iszv == 1) then + ! + ! This is OK, since it may be called by the user even if there + ! is only one level + ! + prec%precv(1)%base_a => a + prec%precv(1)%base_desc => desc_a + + call psb_erractionrestore(err_act) + return + endif + + ! + ! The strategy: + ! 1. The maximum number of levels should be already encoded in the + ! size of the array; + ! 2. If the user did not specify anything, then a default coarse size + ! is generated, and the number of levels is set to the maximum; + ! 3. If the size of the array is different from target number of levels, + ! reallocate; + ! 4. Build the matrix hierarchy, stopping early if either the target + ! coarse size is hit, or the gain falls below the min_cr_ratio + ! threshold. + ! + + if (casize < 0) then + ! + ! Default to the cubic root of the size at base level. + ! + casize = desc_a%get_global_rows() + casize = int((sone*casize)**(sone/(sone*3)),psb_lpk_) + casize = max(casize,lone) + casize = casize*40_psb_lpk_ + call psb_bcast(ictxt,casize) + if (casize > huge(prec%ag_data%min_coarse_size)) then + ! + ! computed coarse size does not fit in IPK_. + ! This is very unlikely, but make sure to put a positive number + ! + prec%ag_data%min_coarse_size = huge(prec%ag_data%min_coarse_size) + else + prec%ag_data%min_coarse_size = casize + end if + end if + nplevs = max(itwo,mxplevs) + + ! + ! The coarse parameters will be needed later + ! + coarseparms = prec%precv(iszv)%parms + call save_smoothers(prec%precv(iszv),coarse_sm,coarse_sm2,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Base level precbuild.') + goto 9999 + end if + ! + ! First set desired number of levels + ! + if (iszv /= nplevs) then + allocate(tprecv(nplevs),stat=info) + ! First all existing levels + do i=1, min(iszv,nplevs) - 1 + if (info == 0) tprecv(i)%parms = prec%precv(i)%parms + if (info == 0) call restore_smoothers(tprecv(i),& + & prec%precv(i)%sm,prec%precv(i)%sm2a,info) + if (info == 0) call move_alloc(prec%precv(i)%aggr,tprecv(i)%aggr) + end do + if (iszv < nplevs) then + ! Further intermediates, if needed + allocate(tmp_aggr,source=tprecv(iszv-1)%aggr,stat=info) + medparms = prec%precv(iszv-1)%parms + call save_smoothers(prec%precv(iszv-1),med_sm,med_sm2,info) + do i=iszv, nplevs - 1 + if (info == 0) tprecv(i)%parms = medparms + if (info == 0) call restore_smoothers(tprecv(i),med_sm,med_sm2,info) + if ((info == 0).and..not.allocated(tprecv(i)%aggr))& + & allocate(tprecv(i)%aggr,source=tmp_aggr,stat=info) + end do + deallocate(tmp_aggr,stat=info) + end if + + ! Then coarse + if (info == 0) tprecv(nplevs)%parms = coarseparms + if (info == 0) call restore_smoothers(tprecv(nplevs),coarse_sm,coarse_sm2,info) + if (info == 0) then + if (nplevs <= iszv) then + allocate(tprecv(nplevs)%aggr,source=prec%precv(nplevs)%aggr,stat=info) + else + allocate(tmp_aggr,source=tprecv(nplevs-1)%aggr,stat=info) + call move_alloc(tmp_aggr,tprecv(nplevs)%aggr) + end if + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + + do i=1,iszv + call prec%precv(i)%free(info) + end do + call move_alloc(tprecv,prec%precv) + iszv = size(prec%precv) + end if + + ! + ! Finest level first; create a GEN_BLOCK + ! copy of the descriptor. + ! + prec%precv(1)%base_a => a + call psb_cd_renum_block(desc_a,prec%precv(1)%desc_ac,info) + prec%precv(1)%base_desc => prec%precv(1)%desc_ac + newsz = 0 + array_build_loop: do i=2, iszv + ! + ! Check on the iprcparm contents: they should be the same + ! on all processes. + ! + call psb_bcast(ictxt,prec%precv(i)%parms) + + ! + ! Sanity checks on the parameters + ! + if (i= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Calling mlprcbld at level ',i + ! + ! Build the mapping between levels i-1 and i and the matrix + ! at level i + ! + if (do_timings) call psb_tic(idx_bldtp) + if (info == psb_success_)& + & call prec%precv(i)%bld_tprol(prec%precv(i-1)%base_a,& + & prec%precv(i-1)%base_desc,& + & ilaggr,nlaggr,op_prol,prec%ag_data,info) + if (do_timings) call psb_toc(idx_bldtp) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Map build') + goto 9999 + endif + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Return from ',i,' call to bld_tprol', info + ! + ! Save op_prol just in case + ! + call op_prol%clone(prec%precv(i)%tprol,info) + ! + ! Check for early termination of aggregation loop. + ! + iaggsize = sum(nlaggr) + + sizeratio = iaggsize + if (i==2) then + sizeratio = desc_a%get_global_rows()/sizeratio + else + sizeratio = sum(prec%precv(i-1)%map%naggr)/sizeratio + end if + prec%precv(i)%szratio = sizeratio + + if (iaggsize <= casize) newsz = i + if (i == iszv) newsz = i + + if (i>2) then + if (sizeratio < mnaggratio) then + if (sizeratio > 1) then + newsz = i + else + ! + ! We are not gaining + ! + newsz = i-1 + end if + end if + + if (all(nlaggr == prec%precv(i-1)%map%naggr)) then + newsz=i-1 + if (me == 0) then + write(debug_unit,*) trim(name),& + &': Warning: aggregates from level ',& + & newsz + write(debug_unit,*) trim(name),& + &': to level ',& + & iszv,' coincide.' + write(debug_unit,*) trim(name),& + &': Number of levels actually used :',newsz + write(debug_unit,*) + end if + end if + end if + call psb_bcast(ictxt,newsz) + + if (newsz > 0) then + ! + ! This is awkward, we are saving the aggregation parms, for the sake + ! of distr/repl matrix at coarse level. Should be rethought. + ! + athresh = prec%precv(newsz)%parms%aggr_thresh + aomega = prec%precv(newsz)%parms%aggr_omega_val + if (info == 0) prec%precv(newsz)%parms = coarseparms + prec%precv(newsz)%parms%aggr_thresh = athresh + prec%precv(newsz)%parms%aggr_omega_val = aomega + + if (info == 0) call restore_smoothers(prec%precv(newsz),& + & coarse_sm,coarse_sm2,info) + if (newsz < i) then + ! + ! We are going back and revisit a previous leve; + ! recover the aggregation. + ! + ilaggr = prec%precv(newsz)%map%iaggr + nlaggr = prec%precv(newsz)%map%naggr + call prec%precv(newsz)%tprol%clone(op_prol,info) + end if + if (do_timings) call psb_tic(idx_matasb) + if (info == psb_success_) call prec%precv(newsz)%mat_asb( & + & prec%precv(newsz-1)%base_a,prec%precv(newsz-1)%base_desc,& + & ilaggr,nlaggr,op_prol,info) + if (do_timings) call psb_toc(idx_matasb) + if (info /= 0) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Mat asb') + goto 9999 + endif + exit array_build_loop + else + if (do_timings) call psb_tic(idx_matasb) + if (info == psb_success_) call prec%precv(i)%mat_asb(& + & prec%precv(i-1)%base_a,prec%precv(i-1)%base_desc,& + & ilaggr,nlaggr,op_prol,info) + if (do_timings) call psb_toc(idx_matasb) + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Map build') + goto 9999 + endif + if (i 0) then + ! + ! We exited early from the build loop, need to fix + ! the size. + ! + allocate(tprecv(newsz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + do i=1,newsz + call prec%precv(i)%move_alloc(tprecv(i),info) + end do + do i=newsz+1, iszv + call prec%precv(i)%free(info) + end do + call move_alloc(tprecv,prec%precv) + ! Ignore errors from transfer + info = psb_success_ + ! + ! Restart + iszv = newsz + ! Fix the pointers, but the level 1 should + ! be treated differently + if (.not.associated(prec%precv(1)%base_desc,desc_a)) then + prec%precv(1)%base_desc => prec%precv(1)%desc_ac + end if + do i=2, iszv + prec%precv(i)%base_a => prec%precv(i)%ac + prec%precv(i)%base_desc => prec%precv(i)%desc_ac + prec%precv(i)%map%p_desc_U => prec%precv(i-1)%base_desc + prec%precv(i)%map%p_desc_V => prec%precv(i)%base_desc + end do + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Internal hierarchy build' ) + goto 9999 + endif + + iszv = size(prec%precv) + + call prec%cmp_complexity() + call prec%cmp_avg_cr() + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Exiting with',iszv,' levels' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + subroutine save_smoothers(level,save1, save2,info) + type(amg_c_onelev_type), intent(inout) :: level + class(amg_c_base_smoother_type), allocatable , intent(inout) :: save1, save2 + integer(psb_ipk_), intent(out) :: info + + info = 0 + if (allocated(save1)) then + call save1%free(info) + if (info == 0) deallocate(save1,stat=info) + if (info /= 0) return + end if + if (allocated(save2)) then + call save2%free(info) + if (info == 0) deallocate(save2,stat=info) + if (info /= 0) return + end if + allocate(save1, mold=level%sm,stat=info) + if (info == 0) call level%sm%clone_settings(save1,info) + if ((info == 0).and.allocated(level%sm2a)) then + allocate(save2, mold=level%sm2a,stat=info) + if (info == 0) call level%sm2a%clone_settings(save2,info) + end if + + return + end subroutine save_smoothers + + subroutine restore_smoothers(level,save1, save2,info) + type(amg_c_onelev_type), intent(inout), target :: level + class(amg_c_base_smoother_type), allocatable, intent(inout) :: save1, save2 + integer(psb_ipk_), intent(out) :: info + + info = 0 + + if (allocated(level%sm)) then + if (info == 0) call level%sm%free(info) + if (info == 0) deallocate(level%sm,stat=info) + end if + if (allocated(save1)) then + if (info == 0) allocate(level%sm,mold=save1,stat=info) + if (info == 0) call save1%clone_settings(level%sm,info) + end if + + if (info /= 0) return + + if (allocated(level%sm2a)) then + if (info == 0) call level%sm2a%free(info) + if (info == 0) deallocate(level%sm2a,stat=info) + end if + if (allocated(save2)) then + if (info == 0) allocate(level%sm2a,mold=save2,stat=info) + if (info == 0) call save2%clone_settings(level%sm2a,info) + if (info == 0) level%sm2 => level%sm2a + else + if (allocated(level%sm)) level%sm2 => level%sm + end if + + return + end subroutine restore_smoothers + +end subroutine amg_c_hierarchy_bld diff --git a/mlprec/impl/amg_c_smoothers_bld.f90 b/mlprec/impl/amg_c_smoothers_bld.f90 new file mode 100644 index 00000000..4f9274c6 --- /dev/null +++ b/mlprec/impl/amg_c_smoothers_bld.f90 @@ -0,0 +1,313 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_c_smoothers_bld.f90 +! +! Subroutine: amg_c_smoothers_bld +! Version: complex +! +! This routine performs the final phase of the multilevel preconditioner +! build process: builds the "smoother" objects at each level, +! based on the matrix hierarchy prepared by amg_c_hierarchy_bld. +! +! A multilevel preconditioner is regarded as an array of 'one-level' +! data structures, each containing the part of the +! preconditioner associated to a certain level, +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level. No transfer operators are associated to level 1. +! Each level provides a "build" method; for the base type, the "one-level" +! build procedure simply invokes the build method of the first smoother object, +! and also on the second object if allocated. +! +! +! Arguments: +! a - type(psb_cspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_cprec_type), input/output. +! The preconditioner data structure containing the local part +! of the preconditioner to be built. +! info - integer, output. +! Error code. +! +! amold - class(psb_c_base_sparse_mat), input, optional +! Mold for the inner format of matrices contained in the +! preconditioner +! +! +! vmold - class(psb_c_base_vect_type), input, optional +! Mold for the inner format of vectors contained in the +! preconditioner +! +! +! +subroutine amg_c_smoothers_bld(a,desc_a,prec,info,amold,vmold,imold) + + use psb_base_mod + !use amg_c_inner_mod + use amg_c_prec_mod, amg_protect_name => amg_c_smoothers_bld + + Implicit None + + ! Arguments + type(psb_cspmat_type),intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_cprec_type),intent(inout),target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local Variables + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, nplevs, mxplevs + real(psb_spk_) :: mnaggratio + integer(psb_ipk_) :: coarse_solve_id + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_c_smoothers_bld' + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' + ! + if (.not.allocated(prec%precv)) then + !! Error: should have called amg_cprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + ! + ! Check to ensure all procs have the same + ! + iszv = size(prec%precv) + call psb_bcast(ictxt,iszv) + if (iszv /= size(prec%precv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of precv') + goto 9999 + end if + + if (iszv < 1) then + ! We should never get here. + info=psb_err_from_subroutine_ + ch_err='size bpv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + endif + + ! + ! Issue a warning for inconsistent changes to COARSE_SOLVE + ! but only if it really is a multilevel + ! + if ((me == psb_root_).and.(iszv>1)) then + coarse_solve_id = prec%precv(iszv)%parms%coarse_solve + select case (coarse_solve_id) + case(amg_umf_,amg_slu_) + if (prec%precv(iszv)%sm%sv%get_id() /= coarse_solve_id) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id) + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) then + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else if (prec%precv(iszv)%parms%coarse_mat == amg_distr_mat_) then + write(psb_err_unit,*) ' but I am building BJAC with ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + end if + write(psb_err_unit,*) 'This may happen if: ' + write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' + write(psb_err_unit,*) ' 2. the solver ', amg_fact_names(coarse_solve_id),& + & ' was not configured at MLD2P4 build time, or' + write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' + end if + if (prec%precv(iszv)%parms%coarse_mat /= amg_repl_mat_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse matrix was requested as replicated', & + & ' but it has been changed to distributed.' + end if + + case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) + if (prec%precv(iszv)%sm%sv%get_id() /= psb_ilu_n_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id) + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) then + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else if (prec%precv(iszv)%parms%coarse_mat == amg_distr_mat_) then + write(psb_err_unit,*) ' but I am building BJAC with ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + end if + write(psb_err_unit,*) & + &'This may happen if coarse_subsolve has been reset' + end if + if (prec%precv(iszv)%parms%coarse_mat /= amg_repl_mat_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id),& + & ' but the coarse matrix has been changed to distributed' + end if + + case(amg_mumps_) + if (prec%precv(iszv)%sm%sv%get_id() /= amg_mumps_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id) + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) then + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else if (prec%precv(iszv)%parms%coarse_mat == amg_distr_mat_) then + write(psb_err_unit,*) ' but I am building BJAC with ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + end if + write(psb_err_unit,*) 'This may happen if: ' + write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' + write(psb_err_unit,*) ' 2. the solver ', amg_fact_names(coarse_solve_id),& + & ' was not configured at MLD2P4 build time, or' + write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' + end if + + case(amg_sludist_) + if (prec%precv(iszv)%sm%sv%get_id() /= coarse_solve_id) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id) + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) then + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else if (prec%precv(iszv)%parms%coarse_mat == amg_distr_mat_) then + write(psb_err_unit,*) ' but I am building BJAC with ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + end if + write(psb_err_unit,*) 'This may happen if: ' + write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' + write(psb_err_unit,*) ' 2. the solver ', amg_fact_names(coarse_solve_id), & + & ' was not configured at MLD2P4 build time, or' + write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' + end if + if (prec%precv(iszv)%parms%coarse_mat /= amg_distr_mat_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id),& + & ' but the coarse matrix has been changed to replicated' + end if + + case(amg_bjac_,amg_l1_bjac_,amg_jac_, amg_l1_jac_, amg_gs_, amg_fbgs_, amg_l1_gs_,amg_l1_fbgs_) + if (prec%precv(iszv)%parms%coarse_mat /= amg_distr_mat_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id),& + & ' but the coarse matrix has been changed to replicated' + end if + + case default + ! We should never get here. + info=psb_err_from_subroutine_ + ch_err='unkn coarse_solve' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + + end select + end if + + ! Sanity check: need to ensure that the MUMPS local/global NZ + ! are handled correctly; this is controlled by local vs global solver. + ! From this point of view, REPL is LOCAL because it owns everyting. + ! Should really find a better way of handling this. + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) & + & call prec%precv(iszv)%sm%sv%set('MUMPS_LOC_GLOB', amg_local_solver_,info) + ! + ! Now do the real build. + ! + + do i=1, iszv + ! + ! build the base preconditioner at level i + ! + call prec%precv(i)%bld(info,amold=amold,vmold=vmold,imold=imold,ilv=i) + + if (info /= psb_success_) then + write(ch_err,'(a,i7)') 'Error @ level',i + call psb_errpush(psb_err_internal_error_,name,& + & a_err=ch_err) + goto 9999 + endif + + end do + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Exiting with',iszv,' levels' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_smoothers_bld diff --git a/mlprec/impl/amg_ccprecset.F90 b/mlprec/impl/amg_ccprecset.F90 new file mode 100644 index 00000000..b7d7b68c --- /dev/null +++ b/mlprec/impl/amg_ccprecset.F90 @@ -0,0 +1,971 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_cprecset.f90 +! +! Subroutine: amg_cprecseti +! Version: complex +! +! This routine sets the integer parameters defining the preconditioner. More +! precisely, the integer parameter identified by 'what' is assigned the value +! contained in 'val'. +! For the multilevel preconditioners, the levels are numbered in increasing +! order starting from the finest one, i.e. level 1 is the finest level. +! +! To set character and complex parameters, see amg_cprecsetc and amg_cprecsetr, +! respectively. +! +! +! Arguments: +! p - type(amg_cprec_type), input/output. +! The preconditioner data structure. +! what - integer, input. +! The number identifying the parameter to be set. +! A mnemonic constant has been associated to each of these +! numbers, as reported in the MLD2P4 User's and Reference Guide. +! val - integer, input. +! The value of the parameter to be set. The list of allowed +! values is reported in the MLD2P4 User's and Reference Guide. +! info - integer, output. +! Error code. +! ilev - integer, optional, input. +! For the multilevel preconditioner, the level at which the +! preconditioner parameter has to be set. +! If nlev is not present, the parameter identified by 'what' +! is set at all the appropriate levels. +! +! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to +! MLD2P4 developers. Indeed, by using ilev it is possible to set different values +! of the same parameter at different levels 1,...,nlev-1, even in cases where +! the parameter must have the same value at all the levels but the coarsest one. +! For this reason, the interface amg_precset to this routine has been built in +! such a way that ilev is not visible to the user (see amg_prec_mod.f90). +! +subroutine amg_ccprecseti(p,what,val,info,ilev,ilmax,pos,idx) + + use psb_base_mod + use amg_c_prec_mod, amg_protect_name => amg_ccprecseti + use amg_c_jac_smoother + use amg_c_as_smoother + use amg_c_diag_solver + use amg_c_l1_diag_solver + use amg_c_ilu_solver + use amg_c_id_solver + use amg_c_gs_solver +#if defined(HAVE_SLU_) + use amg_c_slu_solver +#endif +#if defined(HAVE_MUMPS_) + use amg_c_mumps_solver +#endif + + + implicit none + + ! Arguments + class(amg_cprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_, ilmax_, il + character(len=*), parameter :: name='amg_precseti' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmax_ = nlev_ + end if + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + select case(psb_toupper(what)) + case ('MIN_COARSE_SIZE') + p%ag_data%min_coarse_size = max(val,-1) + return + case('MAX_LEVS') + p%ag_data%max_levs = max(val,1) + return + case ('OUTER_SWEEPS') + p%outer_sweeps = max(val,1) + return + end select + + ! + ! Set preconditioner parameters at level ilev. + ! + if (present(ilev)) then + + select case(psb_toupper(what)) + case('SMOOTHER_TYPE','SUB_SOLVE','SMOOTHER_SWEEPS',& + & 'ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD',& + & 'AGGR_TYPE','AGGR_PROL','AGGR_OMEGA_ALG',& + & 'AGGR_EIG','SUB_RESTR','SUB_PROL', & + & 'SUB_OVR','SUB_FILLIN',& + & 'COARSE_MAT') + do il=ilev_, ilmax_ + call p%precv(il)%set(what,val,info,pos=pos) + end do + + case('COARSE_SUBSOLVE') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + call p%precv(ilev_)%set('SUB_SOLVE',val,info,pos=pos) + case('COARSE_SOLVE') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_SOLVE',val,info,pos=pos) + select case (val) + case(amg_bjac_,amg_l1_bjac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',val,info,pos=pos) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) +#else + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) +#endif + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info) + case(amg_slu_) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) + case(amg_mumps_) +#if defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(amg_umf_) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + + case(amg_sludist_) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(amg_jac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_diag_scale_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + + case(amg_l1_jac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_l1_diag_scale_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_gs_,amg_fbgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_gs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_bwgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_bwgs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_l1_gs_,amg_l1_fbgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_l1_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_gs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + end select + + endif + case('COARSE_SWEEPS') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + call p%precv(nlev_)%set('SMOOTHER_SWEEPS',val,info,pos=pos) + + case('COARSE_FILLIN') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + call p%precv(nlev_)%set('SUB_FILLIN',val,info,pos=pos) + + case default + do il=ilev_, ilmax_ + call p%precv(il)%set(what,val,info,pos=pos,idx=idx) + end do + end select + + + else if (.not.present(ilev)) then + ! + ! ilev not specified: set preconditioner parameters at all the appropriate + ! levels + ! + select case(psb_toupper(trim(what))) + case('SUB_SOLVE','SUB_RESTR','SUB_PROL',& + & 'SUB_OVR','SUB_FILLIN',& + & 'SMOOTHER_SWEEPS','SMOOTHER_TYPE') + do ilev_=1,max(1,nlev_-1) + call p%precv(ilev_)%set(what,val,info,pos=pos) + if (info /= 0) return + end do + + case('ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD','AGGR_PROL','AGGR_TYPE',& + & 'AGGR_OMEGA_ALG','AGGR_EIG','AGGR_FILTER') + do ilev_=1,nlev_ + call p%precv(ilev_)%set(what,val,info,pos=pos) + if (info /= 0) return + end do + + case('COARSE_MAT') + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_MAT',val,info,pos=pos) + end if + + case('COARSE_SOLVE') + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_SOLVE',val,info,pos=pos) + select case (val) + case(amg_bjac_,amg_l1_bjac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',val,info,pos=pos) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) +#else + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) +#endif + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info) + case(amg_slu_) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) + case(amg_mumps_) +#if defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(amg_umf_) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + + case(amg_sludist_) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(amg_jac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_diag_scale_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + + case(amg_l1_jac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_l1_diag_scale_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_gs_,amg_fbgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_gs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_bwgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_bwgs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_l1_gs_,amg_l1_fbgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_l1_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_gs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + end select + endif + + case('COARSE_SUBSOLVE') + if (nlev_ > 1) then + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + endif + + case('COARSE_SWEEPS') + + if (nlev_ > 1) then + call p%precv(nlev_)%set('SMOOTHER_SWEEPS',val,info,pos=pos) + end if + + case('COARSE_FILLIN') + if (nlev_ > 1) then + call p%precv(nlev_)%set('SUB_FILLIN',val,info,pos=pos) + end if + + case default + do ilev_=1,nlev_ + call p%precv(ilev_)%set(what,val,info,pos=pos,idx=idx) + end do + end select + + endif + +end subroutine amg_ccprecseti + +! +! Subroutine: amg_cprecsetc +! Version: complex +! +! This routine sets the character parameters defining the preconditioner. More +! precisely, the character parameter identified by 'what' is assigned the value +! contained in 'val'. +! For the multilevel preconditioners, the levels are numbered in increasing +! order starting from the finest one, i.e. level 1 is the finest level. +! +! To set integer and complex parameters, see amg_cprecseti and amg_cprecsetr, +! respectively. +! +! +! Arguments: +! p - type(amg_cprec_type), input/output. +! The preconditioner data structure. +! what - integer, input. +! The number identifying the parameter to be set. +! A mnemonic constant has been associated to each of these +! numbers, as reported in the MLD2P4 User's and Reference Guide. +! string - character(len=*), input. +! The value of the parameter to be set. The list of allowed +! values is reported in the MLD2P4 User's and Reference Guide. +! info - integer, output. +! Error code. +! ilev - integer, optional, input. +! For the multilevel preconditioner, the level at which the +! preconditioner parameter has to be set. +! If nlev is not present, the parameter identified by 'what' +! is set at all the appropriate levels. +! +! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to +! MLD2P4 developers. Indeed, by using ilev it is possible to set different values +! of the same parameter at different levels 1,...,nlev-1, even in cases where +! the parameter must have the same value at all the levels but the coarsest one. +! For this reason, the interface amg_precset to this routine has been built in +! such a way that ilev is not visible to the user (see amg_prec_mod.f90). +! +subroutine amg_ccprecsetc(p,what,string,info,ilev,ilmax,pos,idx) + + use psb_base_mod + use amg_c_prec_mod, amg_protect_name => amg_ccprecsetc + use amg_c_jac_smoother + use amg_c_as_smoother + use amg_c_diag_solver + use amg_c_l1_diag_solver + use amg_c_ilu_solver + use amg_c_id_solver + use amg_c_gs_solver +#if defined(HAVE_SLU_) + use amg_c_slu_solver +#endif +#if defined(HAVE_MUMPS_) + use amg_c_mumps_solver +#endif + + + implicit none + + ! Arguments + class(amg_cprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + character(len=*), intent(in) :: string + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_,val,ilmax_, il + character(len=*), parameter :: name='amg_precsetc' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmax_ = nlev_ + end if + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + ! + ! Set preconditioner parameters at level ilev. + ! + if (present(ilev)) then + + select case(psb_toupper(what)) + case('SMOOTHER_TYPE','SUB_SOLVE',& + & 'ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD',& + & 'AGGR_TYPE','AGGR_PROL','AGGR_OMEGA_ALG',& + & 'AGGR_EIG','SUB_RESTR','SUB_PROL', & + & 'COARSE_MAT') + do il=ilev_, ilmax_ + call p%precv(il)%set(what,string,info,pos=pos) + end do + + case('COARSE_SUBSOLVE') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + call p%precv(ilev_)%set('SUB_SOLVE',string,info,pos=pos) + case('COARSE_SOLVE') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_SOLVE',string,info,pos=pos) + select case (psb_toupper(trim(string))) + case('BJAC', 'L1-BJAC') + call p%precv(nlev_)%set('SMOOTHER_TYPE',psb_toupper(trim(string)),info,pos=pos) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) +#else + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) +#endif + call p%precv(nlev_)%set('COARSE_MAT','dist',info) + case('SLU') +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('ILU','MILU','ILUT') + call p%precv(nlev_)%set('SMOOTHER_TYPE','bjac',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) + case('MUMPS') +#if defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('UMF') +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + + case('SLUDIST') +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('JAC','JACOBI') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','DIAG',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + + case('L1-JACOBI') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','L1-DIAG',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('GS','FWGS','FBGS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('BWGS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','BWGS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('L1-GS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','L1-BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + end select + + endif + + case default + do il=ilev_, ilmax_ + call p%precv(il)%set(what,string,info,pos=pos,idx=idx) + end do + end select + + + else if (.not.present(ilev)) then + ! + ! ilev not specified: set preconditioner parameters at all the appropriate + ! levels + ! + select case(psb_toupper(trim(what))) + case('SUB_SOLVE','SUB_RESTR','SUB_PROL',& + & 'SMOOTHER_TYPE') + do ilev_=1,max(1,nlev_-1) + call p%precv(ilev_)%set(what,string,info,pos=pos) + if (info /= 0) return + end do + + case('ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD','AGGR_PROL','AGGR_TYPE',& + & 'AGGR_OMEGA_ALG','AGGR_EIG','AGGR_FILTER') + do ilev_=1,nlev_ + call p%precv(ilev_)%set(what,string,info,pos=pos) + if (info /= 0) return + end do + + case('COARSE_MAT') + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_MAT',string,info,pos=pos) + end if + + case('COARSE_SOLVE') + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_SOLVE',string,info,pos=pos) + select case (psb_toupper(trim(string))) + case('BJAC', 'L1-BJAC') + call p%precv(nlev_)%set('SMOOTHER_TYPE',psb_toupper(trim(string)),info,pos=pos) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) +#else + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) +#endif + call p%precv(nlev_)%set('COARSE_MAT','DIST',info) + case('SLU') +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('ILU', 'ILUT','MILU') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) + case('MUMPS') +#if defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('UMF') +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + + case('SLUDIST') +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('JAC','JACOBI') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','DIAG',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('L1-JACOBI') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','L1-DIAG',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('GS','FWGS','FBGS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('BWGS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','BWGS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('L1-GS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','L1-BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + end select + endif + + case('COARSE_SUBSOLVE') + if (nlev_ > 1) then + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + endif + + case default + do ilev_=1,nlev_ + call p%precv(ilev_)%set(what,string,info,pos=pos,idx=idx) + end do + end select + + endif + + +end subroutine amg_ccprecsetc + + +! +! Subroutine: amg_cprecsetr +! Version: complex +! +! This routine sets the complex parameters defining the preconditioner. More +! precisely, the complex parameter identified by 'what' is assigned the value +! contained in 'val'. +! For the multilevel preconditioners, the levels are numbered in increasing +! order starting from the finest one, i.e. level 1 is the finest level. +! +! To set integer and character parameters, see amg_cprecseti and amg_cprecsetc, +! respectively. +! +! Arguments: +! p - type(amg_cprec_type), input/output. +! The preconditioner data structure. +! what - integer, input. +! The number identifying the parameter to be set. +! A mnemonic constant has been associated to each of these +! numbers, as reported in the MLD2P4 User's and Reference Guide. +! val - real(psb_spk_), input. +! The value of the parameter to be set. The list of allowed +! values is reported in the MLD2P4 User's and Reference Guide. +! info - integer, output. +! Error code. +! ilev - integer, optional, input. +! For the multilevel preconditioner, the level at which the +! preconditioner parameter has to be set. +! If nlev is not present, the parameter identified by 'what' +! is set at all the appropriate levels. +! +! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to +! MLD2P4 developers. Indeed, by using ilev it is possible to set different values +! of the same parameter at different levels 1,...,nlev-1, even in cases where +! the parameter must have the same value at all the levels but the coarsest one. +! For this reason, the interface amg_precset to this routine has been built in +! such a way that ilev is not visible to the user (see amg_prec_mod.f90). +! +subroutine amg_ccprecsetr(p,what,val,info,ilev,ilmax,pos,idx) + + use psb_base_mod + use amg_c_prec_mod, amg_protect_name => amg_ccprecsetr + + implicit none + + ! Arguments + class(amg_cprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + + ! Local variables + integer(psb_ipk_) :: ilev_,nlev_, ilmax_, il + real(psb_spk_) :: thr + character(len=*), parameter :: name='amg_precsetr' + + info = psb_success_ + + if (present(ilev)) then + ilev_ = ilev + else + ilev_ = 1 + end if + + select case(psb_toupper(what)) + case ('MIN_CR_RATIO') + p%ag_data%min_cr_ratio = max(sone,val) + return + end select + + if (.not.allocated(p%precv)) then + write(psb_err_unit,*) name,& + &': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + info = 3111 + return + endif + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmax_ = nlev_ + end if + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + + ! + ! Set preconditioner parameters at level ilev. + ! + if (present(ilev)) then + + do il=ilev_, ilmax_ + call p%precv(il)%set(what,val,info,pos=pos,idx=idx) + end do + + else if (.not.present(ilev)) then + ! + ! ilev not specified: set preconditioner parameters at all the appropriate levels + ! + + select case(psb_toupper(what)) + case('COARSE_ILUTHRS') + ilev_=nlev_ + call p%precv(ilev_)%set('SUB_ILUTHRS',val,info,pos=pos) + + case default + + do il=1,nlev_ + call p%precv(il)%set(what,val,info,pos=pos,idx=idx) + end do + end select + + endif + +end subroutine amg_ccprecsetr + + diff --git a/mlprec/impl/amg_cfile_prec_descr.f90 b/mlprec/impl/amg_cfile_prec_descr.f90 new file mode 100644 index 00000000..d7a495e0 --- /dev/null +++ b/mlprec/impl/amg_cfile_prec_descr.f90 @@ -0,0 +1,199 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_dfile_prec_descr.f90 +! +! +! Subroutine: amg_file_prec_descr +! Version: complex +! +! This routine prints a description of the preconditioner to the standard +! output or to a file. It must be called after the preconditioner has been +! built by amg_precbld. +! +! Arguments: +! p - type(amg_Tprec_type), input. +! The preconditioner data structure to be printed out. +! info - integer, output. +! error code. +! iout - integer, input, optional. +! The id of the file where the preconditioner description +! will be printed. If iout is not present, then the standard +! output is condidered. +! root - integer, input, optional. +! The id of the process printing the message; -1 acts as a wildcard. +! Default is psb_root_ +! +subroutine amg_cfile_prec_descr(prec,iout,root) + use psb_base_mod + use amg_c_prec_mod, amg_protect_name => amg_cfile_prec_descr + use amg_c_inner_mod + use amg_c_gs_solver + + implicit none + ! Arguments + class(amg_cprec_type), intent(in) :: prec + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: root + + ! Local variables + integer(psb_ipk_) :: ilev, nlev, ilmin, info, nswps + integer(psb_ipk_) :: ictxt, me, np + logical :: is_symgs + character(len=20), parameter :: name='amg_file_prec_descr' + integer(psb_ipk_) :: iout_ + integer(psb_ipk_) :: root_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + if (iout_ < 0) iout_ = psb_out_unit + + ictxt = prec%ictxt + + if (allocated(prec%precv)) then + + call psb_info(ictxt,me,np) + if (present(root)) then + root_ = root + else + root_ = psb_root_ + end if + if (root_ == -1) root_ = me + + ! + ! The preconditioner description is printed by processor psb_root_. + ! This agrees with the fact that all the parameters defining the + ! preconditioner have the same values on all the procs (this is + ! ensured by amg_precbld). + ! + if (me == root_) then + nlev = size(prec%precv) + do ilev = 1, nlev + if (.not.allocated(prec%precv(ilev)%sm)) then + info = 3111 + write(iout_,*) ' ',name,& + & ': error: inconsistent MLPREC part, should call amg_PRECINIT' + return + endif + end do + + write(iout_,*) + write(iout_,'(a)') 'Preconditioner description' + + if (nlev == 1) then + ! + ! Here we have a gigantic kludge just to handle Symmetrized Gauss-Seidel. + ! Will need rethinking... + ! + if (allocated(prec%precv(1)%sm2a)) then + is_symgs = .false. + select type(sv2 => prec%precv(1)%sm2a%sv) + class is (amg_c_bwgs_solver_type) + select type(sv1 => prec%precv(1)%sm%sv) + class is (amg_c_gs_solver_type) + is_symgs = .true. + end select + end select + if (is_symgs) then + write(iout_,*) ' Forward-Backward (symmetrized) Hybrid Gauss-Seidel' + else + write(iout_,*) 'Pre Smoother: ' + call prec%precv(1)%sm%descr(info,iout=iout_) + write(iout_,*) 'Post smoother:' + call prec%precv(1)%sm2a%descr(info,iout=iout_) + end if + nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) + + else + call prec%precv(1)%sm%descr(info,iout=iout_) + nswps = prec%precv(1)%parms%sweeps_pre + end if + if (nswps > 1) write(iout_,*) ' Number of sweeps : ',nswps + write(iout_,*) + + else if (nlev > 1) then + ! + ! Print description of base preconditioner + ! + write(iout_,*) 'Multilevel Preconditioner' + write(iout_,*) 'Outer sweeps:',prec%outer_sweeps + write(iout_,*) + if (allocated(prec%precv(1)%sm2a)) then + write(iout_,*) 'Pre Smoother: ' + call prec%precv(1)%sm%descr(info,iout=iout_) + write(iout_,*) 'Post smoother:' + call prec%precv(1)%sm2a%descr(info,iout=iout_) + else + write(iout_,*) 'Smoother: ' + call prec%precv(1)%sm%descr(info,iout=iout_) + end if + ! + ! Print multilevel details + ! + write(iout_,*) + write(iout_,*) 'Multilevel hierarchy: ' + write(iout_,*) ' Number of levels : ',nlev + write(iout_,*) ' Operator complexity: ',prec%get_complexity() + write(iout_,*) ' Average coarsening : ',prec%get_avg_cr() + ilmin = 2 + if (nlev == 2) ilmin=1 + do ilev=ilmin,nlev + call prec%precv(ilev)%descr(ilev,nlev,ilmin,info,iout=iout_) + end do + write(iout_,*) + + else + write(iout_,*) trim(name), & + & ': invalid preconditioner array size ?',nlev + info = -2 + return + + end if + end if + + else + write(iout_,*) trim(name), & + & ': Error: no base preconditioner available, something is wrong!' + info = -2 + return + endif + +end subroutine amg_cfile_prec_descr diff --git a/mlprec/impl/amg_cmlprec_aply.f90 b/mlprec/impl/amg_cmlprec_aply.f90 new file mode 100644 index 00000000..bbc63760 --- /dev/null +++ b/mlprec/impl/amg_cmlprec_aply.f90 @@ -0,0 +1,1669 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_cmlprec_aply.f90 +! +! Subroutine: amg_cmlprec_aply +! Version: real +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +! This routine computes +! +! Y = beta*Y + alpha*op(ML^(-1))*X, +! where +! - ML is a multilevel preconditioner associated with +! a certain matrix A and stored in p, +! - op(ML^(-1)) is ML^(-1) or its transpose, according to the value of trans, +! - X and Y are vectors, +! - alpha and beta are scalars. +! +! The following multilevel strategies can be applied: +! +! - Additive multilevel Schwarz, +! - classical V-cycle, +! - classical W-cycle, +! - K-cycle both for symmetric and nonsymmetric matrices, where 2 iterations +! of FCG(1) or GCR, respectively, are applied at each level +! except the coarsest. +! +! For each level we have as many submatrices as processes (except for the coarsest +! level where we might have a replicated index space) and each process takes care +! of one submatrix. +! +! A multilevel preconditioner is regarded as an array of 'one-level' data structures, +! each containing the part of the preconditioner associated to a certain level +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! For each level lev, there is a smoother stored in +! p%precv(lev)%sm +! which in turn contains a solver +! p$precv(lev)%sm%sv +! Typically the solver acts only locally, and the smoother applies any required +! parallel communication/action. +! Each level has a matrix A(lev), obtained by 'tranferring' the original +! matrix A (i.e. the matrix to be preconditioned) to the level lev, through smoothed +! aggregation. +! +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level and A(1) is the matrix A. +! +! This routine is formulated in a recursive way, so it is quite compact. +! +! The V-cycle can be described as follows, where +! P(lev) denotes the smoothed prolongator from level lev to level +! lev-1, while R(lev) denotes the corresponding restriction operator +! (normally its transpose) from level lev-1 to level lev. +! M(lev) is the smoother at the current level. +! +! +! 1. Transfer the outer vector Xest to u(1) (inner X at level 1) +! +! 2. Invoke V-cycle(1,M,P,R,A,b,u) +! +! procedure V-cycle(lev,M,P,R,A,b,u) +! +! if (lev < nlev) then +! +! u(lev) = u(lev) + M(lev)*(b(lev)-A(lev)*u(lev)) +! +! b(lev+1) = R(lev+1)*(b(lev)-A(lev)*u(lev)) +! +! u(lev+1) = V-cycle(lev+1,M,P,R,A,b,u) +! +! u(lev) = u(lev) + P(lev+1) * u(lev+1) +! +! u(lev) = u(lev) + M(lev)*(b(lev)-A(lev)*u(lev)) +! +! else +! +! solve A(lev)*u(lev) = b(lev) +! +! end if +! +! return u(lev) +! end +! +! 3. Transfer u(1) to the external: +! Yext = beta*Yext + alpha*u(1) +! +! +! In the implementation, the recursive procedure is inner_ml_aply, which +! in turn uses amg_inner_add (for additive multilevel), +! amg_inner_mult (for V-cycle and W-cycle), and +! amg_inner_k_cycle (for symmetric and non-symmetric K-cycle). +! +! For a detailed description of the algorithms, see: +! +! - B.F. Smith, P.E. Bjorstad, W.D. Gropp, +! Domain decomposition: parallel multilevel methods for elliptic partial +! differential equations, Cambridge University Press, 1996. +! +! - W. L. Briggs, V. E. Henson, S. F. McCormick, +! A Multigrid Tutorial, Second Edition +! SIAM, 2000. +! +! - K. Stuben, +! An Introduction to Algebraic Multigrid, +! in A. Schuller, U. Trottenberg, C. Oosterlee, Multigrid, Academic Press, 2001. +! +! - Y. Notay, P. S. Vassilevski, +! Recursive Krylov-based multigrid cycles +! Numerical Linear Algebra with Applications, 15 (5), 2008, 473--487. +! +! +! Arguments: +! alpha - complex(psb_spk_), input. +! The scalar alpha. +! p - type(amg_cprec_type), input. +! The multilevel preconditioner data structure containing the +! local part of the preconditioner to be applied. +! Note that nlev = size(p%precv) = number of levels. +! p%precv(lev)%sm - type(psb_cbaseprec_type) +! The pre-'smoother' for the current level +! p%precv(lev)%sm2 - type(psb_cbaseprec_type) +! The post-'smoother' for the current level +! may be the same or different from %sm +! p%precv(lev)%ac - type(psb_cspmat_type) +! The local part of the matrix A(lev). +! p%precv(lev)%parms - type(psb_sml_parms) +! Parameters controllin the multilevel prec. +! p%precv(lev)%desc_ac - type(psb_desc_type). +! The communication descriptor associated to the sparse +! matrix A(lev) +! p%precv(lev)%map - type(psb_inter_desc_type) +! Stores the linear operators mapping level (lev-1) +! to (lev) and vice versa. These are the restriction +! and prolongation operators described in the sequel. +! p%precv(lev)%base_a - type(psb_cspmat_type), pointer. +! Pointer (really a pointer!) to the base matrix of +! the current level, i.e. the local part of A(lev); +! so we have a unified treatment of residuals. We +! need this to avoid passing explicitly the matrix +! A(lev) to the routine which applies the +! preconditioner. +! p%precv(lev)%base_desc - type(psb_desc_type), pointer. +! Pointer to the communication descriptor associated +! to the sparse matrix pointed by base_a. +! +! x - complex(psb_spk_), dimension(:), input. +! The local part of the vector X. +! beta - complex(psb_spk_), input. +! The scalar beta. +! y - complex(psb_spk_), dimension(:), input/output. +! The local part of the vector Y. +! desc_data - type(psb_desc_type), input. +! The communication descriptor associated to the matrix to be +! preconditioned. +! trans - character, optional. +! If trans='N','n' then op(M^(-1)) = M^(-1); +! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). +! work - complex(psb_spk_), dimension (:), optional, target. +! Workspace. Its size must be at least 4*desc_data%get_local_cols(). +! info - integer, output. +! Error code. +! +! Note that when the LU factorization of the matrix A(lev) is computed instead of +! the ILU one, by using UMFPACK or SuperLU or MUMPS, the corresponding +! L and U factors are stored in data structures handled +! by the third party software. +! +subroutine amg_cmlprec_aply_vect(alpha,p,x,beta,y,desc_data,trans,work,info) + + use psb_base_mod + use amg_base_prec_type + use amg_c_inner_mod, amg_protect_name => amg_cmlprec_aply_vect + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_cprec_type), intent(inout) :: p + complex(psb_spk_),intent(in) :: alpha,beta + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + character, intent(in) :: trans + complex(psb_spk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: ictxt, np, me + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, nc2l, level, isweep, err_act + character(len=20) :: name + character :: trans_ + complex(psb_spk_) :: beta_ + logical :: do_alloc_wrk + type(amg_cmlprec_wrk_type), allocatable, target :: mlprec_wrk(:) + + name='amg_cmlprec_aply' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (debug_level >= psb_debug_inner_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Entry ', size(p%precv) + + trans_ = psb_toupper(trans) + nlev = size(p%precv) + + do_alloc_wrk = .not.allocated(p%precv(1)%wrk) + + if (do_alloc_wrk) call p%allocate_wrk(info,vmold=x%v) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') + goto 9999 + end if + level = 1 + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & wv => p%precv(level)%wrk%wv(:)) + ! + ! At first iteration we must use the input BETA + ! + beta_ = beta + + + call psb_geaxpby(cone,x,czero,vx2l,base_desc,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='geaxbpy') + goto 9999 + end if + + do isweep = 1, p%outer_sweeps - 1 + ! + ! With the current implementation, y2l is zeroed internally at first smoother. + ! call p%wrk(level)%vy2l%zero() + ! + call inner_ml_aply(level,p,trans_,work,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Inner prec aply') + goto 9999 + end if + call psb_geaxpby(alpha,vy2l,beta_,y,base_desc,info) + ! all iterations after the first must use BETA = 1 + beta_ = cone + ! + ! Next iteration should use the current residual to compute a correction + ! + call psb_geaxpby(cone,x,czero,vx2l,base_desc,info) + call psb_spmm(-cone,base_a,y,cone,vx2l,base_desc,info) + end do + + ! + ! If outer_sweeps == 1 we have just skipped the loop, and it's + ! equivalent to a single application. + ! + + ! + ! With the current implementation, y2l is zeroed internally at first smoother. + ! call p%wrk(level)%vy2l%zero() + ! + call inner_ml_aply(level,p,trans_,work,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Inner prec aply') + goto 9999 + end if + call psb_geaxpby(alpha,vy2l,beta_,y,base_desc,info) + + end associate + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error final update') + goto 9999 + end if + if (do_alloc_wrk) call p%free_wrk(info) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + ! + ! + ! inner_ml_aply: apply AMG at a given level. + ! This routine dispatches the computation according to the type + ! specified at the current level. + ! Each of the corrections will inturn call recursively this routine. + ! + ! Assumptions: + ! On input: + ! mlprec_wkr(level)%vx2l contains the input vector (RHS) + ! mlprec_wkr(level)%vy2l contains the initial guess + ! + ! On output: + ! mlprec_wkr(level)%vy2l contains the solution + ! + ! Constraints: each of the called routines must properly handle + ! the input/output conditions for level+1 (i.e. apply + ! prolongation/restriction). + ! Note: for historical/convenience reasons the prolongator/restrictor + ! between level and level+1 are stored at level+1. + ! + ! + recursive subroutine inner_ml_aply(level,p,trans,work,info) + + implicit none + + ! Arguments + integer(psb_ipk_) :: level + type(amg_cprec_type), target, intent(inout) :: p + character, intent(in) :: trans + complex(psb_spk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + + type(psb_c_vect_type) :: res + type(psb_c_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_ml_aply' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_ml') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' Start inner_ml_aply at level ',level, info + end if + + select case(p%precv(level)%parms%ml_cycle) + + case(amg_no_ml_) + ! + ! No preconditioning, should not really get here + ! + call psb_errpush(psb_err_internal_error_,name,& + & a_err='amg_no_ml_ in mlprc_aply?') + goto 9999 + + case(amg_add_ml_) + + call amg_c_inner_add(p, level, trans, work) + + case(amg_mult_ml_,amg_vcycle_ml_, amg_wcycle_ml_) + + call amg_c_inner_mult(p, level, trans, work) + + case(amg_kcycle_ml_, amg_kcyclesym_ml_) + + call amg_c_inner_k_cycle(p, level, trans, work) + + case default + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='invalid ml_cycle',& + & i_Err=(/p%precv(level)%parms%ml_cycle,izero,izero,izero,izero/)) + goto 9999 + + end select + if(debug_level > 1) then + write(debug_unit,*) me,' End inner_ml_aply at level ',level + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine inner_ml_aply + + + recursive subroutine amg_c_inner_add(p, level, trans, work) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_cprec_type), intent(inout) :: p + + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + complex(psb_spk_),target :: work(:) + type(psb_c_vect_type) :: res + type(psb_c_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act, k + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_inner_add' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_add') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_add at level ',level + end if + + if ((level<1).or.(level>nlev)) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL>NLEV') + goto 9999 + end if + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & wv => p%precv(level)%wrk%wv) + + if (allocated(p%precv(level)%sm2a)) then + call psb_geaxpby(cone,vx2l,czero,vy2l,base_desc,info) + + sweeps = max(p%precv(level)%parms%sweeps_pre,p%precv(level)%parms%sweeps_post) + do k=1, sweeps + call p%precv(level)%sm%apply(cone,& + & vy2l,czero,vty,& + & base_desc, trans,& + & ione,work,wv,info,init='Z') + + call p%precv(level)%sm2a%apply(cone,& + & vty,czero,vy2l,& + & base_desc, trans,& + & ione,work,wv,info,init='Z') + end do + + else + sweeps = p%precv(level)%parms%sweeps_pre + call p%precv(level)%sm%apply(cone,& + & vx2l,czero,vy2l,& + & base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during ADD smoother_apply') + goto 9999 + end if + + if (level < nlev) then + ! Apply the restriction + call p%precv(level+1)%map%map_U2V(cone,vx2l,& + & czero,p%precv(level+1)%wrk%vx2l,& + & info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + + call inner_ml_aply(level+1,p,trans,work,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in recursive call') + goto 9999 + end if + + ! + ! Apply the prolongator + ! + call p%precv(level+1)%map%map_V2U(cone,& + & p%precv(level+1)%wrk%vy2l, cone,vy2l,& + & info,work=work,& + & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + + end if + end associate + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_c_inner_add + + recursive subroutine amg_c_inner_mult(p, level, trans, work) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_cprec_type), intent(inout) :: p + + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + complex(psb_spk_),target :: work(:) + type(psb_c_vect_type) :: res + type(psb_c_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + name = 'inner_inner_mult' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_mult') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_mult at level ',level + end if + + sweeps_post = p%precv(level)%parms%sweeps_post + sweeps_pre = p%precv(level)%parms%sweeps_pre + pre = ((sweeps_pre>0).and.(trans=='N')).or.((sweeps_post>0).and.(trans/='N')) + post = ((sweeps_post>0).and.(trans=='N')).or.((sweeps_pre>0).and.(trans/='N')) + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & wv => p%precv(level)%wrk%wv) + if (level < nlev) then + ! + ! Apply the first smoother + ! The residual has been prepared before the recursive call. + ! + + if (pre) then + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(cone,& + & vx2l,czero,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(cone,& + & vx2l,czero,vy2l, base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during PRE smoother_apply') + goto 9999 + end if + endif + ! + ! Compute the residual for next level and call recursively + ! + if (pre) then + call psb_geaxpby(cone,vx2l,& + & czero,vty,& + & base_desc,info) + + if (info == psb_success_) call psb_spmm(-cone,base_a,& + & vy2l,cone,vty,& + & base_desc,info,work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + call p%precv(level+1)%map%map_U2V(cone,vty,& + & czero,p%precv(level+1)%wrk%vx2l,& + & info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + else + ! Shortcut: just transfer x2l. + call p%precv(level+1)%map%map_U2V(cone,vx2l,& + & czero,p%precv(level+1)%wrk%vx2l,& + & info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + endif + + call inner_ml_aply(level+1,p,trans,work,info) + + ! + ! Apply the prolongator + ! + call p%precv(level+1)%map%map_V2U(cone,& + & p%precv(level+1)%wrk%vy2l,cone,vy2l,& + & info,work=work,& + & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + if (p%precv(level)%parms%ml_cycle == amg_wcycle_ml_) then + + call psb_geaxpby(cone,vx2l, czero,vty,& + & base_desc,info) + if (info == psb_success_) call psb_spmm(-cone,base_a,& + & vy2l,cone,vty,& + & base_desc,info,work=work,trans=trans) + if (info == psb_success_) & + & call p%precv(level+1)%map%map_U2V(cone,vty,& + & czero,p%precv(level+1)%wrk%vx2l,info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during W-cycle restriction') + goto 9999 + end if + + call inner_ml_aply(level+1,p,trans,work,info) + + if (info == psb_success_) call p%precv(level+1)%map%map_V2U(cone, & + & p%precv(level+1)%wrk%vy2l,cone,vy2l,& + & info,work=work,& + & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during W recusion/prolongation') + goto 9999 + end if + + endif + + + if (post) then + call psb_geaxpby(cone,vx2l,& + & czero,vty,& + & base_desc,info) + if (info == psb_success_) call psb_spmm(-cone,base_a,& + & vy2l, cone,vty,base_desc,info,& + & work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + + ! + ! Apply the second smoother + ! + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(cone,& + & vty,cone,vy2l, base_desc, trans,& + & sweeps,work,wv,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(cone,& + & vty,cone,vy2l, base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during POST smoother_apply') + goto 9999 + end if + + endif + + else if (level == nlev) then + + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(cone,& + & vx2l,czero,vy2l,base_desc, trans,& + & sweeps,work,wv,info) + + else + + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL vs NLEV') + goto 9999 + end if + end associate + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_c_inner_mult + + recursive subroutine amg_c_inner_k_cycle(p, level, trans, work,u) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_cprec_type), intent(inout) :: p + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + complex(psb_spk_),target :: work(:) + type(psb_c_vect_type),intent(inout), optional :: u + + + + type(psb_c_vect_type) :: res + type(psb_c_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_kcycle' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_add') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,name,' start at level ',level + end if + + if ((level<1).or.(level>nlev)) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL>NLEV') + goto 9999 + end if + + !K cycle + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & wv => p%precv(level)%wrk%wv(8:)) + if (level == nlev) then + ! + ! Apply smoother + ! + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(cone,& + & vx2l,czero,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + + else if (level < nlev) then + + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(cone,& + & vx2l,czero,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(cone,& + & vx2l,czero,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during 2-PRE smoother_apply') + goto 9999 + end if + + + ! + ! Compute the residual and call recursively + ! + + call psb_geaxpby(cone,vx2l,& + & czero,vty,& + & base_desc,info) + + if (info == psb_success_) call psb_spmm(-cone,base_a,& + & vy2l,cone,vty,base_desc,info,work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + + ! Apply the restriction + call p%precv(level + 1)%map%map_U2V(cone,vty,& + & czero,p%precv(level + 1)%wrk%vx2l,& + &info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + + !Set the preconditioner + + if (level <= nlev - 2 ) then + if (p%precv(level)%parms%ml_cycle == amg_kcyclesym_ml_) then + call amg_cinneritkcycle(p, level + 1, trans, work, 'FCG') + elseif (p%precv(level)%parms%ml_cycle == amg_kcycle_ml_) then + call amg_cinneritkcycle(p, level + 1, trans, work, 'GCR') + else + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Bad value for ml_cycle') + goto 9999 + endif + else + call inner_ml_aply(level + 1 ,p,trans,work,info) + endif + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in recursive call') + goto 9999 + end if + + ! + ! Apply the prolongator + ! + call p%precv(level+1)%map%map_V2U(cone,& + & p%precv(level+1)%wrk%vy2l,cone,vy2l,& + & info,work=work,& + & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + ! + ! Compute the residual + ! + call psb_geaxpby(cone,vx2l,& + & czero,vty,base_desc,info) + call psb_spmm(-cone,base_a,vy2l,& + & cone,vty,base_desc,info,& + & work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + ! + ! Apply the smoother + ! + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(cone,& + & vty,cone,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(cone,& + & vty,cone,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during POST smoother_apply') + goto 9999 + end if + else + + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL vs NLEV') + goto 9999 + + endif + end associate + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_c_inner_k_cycle + + + recursive subroutine amg_cinneritkcycle(p, level, trans, work, innersolv) + use psb_base_mod + use amg_prec_mod + use amg_c_inner_mod, amg_protect_name => amg_cmlprec_aply + + implicit none + + !Input/Oputput variables + type(amg_cprec_type), intent(inout) :: p + + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + character(len=*), intent(in) :: innersolv + complex(psb_spk_),target :: work(:) + + !Other variables + type(psb_c_vect_type) :: v, w, rhs, v1, x + type(psb_c_vect_type) :: d0, d1 + complex(psb_spk_) :: delta_old, rhs_norm, alpha, tau, tau1, tau2, tau3, tau4, beta + + real(psb_spk_) :: l2_norm, delta, rtol=0.25, delta0, tnrm + complex(psb_spk_), allocatable :: temp_v(:) + integer(psb_ipk_) :: info, nlev, i, iter, max_iter=2, idx + character(len=20) :: name = 'innerit_k_cycle' + + + if (size(p%precv(level)%wrk%wv)<7) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size') + goto 9999 + end if + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & v => p%precv(level)%wrk%wv(1), & + & w => p%precv(level)%wrk%wv(2),& + & rhs => p%precv(level)%wrk%wv(3), & + & v1 => p%precv(level)%wrk%wv(4), & + & x => p%precv(level)%wrk%wv(5), & + & d0 => p%precv(level)%wrk%wv(6), & + & d1 => p%precv(level)%wrk%wv(7)) + + call x%zero() + + ! rhs=vx2l and w=rhs + call psb_geaxpby(cone,vx2l,czero,rhs, base_desc,info) + call psb_geaxpby(cone,vx2l,czero,w, base_desc,info) + + if (psb_errstatus_fatal()) then + nc2l = base_desc%get_local_cols() + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + + delta0 = psb_genrm2(w, base_desc, info) + + !Apply the preconditioner + call vy2l%zero() + + idx=0 + call inner_ml_aply(level,p,trans,work,info) + + call psb_geaxpby(cone,vy2l,czero,d0,base_desc,info) + + call psb_spmm(cone,base_a,d0,czero,v,base_desc,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + + !FCG + if (psb_toupper(trim(innersolv)) == 'FCG') then + delta_old = psb_gedot(d0, w, base_desc, info) + tau = psb_gedot(d0, v, base_desc, info) + !GCR + else if (psb_toupper(trim(innersolv)) == 'GCR') then + delta_old = psb_gedot(v, w, base_desc, info) + tau = psb_gedot(v, v, base_desc, info) + else + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid inner solver') + goto 9999 + endif + + alpha = delta_old/tau + !Update residual w + call psb_geaxpby(-alpha, v, cone, w, base_desc, info) + + l2_norm = psb_genrm2(w, base_desc, info) + iter = 0 + + if (l2_norm <= rtol*delta0) then + !Update solution x + call psb_geaxpby(alpha, d0, cone, x, base_desc, info) + else + iter = iter + 1 + idx=mod(iter,2) + + !Apply preconditioner + call psb_geaxpby(cone,w,czero,vx2l,base_desc,info) + call inner_ml_aply(level,p,trans,work,info) + call psb_geaxpby(cone,vy2l,czero,d1,base_desc,info) + + !Sparse matrix vector product + + call psb_spmm(cone,base_a,d1,czero,v1,base_desc,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + + !tau1, tau2, tau3, tau4 + if (psb_toupper(trim(innersolv)) == 'FCG') then + tau1= psb_gedot(d1, v, base_desc, info) + tau2= psb_gedot(d1, v1, base_desc, info) + tau3= psb_gedot(d1, w, base_desc, info) + tau4= tau2 - (tau1*tau1)/tau + else if (psb_toupper(trim(innersolv)) == 'GCR') then + tau1= psb_gedot(v1, v, base_desc, info) + tau2= psb_gedot(v1, v1, base_desc, info) + tau3= psb_gedot(v1, w, base_desc, info) + tau4= tau2 - (tau1*tau1)/tau + else + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid inner solver') + goto 9999 + endif + + !Update solution + alpha=alpha-(tau1*tau3)/(tau*tau4) + call psb_geaxpby(alpha,d0,cone,x,base_desc,info) + alpha=tau3/tau4 + call psb_geaxpby(alpha,d1,cone,x,base_desc,info) + endif + + call psb_geaxpby(cone,x,czero,vy2l,base_desc,info) + end associate + +9999 continue + call psb_erractionrestore(err_act) + if (err_act.eq.psb_act_abort_) then + call psb_error() + return + end if + return + end subroutine amg_cinneritkcycle + +end subroutine amg_cmlprec_aply_vect + + +! +! Old routine for arrays instead of psb_X_vector. To be deleted eventually. +! +! +subroutine amg_cmlprec_aply(alpha,p,x,beta,y,desc_data,trans,work,info) + + use psb_base_mod + use amg_base_prec_type + use amg_c_inner_mod, amg_protect_name => amg_cmlprec_aply + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_cprec_type), intent(inout) :: p + complex(psb_spk_),intent(in) :: alpha,beta + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + character, intent(in) :: trans + complex(psb_spk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: ictxt, np, me + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: debug_level, debug_unit, nlev,nc2l,nr2l,level + character(len=20) :: name + character :: trans_ + type amg_mlwrk_type + complex(psb_spk_), allocatable :: tx(:), ty(:), x2l(:), y2l(:) + end type amg_mlwrk_type + type(amg_mlwrk_type), allocatable, target :: mlwrk(:) + + name='amg_cmlprec_aply' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (debug_level >= psb_debug_inner_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Entry ', size(p%precv) + + trans_ = psb_toupper(trans) + + nlev = size(p%precv) + allocate(mlwrk(nlev),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') + goto 9999 + end if + level = 1 + + do level = 1, nlev + call psb_geasb(mlwrk(level)%x2l,& + & p%precv(level)%base_desc,info) + call psb_geasb(mlwrk(level)%y2l,& + & p%precv(level)%base_desc,info) + call psb_geasb(mlwrk(level)%tx,& + & p%precv(level)%base_desc,info) + call psb_geasb(mlwrk(level)%ty,& + & p%precv(level)%base_desc,info) + if (psb_errstatus_fatal()) then + nc2l = p%precv(level)%base_desc%get_local_cols() + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + end do + + mlwrk(level)%x2l(:) = x(:) + mlwrk(level)%y2l(:) = czero + + call inner_ml_aply(level,p,mlwrk,trans_,work,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Inner prec aply') + goto 9999 + end if + + call psb_geaxpby(alpha,mlwrk(level)%y2l,beta,y,& + & p%precv(level)%base_desc,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error final update') + goto 9999 + end if + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + + ! + ! + ! inner_ml_aply: apply AMG at a given level. + ! This routine dispatches the computation according to the type + ! specified at the current level. + ! Each of the corrections will inturn call recursively this routine. + ! + ! Assumptions: + ! On input: + ! mlprec_wkr(level)%vx2l contains the input vector (RHS) + ! mlprec_wkr(level)%vy2l contains the initial guess + ! + ! On output: + ! mlprec_wkr(level)%vy2l contains the solution + ! + ! Constraints: each of the called routines must properly handle + ! the input/output conditions for level+1 (i.e. apply + ! prolongation/restriction). + ! Note: for historical/convenience reasons the prolongator/restrictor + ! between level and level+1 are stored at level+1. + ! + ! + recursive subroutine inner_ml_aply(level,p,mlwrk,trans,work,info) + + implicit none + + ! Arguments + integer(psb_ipk_) :: level + type(amg_cprec_type), target, intent(inout) :: p + type(amg_mlwrk_type), intent(inout), target :: mlwrk(:) + character, intent(in) :: trans + complex(psb_spk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + + type(psb_c_vect_type) :: res + type(psb_c_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_ml_aply' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_ml') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_ml_aply at level ',level + end if + + select case(p%precv(level)%parms%ml_cycle) + + case(amg_no_ml_) + ! + ! No preconditioning, should not really get here + ! + call psb_errpush(psb_err_internal_error_,name,& + & a_err='amg_no_ml_ in mlprc_aply?') + goto 9999 + + case(amg_add_ml_) + + call amg_c_inner_add(p, mlwrk, level, trans, work) + + case(amg_mult_ml_, amg_vcycle_ml_, amg_wcycle_ml_) + + call amg_c_inner_mult(p, mlwrk, level, trans, work) + +! !$ case(amg_kcycle_ml_, amg_kcyclesym_ml_) +! !$ +! !$ call amg_c_inner_k_cycle(p, mlwrk, level, trans, work) + + case default + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='invalid ml_cycle',& + & i_Err=(/p%precv(level)%parms%ml_cycle,izero,izero,izero,izero/)) + goto 9999 + + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine inner_ml_aply + + + recursive subroutine amg_c_inner_add(p, mlwrk, level, trans, work) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_cprec_type), intent(inout) :: p + + type(amg_mlwrk_type), target, intent(inout) :: mlwrk(:) + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + complex(psb_spk_),target :: work(:) + type(psb_c_vect_type) :: res + type(psb_c_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_inner_add' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_add') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_add at level ',level + end if + + if ((level<1).or.(level>nlev)) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL>NLEV') + goto 9999 + end if + + sweeps = p%precv(level)%parms%sweeps_pre + call p%precv(level)%sm%apply(cone,& + & mlwrk(level)%x2l,czero,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during ADD smoother_apply') + goto 9999 + end if + + if (level < nlev) then + ! Apply the restriction + call p%precv(level+1)%map%map_U2V(cone,mlwrk(level)%x2l,& + & czero,mlwrk(level+1)%x2l,& + & info,work=work) + mlwrk(level+1)%y2l(:) = czero + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + + call inner_ml_aply(level+1,p,mlwrk,trans,work,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in recursive call') + goto 9999 + end if + + ! + ! Apply the prolongator and add correction. + ! + call p%precv(level+1)%map%map_V2U(cone,& + & mlwrk(level+1)%y2l,cone,mlwrk(level)%y2l,& + & info,work=work) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_c_inner_add + + recursive subroutine amg_c_inner_mult(p, mlwrk, level, trans, work) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_cprec_type), intent(inout) :: p + + type(amg_mlwrk_type), target, intent(inout) :: mlwrk(:) + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + complex(psb_spk_),target :: work(:) + type(psb_c_vect_type) :: res + type(psb_c_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_inner_mult' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_mult') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_mult at level ',level + end if + + if ((level < nlev).or.(nlev == 1)) then + sweeps_post = p%precv(level)%parms%sweeps_post + sweeps_pre = p%precv(level)%parms%sweeps_pre + else + sweeps_post = p%precv(level-1)%parms%sweeps_post + sweeps_pre = p%precv(level-1)%parms%sweeps_pre + endif + + pre = ((sweeps_pre>0).and.(trans=='N')).or.((sweeps_post>0).and.(trans/='N')) + post = ((sweeps_post>0).and.(trans=='N')).or.((sweeps_pre>0).and.(trans/='N')) + + + if (level < nlev) then + + ! + ! Apply the first smoother + ! + + if (pre) then + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(cone,& + & mlwrk(level)%x2l,czero,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info,init='Y') + else + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(cone,& + & mlwrk(level)%x2l,czero,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info,init='Y') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during PRE smoother_apply') + goto 9999 + end if + endif + + ! + ! Compute the residual and call recursively + ! + if (pre) then + call psb_geaxpby(cone,mlwrk(level)%x2l,& + & czero,mlwrk(level)%ty,& + & p%precv(level)%base_desc,info) + + if (info == psb_success_) call psb_spmm(-cone,p%precv(level)%base_a,& + & mlwrk(level)%y2l,cone,mlwrk(level)%ty,& + & p%precv(level)%base_desc,info,work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + call p%precv(level+1)%map%map_U2V(cone,mlwrk(level)%ty,& + & czero,mlwrk(level+1)%x2l,info,work=work) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + else + ! Shortcut: just transfer x2l. + call p%precv(level+1)%map%map_U2V(cone,mlwrk(level)%x2l,& + & czero,mlwrk(level+1)%x2l,info,work=work) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + endif + ! First guess is zero + mlwrk(level+1)%y2l(:) = czero + + + call inner_ml_aply(level+1,p,mlwrk,trans,work,info) + + if (p%precv(level)%parms%ml_cycle == amg_wcycle_ml_) then + ! On second call will use output y2l as initial guess + if (info == psb_success_) call inner_ml_aply(level+1,p,mlwrk,trans,work,info) + endif + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in recursive call') + goto 9999 + end if + + + ! + ! Apply the prolongator + ! + call p%precv(level+1)%map%map_V2U(cone,mlwrk(level+1)%y2l,& + & cone,mlwrk(level)%y2l,info,work=work) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + ! + ! Compute the residual + ! + if (post) then + call psb_geaxpby(cone,mlwrk(level)%x2l,& + & czero,mlwrk(level)%tx,& + & p%precv(level)%base_desc,info) + call psb_spmm(-cone,p%precv(level)%base_a,mlwrk(level)%y2l,& + & cone,mlwrk(level)%tx,p%precv(level)%base_desc,info,& + & work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + ! + ! Apply the second smoother + ! + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(cone,& + & mlwrk(level)%tx,cone,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(cone,& + & mlwrk(level)%tx,cone,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during POST smoother_apply') + goto 9999 + end if + + endif + + else if (level == nlev) then + + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(cone,& + & mlwrk(level)%x2l,czero,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info) + + else + + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL vs NLEV') + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_c_inner_mult + + +end subroutine amg_cmlprec_aply diff --git a/mlprec/impl/amg_cmlprec_bld.f90 b/mlprec/impl/amg_cmlprec_bld.f90 new file mode 100644 index 00000000..0aa52877 --- /dev/null +++ b/mlprec/impl/amg_cmlprec_bld.f90 @@ -0,0 +1,152 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_cmlprec_bld.f90 +! +! Subroutine: amg_cmlprec_bld +! Version: complex +! +! This routine builds the preconditioner according to the requirements made by +! the user trough the subroutines amg_precinit and amg_precset. +! +! A multilevel preconditioner is regarded as an array of 'one-level' data structures, +! each containing the part of the preconditioner associated to a certain level, +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level. No transfer operators are associated to level 1. +! +! This routine simply calls amg_c_hierarchy_bld and amg_c_smoothers_bld; they +! can also be called explicitly from the user. +! +! +! Arguments: +! a - type(psb_cspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_cprec_type), input/output. +! The preconditioner data structure containing the local part +! of the preconditioner to be built. +! info - integer, output. +! Error code. +! +! amold - class(psb_c_base_sparse_mat), input, optional +! Mold for the inner format of matrices contained in the +! preconditioner +! +! +! vmold - class(psb_c_base_vect_type), input, optional +! Mold for the inner format of vectors contained in the +! preconditioner +! +! +! +subroutine amg_cmlprec_bld(a,desc_a,p,info,amold,vmold,imold) + + use psb_base_mod + use amg_c_inner_mod, amg_protect_name => amg_cmlprec_bld + use amg_c_prec_mod + + Implicit None + + ! Arguments + type(psb_cspmat_type),intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + type(amg_cprec_type),intent(inout),target :: p + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local Variables + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, casize, nplevs, mxplevs + real(psb_spk_) :: mnaggratio + integer(psb_ipk_) :: ipv(amg_ifpsz_), val + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_cmlprec_bld' + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' + + call p%hierarchy_build(a,desc_a,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Error from hierarchy build') + goto 9999 + end if + + iszv = p%get_nlevs() + + call p%smoothers_build(a,desc_a,info,amold,vmold,imold) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Error from smoothers build') + goto 9999 + end if + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Exiting with',iszv,' levels' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_cmlprec_bld diff --git a/mlprec/impl/amg_cprecaply.f90 b/mlprec/impl/amg_cprecaply.f90 new file mode 100644 index 00000000..f7a92b20 --- /dev/null +++ b/mlprec/impl/amg_cprecaply.f90 @@ -0,0 +1,600 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_cprecaply.f90 +! +! Subroutine: amg_cprecaply +! Version: complex +! +! This routine applies the preconditioner built by amg_cprecbld, i.e. it computes +! +! Y = op(M^(-1)) * X, +! where +! - M is the preconditioner, +! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, +! - X and Y are vectors. +! This operation is performed at each iteration of a preconditioned Krylov solver. +! +! +! Arguments: +! prec - type(amg_cprec_type), input. +! The preconditioner data structure containing the local part +! of the preconditioner to be applied. +! x - complex(psb_spk_), dimension(:), input. +! The local part of the vector X in Y=op(M^(-1))*X. +! y - complex(psb_spk_), dimension(:), output. +! The local part of the vector Y in Y=op(M^(-1))*X. +! desc_data - type(psb_desc_type), input. +! The communication descriptor associated to the matrix to be +! preconditioned. +! info - integer, output. +! Error code. +! trans - character(len=1), optional. +! If trans='N','n' then op(M^(-1)) = M^(-1); +! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). +! work - complex(psb_spk_), dimension (:), optional, target. +! Workspace. Its size must be at +! least 4*desc_data%get_local_cols(). +! +subroutine amg_cprecaply(prec,x,y,desc_data,info,trans,work) + + use psb_base_mod + use amg_c_inner_mod!, amg_protect_name => amg_cprecaply + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_cprec_type), intent(inout) :: prec + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_spk_),intent(inout), optional, target :: work(:) + + ! Local variables + character :: trans_ + complex(psb_spk_), pointer :: work_(:) + complex(psb_spk_), allocatable :: w1(:), w2(:) + + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: err_act,iwsz, k, nswps + character(len=20) :: name + + name='amg_cprecaply' + info = psb_success_ + call psb_erractionsave(err_act) + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (present(trans)) then + trans_=psb_toupper(trans) + else + trans_='N' + end if + + if (present(work)) then + work_ => work + else + iwsz = max(1,4*desc_data%get_local_cols()) + allocate(work_(iwsz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name, & + & i_err=(/iwsz,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + + end if + + if (.not.(allocated(prec%precv))) then + !! Error 1: should call amg_cprecbld + info=3112 + call psb_errpush(info,name) + goto 9999 + end if + + if (size(prec%precv) >1) then + ! + ! Number of levels > 1: apply the multilevel preconditioner + ! + call amg_mlprec_aply(cone,prec,x,czero,y,desc_data,trans_,work_,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_cmlprec_aply') + goto 9999 + end if + + else if (size(prec%precv) == 1) then + ! + ! Number of levels = 1: apply the base preconditioner + ! + if (allocated(prec%precv(1)%sm2a)) then + nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) + ! + ! This is a kludge for handling the symmetrized GS case. + ! Will need some rethinking. + ! + call psb_geasb(w1,desc_data,info,scratch=.true.) + call psb_geasb(w2,desc_data,info,scratch=.true.) + + call psb_geaxpby(cone,x,czero,w1,desc_data,info) + select case(trans_) + case ('N') + do k=1, nswps + call prec%precv(1)%sm%apply(cone,w1,czero,w2,desc_data,trans_,& + & ione, work_,info) + call prec%precv(1)%sm2a%apply(cone,w2,czero,w1,desc_data,trans_,& + & ione, work_,info) + end do + + case('T','C') + do k=1, nswps + call prec%precv(1)%sm2a%apply(cone,w1,czero,w2,desc_data,trans_,& + & ione, work_,info) + call prec%precv(1)%sm%apply(cone,w2,czero,w1,desc_data,trans_,& + & ione, work_,info) + end do + case default + info = psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='Invalid trans') + goto 9999 + end select + call psb_geaxpby(cone,w1,czero,y,desc_data,info) + call psb_gefree(w1,desc_data,info) + call psb_gefree(w2,desc_data,info) + + else + nswps = prec%precv(1)%parms%sweeps_pre + call prec%precv(1)%sm%apply(cone,x,czero,y,desc_data,trans_,& + & nswps, work_,info) + end if + else + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='Invalid size of precv',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + endif + + ! If the original distribution has an overlap we should fix that. + call psb_halo(y,desc_data,info,data=psb_comm_mov_) + + + if (present(work)) then + else + deallocate(work_) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_cprecaply + + +! +! Subroutine: amg_cprecaply1 +! Version: complex +! +! Applies the preconditioner built by amg_cprecbld, i.e. computes +! +! X = op(M^(-1)) * X, +! where +! - M is the preconditioner, +! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, +! - X is a vectors. +! This operation is performed at each iteration of a preconditioned Krylov solver. +! +! This routine differs from amg_cprecaply because the preconditioned vector X +! overwrites the original one. +! +! +! Arguments: +! prec - type(amg_cprec_type), input. +! The preconditioner data structure containing the local part +! of the preconditioner to be applied. +! x - complex(psb_spk_), dimension(:), input/output. +! The local part of vector X in X := op(M^(-1)) * X. +! desc_data - type(psb_desc_type), input. +! The communication descriptor associated to the matrix to be +! preconditioned. +! info - integer, output. +! Error code. +! trans - character(len=1), optional. +! If trans='N','n' then op(M^(-1)) = M^(-1); +! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). +! +subroutine amg_cprecaply1(prec,x,desc_data,info,trans) + + use psb_base_mod + use amg_c_inner_mod!, amg_protect_name => amg_cprecaply1 + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_cprec_type), intent(inout) :: prec + complex(psb_spk_),intent(inout) :: x(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: err_act + complex(psb_spk_), pointer :: ww(:), w1(:) + character(len=20) :: name + + name='amg_cprecaply1' + info = psb_success_ + call psb_erractionsave(err_act) + + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + allocate(ww(size(x)),w1(size(x)),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name, & + & i_err=(/itwo*size(x),izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + + call prec%apply(x,ww,desc_data,info,trans=trans,work=w1) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_precaply') + goto 9999 + end if + + x(:) = ww(:) + deallocate(ww,w1,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_cprecaply1 + + + +subroutine amg_cprecaply2_vect(prec,x,y,desc_data,info,trans,work) + + use psb_base_mod + use amg_c_inner_mod!, amg_protect_name => amg_cprecaply2_vect + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_cprec_type), intent(inout) :: prec + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_spk_),intent(inout), optional, target :: work(:) + + ! Local variables + character :: trans_ + complex(psb_spk_), pointer :: work_(:) + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: err_act,iwsz, k, nswps + logical :: do_alloc_wrk + character(len=20) :: name + + name='amg_cprecaply' + info = psb_success_ + call psb_erractionsave(err_act) + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (present(trans)) then + trans_=psb_toupper(trans) + else + trans_='N' + end if + + if (present(work)) then + work_ => work + else + iwsz = max(1,4*desc_data%get_local_cols()) + allocate(work_(iwsz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name, & + & i_err=(/iwsz,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + + end if + + if (.not.(allocated(prec%precv))) then + !! Error 1: should call amg_cprecbld + info=3112 + call psb_errpush(info,name) + goto 9999 + end if + + do_alloc_wrk = .not.allocated(prec%precv(1)%wrk) + if (do_alloc_wrk) call prec%allocate_wrk(info,vmold=x%v) + + if (size(prec%precv) >1) then + ! + ! Number of levels > 1: apply the multilevel preconditioner + ! + ! FIXME: generic name causes an ICE with Intel + call amg_cmlprec_aply_vect(cone,prec,x,czero,y,desc_data,trans_,work_,info) + + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_cmlprec_aply') + goto 9999 + end if + + else if (size(prec%precv) == 1) then + ! + ! Number of levels = 1: apply the base preconditioner + ! + nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) + + associate(w1 => prec%precv(1)%wrk%vx2l, w2 => prec%precv(1)%wrk%vy2l,& + & wv => prec%precv(1)%wrk%wv) + if (allocated(prec%precv(1)%sm2a)) then + ! + ! This is a kludge for handling the symmetrized GS case. + ! Will need some rethinking. + ! + call psb_geaxpby(cone,x,czero,w1,desc_data,info) + select case(trans_) + case ('N') + do k=1, nswps + if (info == 0) call prec%precv(1)%sm%apply(cone,w1,czero,w2,desc_data,trans_,& + & ione, work_,wv,info) + if (info == 0) call prec%precv(1)%sm2a%apply(cone,w2,czero,w1,desc_data,trans_,& + & ione, work_,wv,info) + end do + + case('T','C') + do k=1, nswps + if (info == 0) call prec%precv(1)%sm2a%apply(cone,w1,czero,w2,desc_data,trans_,& + & ione, work_,wv,info) + if (info == 0) call prec%precv(1)%sm%apply(cone,w2,czero,w1,desc_data,trans_,& + & ione, work_,wv,info) + end do + case default + info = psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='Invalid trans') + goto 9999 + end select + if (info == 0) call psb_geaxpby(cone,w1,czero,y,desc_data,info) + else + if (info == 0) call prec%precv(1)%sm%apply(cone,x,czero,y,desc_data,trans_,& + & nswps,work_,wv,info) + end if + end associate + if (psb_errstatus_fatal()) info = psb_err_internal_error_ + if (info /= 0) then + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='Smoother application',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + end if + + else + + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='Invalid size of precv',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + endif + + ! If the original distribution has an overlap we should fix that. + call psb_halo(y,desc_data,info,data=psb_comm_mov_) + + if (do_alloc_wrk) call prec%free_wrk(info) + + if (present(work)) then + else + deallocate(work_) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_cprecaply2_vect + + +subroutine amg_cprecaply1_vect(prec,x,desc_data,info,trans,work) + + use psb_base_mod + use amg_c_inner_mod!, amg_protect_name => amg_cprecaply1_vect + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_cprec_type), intent(inout) :: prec + type(psb_c_vect_type),intent(inout) :: x + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_spk_),intent(inout), optional, target :: work(:) + + ! Local variables + character :: trans_ + complex(psb_spk_), pointer :: work_(:) + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: err_act,iwsz, k, nswps + logical :: do_alloc_wrk + character(len=20) :: name + + name='amg_cprecaply' + info = psb_success_ + call psb_erractionsave(err_act) + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (present(trans)) then + trans_=psb_toupper(trans) + else + trans_='N' + end if + + if (present(work)) then + work_ => work + else + iwsz = max(1,4*desc_data%get_local_cols()) + allocate(work_(iwsz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name, & + & i_err=(/iwsz,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + + end if + + if (.not.(allocated(prec%precv))) then + !! Error 1: should call amg_cprecbld + info=3112 + call psb_errpush(info,name) + goto 9999 + end if + + do_alloc_wrk = .not.allocated(prec%precv(1)%wrk) + if (do_alloc_wrk) call prec%allocate_wrk(info,vmold=x%v) + + associate(ww => prec%precv(1)%wrk%vtx, wv => prec%precv(1)%wrk%wv) + + if (size(prec%precv) >1) then + ! + ! Number of levels > 1: apply the multilevel preconditioner + ! + ! FIXME: generic name causes an ICE with Intel + call amg_cmlprec_aply_vect(cone,prec,x,czero,ww,desc_data,trans_,work_,info) + if (info == 0) call psb_geaxpby(cone,ww,czero,x,desc_data,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_cmlprec_aply') + goto 9999 + end if + + else if (size(prec%precv) == 1) then + ! + ! Number of levels = 1: apply the base preconditioner + ! + nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) + if (allocated(prec%precv(1)%sm2a)) then + ! + ! This is a kludge for handling the symmetrized GS case. + ! Will need some rethinking. + ! + select case(trans_) + case ('N') + do k=1, nswps + if (info == 0) call prec%precv(1)%sm%apply(cone,x,czero,ww,desc_data,trans_,& + & ione, work_,wv,info) + if (info == 0) call prec%precv(1)%sm2a%apply(cone,ww,czero,x,desc_data,trans_,& + & ione, work_,wv,info) + end do + case('T','C') + do k=1, nswps + if (info == 0) call prec%precv(1)%sm2a%apply(cone,x,czero,ww,desc_data,trans_,& + & ione, work_,wv,info) + if (info == 0) call prec%precv(1)%sm%apply(cone,ww,czero,x,desc_data,trans_,& + & ione, work_,wv,info) + end do + case default + info = psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='Invalid trans') + goto 9999 + end select + + else + if (info == 0) call prec%precv(1)%sm%apply(cone,x,czero,ww,desc_data,trans_,& + & nswps, work_,wv,info) + if (info == 0) call psb_geaxpby(cone,ww,czero,x,desc_data,info) + end if + + if (psb_errstatus_fatal()) info = psb_err_internal_error_ + if (info /=0) then + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='Smoother application',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + end if + + else + + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='Invalid size of precv',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + endif + end associate + + ! If the original distribution has an overlap we should fix that. + call psb_halo(x,desc_data,info,data=psb_comm_mov_) + + if (do_alloc_wrk) call prec%free_wrk(info) + + if (present(work)) then + else + deallocate(work_) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_cprecaply1_vect diff --git a/mlprec/impl/amg_cprecbld.f90 b/mlprec/impl/amg_cprecbld.f90 new file mode 100644 index 00000000..c409c9b8 --- /dev/null +++ b/mlprec/impl/amg_cprecbld.f90 @@ -0,0 +1,161 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_cprecbld.f90 +! +! Subroutine: amg_cprecbld +! Version: complex +! Contains: subroutine init_baseprec_av +! +! This routine builds the preconditioner according to the requirements made by +! the user through the subroutines amg_precinit and amg_precset. +! +! +! Arguments: +! a - type(psb_cspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_cprec_type), input/output. +! The preconditioner data structure containing the local part +! of the preconditioner to be built. +! info - integer, output. +! Error code. +! +subroutine amg_cprecbld(a,desc_a,prec,info,amold,vmold,imold) + + use psb_base_mod + use amg_c_prec_mod, amg_protect_name => amg_cprecbld + + Implicit None + + ! Arguments + type(psb_cspmat_type),intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_cprec_type),intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local Variables + type(amg_cprec_type) :: t_prec + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k,err_act, iszv, newsz + integer(psb_ipk_) :: ipv(amg_ifpsz_), val + integer(psb_ipk_) :: int_err(5) + type(amg_dml_parms) :: prm + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_cprecbld' + info = psb_success_ + int_err(1) = 0 + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + prec%ictxt = ictxt + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' + ! + + if (.not.allocated(prec%precv)) then + !! Error: should have called amg_cprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + ! + ! Check to ensure all procs have the same + ! + newsz = -1 + iszv = size(prec%precv) + call psb_bcast(ictxt,iszv) + if (iszv /= size(prec%precv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of precv') + goto 9999 + end if + + if (iszv <= 0) then + ! Is this really possible? probably not. + info=psb_err_from_subroutine_ + ch_err='size bpv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + ! + ! Build the preconditioner + ! + call prec%hierarchy_build(a,desc_a,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Error from hierarchy build') + goto 9999 + end if + + call prec%smoothers_build(a,desc_a,info,amold,vmold,imold) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Error from smoothers build') + goto 9999 + end if + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_cprecbld diff --git a/mlprec/impl/amg_cprecinit.F90 b/mlprec/impl/amg_cprecinit.F90 new file mode 100644 index 00000000..6765fb2e --- /dev/null +++ b/mlprec/impl/amg_cprecinit.F90 @@ -0,0 +1,237 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_cprecinit.f90 +! +! Subroutine: amg_cprecinit +! Version: complex +! +! This routine allocates and initializes the preconditioner data structure, +! according to the preconditioner type chosen by the user. +! +! A default preconditioner is set for each preconditioner type +! specified by the user: +! +! 'NOPREC' - no preconditioner +! +! 'DIAG', 'JACOBI' - diagonal/Jacobi +! +! 'L1-DIAG', 'L1-JACOBI' - diagonal/Jacobi with L1 norm correction +! +! 'GS', 'FBGS' - Hybrid Gauss-Seidel, also symmetrized +! +! 'BJAC' - block Jacobi preconditioner, with ILU(0) +! on the local blocks +! +! 'L1-BJAC' - block Jacobi preconditioner, with ILU(0) +! on the local blocks and L1 correction for off-diag blocks +! +! 'AS' - Additive Schwarz (AS), with +! overlap 1 and ILU(0) on the local submatrices +! +! 'ML' - Multilevel hybrid preconditioner (additive on the +! same level and multiplicative through the levels), +! with 2 levels, pre and post-smoothing, RAS with +! overlap 1 and ILU(0) on the local blocks is +! applied as post-smoother at each level, but the +! coarsest one; four sweeps of the block-Jacobi solver, +! with LU from UMFPACK on the blocks, are applied at +! the coarsest level, on the distributed coarse matrix. +! The smoothed aggregation algorithm with threshold 0 +! is used to build the coarse matrix. +! +! For the multilevel preconditioners, the levels are numbered in increasing +! order starting from the finest one, i.e. level 1 is the finest level. +! +! +! Arguments: +! p - type(amg_cprec_type), input/output. +! The preconditioner data structure. +! ptype - character(len=*), input. +! The type of preconditioner. Its values are 'NOPREC', +! 'DIAG', 'BJAC', 'AS', 'ML' (and the corresponding +! lowercase strings). +! info - integer, output. +! Error code. +! +subroutine amg_cprecinit(ictxt,prec,ptype,info) + + use psb_base_mod + use amg_c_prec_mod, amg_protect_name => amg_cprecinit + use amg_c_jac_smoother + use amg_c_as_smoother + use amg_c_id_solver + use amg_c_diag_solver + use amg_c_ilu_solver + use amg_c_gs_solver +#if defined(HAVE_SLU_) + use amg_c_slu_solver +#endif + + + implicit none + + ! Arguments + integer(psb_ipk_), intent(in) :: ictxt + class(amg_cprec_type), intent(inout) :: prec + character(len=*), intent(in) :: ptype + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: nlev_, ilev_ + real(psb_spk_) :: thr + character(len=*), parameter :: name='amg_precinit' + info = psb_success_ + + if (allocated(prec%precv)) then + call prec%free(info) + if (info /= psb_success_) then + ! Do we want to do something? + endif + endif + prec%ictxt = ictxt + prec%ag_data%min_coarse_size = -1 + + select case(psb_toupper(trim(ptype))) + case ('NOPREC','NONE') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_c_base_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_c_id_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('JAC','DIAG','JACOBI') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_c_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_c_diag_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('L1-DIAG','L1-JACOBI','L1_DIAG','L1_JACOBI') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_c_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_c_l1_diag_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('GS','FWGS') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_c_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_c_gs_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('BWGS') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_c_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_c_bwgs_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('FBGS') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + call prec%set('SMOOTHER_TYPE','FBGS',info) + call prec%precv(ilev_)%default() + + case ('BJAC') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_c_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_c_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('L1-BJAC','L1_BJAC') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_c_l1_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_c_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('AS') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_c_as_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_c_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + + case ('ML') + + nlev_ = prec%ag_data%max_levs + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + + do ilev_ = 1, nlev_ + call prec%precv(ilev_)%default() + end do + call prec%set('ML_CYCLE','VCYCLE',info) + call prec%set('SMOOTHER_TYPE','FBGS',info) +#if defined(HAVE_MUMPS_) + call prec%set('COARSE_SOLVE','MUMPS',info) +#elif defined(HAVE_SLU_) + call prec%set('COARSE_SOLVE','SLU',info) +#else + call prec%set('COARSE_SOLVE','ILU',info) +#endif + + case default + write(psb_err_unit,*) name,& + &': Warning: Unknown preconditioner type request "',ptype,'"' + info = psb_err_pivot_too_small_ + + end select + + +end subroutine amg_cprecinit diff --git a/mlprec/impl/amg_cprecset.F90 b/mlprec/impl/amg_cprecset.F90 new file mode 100644 index 00000000..0f603b31 --- /dev/null +++ b/mlprec/impl/amg_cprecset.F90 @@ -0,0 +1,229 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_cprecset.f90 +! +subroutine amg_cprecsetsm(p,val,info,ilev,ilmax,pos) + + use psb_base_mod + use amg_c_prec_mod, amg_protect_name => amg_cprecsetsm + + implicit none + + ! Arguments + class(amg_cprec_type), intent(inout) :: p + class(amg_c_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ + character(len=*), parameter :: name='amg_precsetsm' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + ilmin_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmin_ = 1 + ilmax_ = nlev_ + end if + + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + do ilev_ = ilmin_, ilmax_ + call p%precv(ilev_)%set(val,info,pos=pos) + if (info /= 0) return + end do + +end subroutine amg_cprecsetsm + +subroutine amg_cprecsetsv(p,val,info,ilev,ilmax,pos) + + use psb_base_mod + use amg_c_prec_mod, amg_protect_name => amg_cprecsetsv + + implicit none + + ! Arguments + class(amg_cprec_type), intent(inout) :: p + class(amg_c_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ + character(len=*), parameter :: name='amg_precsetsv' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + ilmin_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmin_ = 1 + ilmax_ = nlev_ + end if + + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + do ilev_ = ilmin_, ilmax_ + call p%precv(ilev_)%set(val,info,pos=pos) + if (info /= 0) return + end do + +end subroutine amg_cprecsetsv + +subroutine amg_cprecsetag(p,val,info,ilev,ilmax,pos) + + use psb_base_mod + use amg_c_prec_mod, amg_protect_name => amg_cprecsetag + + implicit none + + ! Arguments + class(amg_cprec_type), intent(inout) :: p + class(amg_c_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev, ilmax + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ + character(len=*), parameter :: name='amg_precsetag' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + ilmin_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmin_ = 1 + ilmax_ = nlev_ + end if + + + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + do ilev_ = ilmin_, ilmax_ + call p%precv(ilev_)%set(val,info,pos=pos) + if (info /= 0) return + end do + +end subroutine amg_cprecsetag + diff --git a/mlprec/impl/amg_cslu_interface.c b/mlprec/impl/amg_cslu_interface.c new file mode 100644 index 00000000..523a7f38 --- /dev/null +++ b/mlprec/impl/amg_cslu_interface.c @@ -0,0 +1,328 @@ +/* + * + * MLD2P4 version 2.1 + * MultiLevel Domain Decomposition Parallel Preconditioners Package + * based on PSBLAS (Parallel Sparse BLAS version 3.5) + * + * (C) Copyright 2008-2018 + * + * Salvatore Filippone + * Pasqua D'Ambra + * Daniela di Serafino + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions, and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the MLD2P4 group or the names of its contributors may + * not be used to endorse or promote products derived from this + * software without specific written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * + * File: amg_cslu_interface.c + * + * Functions: amg_cslu_fact, amg_cslu_solve, amg_cslu_free. + * + * This file is an interface to the SuperLU routines for sparse factorization and + * solve. It was obtained by modifying the c_fortran_cgssv.c file from the SuperLU + * source distribution; original copyright terms are reproduced below. + * + */ + + +/* ===================== + +Copyright (c) 2003, The Regents of the University of California, through +Lawrence Berkeley National Laboratory (subject to receipt of any required +approvals from U.S. Dept. of Energy) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +(1) Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +(2) Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. +(3) Neither the name of Lawrence Berkeley National Laboratory, U.S. Dept. of +Energy nor the names of its contributors may be used to endorse or promote +products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +/* + * -- SuperLU routine (version 3.0) -- + * Univ. of California Berkeley, Xerox Palo Alto Research Center, + * and Lawrence Berkeley National Lab. + * October 15, 2003 + * + */ + +#ifdef Have_SLU_ +#include "slu_cdefs.h" +#define HANDLE_SIZE 8 + + +typedef struct { + SuperMatrix *L; + SuperMatrix *U; + int *perm_c; + int *perm_r; +} factors_t; + + +#else + +#include + +#endif + + + +int amg_cslu_fact(int n, int nnz, +#ifdef HAVE_SLU_ + complex *values, +#else + void *values, +#endif + int *colptr, int *rowind, void **f_factors) +{ +/* + * This routine can be called from Fortran. + * performs LU decomposition. + * + * f_factors (input/output) + * On output contains the pointer pointing to + * the structure of the factored matrices. + * + */ + +#ifdef Have_SLU_ + SuperMatrix A, AC; + SuperMatrix *L, *U; + int *perm_r; /* row permutations from partial pivoting */ + int *perm_c; /* column permutation vector */ + int *etree; /* column elimination tree */ + SCformat *Lstore; + NCformat *Ustore; + int i, panel_size, permc_spec, relax; + trans_t trans; + mem_usage_t mem_usage; + superlu_options_t options; + SuperLUStat_t stat; + factors_t *LUfactors; + GlobalLU_t Glu; /* Not needed on return. */ + int info; + + trans = NOTRANS; + + + /* Set the default input options. */ + set_default_options(&options); + + /* Initialize the statistics variables. */ + StatInit(&stat); + + cCreate_CompCol_Matrix(&A, n, n, nnz, values, rowind, colptr, + SLU_NC, SLU_C, SLU_GE); + L = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) ); + U = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) ); + if ( !(perm_r = intMalloc(n)) ) ABORT("Malloc fails for perm_r[]."); + if ( !(perm_c = intMalloc(n)) ) ABORT("Malloc fails for perm_c[]."); + if ( !(etree = intMalloc(n)) ) ABORT("Malloc fails for etree[]."); + + /* + * Get column permutation vector perm_c[], according to permc_spec: + * permc_spec = 0: natural ordering + * permc_spec = 1: minimum degree on structure of A'*A + * permc_spec = 2: minimum degree on structure of A'+A + * permc_spec = 3: approximate minimum degree for unsymmetric matrices + */ + options.ColPerm=2; + permc_spec = options.ColPerm; + get_perm_c(permc_spec, &A, perm_c); + + sp_preorder(&options, &A, perm_c, etree, &AC); + + panel_size = sp_ienv(1); + relax = sp_ienv(2); +#if defined(SLU_VERSION_5) + cgstrf(&options, &AC, relax, panel_size, etree, + NULL, 0, perm_c, perm_r, L, U, &Glu, &stat, &info); +#elif defined(SLU_VERSION_4) + cgstrf(&options, &AC, relax, panel_size, etree, + NULL, 0, perm_c, perm_r, L, U, &stat, &info); +#else + choke_on_me; +#endif + + if ( info == 0 ) { + Lstore = (SCformat *) L->Store; + Ustore = (NCformat *) U->Store; + cQuerySpace(L, U, &mem_usage); +#if 0 + printf("No of nonzeros in factor L = %d\n", Lstore->nnz); + printf("No of nonzeros in factor U = %d\n", Ustore->nnz); + printf("No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz); + printf("L\\U MB %.3f\ttotal MB needed %.3f\n", + mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); +#endif + } else { + printf("cgstrf() error returns INFO= %d\n", info); + if ( info <= n ) { /* factorization completes */ + cQuerySpace(L, U, &mem_usage); + printf("L\\U MB %.3f\ttotal MB needed %.3f\n", + mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); + } + } + + /* Save the LU factors in the factors handle */ + LUfactors = (factors_t*) SUPERLU_MALLOC(sizeof(factors_t)); + LUfactors->L = L; + LUfactors->U = U; + LUfactors->perm_c = perm_c; + LUfactors->perm_r = perm_r; + *f_factors = (void *) LUfactors; + + /* Free un-wanted storage */ + SUPERLU_FREE(etree); + Destroy_SuperMatrix_Store(&A); + Destroy_CompCol_Permuted(&AC); + StatFree(&stat); + return(info); +#else + fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); + return(-1); +#endif +} + + +int amg_cslu_solve(int itrans, int n, int nrhs, +#ifdef HAVE_SLU_ + complex *b, +#else + void *b, +#endif + int ldb,void *f_factors) +{ + /* + * This routine can be called from Fortran. + * performs triangular solve + * + */ + int info; +#ifdef Have_SLU_ + SuperMatrix B; + SuperMatrix *L, *U; + int *perm_r; /* row permutations from partial pivoting */ + int *perm_c; /* column permutation vector */ + int *etree; /* column elimination tree */ + SCformat *Lstore; + NCformat *Ustore; + int i, panel_size, permc_spec, relax; + trans_t trans; + float drop_tol = 0.0; + mem_usage_t mem_usage; + superlu_options_t options; + SuperLUStat_t stat; + factors_t *LUfactors; + + if (itrans == 0) { + trans = NOTRANS; + } else if (itrans ==1) { + trans = TRANS; + } else if (itrans ==2) { + trans = CONJ; + } else { + trans = NOTRANS; + } + /* Initialize the statistics variables. */ + StatInit(&stat); + + /* Extract the LU factors in the factors handle */ + LUfactors = (factors_t*) f_factors; + L = LUfactors->L; + U = LUfactors->U; + perm_c = LUfactors->perm_c; + perm_r = LUfactors->perm_r; + + cCreate_Dense_Matrix(&B, n, nrhs, b, ldb, SLU_DN, SLU_C, SLU_GE); + /* Solve the system A*X=B, overwriting B with X. */ + cgstrs (trans, L, U, perm_c, perm_r, &B, &stat, &info); + if (info != 0) { + if (B.Stype != SLU_DN) fprintf(stderr,"cgstrs error kind 1: SLU_DN\n"); + if (B.Dtype != SLU_C) fprintf(stderr,"cgstrs error kind 2: SLU_C\n"); + if (B.Mtype != SLU_GE) fprintf(stderr,"cgstrs error kind 3: SLU_GE\n"); + } + + Destroy_SuperMatrix_Store(&B); + StatFree(&stat); +#else + fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); + info=-1; +#endif + return(info); +} + + +int amg_cslu_free(void *f_factors) +{ +/* + * This routine can be called from Fortran. + * + * free all storage in the end + * + */ +#ifdef Have_SLU_ + factors_t *LUfactors; + + /* Free the LU factors in the factors handle */ + LUfactors = (factors_t*) f_factors; + if (LUfactors != NULL) { + SUPERLU_FREE (LUfactors->perm_r); + SUPERLU_FREE (LUfactors->perm_c); + Destroy_SuperNode_Matrix(LUfactors->L); + Destroy_CompCol_Matrix(LUfactors->U); + SUPERLU_FREE (LUfactors->L); + SUPERLU_FREE (LUfactors->U); + SUPERLU_FREE (LUfactors); + } + return(0); +#else + fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); + return(-1); +#endif +} + + diff --git a/mlprec/impl/amg_d_extprol_bld.F90 b/mlprec/impl/amg_d_extprol_bld.F90 new file mode 100644 index 00000000..8204b84b --- /dev/null +++ b/mlprec/impl/amg_d_extprol_bld.F90 @@ -0,0 +1,534 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_d_extprol_bld.f90 +! +! Subroutine: amg_d_extprol_bld +! Version: real +! +! This routine builds the preconditioner according to the requirements made by +! the user trough the subroutines amg_precinit and amg_precset. +! +! A multilevel preconditioner is regarded as an array of 'one-level' data structures, +! each containing the part of the preconditioner associated to a certain level, +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level. No transfer operators are associated to level 1. +! +! +! Arguments: +! a - type(psb_dspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_dprec_type), input/output. +! The preconditioner data structure containing the local part +! of the preconditioner to be built. +! info - integer, output. +! Error code. +! +! amold - class(psb_d_base_sparse_mat), input, optional +! Mold for the inner format of matrices contained in the +! preconditioner +! +! +! vmold - class(psb_d_base_vect_type), input, optional +! Mold for the inner format of vectors contained in the +! preconditioner +! +! +! +subroutine amg_d_extprol_bld(a,desc_a,p,prolv,restrv,info,amold,vmold,imold) + + use psb_base_mod + use amg_d_inner_mod + use amg_d_prec_mod, amg_protect_name => amg_d_extprol_bld + + Implicit None + + ! Arguments + type(psb_dspmat_type),intent(in), target :: a + type(psb_dspmat_type),intent(inout), target :: prolv(:) + type(psb_dspmat_type),intent(inout), target :: restrv(:) + type(psb_desc_type), intent(inout), target :: desc_a + type(amg_dprec_type),intent(inout),target :: p + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! !$ character, intent(in), optional :: upd + + ! Local Variables + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, casize, nplevs, mxplevs + integer(psb_ipk_) :: nprolv, nrestrv + real(psb_dpk_) :: mnaggratio + integer(psb_ipk_) :: ipv(amg_ifpsz_), val + class(amg_d_base_smoother_type), allocatable :: coarse_sm, base_sm, med_sm + type(amg_dml_parms) :: baseparms, medparms, coarseparms + type(amg_d_onelev_type), allocatable :: tprecv(:) + integer(psb_ipk_) :: int_err(5) + character :: upd_ + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + logical, parameter :: debug=.false. + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_d_extprol_bld' + info = psb_success_ + int_err(1) = 0 + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + p%ictxt = ictxt + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' +#if defined(LPK8) + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Need fix for LPK8') + goto 9999 +#else + + ! + ! For the time being we are commenting out the UPDATE argument + ! we plan to resurrect it later. + ! !$ if (present(upd)) then + ! !$ if (debug_level >= psb_debug_outer_) & + ! !$ & write(debug_unit,*) me,' ',trim(name),'UPD ', upd + ! !$ + ! !$ if ((psb_toupper(upd).eq.'F').or.(psb_toupper(upd).eq.'T')) then + ! !$ upd_=psb_toupper(upd) + ! !$ else + ! !$ upd_='F' + ! !$ endif + ! !$ else + ! !$ upd_='F' + ! !$ endif + upd_ = 'F' + + if (.not.allocated(p%precv)) then + !! Error: should have called amg_dprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + ! + ! Check to ensure all procs have the same + ! + newsz = -1 + mxplevs = p%ag_data%max_levs + mnaggratio = p%ag_data%min_cr_ratio + casize = p%ag_data%min_coarse_size + iszv = size(p%precv) + nprolv = size(prolv) + nrestrv = size(restrv) + call psb_bcast(ictxt,iszv) + call psb_bcast(ictxt,casize) + call psb_bcast(ictxt,mxplevs) + call psb_bcast(ictxt,mnaggratio) + call psb_bcast(ictxt,nprolv) + call psb_bcast(ictxt,nrestrv) + if (casize /= p%ag_data%min_coarse_size) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent min_coarse_size') + goto 9999 + end if + if (mxplevs /= p%ag_data%max_levs) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent max_levs') + goto 9999 + end if + if (mnaggratio /= p%ag_data%min_cr_ratio) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent min_cr_ratio') + goto 9999 + end if + if (iszv /= size(p%precv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of precv') + goto 9999 + end if + if (nprolv /= size(prolv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of prolv') + goto 9999 + end if + if (nrestrv /= size(restrv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of restrv') + goto 9999 + end if + if (nrestrv /= nprolv) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size prolv vs restrv') + goto 9999 + end if + + if (iszv <= 1) then + ! We should only ever get here for multilevel. + info=psb_err_from_subroutine_ + ch_err='size bpv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + endif + + if (nrestrv < 1) then + ! We should only ever get here for multilevel. + info=psb_err_from_subroutine_ + ch_err='size restrv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + endif + + ! + nplevs = nrestrv + 1 + p%ag_data%max_levs = nplevs + + ! + ! Fixed number of levels. + ! + nplevs = max(itwo,mxplevs) + + coarseparms = p%precv(iszv)%parms + baseparms = p%precv(1)%parms + medparms = p%precv(2)%parms + + allocate(coarse_sm, source=p%precv(iszv)%sm,stat=info) + if (info == psb_success_) & + & allocate(med_sm, source=p%precv(2)%sm,stat=info) + if (info == psb_success_) & + & allocate(base_sm, source=p%precv(1)%sm,stat=info) + if (info /= psb_success_) then + write(0,*) 'Error in saving smoothers',info + call psb_errpush(psb_err_internal_error_,name,a_err='Base level precbuild.') + goto 9999 + end if + + if (iszv /= nplevs) then + allocate(tprecv(nplevs),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + tprecv(1)%parms = baseparms + allocate(tprecv(1)%sm,source=base_sm,stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + do i=2,nplevs-1 + tprecv(i)%parms = medparms + allocate(tprecv(i)%sm,source=med_sm,stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + end do + tprecv(nplevs)%parms = coarseparms + allocate(tprecv(nplevs)%sm,source=coarse_sm,stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + do i=1,iszv + call p%precv(i)%free(info) + end do + call move_alloc(tprecv,p%precv) + iszv = size(p%precv) + end if + ! + ! Finest level first; remember to fix base_a and base_desc + ! + p%precv(1)%base_a => a + p%precv(1)%base_desc => desc_a + newsz = 0 + array_build_loop: do i=2, iszv + + ! + ! Sanity checks on the parameters + ! + if (i p%precv(i)%ac + p%precv(i)%base_desc => p%precv(i)%desc_ac + + + if (i>2) then + if (all(p%precv(i)%map%naggr == p%precv(i-1)%map%naggr)) then + newsz=i-1 + end if + call psb_bcast(ictxt,newsz) + if (newsz > 0) exit array_build_loop + end if + end do array_build_loop + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Internal extprol build' ) + goto 9999 + endif + + iszv = size(p%precv) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Exiting with',iszv,' levels' +#endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + + subroutine amg_d_extaggr_bld(a,desc_a,p,op_restr,op_prol,info) + use psb_base_mod + use amg_d_inner_mod + + implicit none + + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + type(psb_dspmat_type), intent(inout) :: op_restr,op_prol + type(psb_desc_type), intent(in), target :: desc_a + type(amg_d_onelev_type), intent(inout),target :: p + integer(psb_ipk_), intent(out) :: info + + ! Local variables + character(len=20) :: name + integer(psb_mpk_) :: ictxt, np, me, ncol + integer(psb_ipk_) :: err_act,ntaggr,nzl + integer(psb_ipk_), allocatable :: ilaggr(:), nlaggr(:) + type(psb_dspmat_type) :: ac, am2, am3, am4 + type(psb_d_coo_sparse_mat) :: acoo, bcoo + type(psb_d_csr_sparse_mat) :: acsr1 + logical, parameter :: debug=.false. + + name='amg_d_extaggr_bld' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) +#if defined(LPK8) + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Need fix for LPK8') + goto 9999 +#else + allocate(nlaggr(np),ilaggr(1)) + nlaggr = 0 + ilaggr = 0 + p%parms%par_aggr_alg = amg_ext_aggr_ + call amg_check_def(p%parms%ml_cycle,'Multilevel cycle',& + & amg_mult_ml_,is_legal_ml_cycle) + call amg_check_def(p%parms%coarse_mat,'Coarse matrix',& + & amg_distr_mat_,is_legal_ml_coarse_mat) + + nlaggr(me+1) = op_restr%get_nrows() + if (op_restr%get_nrows() /= op_prol%get_ncols()) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent restr/prol sizes') + goto 9999 + end if + call psb_sum(ictxt,nlaggr) + ntaggr = sum(nlaggr) + ncol = desc_a%get_local_cols() + if (debug) write(0,*)me,' Sizes:',op_restr%get_nrows(),op_restr%get_ncols(),& + & op_prol%get_nrows(),op_prol%get_ncols(), a%get_nrows(),a%get_ncols() + ! + ! Compute local part of AC + ! + call op_prol%clone(am2,info) + if (info == psb_success_) call psb_sphalo(am2,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.) + if (info == psb_success_) call psb_rwextd(ncol,am2,info,b=am4) + if (info == psb_success_) call am4%free() + call psb_spspmm(a,am2,am3,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 2') + goto 9999 + end if + call psb_sphalo(am3,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.) + if (info == psb_success_) call psb_rwextd(ncol,am3,info,b=am4) + if (info == psb_success_) call am4%free() + if(info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Extend am3') + goto 9999 + end if + call psb_spspmm(op_restr,am3,ac,info) + if (info == psb_success_) call am3%free() + if (info == psb_success_) call ac%cscnv(info,type='csr',dupl=psb_dupl_add_) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Build ac = op_restr x am3') + goto 9999 + end if + + select case(p%parms%coarse_mat) + + case(amg_distr_mat_) + + call ac%mv_to(bcoo) + nzl = bcoo%get_nzeros() + + if (info == psb_success_) call psb_cdall(ictxt,p%desc_ac,info,nl=nlaggr(me+1)) + if (info == psb_success_) call psb_cdins(nzl,bcoo%ia,bcoo%ja,p%desc_ac,info) + if (info == psb_success_) call psb_cdasb(p%desc_ac,info) + if (info == psb_success_) call psb_glob_to_loc(bcoo%ia(1:nzl),p%desc_ac,info,iact='I') + if (info == psb_success_) call psb_glob_to_loc(bcoo%ja(1:nzl),p%desc_ac,info,iact='I') + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Creating p%desc_ac and converting ac') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Assembld aux descr. distr.' + call p%ac%mv_from(bcoo) + + call p%ac%set_nrows(p%desc_ac%get_local_rows()) + call p%ac%set_ncols(p%desc_ac%get_local_cols()) + call p%ac%set_asb() + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_sp_free') + goto 9999 + end if + + if (np>1) then + call op_prol%mv_to(acsr1) + nzl = acsr1%get_nzeros() + call psb_glob_to_loc(acsr1%ja(1:nzl),p%desc_ac,info,'I') + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_glob_to_loc') + goto 9999 + end if + call op_prol%mv_from(acsr1) + endif + call op_prol%set_ncols(p%desc_ac%get_local_cols()) + + if (np>1) then + call op_restr%cscnv(info,type='coo',dupl=psb_dupl_add_) + call op_restr%mv_to(acoo) + nzl = acoo%get_nzeros() + if (info == psb_success_) call psb_glob_to_loc(acoo%ia(1:nzl),p%desc_ac,info,'I') + call acoo%set_dupl(psb_dupl_add_) + if (info == psb_success_) call op_restr%mv_from(acoo) + if (info == psb_success_) call op_restr%cscnv(info,type='csr') + if(info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Converting op_restr to local') + goto 9999 + end if + end if + call op_restr%set_nrows(p%desc_ac%get_local_cols()) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ac ' + + case(amg_repl_mat_) + ! + ! + call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) + if (info == psb_success_) call psb_cdasb(p%desc_ac,info) + if (info == psb_success_) & + & call psb_gather(p%ac,ac,p%desc_ac,info,dupl=psb_dupl_add_,keeploc=.false.) + + if (info /= psb_success_) goto 9999 + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_coarse_mat_') + goto 9999 + end select + + call p%ac%cscnv(info,type='csr',dupl=psb_dupl_add_) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv') + goto 9999 + end if + + ! + ! Copy the prolongation/restriction matrices into the descriptor map. + ! op_restr => PR^T i.e. restriction operator + ! op_prol => PR i.e. prolongation operator + ! + + p%map = psb_linmap(psb_map_aggr_,desc_a,& + & p%desc_ac,op_restr,op_prol,ilaggr,nlaggr) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_Free') + goto 9999 + end if +#endif + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + end subroutine amg_d_extaggr_bld + +end subroutine amg_d_extprol_bld diff --git a/mlprec/impl/amg_d_hierarchy_bld.f90 b/mlprec/impl/amg_d_hierarchy_bld.f90 new file mode 100644 index 00000000..b12fd316 --- /dev/null +++ b/mlprec/impl/amg_d_hierarchy_bld.f90 @@ -0,0 +1,539 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_d_hierarchy_bld.f90 +! +! Subroutine: amg_d_hierarchy_bld +! Version: real +! +! This routine builds the preconditioner according to the requirements made by +! the user trough the subroutines amg_precinit and amg_precset. +! +! A multilevel preconditioner is regarded as an array of 'one-level' data structures, +! each containing the part of the preconditioner associated to a certain level, +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level. No transfer operators are associated to level 1. +! +! +! Arguments: +! a - type(psb_dspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_dprec_type), input/output. +! The preconditioner data structure; upon exit it contains +! the multilevel hierarchy of prolongators, restrictors +! and coarse matrices. +! info - integer, output. +! Error code. +! +subroutine amg_d_hierarchy_bld(a,desc_a,prec,info) + + use psb_base_mod + use amg_d_inner_mod + use amg_d_prec_mod, amg_protect_name => amg_d_hierarchy_bld + + Implicit None + + ! Arguments + type(psb_dspmat_type),intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_dprec_type),intent(inout),target :: prec + integer(psb_ipk_), intent(out) :: info + + ! Local Variables + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz,& + & nplevs, mxplevs + integer(psb_lpk_) :: iaggsize, casize + real(psb_dpk_) :: mnaggratio, sizeratio, athresh, aomega + class(amg_d_base_smoother_type), allocatable :: coarse_sm, med_sm, & + & med_sm2, coarse_sm2 + class(amg_d_base_aggregator_type), allocatable :: tmp_aggr + type(amg_dml_parms) :: medparms, coarseparms + integer(psb_lpk_), allocatable :: ilaggr(:), nlaggr(:) + type(psb_ldspmat_type) :: op_prol + type(amg_d_onelev_type), allocatable :: tprecv(:) + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + integer(psb_ipk_), save :: idx_bldtp=-1, idx_matasb=-1 + logical, parameter :: do_timings=.false. + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_d_hierarchy_bld' + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + prec%ictxt = ictxt + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' + if ((do_timings).and.(idx_bldtp==-1)) & + & idx_bldtp = psb_get_timer_idx("BLD_HIER: bld_tprol") + if ((do_timings).and.(idx_matasb==-1)) & + & idx_matasb = psb_get_timer_idx("BLD_HIER: mmat_asb") + ! + + if (.not.allocated(prec%precv)) then + !! Error: should have called amg_dprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + ! + ! Check to ensure all procs have the same + ! + newsz = -1 + mxplevs = prec%ag_data%max_levs + mnaggratio = prec%ag_data%min_cr_ratio + casize = prec%ag_data%min_coarse_size + iszv = size(prec%precv) + call psb_bcast(ictxt,iszv) + call psb_bcast(ictxt,casize) + call psb_bcast(ictxt,mxplevs) + call psb_bcast(ictxt,mnaggratio) + if (casize /= prec%ag_data%min_coarse_size) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent min_coarse_size') + goto 9999 + end if + if (mxplevs /= prec%ag_data%max_levs) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent max_levs') + goto 9999 + end if + if (mnaggratio /= prec%ag_data%min_cr_ratio) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent min_cr_ratio') + goto 9999 + end if + if (iszv /= size(prec%precv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of precv') + goto 9999 + end if + + if (iszv < 1) then + ! + ! This is wrong, cannot be size <1 + ! + info=psb_err_from_subroutine_ + ch_err='size bpv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + endif + if (iszv == 1) then + ! + ! This is OK, since it may be called by the user even if there + ! is only one level + ! + prec%precv(1)%base_a => a + prec%precv(1)%base_desc => desc_a + + call psb_erractionrestore(err_act) + return + endif + + ! + ! The strategy: + ! 1. The maximum number of levels should be already encoded in the + ! size of the array; + ! 2. If the user did not specify anything, then a default coarse size + ! is generated, and the number of levels is set to the maximum; + ! 3. If the size of the array is different from target number of levels, + ! reallocate; + ! 4. Build the matrix hierarchy, stopping early if either the target + ! coarse size is hit, or the gain falls below the min_cr_ratio + ! threshold. + ! + + if (casize < 0) then + ! + ! Default to the cubic root of the size at base level. + ! + casize = desc_a%get_global_rows() + casize = int((done*casize)**(done/(done*3)),psb_lpk_) + casize = max(casize,lone) + casize = casize*40_psb_lpk_ + call psb_bcast(ictxt,casize) + if (casize > huge(prec%ag_data%min_coarse_size)) then + ! + ! computed coarse size does not fit in IPK_. + ! This is very unlikely, but make sure to put a positive number + ! + prec%ag_data%min_coarse_size = huge(prec%ag_data%min_coarse_size) + else + prec%ag_data%min_coarse_size = casize + end if + end if + nplevs = max(itwo,mxplevs) + + ! + ! The coarse parameters will be needed later + ! + coarseparms = prec%precv(iszv)%parms + call save_smoothers(prec%precv(iszv),coarse_sm,coarse_sm2,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Base level precbuild.') + goto 9999 + end if + ! + ! First set desired number of levels + ! + if (iszv /= nplevs) then + allocate(tprecv(nplevs),stat=info) + ! First all existing levels + do i=1, min(iszv,nplevs) - 1 + if (info == 0) tprecv(i)%parms = prec%precv(i)%parms + if (info == 0) call restore_smoothers(tprecv(i),& + & prec%precv(i)%sm,prec%precv(i)%sm2a,info) + if (info == 0) call move_alloc(prec%precv(i)%aggr,tprecv(i)%aggr) + end do + if (iszv < nplevs) then + ! Further intermediates, if needed + allocate(tmp_aggr,source=tprecv(iszv-1)%aggr,stat=info) + medparms = prec%precv(iszv-1)%parms + call save_smoothers(prec%precv(iszv-1),med_sm,med_sm2,info) + do i=iszv, nplevs - 1 + if (info == 0) tprecv(i)%parms = medparms + if (info == 0) call restore_smoothers(tprecv(i),med_sm,med_sm2,info) + if ((info == 0).and..not.allocated(tprecv(i)%aggr))& + & allocate(tprecv(i)%aggr,source=tmp_aggr,stat=info) + end do + deallocate(tmp_aggr,stat=info) + end if + + ! Then coarse + if (info == 0) tprecv(nplevs)%parms = coarseparms + if (info == 0) call restore_smoothers(tprecv(nplevs),coarse_sm,coarse_sm2,info) + if (info == 0) then + if (nplevs <= iszv) then + allocate(tprecv(nplevs)%aggr,source=prec%precv(nplevs)%aggr,stat=info) + else + allocate(tmp_aggr,source=tprecv(nplevs-1)%aggr,stat=info) + call move_alloc(tmp_aggr,tprecv(nplevs)%aggr) + end if + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + + do i=1,iszv + call prec%precv(i)%free(info) + end do + call move_alloc(tprecv,prec%precv) + iszv = size(prec%precv) + end if + + ! + ! Finest level first; create a GEN_BLOCK + ! copy of the descriptor. + ! + prec%precv(1)%base_a => a + call psb_cd_renum_block(desc_a,prec%precv(1)%desc_ac,info) + prec%precv(1)%base_desc => prec%precv(1)%desc_ac + newsz = 0 + array_build_loop: do i=2, iszv + ! + ! Check on the iprcparm contents: they should be the same + ! on all processes. + ! + call psb_bcast(ictxt,prec%precv(i)%parms) + + ! + ! Sanity checks on the parameters + ! + if (i= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Calling mlprcbld at level ',i + ! + ! Build the mapping between levels i-1 and i and the matrix + ! at level i + ! + if (do_timings) call psb_tic(idx_bldtp) + if (info == psb_success_)& + & call prec%precv(i)%bld_tprol(prec%precv(i-1)%base_a,& + & prec%precv(i-1)%base_desc,& + & ilaggr,nlaggr,op_prol,prec%ag_data,info) + if (do_timings) call psb_toc(idx_bldtp) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Map build') + goto 9999 + endif + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Return from ',i,' call to bld_tprol', info + ! + ! Save op_prol just in case + ! + call op_prol%clone(prec%precv(i)%tprol,info) + ! + ! Check for early termination of aggregation loop. + ! + iaggsize = sum(nlaggr) + + sizeratio = iaggsize + if (i==2) then + sizeratio = desc_a%get_global_rows()/sizeratio + else + sizeratio = sum(prec%precv(i-1)%map%naggr)/sizeratio + end if + prec%precv(i)%szratio = sizeratio + + if (iaggsize <= casize) newsz = i + if (i == iszv) newsz = i + + if (i>2) then + if (sizeratio < mnaggratio) then + if (sizeratio > 1) then + newsz = i + else + ! + ! We are not gaining + ! + newsz = i-1 + end if + end if + + if (all(nlaggr == prec%precv(i-1)%map%naggr)) then + newsz=i-1 + if (me == 0) then + write(debug_unit,*) trim(name),& + &': Warning: aggregates from level ',& + & newsz + write(debug_unit,*) trim(name),& + &': to level ',& + & iszv,' coincide.' + write(debug_unit,*) trim(name),& + &': Number of levels actually used :',newsz + write(debug_unit,*) + end if + end if + end if + call psb_bcast(ictxt,newsz) + + if (newsz > 0) then + ! + ! This is awkward, we are saving the aggregation parms, for the sake + ! of distr/repl matrix at coarse level. Should be rethought. + ! + athresh = prec%precv(newsz)%parms%aggr_thresh + aomega = prec%precv(newsz)%parms%aggr_omega_val + if (info == 0) prec%precv(newsz)%parms = coarseparms + prec%precv(newsz)%parms%aggr_thresh = athresh + prec%precv(newsz)%parms%aggr_omega_val = aomega + + if (info == 0) call restore_smoothers(prec%precv(newsz),& + & coarse_sm,coarse_sm2,info) + if (newsz < i) then + ! + ! We are going back and revisit a previous leve; + ! recover the aggregation. + ! + ilaggr = prec%precv(newsz)%map%iaggr + nlaggr = prec%precv(newsz)%map%naggr + call prec%precv(newsz)%tprol%clone(op_prol,info) + end if + if (do_timings) call psb_tic(idx_matasb) + if (info == psb_success_) call prec%precv(newsz)%mat_asb( & + & prec%precv(newsz-1)%base_a,prec%precv(newsz-1)%base_desc,& + & ilaggr,nlaggr,op_prol,info) + if (do_timings) call psb_toc(idx_matasb) + if (info /= 0) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Mat asb') + goto 9999 + endif + exit array_build_loop + else + if (do_timings) call psb_tic(idx_matasb) + if (info == psb_success_) call prec%precv(i)%mat_asb(& + & prec%precv(i-1)%base_a,prec%precv(i-1)%base_desc,& + & ilaggr,nlaggr,op_prol,info) + if (do_timings) call psb_toc(idx_matasb) + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Map build') + goto 9999 + endif + if (i 0) then + ! + ! We exited early from the build loop, need to fix + ! the size. + ! + allocate(tprecv(newsz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + do i=1,newsz + call prec%precv(i)%move_alloc(tprecv(i),info) + end do + do i=newsz+1, iszv + call prec%precv(i)%free(info) + end do + call move_alloc(tprecv,prec%precv) + ! Ignore errors from transfer + info = psb_success_ + ! + ! Restart + iszv = newsz + ! Fix the pointers, but the level 1 should + ! be treated differently + if (.not.associated(prec%precv(1)%base_desc,desc_a)) then + prec%precv(1)%base_desc => prec%precv(1)%desc_ac + end if + do i=2, iszv + prec%precv(i)%base_a => prec%precv(i)%ac + prec%precv(i)%base_desc => prec%precv(i)%desc_ac + prec%precv(i)%map%p_desc_U => prec%precv(i-1)%base_desc + prec%precv(i)%map%p_desc_V => prec%precv(i)%base_desc + end do + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Internal hierarchy build' ) + goto 9999 + endif + + iszv = size(prec%precv) + + call prec%cmp_complexity() + call prec%cmp_avg_cr() + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Exiting with',iszv,' levels' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + subroutine save_smoothers(level,save1, save2,info) + type(amg_d_onelev_type), intent(inout) :: level + class(amg_d_base_smoother_type), allocatable , intent(inout) :: save1, save2 + integer(psb_ipk_), intent(out) :: info + + info = 0 + if (allocated(save1)) then + call save1%free(info) + if (info == 0) deallocate(save1,stat=info) + if (info /= 0) return + end if + if (allocated(save2)) then + call save2%free(info) + if (info == 0) deallocate(save2,stat=info) + if (info /= 0) return + end if + allocate(save1, mold=level%sm,stat=info) + if (info == 0) call level%sm%clone_settings(save1,info) + if ((info == 0).and.allocated(level%sm2a)) then + allocate(save2, mold=level%sm2a,stat=info) + if (info == 0) call level%sm2a%clone_settings(save2,info) + end if + + return + end subroutine save_smoothers + + subroutine restore_smoothers(level,save1, save2,info) + type(amg_d_onelev_type), intent(inout), target :: level + class(amg_d_base_smoother_type), allocatable, intent(inout) :: save1, save2 + integer(psb_ipk_), intent(out) :: info + + info = 0 + + if (allocated(level%sm)) then + if (info == 0) call level%sm%free(info) + if (info == 0) deallocate(level%sm,stat=info) + end if + if (allocated(save1)) then + if (info == 0) allocate(level%sm,mold=save1,stat=info) + if (info == 0) call save1%clone_settings(level%sm,info) + end if + + if (info /= 0) return + + if (allocated(level%sm2a)) then + if (info == 0) call level%sm2a%free(info) + if (info == 0) deallocate(level%sm2a,stat=info) + end if + if (allocated(save2)) then + if (info == 0) allocate(level%sm2a,mold=save2,stat=info) + if (info == 0) call save2%clone_settings(level%sm2a,info) + if (info == 0) level%sm2 => level%sm2a + else + if (allocated(level%sm)) level%sm2 => level%sm + end if + + return + end subroutine restore_smoothers + +end subroutine amg_d_hierarchy_bld diff --git a/mlprec/impl/amg_d_smoothers_bld.f90 b/mlprec/impl/amg_d_smoothers_bld.f90 new file mode 100644 index 00000000..132b2e01 --- /dev/null +++ b/mlprec/impl/amg_d_smoothers_bld.f90 @@ -0,0 +1,313 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_d_smoothers_bld.f90 +! +! Subroutine: amg_d_smoothers_bld +! Version: real +! +! This routine performs the final phase of the multilevel preconditioner +! build process: builds the "smoother" objects at each level, +! based on the matrix hierarchy prepared by amg_d_hierarchy_bld. +! +! A multilevel preconditioner is regarded as an array of 'one-level' +! data structures, each containing the part of the +! preconditioner associated to a certain level, +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level. No transfer operators are associated to level 1. +! Each level provides a "build" method; for the base type, the "one-level" +! build procedure simply invokes the build method of the first smoother object, +! and also on the second object if allocated. +! +! +! Arguments: +! a - type(psb_dspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_dprec_type), input/output. +! The preconditioner data structure containing the local part +! of the preconditioner to be built. +! info - integer, output. +! Error code. +! +! amold - class(psb_d_base_sparse_mat), input, optional +! Mold for the inner format of matrices contained in the +! preconditioner +! +! +! vmold - class(psb_d_base_vect_type), input, optional +! Mold for the inner format of vectors contained in the +! preconditioner +! +! +! +subroutine amg_d_smoothers_bld(a,desc_a,prec,info,amold,vmold,imold) + + use psb_base_mod + !use amg_d_inner_mod + use amg_d_prec_mod, amg_protect_name => amg_d_smoothers_bld + + Implicit None + + ! Arguments + type(psb_dspmat_type),intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_dprec_type),intent(inout),target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local Variables + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, nplevs, mxplevs + real(psb_dpk_) :: mnaggratio + integer(psb_ipk_) :: coarse_solve_id + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_d_smoothers_bld' + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' + ! + if (.not.allocated(prec%precv)) then + !! Error: should have called amg_dprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + ! + ! Check to ensure all procs have the same + ! + iszv = size(prec%precv) + call psb_bcast(ictxt,iszv) + if (iszv /= size(prec%precv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of precv') + goto 9999 + end if + + if (iszv < 1) then + ! We should never get here. + info=psb_err_from_subroutine_ + ch_err='size bpv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + endif + + ! + ! Issue a warning for inconsistent changes to COARSE_SOLVE + ! but only if it really is a multilevel + ! + if ((me == psb_root_).and.(iszv>1)) then + coarse_solve_id = prec%precv(iszv)%parms%coarse_solve + select case (coarse_solve_id) + case(amg_umf_,amg_slu_) + if (prec%precv(iszv)%sm%sv%get_id() /= coarse_solve_id) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id) + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) then + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else if (prec%precv(iszv)%parms%coarse_mat == amg_distr_mat_) then + write(psb_err_unit,*) ' but I am building BJAC with ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + end if + write(psb_err_unit,*) 'This may happen if: ' + write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' + write(psb_err_unit,*) ' 2. the solver ', amg_fact_names(coarse_solve_id),& + & ' was not configured at MLD2P4 build time, or' + write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' + end if + if (prec%precv(iszv)%parms%coarse_mat /= amg_repl_mat_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse matrix was requested as replicated', & + & ' but it has been changed to distributed.' + end if + + case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) + if (prec%precv(iszv)%sm%sv%get_id() /= psb_ilu_n_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id) + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) then + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else if (prec%precv(iszv)%parms%coarse_mat == amg_distr_mat_) then + write(psb_err_unit,*) ' but I am building BJAC with ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + end if + write(psb_err_unit,*) & + &'This may happen if coarse_subsolve has been reset' + end if + if (prec%precv(iszv)%parms%coarse_mat /= amg_repl_mat_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id),& + & ' but the coarse matrix has been changed to distributed' + end if + + case(amg_mumps_) + if (prec%precv(iszv)%sm%sv%get_id() /= amg_mumps_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id) + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) then + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else if (prec%precv(iszv)%parms%coarse_mat == amg_distr_mat_) then + write(psb_err_unit,*) ' but I am building BJAC with ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + end if + write(psb_err_unit,*) 'This may happen if: ' + write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' + write(psb_err_unit,*) ' 2. the solver ', amg_fact_names(coarse_solve_id),& + & ' was not configured at MLD2P4 build time, or' + write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' + end if + + case(amg_sludist_) + if (prec%precv(iszv)%sm%sv%get_id() /= coarse_solve_id) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id) + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) then + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else if (prec%precv(iszv)%parms%coarse_mat == amg_distr_mat_) then + write(psb_err_unit,*) ' but I am building BJAC with ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + end if + write(psb_err_unit,*) 'This may happen if: ' + write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' + write(psb_err_unit,*) ' 2. the solver ', amg_fact_names(coarse_solve_id), & + & ' was not configured at MLD2P4 build time, or' + write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' + end if + if (prec%precv(iszv)%parms%coarse_mat /= amg_distr_mat_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id),& + & ' but the coarse matrix has been changed to replicated' + end if + + case(amg_bjac_,amg_l1_bjac_,amg_jac_, amg_l1_jac_, amg_gs_, amg_fbgs_, amg_l1_gs_,amg_l1_fbgs_) + if (prec%precv(iszv)%parms%coarse_mat /= amg_distr_mat_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id),& + & ' but the coarse matrix has been changed to replicated' + end if + + case default + ! We should never get here. + info=psb_err_from_subroutine_ + ch_err='unkn coarse_solve' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + + end select + end if + + ! Sanity check: need to ensure that the MUMPS local/global NZ + ! are handled correctly; this is controlled by local vs global solver. + ! From this point of view, REPL is LOCAL because it owns everyting. + ! Should really find a better way of handling this. + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) & + & call prec%precv(iszv)%sm%sv%set('MUMPS_LOC_GLOB', amg_local_solver_,info) + ! + ! Now do the real build. + ! + + do i=1, iszv + ! + ! build the base preconditioner at level i + ! + call prec%precv(i)%bld(info,amold=amold,vmold=vmold,imold=imold,ilv=i) + + if (info /= psb_success_) then + write(ch_err,'(a,i7)') 'Error @ level',i + call psb_errpush(psb_err_internal_error_,name,& + & a_err=ch_err) + goto 9999 + endif + + end do + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Exiting with',iszv,' levels' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_smoothers_bld diff --git a/mlprec/impl/amg_dcprecset.F90 b/mlprec/impl/amg_dcprecset.F90 new file mode 100644 index 00000000..50157220 --- /dev/null +++ b/mlprec/impl/amg_dcprecset.F90 @@ -0,0 +1,1038 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_dprecset.f90 +! +! Subroutine: amg_dprecseti +! Version: real +! +! This routine sets the integer parameters defining the preconditioner. More +! precisely, the integer parameter identified by 'what' is assigned the value +! contained in 'val'. +! For the multilevel preconditioners, the levels are numbered in increasing +! order starting from the finest one, i.e. level 1 is the finest level. +! +! To set character and real parameters, see amg_dprecsetc and amg_dprecsetr, +! respectively. +! +! +! Arguments: +! p - type(amg_dprec_type), input/output. +! The preconditioner data structure. +! what - integer, input. +! The number identifying the parameter to be set. +! A mnemonic constant has been associated to each of these +! numbers, as reported in the MLD2P4 User's and Reference Guide. +! val - integer, input. +! The value of the parameter to be set. The list of allowed +! values is reported in the MLD2P4 User's and Reference Guide. +! info - integer, output. +! Error code. +! ilev - integer, optional, input. +! For the multilevel preconditioner, the level at which the +! preconditioner parameter has to be set. +! If nlev is not present, the parameter identified by 'what' +! is set at all the appropriate levels. +! +! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to +! MLD2P4 developers. Indeed, by using ilev it is possible to set different values +! of the same parameter at different levels 1,...,nlev-1, even in cases where +! the parameter must have the same value at all the levels but the coarsest one. +! For this reason, the interface amg_precset to this routine has been built in +! such a way that ilev is not visible to the user (see amg_prec_mod.f90). +! +subroutine amg_dcprecseti(p,what,val,info,ilev,ilmax,pos,idx) + + use psb_base_mod + use amg_d_prec_mod, amg_protect_name => amg_dcprecseti + use amg_d_jac_smoother + use amg_d_as_smoother + use amg_d_diag_solver + use amg_d_l1_diag_solver + use amg_d_ilu_solver + use amg_d_id_solver + use amg_d_gs_solver +#if defined(HAVE_UMF_) + use amg_d_umf_solver +#endif +#if defined(HAVE_SLUDIST_) + use amg_d_sludist_solver +#endif +#if defined(HAVE_SLU_) + use amg_d_slu_solver +#endif +#if defined(HAVE_MUMPS_) + use amg_d_mumps_solver +#endif + + + implicit none + + ! Arguments + class(amg_dprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_, ilmax_, il + character(len=*), parameter :: name='amg_precseti' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmax_ = nlev_ + end if + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + select case(psb_toupper(what)) + case ('MIN_COARSE_SIZE') + p%ag_data%min_coarse_size = max(val,-1) + return + case('MAX_LEVS') + p%ag_data%max_levs = max(val,1) + return + case ('OUTER_SWEEPS') + p%outer_sweeps = max(val,1) + return + end select + + ! + ! Set preconditioner parameters at level ilev. + ! + if (present(ilev)) then + + select case(psb_toupper(what)) + case('SMOOTHER_TYPE','SUB_SOLVE','SMOOTHER_SWEEPS',& + & 'ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD',& + & 'AGGR_TYPE','AGGR_PROL','AGGR_OMEGA_ALG',& + & 'AGGR_EIG','SUB_RESTR','SUB_PROL', & + & 'SUB_OVR','SUB_FILLIN',& + & 'COARSE_MAT') + do il=ilev_, ilmax_ + call p%precv(il)%set(what,val,info,pos=pos) + end do + + case('COARSE_SUBSOLVE') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + call p%precv(ilev_)%set('SUB_SOLVE',val,info,pos=pos) + case('COARSE_SOLVE') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_SOLVE',val,info,pos=pos) + select case (val) + case(amg_bjac_,amg_l1_bjac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',val,info,pos=pos) +#if defined(HAVE_UMF_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_umf_,info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) +#else + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) +#endif + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info) + case(amg_slu_) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) + case(amg_mumps_) +#if defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(amg_umf_) +#if defined(HAVE_UMF_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + + case(amg_sludist_) +#if defined(HAVE_SLUDIST_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#elif defined(HAVE_UMF_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_umf_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(amg_jac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_diag_scale_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + + case(amg_l1_jac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_l1_diag_scale_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_gs_,amg_fbgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_gs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_bwgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_bwgs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_l1_gs_,amg_l1_fbgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_l1_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_gs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + end select + + endif + case('COARSE_SWEEPS') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + call p%precv(nlev_)%set('SMOOTHER_SWEEPS',val,info,pos=pos) + + case('COARSE_FILLIN') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + call p%precv(nlev_)%set('SUB_FILLIN',val,info,pos=pos) + + case default + do il=ilev_, ilmax_ + call p%precv(il)%set(what,val,info,pos=pos,idx=idx) + end do + end select + + + else if (.not.present(ilev)) then + ! + ! ilev not specified: set preconditioner parameters at all the appropriate + ! levels + ! + select case(psb_toupper(trim(what))) + case('SUB_SOLVE','SUB_RESTR','SUB_PROL',& + & 'SUB_OVR','SUB_FILLIN',& + & 'SMOOTHER_SWEEPS','SMOOTHER_TYPE') + do ilev_=1,max(1,nlev_-1) + call p%precv(ilev_)%set(what,val,info,pos=pos) + if (info /= 0) return + end do + + case('ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD','AGGR_PROL','AGGR_TYPE',& + & 'AGGR_OMEGA_ALG','AGGR_EIG','AGGR_FILTER') + do ilev_=1,nlev_ + call p%precv(ilev_)%set(what,val,info,pos=pos) + if (info /= 0) return + end do + + case('COARSE_MAT') + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_MAT',val,info,pos=pos) + end if + + case('COARSE_SOLVE') + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_SOLVE',val,info,pos=pos) + select case (val) + case(amg_bjac_,amg_l1_bjac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',val,info,pos=pos) +#if defined(HAVE_UMF_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_umf_,info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) +#else + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) +#endif + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info) + case(amg_slu_) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) + case(amg_mumps_) +#if defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(amg_umf_) +#if defined(HAVE_UMF_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + + case(amg_sludist_) +#if defined(HAVE_SLUDIST_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#elif defined(HAVE_UMF_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_umf_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(amg_jac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_diag_scale_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + + case(amg_l1_jac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_l1_diag_scale_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_gs_,amg_fbgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_gs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_bwgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_bwgs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_l1_gs_,amg_l1_fbgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_l1_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_gs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + end select + endif + + case('COARSE_SUBSOLVE') + if (nlev_ > 1) then + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + endif + + case('COARSE_SWEEPS') + + if (nlev_ > 1) then + call p%precv(nlev_)%set('SMOOTHER_SWEEPS',val,info,pos=pos) + end if + + case('COARSE_FILLIN') + if (nlev_ > 1) then + call p%precv(nlev_)%set('SUB_FILLIN',val,info,pos=pos) + end if + + case default + do ilev_=1,nlev_ + call p%precv(ilev_)%set(what,val,info,pos=pos,idx=idx) + end do + end select + + endif + +end subroutine amg_dcprecseti + +! +! Subroutine: amg_dprecsetc +! Version: real +! +! This routine sets the character parameters defining the preconditioner. More +! precisely, the character parameter identified by 'what' is assigned the value +! contained in 'val'. +! For the multilevel preconditioners, the levels are numbered in increasing +! order starting from the finest one, i.e. level 1 is the finest level. +! +! To set integer and real parameters, see amg_dprecseti and amg_dprecsetr, +! respectively. +! +! +! Arguments: +! p - type(amg_dprec_type), input/output. +! The preconditioner data structure. +! what - integer, input. +! The number identifying the parameter to be set. +! A mnemonic constant has been associated to each of these +! numbers, as reported in the MLD2P4 User's and Reference Guide. +! string - character(len=*), input. +! The value of the parameter to be set. The list of allowed +! values is reported in the MLD2P4 User's and Reference Guide. +! info - integer, output. +! Error code. +! ilev - integer, optional, input. +! For the multilevel preconditioner, the level at which the +! preconditioner parameter has to be set. +! If nlev is not present, the parameter identified by 'what' +! is set at all the appropriate levels. +! +! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to +! MLD2P4 developers. Indeed, by using ilev it is possible to set different values +! of the same parameter at different levels 1,...,nlev-1, even in cases where +! the parameter must have the same value at all the levels but the coarsest one. +! For this reason, the interface amg_precset to this routine has been built in +! such a way that ilev is not visible to the user (see amg_prec_mod.f90). +! +subroutine amg_dcprecsetc(p,what,string,info,ilev,ilmax,pos,idx) + + use psb_base_mod + use amg_d_prec_mod, amg_protect_name => amg_dcprecsetc + use amg_d_jac_smoother + use amg_d_as_smoother + use amg_d_diag_solver + use amg_d_l1_diag_solver + use amg_d_ilu_solver + use amg_d_id_solver + use amg_d_gs_solver +#if defined(HAVE_UMF_) + use amg_d_umf_solver +#endif +#if defined(HAVE_SLUDIST_) + use amg_d_sludist_solver +#endif +#if defined(HAVE_SLU_) + use amg_d_slu_solver +#endif +#if defined(HAVE_MUMPS_) + use amg_d_mumps_solver +#endif + + + implicit none + + ! Arguments + class(amg_dprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + character(len=*), intent(in) :: string + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_,val,ilmax_, il + character(len=*), parameter :: name='amg_precsetc' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmax_ = nlev_ + end if + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + ! + ! Set preconditioner parameters at level ilev. + ! + if (present(ilev)) then + + select case(psb_toupper(what)) + case('SMOOTHER_TYPE','SUB_SOLVE',& + & 'ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD',& + & 'AGGR_TYPE','AGGR_PROL','AGGR_OMEGA_ALG',& + & 'AGGR_EIG','SUB_RESTR','SUB_PROL', & + & 'COARSE_MAT') + do il=ilev_, ilmax_ + call p%precv(il)%set(what,string,info,pos=pos) + end do + + case('COARSE_SUBSOLVE') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + call p%precv(ilev_)%set('SUB_SOLVE',string,info,pos=pos) + case('COARSE_SOLVE') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_SOLVE',string,info,pos=pos) + select case (psb_toupper(trim(string))) + case('BJAC', 'L1-BJAC') + call p%precv(nlev_)%set('SMOOTHER_TYPE',psb_toupper(trim(string)),info,pos=pos) +#if defined(HAVE_UMF_) + call p%precv(nlev_)%set('SUB_SOLVE','UMF',info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) +#else + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) +#endif + call p%precv(nlev_)%set('COARSE_MAT','dist',info) + case('SLU') +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('ILU','MILU','ILUT') + call p%precv(nlev_)%set('SMOOTHER_TYPE','bjac',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) + case('MUMPS') +#if defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('UMF') +#if defined(HAVE_UMF_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('SLUDIST') +#if defined(HAVE_SLUDIST_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#elif defined(HAVE_UMF_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','UMF',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('JAC','JACOBI') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','DIAG',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + + case('L1-JACOBI') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','L1-DIAG',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('GS','FWGS','FBGS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('BWGS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','BWGS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('L1-GS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','L1-BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + end select + + endif + + case default + do il=ilev_, ilmax_ + call p%precv(il)%set(what,string,info,pos=pos,idx=idx) + end do + end select + + + else if (.not.present(ilev)) then + ! + ! ilev not specified: set preconditioner parameters at all the appropriate + ! levels + ! + select case(psb_toupper(trim(what))) + case('SUB_SOLVE','SUB_RESTR','SUB_PROL',& + & 'SMOOTHER_TYPE') + do ilev_=1,max(1,nlev_-1) + call p%precv(ilev_)%set(what,string,info,pos=pos) + if (info /= 0) return + end do + + case('ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD','AGGR_PROL','AGGR_TYPE',& + & 'AGGR_OMEGA_ALG','AGGR_EIG','AGGR_FILTER') + do ilev_=1,nlev_ + call p%precv(ilev_)%set(what,string,info,pos=pos) + if (info /= 0) return + end do + + case('COARSE_MAT') + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_MAT',string,info,pos=pos) + end if + + case('COARSE_SOLVE') + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_SOLVE',string,info,pos=pos) + select case (psb_toupper(trim(string))) + case('BJAC', 'L1-BJAC') + call p%precv(nlev_)%set('SMOOTHER_TYPE',psb_toupper(trim(string)),info,pos=pos) +#if defined(HAVE_UMF_) + call p%precv(nlev_)%set('SUB_SOLVE','UMF',info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) +#else + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) +#endif + call p%precv(nlev_)%set('COARSE_MAT','DIST',info) + case('SLU') +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('ILU', 'ILUT','MILU') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) + case('MUMPS') +#if defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('UMF') +#if defined(HAVE_UMF_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + + case('SLUDIST') +#if defined(HAVE_SLUDIST_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#elif defined(HAVE_UMF_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','UMF',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('JAC','JACOBI') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','DIAG',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('L1-JACOBI') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','L1-DIAG',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('GS','FWGS','FBGS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('BWGS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','BWGS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('L1-GS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','L1-BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + end select + endif + + case('COARSE_SUBSOLVE') + if (nlev_ > 1) then + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + endif + + case default + do ilev_=1,nlev_ + call p%precv(ilev_)%set(what,string,info,pos=pos,idx=idx) + end do + end select + + endif + + +end subroutine amg_dcprecsetc + + +! +! Subroutine: amg_dprecsetr +! Version: real +! +! This routine sets the real parameters defining the preconditioner. More +! precisely, the real parameter identified by 'what' is assigned the value +! contained in 'val'. +! For the multilevel preconditioners, the levels are numbered in increasing +! order starting from the finest one, i.e. level 1 is the finest level. +! +! To set integer and character parameters, see amg_dprecseti and amg_dprecsetc, +! respectively. +! +! Arguments: +! p - type(amg_dprec_type), input/output. +! The preconditioner data structure. +! what - integer, input. +! The number identifying the parameter to be set. +! A mnemonic constant has been associated to each of these +! numbers, as reported in the MLD2P4 User's and Reference Guide. +! val - real(psb_dpk_), input. +! The value of the parameter to be set. The list of allowed +! values is reported in the MLD2P4 User's and Reference Guide. +! info - integer, output. +! Error code. +! ilev - integer, optional, input. +! For the multilevel preconditioner, the level at which the +! preconditioner parameter has to be set. +! If nlev is not present, the parameter identified by 'what' +! is set at all the appropriate levels. +! +! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to +! MLD2P4 developers. Indeed, by using ilev it is possible to set different values +! of the same parameter at different levels 1,...,nlev-1, even in cases where +! the parameter must have the same value at all the levels but the coarsest one. +! For this reason, the interface amg_precset to this routine has been built in +! such a way that ilev is not visible to the user (see amg_prec_mod.f90). +! +subroutine amg_dcprecsetr(p,what,val,info,ilev,ilmax,pos,idx) + + use psb_base_mod + use amg_d_prec_mod, amg_protect_name => amg_dcprecsetr + + implicit none + + ! Arguments + class(amg_dprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + + ! Local variables + integer(psb_ipk_) :: ilev_,nlev_, ilmax_, il + real(psb_dpk_) :: thr + character(len=*), parameter :: name='amg_precsetr' + + info = psb_success_ + + if (present(ilev)) then + ilev_ = ilev + else + ilev_ = 1 + end if + + select case(psb_toupper(what)) + case ('MIN_CR_RATIO') + p%ag_data%min_cr_ratio = max(done,val) + return + end select + + if (.not.allocated(p%precv)) then + write(psb_err_unit,*) name,& + &': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + info = 3111 + return + endif + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmax_ = nlev_ + end if + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + + ! + ! Set preconditioner parameters at level ilev. + ! + if (present(ilev)) then + + do il=ilev_, ilmax_ + call p%precv(il)%set(what,val,info,pos=pos,idx=idx) + end do + + else if (.not.present(ilev)) then + ! + ! ilev not specified: set preconditioner parameters at all the appropriate levels + ! + + select case(psb_toupper(what)) + case('COARSE_ILUTHRS') + ilev_=nlev_ + call p%precv(ilev_)%set('SUB_ILUTHRS',val,info,pos=pos) + + case default + + do il=1,nlev_ + call p%precv(il)%set(what,val,info,pos=pos,idx=idx) + end do + end select + + endif + +end subroutine amg_dcprecsetr + + diff --git a/mlprec/impl/amg_dfile_prec_descr.f90 b/mlprec/impl/amg_dfile_prec_descr.f90 new file mode 100644 index 00000000..7a65d172 --- /dev/null +++ b/mlprec/impl/amg_dfile_prec_descr.f90 @@ -0,0 +1,199 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_dfile_prec_descr.f90 +! +! +! Subroutine: amg_file_prec_descr +! Version: real +! +! This routine prints a description of the preconditioner to the standard +! output or to a file. It must be called after the preconditioner has been +! built by amg_precbld. +! +! Arguments: +! p - type(amg_Tprec_type), input. +! The preconditioner data structure to be printed out. +! info - integer, output. +! error code. +! iout - integer, input, optional. +! The id of the file where the preconditioner description +! will be printed. If iout is not present, then the standard +! output is condidered. +! root - integer, input, optional. +! The id of the process printing the message; -1 acts as a wildcard. +! Default is psb_root_ +! +subroutine amg_dfile_prec_descr(prec,iout,root) + use psb_base_mod + use amg_d_prec_mod, amg_protect_name => amg_dfile_prec_descr + use amg_d_inner_mod + use amg_d_gs_solver + + implicit none + ! Arguments + class(amg_dprec_type), intent(in) :: prec + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: root + + ! Local variables + integer(psb_ipk_) :: ilev, nlev, ilmin, info, nswps + integer(psb_ipk_) :: ictxt, me, np + logical :: is_symgs + character(len=20), parameter :: name='amg_file_prec_descr' + integer(psb_ipk_) :: iout_ + integer(psb_ipk_) :: root_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + if (iout_ < 0) iout_ = psb_out_unit + + ictxt = prec%ictxt + + if (allocated(prec%precv)) then + + call psb_info(ictxt,me,np) + if (present(root)) then + root_ = root + else + root_ = psb_root_ + end if + if (root_ == -1) root_ = me + + ! + ! The preconditioner description is printed by processor psb_root_. + ! This agrees with the fact that all the parameters defining the + ! preconditioner have the same values on all the procs (this is + ! ensured by amg_precbld). + ! + if (me == root_) then + nlev = size(prec%precv) + do ilev = 1, nlev + if (.not.allocated(prec%precv(ilev)%sm)) then + info = 3111 + write(iout_,*) ' ',name,& + & ': error: inconsistent MLPREC part, should call amg_PRECINIT' + return + endif + end do + + write(iout_,*) + write(iout_,'(a)') 'Preconditioner description' + + if (nlev == 1) then + ! + ! Here we have a gigantic kludge just to handle Symmetrized Gauss-Seidel. + ! Will need rethinking... + ! + if (allocated(prec%precv(1)%sm2a)) then + is_symgs = .false. + select type(sv2 => prec%precv(1)%sm2a%sv) + class is (amg_d_bwgs_solver_type) + select type(sv1 => prec%precv(1)%sm%sv) + class is (amg_d_gs_solver_type) + is_symgs = .true. + end select + end select + if (is_symgs) then + write(iout_,*) ' Forward-Backward (symmetrized) Hybrid Gauss-Seidel' + else + write(iout_,*) 'Pre Smoother: ' + call prec%precv(1)%sm%descr(info,iout=iout_) + write(iout_,*) 'Post smoother:' + call prec%precv(1)%sm2a%descr(info,iout=iout_) + end if + nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) + + else + call prec%precv(1)%sm%descr(info,iout=iout_) + nswps = prec%precv(1)%parms%sweeps_pre + end if + if (nswps > 1) write(iout_,*) ' Number of sweeps : ',nswps + write(iout_,*) + + else if (nlev > 1) then + ! + ! Print description of base preconditioner + ! + write(iout_,*) 'Multilevel Preconditioner' + write(iout_,*) 'Outer sweeps:',prec%outer_sweeps + write(iout_,*) + if (allocated(prec%precv(1)%sm2a)) then + write(iout_,*) 'Pre Smoother: ' + call prec%precv(1)%sm%descr(info,iout=iout_) + write(iout_,*) 'Post smoother:' + call prec%precv(1)%sm2a%descr(info,iout=iout_) + else + write(iout_,*) 'Smoother: ' + call prec%precv(1)%sm%descr(info,iout=iout_) + end if + ! + ! Print multilevel details + ! + write(iout_,*) + write(iout_,*) 'Multilevel hierarchy: ' + write(iout_,*) ' Number of levels : ',nlev + write(iout_,*) ' Operator complexity: ',prec%get_complexity() + write(iout_,*) ' Average coarsening : ',prec%get_avg_cr() + ilmin = 2 + if (nlev == 2) ilmin=1 + do ilev=ilmin,nlev + call prec%precv(ilev)%descr(ilev,nlev,ilmin,info,iout=iout_) + end do + write(iout_,*) + + else + write(iout_,*) trim(name), & + & ': invalid preconditioner array size ?',nlev + info = -2 + return + + end if + end if + + else + write(iout_,*) trim(name), & + & ': Error: no base preconditioner available, something is wrong!' + info = -2 + return + endif + +end subroutine amg_dfile_prec_descr diff --git a/mlprec/impl/amg_dmlprec_aply.f90 b/mlprec/impl/amg_dmlprec_aply.f90 new file mode 100644 index 00000000..5297cfe1 --- /dev/null +++ b/mlprec/impl/amg_dmlprec_aply.f90 @@ -0,0 +1,1669 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_dmlprec_aply.f90 +! +! Subroutine: amg_dmlprec_aply +! Version: real +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +! This routine computes +! +! Y = beta*Y + alpha*op(ML^(-1))*X, +! where +! - ML is a multilevel preconditioner associated with +! a certain matrix A and stored in p, +! - op(ML^(-1)) is ML^(-1) or its transpose, according to the value of trans, +! - X and Y are vectors, +! - alpha and beta are scalars. +! +! The following multilevel strategies can be applied: +! +! - Additive multilevel Schwarz, +! - classical V-cycle, +! - classical W-cycle, +! - K-cycle both for symmetric and nonsymmetric matrices, where 2 iterations +! of FCG(1) or GCR, respectively, are applied at each level +! except the coarsest. +! +! For each level we have as many submatrices as processes (except for the coarsest +! level where we might have a replicated index space) and each process takes care +! of one submatrix. +! +! A multilevel preconditioner is regarded as an array of 'one-level' data structures, +! each containing the part of the preconditioner associated to a certain level +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! For each level lev, there is a smoother stored in +! p%precv(lev)%sm +! which in turn contains a solver +! p$precv(lev)%sm%sv +! Typically the solver acts only locally, and the smoother applies any required +! parallel communication/action. +! Each level has a matrix A(lev), obtained by 'tranferring' the original +! matrix A (i.e. the matrix to be preconditioned) to the level lev, through smoothed +! aggregation. +! +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level and A(1) is the matrix A. +! +! This routine is formulated in a recursive way, so it is quite compact. +! +! The V-cycle can be described as follows, where +! P(lev) denotes the smoothed prolongator from level lev to level +! lev-1, while R(lev) denotes the corresponding restriction operator +! (normally its transpose) from level lev-1 to level lev. +! M(lev) is the smoother at the current level. +! +! +! 1. Transfer the outer vector Xest to u(1) (inner X at level 1) +! +! 2. Invoke V-cycle(1,M,P,R,A,b,u) +! +! procedure V-cycle(lev,M,P,R,A,b,u) +! +! if (lev < nlev) then +! +! u(lev) = u(lev) + M(lev)*(b(lev)-A(lev)*u(lev)) +! +! b(lev+1) = R(lev+1)*(b(lev)-A(lev)*u(lev)) +! +! u(lev+1) = V-cycle(lev+1,M,P,R,A,b,u) +! +! u(lev) = u(lev) + P(lev+1) * u(lev+1) +! +! u(lev) = u(lev) + M(lev)*(b(lev)-A(lev)*u(lev)) +! +! else +! +! solve A(lev)*u(lev) = b(lev) +! +! end if +! +! return u(lev) +! end +! +! 3. Transfer u(1) to the external: +! Yext = beta*Yext + alpha*u(1) +! +! +! In the implementation, the recursive procedure is inner_ml_aply, which +! in turn uses amg_inner_add (for additive multilevel), +! amg_inner_mult (for V-cycle and W-cycle), and +! amg_inner_k_cycle (for symmetric and non-symmetric K-cycle). +! +! For a detailed description of the algorithms, see: +! +! - B.F. Smith, P.E. Bjorstad, W.D. Gropp, +! Domain decomposition: parallel multilevel methods for elliptic partial +! differential equations, Cambridge University Press, 1996. +! +! - W. L. Briggs, V. E. Henson, S. F. McCormick, +! A Multigrid Tutorial, Second Edition +! SIAM, 2000. +! +! - K. Stuben, +! An Introduction to Algebraic Multigrid, +! in A. Schuller, U. Trottenberg, C. Oosterlee, Multigrid, Academic Press, 2001. +! +! - Y. Notay, P. S. Vassilevski, +! Recursive Krylov-based multigrid cycles +! Numerical Linear Algebra with Applications, 15 (5), 2008, 473--487. +! +! +! Arguments: +! alpha - real(psb_dpk_), input. +! The scalar alpha. +! p - type(amg_dprec_type), input. +! The multilevel preconditioner data structure containing the +! local part of the preconditioner to be applied. +! Note that nlev = size(p%precv) = number of levels. +! p%precv(lev)%sm - type(psb_dbaseprec_type) +! The pre-'smoother' for the current level +! p%precv(lev)%sm2 - type(psb_dbaseprec_type) +! The post-'smoother' for the current level +! may be the same or different from %sm +! p%precv(lev)%ac - type(psb_dspmat_type) +! The local part of the matrix A(lev). +! p%precv(lev)%parms - type(psb_dml_parms) +! Parameters controllin the multilevel prec. +! p%precv(lev)%desc_ac - type(psb_desc_type). +! The communication descriptor associated to the sparse +! matrix A(lev) +! p%precv(lev)%map - type(psb_inter_desc_type) +! Stores the linear operators mapping level (lev-1) +! to (lev) and vice versa. These are the restriction +! and prolongation operators described in the sequel. +! p%precv(lev)%base_a - type(psb_dspmat_type), pointer. +! Pointer (really a pointer!) to the base matrix of +! the current level, i.e. the local part of A(lev); +! so we have a unified treatment of residuals. We +! need this to avoid passing explicitly the matrix +! A(lev) to the routine which applies the +! preconditioner. +! p%precv(lev)%base_desc - type(psb_desc_type), pointer. +! Pointer to the communication descriptor associated +! to the sparse matrix pointed by base_a. +! +! x - real(psb_dpk_), dimension(:), input. +! The local part of the vector X. +! beta - real(psb_dpk_), input. +! The scalar beta. +! y - real(psb_dpk_), dimension(:), input/output. +! The local part of the vector Y. +! desc_data - type(psb_desc_type), input. +! The communication descriptor associated to the matrix to be +! preconditioned. +! trans - character, optional. +! If trans='N','n' then op(M^(-1)) = M^(-1); +! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). +! work - real(psb_dpk_), dimension (:), optional, target. +! Workspace. Its size must be at least 4*desc_data%get_local_cols(). +! info - integer, output. +! Error code. +! +! Note that when the LU factorization of the matrix A(lev) is computed instead of +! the ILU one, by using UMFPACK or SuperLU or MUMPS, the corresponding +! L and U factors are stored in data structures handled +! by the third party software. +! +subroutine amg_dmlprec_aply_vect(alpha,p,x,beta,y,desc_data,trans,work,info) + + use psb_base_mod + use amg_base_prec_type + use amg_d_inner_mod, amg_protect_name => amg_dmlprec_aply_vect + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_dprec_type), intent(inout) :: p + real(psb_dpk_),intent(in) :: alpha,beta + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + character, intent(in) :: trans + real(psb_dpk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: ictxt, np, me + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, nc2l, level, isweep, err_act + character(len=20) :: name + character :: trans_ + real(psb_dpk_) :: beta_ + logical :: do_alloc_wrk + type(amg_dmlprec_wrk_type), allocatable, target :: mlprec_wrk(:) + + name='amg_dmlprec_aply' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (debug_level >= psb_debug_inner_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Entry ', size(p%precv) + + trans_ = psb_toupper(trans) + nlev = size(p%precv) + + do_alloc_wrk = .not.allocated(p%precv(1)%wrk) + + if (do_alloc_wrk) call p%allocate_wrk(info,vmold=x%v) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') + goto 9999 + end if + level = 1 + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & wv => p%precv(level)%wrk%wv(:)) + ! + ! At first iteration we must use the input BETA + ! + beta_ = beta + + + call psb_geaxpby(done,x,dzero,vx2l,base_desc,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='geaxbpy') + goto 9999 + end if + + do isweep = 1, p%outer_sweeps - 1 + ! + ! With the current implementation, y2l is zeroed internally at first smoother. + ! call p%wrk(level)%vy2l%zero() + ! + call inner_ml_aply(level,p,trans_,work,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Inner prec aply') + goto 9999 + end if + call psb_geaxpby(alpha,vy2l,beta_,y,base_desc,info) + ! all iterations after the first must use BETA = 1 + beta_ = done + ! + ! Next iteration should use the current residual to compute a correction + ! + call psb_geaxpby(done,x,dzero,vx2l,base_desc,info) + call psb_spmm(-done,base_a,y,done,vx2l,base_desc,info) + end do + + ! + ! If outer_sweeps == 1 we have just skipped the loop, and it's + ! equivalent to a single application. + ! + + ! + ! With the current implementation, y2l is zeroed internally at first smoother. + ! call p%wrk(level)%vy2l%zero() + ! + call inner_ml_aply(level,p,trans_,work,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Inner prec aply') + goto 9999 + end if + call psb_geaxpby(alpha,vy2l,beta_,y,base_desc,info) + + end associate + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error final update') + goto 9999 + end if + if (do_alloc_wrk) call p%free_wrk(info) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + ! + ! + ! inner_ml_aply: apply AMG at a given level. + ! This routine dispatches the computation according to the type + ! specified at the current level. + ! Each of the corrections will inturn call recursively this routine. + ! + ! Assumptions: + ! On input: + ! mlprec_wkr(level)%vx2l contains the input vector (RHS) + ! mlprec_wkr(level)%vy2l contains the initial guess + ! + ! On output: + ! mlprec_wkr(level)%vy2l contains the solution + ! + ! Constraints: each of the called routines must properly handle + ! the input/output conditions for level+1 (i.e. apply + ! prolongation/restriction). + ! Note: for historical/convenience reasons the prolongator/restrictor + ! between level and level+1 are stored at level+1. + ! + ! + recursive subroutine inner_ml_aply(level,p,trans,work,info) + + implicit none + + ! Arguments + integer(psb_ipk_) :: level + type(amg_dprec_type), target, intent(inout) :: p + character, intent(in) :: trans + real(psb_dpk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + + type(psb_d_vect_type) :: res + type(psb_d_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_ml_aply' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_ml') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' Start inner_ml_aply at level ',level, info + end if + + select case(p%precv(level)%parms%ml_cycle) + + case(amg_no_ml_) + ! + ! No preconditioning, should not really get here + ! + call psb_errpush(psb_err_internal_error_,name,& + & a_err='amg_no_ml_ in mlprc_aply?') + goto 9999 + + case(amg_add_ml_) + + call amg_d_inner_add(p, level, trans, work) + + case(amg_mult_ml_,amg_vcycle_ml_, amg_wcycle_ml_) + + call amg_d_inner_mult(p, level, trans, work) + + case(amg_kcycle_ml_, amg_kcyclesym_ml_) + + call amg_d_inner_k_cycle(p, level, trans, work) + + case default + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='invalid ml_cycle',& + & i_Err=(/p%precv(level)%parms%ml_cycle,izero,izero,izero,izero/)) + goto 9999 + + end select + if(debug_level > 1) then + write(debug_unit,*) me,' End inner_ml_aply at level ',level + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine inner_ml_aply + + + recursive subroutine amg_d_inner_add(p, level, trans, work) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_dprec_type), intent(inout) :: p + + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + real(psb_dpk_),target :: work(:) + type(psb_d_vect_type) :: res + type(psb_d_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act, k + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_inner_add' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_add') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_add at level ',level + end if + + if ((level<1).or.(level>nlev)) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL>NLEV') + goto 9999 + end if + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & wv => p%precv(level)%wrk%wv) + + if (allocated(p%precv(level)%sm2a)) then + call psb_geaxpby(done,vx2l,dzero,vy2l,base_desc,info) + + sweeps = max(p%precv(level)%parms%sweeps_pre,p%precv(level)%parms%sweeps_post) + do k=1, sweeps + call p%precv(level)%sm%apply(done,& + & vy2l,dzero,vty,& + & base_desc, trans,& + & ione,work,wv,info,init='Z') + + call p%precv(level)%sm2a%apply(done,& + & vty,dzero,vy2l,& + & base_desc, trans,& + & ione,work,wv,info,init='Z') + end do + + else + sweeps = p%precv(level)%parms%sweeps_pre + call p%precv(level)%sm%apply(done,& + & vx2l,dzero,vy2l,& + & base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during ADD smoother_apply') + goto 9999 + end if + + if (level < nlev) then + ! Apply the restriction + call p%precv(level+1)%map%map_U2V(done,vx2l,& + & dzero,p%precv(level+1)%wrk%vx2l,& + & info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + + call inner_ml_aply(level+1,p,trans,work,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in recursive call') + goto 9999 + end if + + ! + ! Apply the prolongator + ! + call p%precv(level+1)%map%map_V2U(done,& + & p%precv(level+1)%wrk%vy2l, done,vy2l,& + & info,work=work,& + & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + + end if + end associate + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_d_inner_add + + recursive subroutine amg_d_inner_mult(p, level, trans, work) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_dprec_type), intent(inout) :: p + + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + real(psb_dpk_),target :: work(:) + type(psb_d_vect_type) :: res + type(psb_d_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + name = 'inner_inner_mult' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_mult') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_mult at level ',level + end if + + sweeps_post = p%precv(level)%parms%sweeps_post + sweeps_pre = p%precv(level)%parms%sweeps_pre + pre = ((sweeps_pre>0).and.(trans=='N')).or.((sweeps_post>0).and.(trans/='N')) + post = ((sweeps_post>0).and.(trans=='N')).or.((sweeps_pre>0).and.(trans/='N')) + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & wv => p%precv(level)%wrk%wv) + if (level < nlev) then + ! + ! Apply the first smoother + ! The residual has been prepared before the recursive call. + ! + + if (pre) then + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(done,& + & vx2l,dzero,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(done,& + & vx2l,dzero,vy2l, base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during PRE smoother_apply') + goto 9999 + end if + endif + ! + ! Compute the residual for next level and call recursively + ! + if (pre) then + call psb_geaxpby(done,vx2l,& + & dzero,vty,& + & base_desc,info) + + if (info == psb_success_) call psb_spmm(-done,base_a,& + & vy2l,done,vty,& + & base_desc,info,work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + call p%precv(level+1)%map%map_U2V(done,vty,& + & dzero,p%precv(level+1)%wrk%vx2l,& + & info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + else + ! Shortcut: just transfer x2l. + call p%precv(level+1)%map%map_U2V(done,vx2l,& + & dzero,p%precv(level+1)%wrk%vx2l,& + & info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + endif + + call inner_ml_aply(level+1,p,trans,work,info) + + ! + ! Apply the prolongator + ! + call p%precv(level+1)%map%map_V2U(done,& + & p%precv(level+1)%wrk%vy2l,done,vy2l,& + & info,work=work,& + & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + if (p%precv(level)%parms%ml_cycle == amg_wcycle_ml_) then + + call psb_geaxpby(done,vx2l, dzero,vty,& + & base_desc,info) + if (info == psb_success_) call psb_spmm(-done,base_a,& + & vy2l,done,vty,& + & base_desc,info,work=work,trans=trans) + if (info == psb_success_) & + & call p%precv(level+1)%map%map_U2V(done,vty,& + & dzero,p%precv(level+1)%wrk%vx2l,info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during W-cycle restriction') + goto 9999 + end if + + call inner_ml_aply(level+1,p,trans,work,info) + + if (info == psb_success_) call p%precv(level+1)%map%map_V2U(done, & + & p%precv(level+1)%wrk%vy2l,done,vy2l,& + & info,work=work,& + & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during W recusion/prolongation') + goto 9999 + end if + + endif + + + if (post) then + call psb_geaxpby(done,vx2l,& + & dzero,vty,& + & base_desc,info) + if (info == psb_success_) call psb_spmm(-done,base_a,& + & vy2l, done,vty,base_desc,info,& + & work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + + ! + ! Apply the second smoother + ! + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(done,& + & vty,done,vy2l, base_desc, trans,& + & sweeps,work,wv,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(done,& + & vty,done,vy2l, base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during POST smoother_apply') + goto 9999 + end if + + endif + + else if (level == nlev) then + + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(done,& + & vx2l,dzero,vy2l,base_desc, trans,& + & sweeps,work,wv,info) + + else + + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL vs NLEV') + goto 9999 + end if + end associate + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_d_inner_mult + + recursive subroutine amg_d_inner_k_cycle(p, level, trans, work,u) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_dprec_type), intent(inout) :: p + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + real(psb_dpk_),target :: work(:) + type(psb_d_vect_type),intent(inout), optional :: u + + + + type(psb_d_vect_type) :: res + type(psb_d_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_kcycle' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_add') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,name,' start at level ',level + end if + + if ((level<1).or.(level>nlev)) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL>NLEV') + goto 9999 + end if + + !K cycle + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & wv => p%precv(level)%wrk%wv(8:)) + if (level == nlev) then + ! + ! Apply smoother + ! + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(done,& + & vx2l,dzero,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + + else if (level < nlev) then + + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(done,& + & vx2l,dzero,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(done,& + & vx2l,dzero,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during 2-PRE smoother_apply') + goto 9999 + end if + + + ! + ! Compute the residual and call recursively + ! + + call psb_geaxpby(done,vx2l,& + & dzero,vty,& + & base_desc,info) + + if (info == psb_success_) call psb_spmm(-done,base_a,& + & vy2l,done,vty,base_desc,info,work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + + ! Apply the restriction + call p%precv(level + 1)%map%map_U2V(done,vty,& + & dzero,p%precv(level + 1)%wrk%vx2l,& + &info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + + !Set the preconditioner + + if (level <= nlev - 2 ) then + if (p%precv(level)%parms%ml_cycle == amg_kcyclesym_ml_) then + call amg_dinneritkcycle(p, level + 1, trans, work, 'FCG') + elseif (p%precv(level)%parms%ml_cycle == amg_kcycle_ml_) then + call amg_dinneritkcycle(p, level + 1, trans, work, 'GCR') + else + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Bad value for ml_cycle') + goto 9999 + endif + else + call inner_ml_aply(level + 1 ,p,trans,work,info) + endif + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in recursive call') + goto 9999 + end if + + ! + ! Apply the prolongator + ! + call p%precv(level+1)%map%map_V2U(done,& + & p%precv(level+1)%wrk%vy2l,done,vy2l,& + & info,work=work,& + & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + ! + ! Compute the residual + ! + call psb_geaxpby(done,vx2l,& + & dzero,vty,base_desc,info) + call psb_spmm(-done,base_a,vy2l,& + & done,vty,base_desc,info,& + & work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + ! + ! Apply the smoother + ! + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(done,& + & vty,done,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(done,& + & vty,done,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during POST smoother_apply') + goto 9999 + end if + else + + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL vs NLEV') + goto 9999 + + endif + end associate + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_d_inner_k_cycle + + + recursive subroutine amg_dinneritkcycle(p, level, trans, work, innersolv) + use psb_base_mod + use amg_prec_mod + use amg_d_inner_mod, amg_protect_name => amg_dmlprec_aply + + implicit none + + !Input/Oputput variables + type(amg_dprec_type), intent(inout) :: p + + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + character(len=*), intent(in) :: innersolv + real(psb_dpk_),target :: work(:) + + !Other variables + type(psb_d_vect_type) :: v, w, rhs, v1, x + type(psb_d_vect_type) :: d0, d1 + real(psb_dpk_) :: delta_old, rhs_norm, alpha, tau, tau1, tau2, tau3, tau4, beta + + real(psb_dpk_) :: l2_norm, delta, rtol=0.25, delta0, tnrm + real(psb_dpk_), allocatable :: temp_v(:) + integer(psb_ipk_) :: info, nlev, i, iter, max_iter=2, idx + character(len=20) :: name = 'innerit_k_cycle' + + + if (size(p%precv(level)%wrk%wv)<7) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size') + goto 9999 + end if + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & v => p%precv(level)%wrk%wv(1), & + & w => p%precv(level)%wrk%wv(2),& + & rhs => p%precv(level)%wrk%wv(3), & + & v1 => p%precv(level)%wrk%wv(4), & + & x => p%precv(level)%wrk%wv(5), & + & d0 => p%precv(level)%wrk%wv(6), & + & d1 => p%precv(level)%wrk%wv(7)) + + call x%zero() + + ! rhs=vx2l and w=rhs + call psb_geaxpby(done,vx2l,dzero,rhs, base_desc,info) + call psb_geaxpby(done,vx2l,dzero,w, base_desc,info) + + if (psb_errstatus_fatal()) then + nc2l = base_desc%get_local_cols() + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + + delta0 = psb_genrm2(w, base_desc, info) + + !Apply the preconditioner + call vy2l%zero() + + idx=0 + call inner_ml_aply(level,p,trans,work,info) + + call psb_geaxpby(done,vy2l,dzero,d0,base_desc,info) + + call psb_spmm(done,base_a,d0,dzero,v,base_desc,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + + !FCG + if (psb_toupper(trim(innersolv)) == 'FCG') then + delta_old = psb_gedot(d0, w, base_desc, info) + tau = psb_gedot(d0, v, base_desc, info) + !GCR + else if (psb_toupper(trim(innersolv)) == 'GCR') then + delta_old = psb_gedot(v, w, base_desc, info) + tau = psb_gedot(v, v, base_desc, info) + else + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid inner solver') + goto 9999 + endif + + alpha = delta_old/tau + !Update residual w + call psb_geaxpby(-alpha, v, done, w, base_desc, info) + + l2_norm = psb_genrm2(w, base_desc, info) + iter = 0 + + if (l2_norm <= rtol*delta0) then + !Update solution x + call psb_geaxpby(alpha, d0, done, x, base_desc, info) + else + iter = iter + 1 + idx=mod(iter,2) + + !Apply preconditioner + call psb_geaxpby(done,w,dzero,vx2l,base_desc,info) + call inner_ml_aply(level,p,trans,work,info) + call psb_geaxpby(done,vy2l,dzero,d1,base_desc,info) + + !Sparse matrix vector product + + call psb_spmm(done,base_a,d1,dzero,v1,base_desc,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + + !tau1, tau2, tau3, tau4 + if (psb_toupper(trim(innersolv)) == 'FCG') then + tau1= psb_gedot(d1, v, base_desc, info) + tau2= psb_gedot(d1, v1, base_desc, info) + tau3= psb_gedot(d1, w, base_desc, info) + tau4= tau2 - (tau1*tau1)/tau + else if (psb_toupper(trim(innersolv)) == 'GCR') then + tau1= psb_gedot(v1, v, base_desc, info) + tau2= psb_gedot(v1, v1, base_desc, info) + tau3= psb_gedot(v1, w, base_desc, info) + tau4= tau2 - (tau1*tau1)/tau + else + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid inner solver') + goto 9999 + endif + + !Update solution + alpha=alpha-(tau1*tau3)/(tau*tau4) + call psb_geaxpby(alpha,d0,done,x,base_desc,info) + alpha=tau3/tau4 + call psb_geaxpby(alpha,d1,done,x,base_desc,info) + endif + + call psb_geaxpby(done,x,dzero,vy2l,base_desc,info) + end associate + +9999 continue + call psb_erractionrestore(err_act) + if (err_act.eq.psb_act_abort_) then + call psb_error() + return + end if + return + end subroutine amg_dinneritkcycle + +end subroutine amg_dmlprec_aply_vect + + +! +! Old routine for arrays instead of psb_X_vector. To be deleted eventually. +! +! +subroutine amg_dmlprec_aply(alpha,p,x,beta,y,desc_data,trans,work,info) + + use psb_base_mod + use amg_base_prec_type + use amg_d_inner_mod, amg_protect_name => amg_dmlprec_aply + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_dprec_type), intent(inout) :: p + real(psb_dpk_),intent(in) :: alpha,beta + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + character, intent(in) :: trans + real(psb_dpk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: ictxt, np, me + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: debug_level, debug_unit, nlev,nc2l,nr2l,level + character(len=20) :: name + character :: trans_ + type amg_mlwrk_type + real(psb_dpk_), allocatable :: tx(:), ty(:), x2l(:), y2l(:) + end type amg_mlwrk_type + type(amg_mlwrk_type), allocatable, target :: mlwrk(:) + + name='amg_dmlprec_aply' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (debug_level >= psb_debug_inner_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Entry ', size(p%precv) + + trans_ = psb_toupper(trans) + + nlev = size(p%precv) + allocate(mlwrk(nlev),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') + goto 9999 + end if + level = 1 + + do level = 1, nlev + call psb_geasb(mlwrk(level)%x2l,& + & p%precv(level)%base_desc,info) + call psb_geasb(mlwrk(level)%y2l,& + & p%precv(level)%base_desc,info) + call psb_geasb(mlwrk(level)%tx,& + & p%precv(level)%base_desc,info) + call psb_geasb(mlwrk(level)%ty,& + & p%precv(level)%base_desc,info) + if (psb_errstatus_fatal()) then + nc2l = p%precv(level)%base_desc%get_local_cols() + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + end do + + mlwrk(level)%x2l(:) = x(:) + mlwrk(level)%y2l(:) = dzero + + call inner_ml_aply(level,p,mlwrk,trans_,work,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Inner prec aply') + goto 9999 + end if + + call psb_geaxpby(alpha,mlwrk(level)%y2l,beta,y,& + & p%precv(level)%base_desc,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error final update') + goto 9999 + end if + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + + ! + ! + ! inner_ml_aply: apply AMG at a given level. + ! This routine dispatches the computation according to the type + ! specified at the current level. + ! Each of the corrections will inturn call recursively this routine. + ! + ! Assumptions: + ! On input: + ! mlprec_wkr(level)%vx2l contains the input vector (RHS) + ! mlprec_wkr(level)%vy2l contains the initial guess + ! + ! On output: + ! mlprec_wkr(level)%vy2l contains the solution + ! + ! Constraints: each of the called routines must properly handle + ! the input/output conditions for level+1 (i.e. apply + ! prolongation/restriction). + ! Note: for historical/convenience reasons the prolongator/restrictor + ! between level and level+1 are stored at level+1. + ! + ! + recursive subroutine inner_ml_aply(level,p,mlwrk,trans,work,info) + + implicit none + + ! Arguments + integer(psb_ipk_) :: level + type(amg_dprec_type), target, intent(inout) :: p + type(amg_mlwrk_type), intent(inout), target :: mlwrk(:) + character, intent(in) :: trans + real(psb_dpk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + + type(psb_d_vect_type) :: res + type(psb_d_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_ml_aply' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_ml') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_ml_aply at level ',level + end if + + select case(p%precv(level)%parms%ml_cycle) + + case(amg_no_ml_) + ! + ! No preconditioning, should not really get here + ! + call psb_errpush(psb_err_internal_error_,name,& + & a_err='amg_no_ml_ in mlprc_aply?') + goto 9999 + + case(amg_add_ml_) + + call amg_d_inner_add(p, mlwrk, level, trans, work) + + case(amg_mult_ml_, amg_vcycle_ml_, amg_wcycle_ml_) + + call amg_d_inner_mult(p, mlwrk, level, trans, work) + +! !$ case(amg_kcycle_ml_, amg_kcyclesym_ml_) +! !$ +! !$ call amg_d_inner_k_cycle(p, mlwrk, level, trans, work) + + case default + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='invalid ml_cycle',& + & i_Err=(/p%precv(level)%parms%ml_cycle,izero,izero,izero,izero/)) + goto 9999 + + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine inner_ml_aply + + + recursive subroutine amg_d_inner_add(p, mlwrk, level, trans, work) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_dprec_type), intent(inout) :: p + + type(amg_mlwrk_type), target, intent(inout) :: mlwrk(:) + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + real(psb_dpk_),target :: work(:) + type(psb_d_vect_type) :: res + type(psb_d_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_inner_add' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_add') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_add at level ',level + end if + + if ((level<1).or.(level>nlev)) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL>NLEV') + goto 9999 + end if + + sweeps = p%precv(level)%parms%sweeps_pre + call p%precv(level)%sm%apply(done,& + & mlwrk(level)%x2l,dzero,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during ADD smoother_apply') + goto 9999 + end if + + if (level < nlev) then + ! Apply the restriction + call p%precv(level+1)%map%map_U2V(done,mlwrk(level)%x2l,& + & dzero,mlwrk(level+1)%x2l,& + & info,work=work) + mlwrk(level+1)%y2l(:) = dzero + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + + call inner_ml_aply(level+1,p,mlwrk,trans,work,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in recursive call') + goto 9999 + end if + + ! + ! Apply the prolongator and add correction. + ! + call p%precv(level+1)%map%map_V2U(done,& + & mlwrk(level+1)%y2l,done,mlwrk(level)%y2l,& + & info,work=work) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_d_inner_add + + recursive subroutine amg_d_inner_mult(p, mlwrk, level, trans, work) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_dprec_type), intent(inout) :: p + + type(amg_mlwrk_type), target, intent(inout) :: mlwrk(:) + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + real(psb_dpk_),target :: work(:) + type(psb_d_vect_type) :: res + type(psb_d_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_inner_mult' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_mult') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_mult at level ',level + end if + + if ((level < nlev).or.(nlev == 1)) then + sweeps_post = p%precv(level)%parms%sweeps_post + sweeps_pre = p%precv(level)%parms%sweeps_pre + else + sweeps_post = p%precv(level-1)%parms%sweeps_post + sweeps_pre = p%precv(level-1)%parms%sweeps_pre + endif + + pre = ((sweeps_pre>0).and.(trans=='N')).or.((sweeps_post>0).and.(trans/='N')) + post = ((sweeps_post>0).and.(trans=='N')).or.((sweeps_pre>0).and.(trans/='N')) + + + if (level < nlev) then + + ! + ! Apply the first smoother + ! + + if (pre) then + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(done,& + & mlwrk(level)%x2l,dzero,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info,init='Y') + else + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(done,& + & mlwrk(level)%x2l,dzero,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info,init='Y') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during PRE smoother_apply') + goto 9999 + end if + endif + + ! + ! Compute the residual and call recursively + ! + if (pre) then + call psb_geaxpby(done,mlwrk(level)%x2l,& + & dzero,mlwrk(level)%ty,& + & p%precv(level)%base_desc,info) + + if (info == psb_success_) call psb_spmm(-done,p%precv(level)%base_a,& + & mlwrk(level)%y2l,done,mlwrk(level)%ty,& + & p%precv(level)%base_desc,info,work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + call p%precv(level+1)%map%map_U2V(done,mlwrk(level)%ty,& + & dzero,mlwrk(level+1)%x2l,info,work=work) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + else + ! Shortcut: just transfer x2l. + call p%precv(level+1)%map%map_U2V(done,mlwrk(level)%x2l,& + & dzero,mlwrk(level+1)%x2l,info,work=work) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + endif + ! First guess is zero + mlwrk(level+1)%y2l(:) = dzero + + + call inner_ml_aply(level+1,p,mlwrk,trans,work,info) + + if (p%precv(level)%parms%ml_cycle == amg_wcycle_ml_) then + ! On second call will use output y2l as initial guess + if (info == psb_success_) call inner_ml_aply(level+1,p,mlwrk,trans,work,info) + endif + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in recursive call') + goto 9999 + end if + + + ! + ! Apply the prolongator + ! + call p%precv(level+1)%map%map_V2U(done,mlwrk(level+1)%y2l,& + & done,mlwrk(level)%y2l,info,work=work) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + ! + ! Compute the residual + ! + if (post) then + call psb_geaxpby(done,mlwrk(level)%x2l,& + & dzero,mlwrk(level)%tx,& + & p%precv(level)%base_desc,info) + call psb_spmm(-done,p%precv(level)%base_a,mlwrk(level)%y2l,& + & done,mlwrk(level)%tx,p%precv(level)%base_desc,info,& + & work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + ! + ! Apply the second smoother + ! + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(done,& + & mlwrk(level)%tx,done,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(done,& + & mlwrk(level)%tx,done,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during POST smoother_apply') + goto 9999 + end if + + endif + + else if (level == nlev) then + + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(done,& + & mlwrk(level)%x2l,dzero,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info) + + else + + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL vs NLEV') + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_d_inner_mult + + +end subroutine amg_dmlprec_aply diff --git a/mlprec/impl/amg_dmlprec_bld.f90 b/mlprec/impl/amg_dmlprec_bld.f90 new file mode 100644 index 00000000..c505f12e --- /dev/null +++ b/mlprec/impl/amg_dmlprec_bld.f90 @@ -0,0 +1,152 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_dmlprec_bld.f90 +! +! Subroutine: amg_dmlprec_bld +! Version: real +! +! This routine builds the preconditioner according to the requirements made by +! the user trough the subroutines amg_precinit and amg_precset. +! +! A multilevel preconditioner is regarded as an array of 'one-level' data structures, +! each containing the part of the preconditioner associated to a certain level, +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level. No transfer operators are associated to level 1. +! +! This routine simply calls amg_d_hierarchy_bld and amg_d_smoothers_bld; they +! can also be called explicitly from the user. +! +! +! Arguments: +! a - type(psb_dspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_dprec_type), input/output. +! The preconditioner data structure containing the local part +! of the preconditioner to be built. +! info - integer, output. +! Error code. +! +! amold - class(psb_d_base_sparse_mat), input, optional +! Mold for the inner format of matrices contained in the +! preconditioner +! +! +! vmold - class(psb_d_base_vect_type), input, optional +! Mold for the inner format of vectors contained in the +! preconditioner +! +! +! +subroutine amg_dmlprec_bld(a,desc_a,p,info,amold,vmold,imold) + + use psb_base_mod + use amg_d_inner_mod, amg_protect_name => amg_dmlprec_bld + use amg_d_prec_mod + + Implicit None + + ! Arguments + type(psb_dspmat_type),intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + type(amg_dprec_type),intent(inout),target :: p + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local Variables + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, casize, nplevs, mxplevs + real(psb_dpk_) :: mnaggratio + integer(psb_ipk_) :: ipv(amg_ifpsz_), val + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_dmlprec_bld' + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' + + call p%hierarchy_build(a,desc_a,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Error from hierarchy build') + goto 9999 + end if + + iszv = p%get_nlevs() + + call p%smoothers_build(a,desc_a,info,amold,vmold,imold) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Error from smoothers build') + goto 9999 + end if + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Exiting with',iszv,' levels' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_dmlprec_bld diff --git a/mlprec/impl/amg_dprecaply.f90 b/mlprec/impl/amg_dprecaply.f90 new file mode 100644 index 00000000..82f01414 --- /dev/null +++ b/mlprec/impl/amg_dprecaply.f90 @@ -0,0 +1,600 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_dprecaply.f90 +! +! Subroutine: amg_dprecaply +! Version: real +! +! This routine applies the preconditioner built by amg_dprecbld, i.e. it computes +! +! Y = op(M^(-1)) * X, +! where +! - M is the preconditioner, +! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, +! - X and Y are vectors. +! This operation is performed at each iteration of a preconditioned Krylov solver. +! +! +! Arguments: +! prec - type(amg_dprec_type), input. +! The preconditioner data structure containing the local part +! of the preconditioner to be applied. +! x - real(psb_dpk_), dimension(:), input. +! The local part of the vector X in Y=op(M^(-1))*X. +! y - real(psb_dpk_), dimension(:), output. +! The local part of the vector Y in Y=op(M^(-1))*X. +! desc_data - type(psb_desc_type), input. +! The communication descriptor associated to the matrix to be +! preconditioned. +! info - integer, output. +! Error code. +! trans - character(len=1), optional. +! If trans='N','n' then op(M^(-1)) = M^(-1); +! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). +! work - real(psb_dpk_), dimension (:), optional, target. +! Workspace. Its size must be at +! least 4*desc_data%get_local_cols(). +! +subroutine amg_dprecaply(prec,x,y,desc_data,info,trans,work) + + use psb_base_mod + use amg_d_inner_mod!, amg_protect_name => amg_dprecaply + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_dprec_type), intent(inout) :: prec + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_dpk_),intent(inout), optional, target :: work(:) + + ! Local variables + character :: trans_ + real(psb_dpk_), pointer :: work_(:) + real(psb_dpk_), allocatable :: w1(:), w2(:) + + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: err_act,iwsz, k, nswps + character(len=20) :: name + + name='amg_dprecaply' + info = psb_success_ + call psb_erractionsave(err_act) + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (present(trans)) then + trans_=psb_toupper(trans) + else + trans_='N' + end if + + if (present(work)) then + work_ => work + else + iwsz = max(1,4*desc_data%get_local_cols()) + allocate(work_(iwsz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name, & + & i_err=(/iwsz,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + + end if + + if (.not.(allocated(prec%precv))) then + !! Error 1: should call amg_dprecbld + info=3112 + call psb_errpush(info,name) + goto 9999 + end if + + if (size(prec%precv) >1) then + ! + ! Number of levels > 1: apply the multilevel preconditioner + ! + call amg_mlprec_aply(done,prec,x,dzero,y,desc_data,trans_,work_,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_dmlprec_aply') + goto 9999 + end if + + else if (size(prec%precv) == 1) then + ! + ! Number of levels = 1: apply the base preconditioner + ! + if (allocated(prec%precv(1)%sm2a)) then + nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) + ! + ! This is a kludge for handling the symmetrized GS case. + ! Will need some rethinking. + ! + call psb_geasb(w1,desc_data,info,scratch=.true.) + call psb_geasb(w2,desc_data,info,scratch=.true.) + + call psb_geaxpby(done,x,dzero,w1,desc_data,info) + select case(trans_) + case ('N') + do k=1, nswps + call prec%precv(1)%sm%apply(done,w1,dzero,w2,desc_data,trans_,& + & ione, work_,info) + call prec%precv(1)%sm2a%apply(done,w2,dzero,w1,desc_data,trans_,& + & ione, work_,info) + end do + + case('T','C') + do k=1, nswps + call prec%precv(1)%sm2a%apply(done,w1,dzero,w2,desc_data,trans_,& + & ione, work_,info) + call prec%precv(1)%sm%apply(done,w2,dzero,w1,desc_data,trans_,& + & ione, work_,info) + end do + case default + info = psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='Invalid trans') + goto 9999 + end select + call psb_geaxpby(done,w1,dzero,y,desc_data,info) + call psb_gefree(w1,desc_data,info) + call psb_gefree(w2,desc_data,info) + + else + nswps = prec%precv(1)%parms%sweeps_pre + call prec%precv(1)%sm%apply(done,x,dzero,y,desc_data,trans_,& + & nswps, work_,info) + end if + else + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='Invalid size of precv',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + endif + + ! If the original distribution has an overlap we should fix that. + call psb_halo(y,desc_data,info,data=psb_comm_mov_) + + + if (present(work)) then + else + deallocate(work_) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_dprecaply + + +! +! Subroutine: amg_dprecaply1 +! Version: real +! +! Applies the preconditioner built by amg_dprecbld, i.e. computes +! +! X = op(M^(-1)) * X, +! where +! - M is the preconditioner, +! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, +! - X is a vectors. +! This operation is performed at each iteration of a preconditioned Krylov solver. +! +! This routine differs from amg_dprecaply because the preconditioned vector X +! overwrites the original one. +! +! +! Arguments: +! prec - type(amg_dprec_type), input. +! The preconditioner data structure containing the local part +! of the preconditioner to be applied. +! x - real(psb_dpk_), dimension(:), input/output. +! The local part of vector X in X := op(M^(-1)) * X. +! desc_data - type(psb_desc_type), input. +! The communication descriptor associated to the matrix to be +! preconditioned. +! info - integer, output. +! Error code. +! trans - character(len=1), optional. +! If trans='N','n' then op(M^(-1)) = M^(-1); +! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). +! +subroutine amg_dprecaply1(prec,x,desc_data,info,trans) + + use psb_base_mod + use amg_d_inner_mod!, amg_protect_name => amg_dprecaply1 + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_dprec_type), intent(inout) :: prec + real(psb_dpk_),intent(inout) :: x(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: err_act + real(psb_dpk_), pointer :: ww(:), w1(:) + character(len=20) :: name + + name='amg_dprecaply1' + info = psb_success_ + call psb_erractionsave(err_act) + + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + allocate(ww(size(x)),w1(size(x)),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name, & + & i_err=(/itwo*size(x),izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + + call prec%apply(x,ww,desc_data,info,trans=trans,work=w1) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_precaply') + goto 9999 + end if + + x(:) = ww(:) + deallocate(ww,w1,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_dprecaply1 + + + +subroutine amg_dprecaply2_vect(prec,x,y,desc_data,info,trans,work) + + use psb_base_mod + use amg_d_inner_mod!, amg_protect_name => amg_dprecaply2_vect + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_dprec_type), intent(inout) :: prec + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_dpk_),intent(inout), optional, target :: work(:) + + ! Local variables + character :: trans_ + real(psb_dpk_), pointer :: work_(:) + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: err_act,iwsz, k, nswps + logical :: do_alloc_wrk + character(len=20) :: name + + name='amg_dprecaply' + info = psb_success_ + call psb_erractionsave(err_act) + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (present(trans)) then + trans_=psb_toupper(trans) + else + trans_='N' + end if + + if (present(work)) then + work_ => work + else + iwsz = max(1,4*desc_data%get_local_cols()) + allocate(work_(iwsz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name, & + & i_err=(/iwsz,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + + end if + + if (.not.(allocated(prec%precv))) then + !! Error 1: should call amg_dprecbld + info=3112 + call psb_errpush(info,name) + goto 9999 + end if + + do_alloc_wrk = .not.allocated(prec%precv(1)%wrk) + if (do_alloc_wrk) call prec%allocate_wrk(info,vmold=x%v) + + if (size(prec%precv) >1) then + ! + ! Number of levels > 1: apply the multilevel preconditioner + ! + ! FIXME: generic name causes an ICE with Intel + call amg_dmlprec_aply_vect(done,prec,x,dzero,y,desc_data,trans_,work_,info) + + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_dmlprec_aply') + goto 9999 + end if + + else if (size(prec%precv) == 1) then + ! + ! Number of levels = 1: apply the base preconditioner + ! + nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) + + associate(w1 => prec%precv(1)%wrk%vx2l, w2 => prec%precv(1)%wrk%vy2l,& + & wv => prec%precv(1)%wrk%wv) + if (allocated(prec%precv(1)%sm2a)) then + ! + ! This is a kludge for handling the symmetrized GS case. + ! Will need some rethinking. + ! + call psb_geaxpby(done,x,dzero,w1,desc_data,info) + select case(trans_) + case ('N') + do k=1, nswps + if (info == 0) call prec%precv(1)%sm%apply(done,w1,dzero,w2,desc_data,trans_,& + & ione, work_,wv,info) + if (info == 0) call prec%precv(1)%sm2a%apply(done,w2,dzero,w1,desc_data,trans_,& + & ione, work_,wv,info) + end do + + case('T','C') + do k=1, nswps + if (info == 0) call prec%precv(1)%sm2a%apply(done,w1,dzero,w2,desc_data,trans_,& + & ione, work_,wv,info) + if (info == 0) call prec%precv(1)%sm%apply(done,w2,dzero,w1,desc_data,trans_,& + & ione, work_,wv,info) + end do + case default + info = psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='Invalid trans') + goto 9999 + end select + if (info == 0) call psb_geaxpby(done,w1,dzero,y,desc_data,info) + else + if (info == 0) call prec%precv(1)%sm%apply(done,x,dzero,y,desc_data,trans_,& + & nswps,work_,wv,info) + end if + end associate + if (psb_errstatus_fatal()) info = psb_err_internal_error_ + if (info /= 0) then + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='Smoother application',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + end if + + else + + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='Invalid size of precv',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + endif + + ! If the original distribution has an overlap we should fix that. + call psb_halo(y,desc_data,info,data=psb_comm_mov_) + + if (do_alloc_wrk) call prec%free_wrk(info) + + if (present(work)) then + else + deallocate(work_) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_dprecaply2_vect + + +subroutine amg_dprecaply1_vect(prec,x,desc_data,info,trans,work) + + use psb_base_mod + use amg_d_inner_mod!, amg_protect_name => amg_dprecaply1_vect + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_dprec_type), intent(inout) :: prec + type(psb_d_vect_type),intent(inout) :: x + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_dpk_),intent(inout), optional, target :: work(:) + + ! Local variables + character :: trans_ + real(psb_dpk_), pointer :: work_(:) + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: err_act,iwsz, k, nswps + logical :: do_alloc_wrk + character(len=20) :: name + + name='amg_dprecaply' + info = psb_success_ + call psb_erractionsave(err_act) + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (present(trans)) then + trans_=psb_toupper(trans) + else + trans_='N' + end if + + if (present(work)) then + work_ => work + else + iwsz = max(1,4*desc_data%get_local_cols()) + allocate(work_(iwsz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name, & + & i_err=(/iwsz,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + + end if + + if (.not.(allocated(prec%precv))) then + !! Error 1: should call amg_dprecbld + info=3112 + call psb_errpush(info,name) + goto 9999 + end if + + do_alloc_wrk = .not.allocated(prec%precv(1)%wrk) + if (do_alloc_wrk) call prec%allocate_wrk(info,vmold=x%v) + + associate(ww => prec%precv(1)%wrk%vtx, wv => prec%precv(1)%wrk%wv) + + if (size(prec%precv) >1) then + ! + ! Number of levels > 1: apply the multilevel preconditioner + ! + ! FIXME: generic name causes an ICE with Intel + call amg_dmlprec_aply_vect(done,prec,x,dzero,ww,desc_data,trans_,work_,info) + if (info == 0) call psb_geaxpby(done,ww,dzero,x,desc_data,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_dmlprec_aply') + goto 9999 + end if + + else if (size(prec%precv) == 1) then + ! + ! Number of levels = 1: apply the base preconditioner + ! + nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) + if (allocated(prec%precv(1)%sm2a)) then + ! + ! This is a kludge for handling the symmetrized GS case. + ! Will need some rethinking. + ! + select case(trans_) + case ('N') + do k=1, nswps + if (info == 0) call prec%precv(1)%sm%apply(done,x,dzero,ww,desc_data,trans_,& + & ione, work_,wv,info) + if (info == 0) call prec%precv(1)%sm2a%apply(done,ww,dzero,x,desc_data,trans_,& + & ione, work_,wv,info) + end do + case('T','C') + do k=1, nswps + if (info == 0) call prec%precv(1)%sm2a%apply(done,x,dzero,ww,desc_data,trans_,& + & ione, work_,wv,info) + if (info == 0) call prec%precv(1)%sm%apply(done,ww,dzero,x,desc_data,trans_,& + & ione, work_,wv,info) + end do + case default + info = psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='Invalid trans') + goto 9999 + end select + + else + if (info == 0) call prec%precv(1)%sm%apply(done,x,dzero,ww,desc_data,trans_,& + & nswps, work_,wv,info) + if (info == 0) call psb_geaxpby(done,ww,dzero,x,desc_data,info) + end if + + if (psb_errstatus_fatal()) info = psb_err_internal_error_ + if (info /=0) then + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='Smoother application',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + end if + + else + + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='Invalid size of precv',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + endif + end associate + + ! If the original distribution has an overlap we should fix that. + call psb_halo(x,desc_data,info,data=psb_comm_mov_) + + if (do_alloc_wrk) call prec%free_wrk(info) + + if (present(work)) then + else + deallocate(work_) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_dprecaply1_vect diff --git a/mlprec/impl/amg_dprecbld.f90 b/mlprec/impl/amg_dprecbld.f90 new file mode 100644 index 00000000..d5ac30f7 --- /dev/null +++ b/mlprec/impl/amg_dprecbld.f90 @@ -0,0 +1,161 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_dprecbld.f90 +! +! Subroutine: amg_dprecbld +! Version: real +! Contains: subroutine init_baseprec_av +! +! This routine builds the preconditioner according to the requirements made by +! the user through the subroutines amg_precinit and amg_precset. +! +! +! Arguments: +! a - type(psb_dspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_dprec_type), input/output. +! The preconditioner data structure containing the local part +! of the preconditioner to be built. +! info - integer, output. +! Error code. +! +subroutine amg_dprecbld(a,desc_a,prec,info,amold,vmold,imold) + + use psb_base_mod + use amg_d_prec_mod, amg_protect_name => amg_dprecbld + + Implicit None + + ! Arguments + type(psb_dspmat_type),intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_dprec_type),intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local Variables + type(amg_dprec_type) :: t_prec + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k,err_act, iszv, newsz + integer(psb_ipk_) :: ipv(amg_ifpsz_), val + integer(psb_ipk_) :: int_err(5) + type(amg_dml_parms) :: prm + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_dprecbld' + info = psb_success_ + int_err(1) = 0 + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + prec%ictxt = ictxt + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' + ! + + if (.not.allocated(prec%precv)) then + !! Error: should have called amg_dprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + ! + ! Check to ensure all procs have the same + ! + newsz = -1 + iszv = size(prec%precv) + call psb_bcast(ictxt,iszv) + if (iszv /= size(prec%precv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of precv') + goto 9999 + end if + + if (iszv <= 0) then + ! Is this really possible? probably not. + info=psb_err_from_subroutine_ + ch_err='size bpv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + ! + ! Build the preconditioner + ! + call prec%hierarchy_build(a,desc_a,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Error from hierarchy build') + goto 9999 + end if + + call prec%smoothers_build(a,desc_a,info,amold,vmold,imold) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Error from smoothers build') + goto 9999 + end if + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_dprecbld diff --git a/mlprec/impl/amg_dprecinit.F90 b/mlprec/impl/amg_dprecinit.F90 new file mode 100644 index 00000000..8181372c --- /dev/null +++ b/mlprec/impl/amg_dprecinit.F90 @@ -0,0 +1,242 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_dprecinit.f90 +! +! Subroutine: amg_dprecinit +! Version: real +! +! This routine allocates and initializes the preconditioner data structure, +! according to the preconditioner type chosen by the user. +! +! A default preconditioner is set for each preconditioner type +! specified by the user: +! +! 'NOPREC' - no preconditioner +! +! 'DIAG', 'JACOBI' - diagonal/Jacobi +! +! 'L1-DIAG', 'L1-JACOBI' - diagonal/Jacobi with L1 norm correction +! +! 'GS', 'FBGS' - Hybrid Gauss-Seidel, also symmetrized +! +! 'BJAC' - block Jacobi preconditioner, with ILU(0) +! on the local blocks +! +! 'L1-BJAC' - block Jacobi preconditioner, with ILU(0) +! on the local blocks and L1 correction for off-diag blocks +! +! 'AS' - Additive Schwarz (AS), with +! overlap 1 and ILU(0) on the local submatrices +! +! 'ML' - Multilevel hybrid preconditioner (additive on the +! same level and multiplicative through the levels), +! with 2 levels, pre and post-smoothing, RAS with +! overlap 1 and ILU(0) on the local blocks is +! applied as post-smoother at each level, but the +! coarsest one; four sweeps of the block-Jacobi solver, +! with LU from UMFPACK on the blocks, are applied at +! the coarsest level, on the distributed coarse matrix. +! The smoothed aggregation algorithm with threshold 0 +! is used to build the coarse matrix. +! +! For the multilevel preconditioners, the levels are numbered in increasing +! order starting from the finest one, i.e. level 1 is the finest level. +! +! +! Arguments: +! p - type(amg_dprec_type), input/output. +! The preconditioner data structure. +! ptype - character(len=*), input. +! The type of preconditioner. Its values are 'NOPREC', +! 'DIAG', 'BJAC', 'AS', 'ML' (and the corresponding +! lowercase strings). +! info - integer, output. +! Error code. +! +subroutine amg_dprecinit(ictxt,prec,ptype,info) + + use psb_base_mod + use amg_d_prec_mod, amg_protect_name => amg_dprecinit + use amg_d_jac_smoother + use amg_d_as_smoother + use amg_d_id_solver + use amg_d_diag_solver + use amg_d_ilu_solver + use amg_d_gs_solver +#if defined(HAVE_UMF_) + use amg_d_umf_solver +#endif +#if defined(HAVE_SLU_) + use amg_d_slu_solver +#endif + + + implicit none + + ! Arguments + integer(psb_ipk_), intent(in) :: ictxt + class(amg_dprec_type), intent(inout) :: prec + character(len=*), intent(in) :: ptype + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: nlev_, ilev_ + real(psb_dpk_) :: thr + character(len=*), parameter :: name='amg_precinit' + info = psb_success_ + + if (allocated(prec%precv)) then + call prec%free(info) + if (info /= psb_success_) then + ! Do we want to do something? + endif + endif + prec%ictxt = ictxt + prec%ag_data%min_coarse_size = -1 + + select case(psb_toupper(trim(ptype))) + case ('NOPREC','NONE') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_d_base_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_d_id_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('JAC','DIAG','JACOBI') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_d_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_d_diag_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('L1-DIAG','L1-JACOBI','L1_DIAG','L1_JACOBI') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_d_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_d_l1_diag_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('GS','FWGS') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_d_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_d_gs_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('BWGS') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_d_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_d_bwgs_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('FBGS') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + call prec%set('SMOOTHER_TYPE','FBGS',info) + call prec%precv(ilev_)%default() + + case ('BJAC') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_d_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_d_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('L1-BJAC','L1_BJAC') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_d_l1_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_d_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('AS') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_d_as_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_d_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + + case ('ML') + + nlev_ = prec%ag_data%max_levs + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + + do ilev_ = 1, nlev_ + call prec%precv(ilev_)%default() + end do + call prec%set('ML_CYCLE','VCYCLE',info) + call prec%set('SMOOTHER_TYPE','FBGS',info) +#if defined(HAVE_UMF_) + call prec%set('COARSE_SOLVE','UMF',info) +#elif defined(HAVE_MUMPS_) + call prec%set('COARSE_SOLVE','MUMPS',info) +#elif defined(HAVE_SLU_) + call prec%set('COARSE_SOLVE','SLU',info) +#else + call prec%set('COARSE_SOLVE','ILU',info) +#endif + + case default + write(psb_err_unit,*) name,& + &': Warning: Unknown preconditioner type request "',ptype,'"' + info = psb_err_pivot_too_small_ + + end select + + +end subroutine amg_dprecinit diff --git a/mlprec/impl/amg_dprecset.F90 b/mlprec/impl/amg_dprecset.F90 new file mode 100644 index 00000000..1e49287b --- /dev/null +++ b/mlprec/impl/amg_dprecset.F90 @@ -0,0 +1,229 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_dprecset.f90 +! +subroutine amg_dprecsetsm(p,val,info,ilev,ilmax,pos) + + use psb_base_mod + use amg_d_prec_mod, amg_protect_name => amg_dprecsetsm + + implicit none + + ! Arguments + class(amg_dprec_type), intent(inout) :: p + class(amg_d_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ + character(len=*), parameter :: name='amg_precsetsm' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + ilmin_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmin_ = 1 + ilmax_ = nlev_ + end if + + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + do ilev_ = ilmin_, ilmax_ + call p%precv(ilev_)%set(val,info,pos=pos) + if (info /= 0) return + end do + +end subroutine amg_dprecsetsm + +subroutine amg_dprecsetsv(p,val,info,ilev,ilmax,pos) + + use psb_base_mod + use amg_d_prec_mod, amg_protect_name => amg_dprecsetsv + + implicit none + + ! Arguments + class(amg_dprec_type), intent(inout) :: p + class(amg_d_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ + character(len=*), parameter :: name='amg_precsetsv' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + ilmin_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmin_ = 1 + ilmax_ = nlev_ + end if + + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + do ilev_ = ilmin_, ilmax_ + call p%precv(ilev_)%set(val,info,pos=pos) + if (info /= 0) return + end do + +end subroutine amg_dprecsetsv + +subroutine amg_dprecsetag(p,val,info,ilev,ilmax,pos) + + use psb_base_mod + use amg_d_prec_mod, amg_protect_name => amg_dprecsetag + + implicit none + + ! Arguments + class(amg_dprec_type), intent(inout) :: p + class(amg_d_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev, ilmax + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ + character(len=*), parameter :: name='amg_precsetag' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + ilmin_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmin_ = 1 + ilmax_ = nlev_ + end if + + + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + do ilev_ = ilmin_, ilmax_ + call p%precv(ilev_)%set(val,info,pos=pos) + if (info /= 0) return + end do + +end subroutine amg_dprecsetag + diff --git a/mlprec/impl/amg_dslu_interface.c b/mlprec/impl/amg_dslu_interface.c new file mode 100644 index 00000000..b7ae17bb --- /dev/null +++ b/mlprec/impl/amg_dslu_interface.c @@ -0,0 +1,309 @@ +/* + * + * MLD2P4 version 2.1 + * MultiLevel Domain Decomposition Parallel Preconditioners Package + * based on PSBLAS (Parallel Sparse BLAS version 3.5) + * + * (C) Copyright 2008-2018 + * + * Salvatore Filippone + * Pasqua D'Ambra + * Daniela di Serafino + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions, and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the MLD2P4 group or the names of its contributors may + * not be used to endorse or promote products derived from this + * software without specific written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * + * File: amg_slu_interface.c + * + * Functions: amg_dslu_fact, amg_dslu_solve, amg_dslu_free. + * + * This file is an interface to the SuperLU routines for sparse factorization and + * solve. It was obtained by modifying the c_fortran_dgssv.c file from the SuperLU + * source distribution; original copyright terms are reproduced below. + * + */ + + +/* ===================== + +Copyright (c) 2003, The Regents of the University of California, through +Lawrence Berkeley National Laboratory (subject to receipt of any required +approvals from U.S. Dept. of Energy) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +(1) Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +(2) Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. +(3) Neither the name of Lawrence Berkeley National Laboratory, U.S. Dept. of +Energy nor the names of its contributors may be used to endorse or promote +products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +/* + * -- SuperLU routine (version 3.0) -- + * Univ. of California Berkeley, Xerox Palo Alto Research Center, + * and Lawrence Berkeley National Lab. + * October 15, 2003 + * + */ + +#ifdef Have_SLU_ +#include "slu_ddefs.h" + +#define HANDLE_SIZE 8 + +typedef struct { + SuperMatrix *L; + SuperMatrix *U; + int *perm_c; + int *perm_r; +} factors_t; + + +#else + +#include + +#endif + + + +int amg_dslu_fact(int n, int nnz, double *values, + int *colptr, int *rowind, void **f_factors) +{ +/* + * This routine can be called from Fortran. + * performs LU decomposition. + * + * f_factors (input/output) + * On output contains the pointer pointing to + * the structure of the factored matrices. + * + */ + +#ifdef Have_SLU_ + SuperMatrix A, AC; + SuperMatrix *L, *U; + int *perm_r; /* row permutations from partial pivoting */ + int *perm_c; /* column permutation vector */ + int *etree; /* column elimination tree */ + SCformat *Lstore; + NCformat *Ustore; + int i, panel_size, permc_spec, relax; + trans_t trans; + mem_usage_t mem_usage; + superlu_options_t options; + SuperLUStat_t stat; + factors_t *LUfactors; + GlobalLU_t Glu; /* Not needed on return. */ + int info; + + trans = NOTRANS; + + + /* Set the default input options. */ + set_default_options(&options); + + /* Initialize the statistics variables. */ + StatInit(&stat); + + dCreate_CompCol_Matrix(&A, n, n, nnz, values, rowind, colptr, + SLU_NC, SLU_D, SLU_GE); + L = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) ); + U = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) ); + if ( !(perm_r = intMalloc(n)) ) ABORT("Malloc fails for perm_r[]."); + if ( !(perm_c = intMalloc(n)) ) ABORT("Malloc fails for perm_c[]."); + if ( !(etree = intMalloc(n)) ) ABORT("Malloc fails for etree[]."); + + /* + * Get column permutation vector perm_c[], according to permc_spec: + * permc_spec = 0: natural ordering + * permc_spec = 1: minimum degree on structure of A'*A + * permc_spec = 2: minimum degree on structure of A'+A + * permc_spec = 3: approximate minimum degree for unsymmetric matrices + */ + options.ColPerm=2; + permc_spec = options.ColPerm; + get_perm_c(permc_spec, &A, perm_c); + + sp_preorder(&options, &A, perm_c, etree, &AC); + + panel_size = sp_ienv(1); + relax = sp_ienv(2); +#if defined(SLU_VERSION_5) + dgstrf(&options, &AC, relax, panel_size, etree, + NULL, 0, perm_c, perm_r, L, U, &Glu, &stat, &info); +#elif defined(SLU_VERSION_4) + dgstrf(&options, &AC, relax, panel_size, etree, + NULL, 0, perm_c, perm_r, L, U, &stat, &info); +#else + choke_on_me; +#endif + + if ( info == 0 ) { + Lstore = (SCformat *) L->Store; + Ustore = (NCformat *) U->Store; + dQuerySpace(L, U, &mem_usage); +#if 0 + printf("No of nonzeros in factor L = %d\n", Lstore->nnz); + printf("No of nonzeros in factor U = %d\n", Ustore->nnz); + printf("No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz); + printf("L\\U MB %.3f\ttotal MB needed %.3f\n", + mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); +#endif + } else { + printf("dgstrf() error returns INFO= %d\n", info); + if ( info <= n ) { /* factorization completes */ + dQuerySpace(L, U, &mem_usage); + printf("L\\U MB %.3f\ttotal MB needed %.3f\n", + mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); + } + } + + /* Save the LU factors in the factors handle */ + LUfactors = (factors_t*) SUPERLU_MALLOC(sizeof(factors_t)); + LUfactors->L = L; + LUfactors->U = U; + LUfactors->perm_c = perm_c; + LUfactors->perm_r = perm_r; + *f_factors = (void *) LUfactors; + + /* Free un-wanted storage */ + SUPERLU_FREE(etree); + Destroy_SuperMatrix_Store(&A); + Destroy_CompCol_Permuted(&AC); + StatFree(&stat); + return(info); +#else + fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); + return(-1); +#endif +} + + +int amg_dslu_solve(int itrans, int n, int nrhs, double *b, int ldb, + void *f_factors) +{ + /* + * This routine can be called from Fortran. + * performs triangular solve + * + */ + int info; +#ifdef Have_SLU_ + SuperMatrix B; + SuperMatrix *L, *U; + int *perm_r; /* row permutations from partial pivoting */ + int *perm_c; /* column permutation vector */ + int *etree; /* column elimination tree */ + SCformat *Lstore; + NCformat *Ustore; + int i, panel_size, permc_spec, relax; + trans_t trans; + SuperLUStat_t stat; + factors_t *LUfactors; + + if (itrans == 0) { + trans = NOTRANS; + } else if (itrans ==1) { + trans = TRANS; + } else if (itrans ==2) { + trans = CONJ; + } else { + trans = NOTRANS; + } + /* Initialize the statistics variables. */ + StatInit(&stat); + + /* Extract the LU factors in the factors handle */ + LUfactors = (factors_t*) f_factors; + L = LUfactors->L; + U = LUfactors->U; + perm_c = LUfactors->perm_c; + perm_r = LUfactors->perm_r; + + dCreate_Dense_Matrix(&B, n, nrhs, b, ldb, SLU_DN, SLU_D, SLU_GE); + /* Solve the system A*X=B, overwriting B with X. */ + dgstrs(trans, L, U, perm_c, perm_r, &B, &stat, &info); + + Destroy_SuperMatrix_Store(&B); + StatFree(&stat); +#else + fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); + info=-1; +#endif + return(info); +} + + +int amg_dslu_free(void *f_factors) +{ + /* + * This routine can be called from Fortran. + * + * free all storage in the end + * + */ +#ifdef Have_SLU_ + factors_t *LUfactors; + + /* Free the LU factors in the factors handle */ + LUfactors = (factors_t*) f_factors; + if (LUfactors != NULL) { + SUPERLU_FREE (LUfactors->perm_r); + SUPERLU_FREE (LUfactors->perm_c); + Destroy_SuperNode_Matrix(LUfactors->L); + Destroy_CompCol_Matrix(LUfactors->U); + SUPERLU_FREE (LUfactors->L); + SUPERLU_FREE (LUfactors->U); + SUPERLU_FREE (LUfactors); + } + return(0); +#else + fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); + return(-1); +#endif +} + + diff --git a/mlprec/impl/amg_dslud_interface.c b/mlprec/impl/amg_dslud_interface.c new file mode 100644 index 00000000..8f681a23 --- /dev/null +++ b/mlprec/impl/amg_dslud_interface.c @@ -0,0 +1,391 @@ +/* + * + * MLD2P4 version 2.1 + * MultiLevel Domain Decomposition Parallel Preconditioners Package + * based on PSBLAS (Parallel Sparse BLAS version 3.5) + * + * (C) Copyright 2008-2018 + * + * Salvatore Filippone + * Ambra Abdullahi Hassan + * Alfredo Buttari CNRS-IRIT, Toulouse, FR + * Pasqua D'Ambra + * Daniela di Serafino + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions, and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the MLD2P4 group or the names of its contributors may + * not be used to endorse or promote products derived from this + * software without specific written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * + * File: amg_dslud_interface.c + * + * Functions: amg_dsludist_fact, amg_dsludist_solve, amg_dsludist_free. + * + * This file is an interface to the SuperLU_dist routines for sparse factorization and + * solve. It was obtained by modifying the c_fortran_dgssv.c file from the SuperLU_dist + * source distribution; original copyright terms are reproduced below. + * + */ + +/* ===================== + +Copyright (c) 2003, The Regents of the University of California, through +Lawrence Berkeley National Laboratory (subject to receipt of any required +approvals from U.S. Dept. of Energy) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +(1) Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +(2) Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. +(3) Neither the name of Lawrence Berkeley National Laboratory, U.S. Dept. of +Energy nor the names of its contributors may be used to endorse or promote +products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +/* + * -- Distributed SuperLU routine (version 2.0) -- + * Lawrence Berkeley National Lab, Univ. of California Berkeley. + * March 15, 2003 + * + */ + +#ifdef Have_SLUDist_ +#include +#include "superlu_ddefs.h" + +#define HANDLE_SIZE 8 + +#if defined(SLUD_VERSION_63) +typedef struct { + SuperMatrix *A; + dLUstruct_t *LUstruct; + gridinfo_t *grid; + dScalePermstruct_t *ScalePermstruct; +} factors_t; +#else +typedef struct { + SuperMatrix *A; + LUstruct_t *LUstruct; + gridinfo_t *grid; + ScalePermstruct_t *ScalePermstruct; +} factors_t; +#endif + +#else + +#include + +#endif + + +int amg_dsludist_fact(int n, int nl, int nnzl, int ffstr, + double *values, int *rowptr, int *colind, + void **f_factors, int nprow, int npcol) +{ +/* + * This routine can be called from Fortran. + * performs LU decomposition. + * + * f_factors (input/output) void** + * On output contains the pointer pointing to + * the structure of the factored matrices. + * + */ + +#ifdef Have_SLUDist_ + SuperMatrix *A; + NRformat_loc *Astore; + +#if defined(SLUD_VERSION_63) + dScalePermstruct_t *ScalePermstruct; + dLUstruct_t *LUstruct; + dSOLVEstruct_t SOLVEstruct; +#else + ScalePermstruct_t *ScalePermstruct; + LUstruct_t *LUstruct; + SOLVEstruct_t SOLVEstruct; +#endif + gridinfo_t *grid; + int i, panel_size, permc_spec, relax, info; + trans_t trans; + double drop_tol = 0.0, b[1], berr[1]; +#if defined(SLUD_VERSION_63) || defined(SLUD_VERSION_6)||defined(SLUD_VERSION_5) + superlu_dist_options_t options; +#elif defined(SLUD_VERSION_4)||defined(SLUD_VERSION_3) + superlu_options_t options; +#else + choke_on_me; +#endif + SuperLUStat_t stat; + factors_t *LUfactors; + int fst_row; + int *icol,*irpt; + double *ival; + + trans = NOTRANS; + grid = (gridinfo_t *) SUPERLU_MALLOC(sizeof(gridinfo_t)); + superlu_gridinit(MPI_COMM_WORLD, nprow, npcol, grid); + /* Initialize the statistics variables. */ + PStatInit(&stat); + fst_row = (ffstr); + + A = (SuperMatrix *) malloc(sizeof(SuperMatrix)); + dCreate_CompRowLoc_Matrix_dist(A, n, n, nnzl, nl, fst_row, + values, colind, rowptr, + SLU_NR_loc, SLU_D, SLU_GE); + + /* Initialize ScalePermstruct and LUstruct. */ +#if defined(SLUD_VERSION_63) + ScalePermstruct = (dScalePermstruct_t *) SUPERLU_MALLOC(sizeof(dScalePermstruct_t)); + LUstruct = (dLUstruct_t *) SUPERLU_MALLOC(sizeof(dLUstruct_t)); + dScalePermstructInit(n,n, ScalePermstruct); +#else + ScalePermstruct = (ScalePermstruct_t *) SUPERLU_MALLOC(sizeof(ScalePermstruct_t)); + LUstruct = (LUstruct_t *) SUPERLU_MALLOC(sizeof(LUstruct_t)); + ScalePermstructInit(n,n, ScalePermstruct); +#endif +#if defined(SLUD_VERSION_63) + dLUstructInit(n, LUstruct); +#elif defined(SLUD_VERSION_4) || defined(SLUD_VERSION_5) || defined(SLUD_VERSION_6) + LUstructInit(n, LUstruct); +#elif defined(SLUD_VERSION_3) + LUstructInit(n,n, LUstruct); +#else + choke_on_me; +#endif + + /* Set the default input options. */ + set_default_options_dist(&options); + options.IterRefine=NO; + options.PrintStat=NO; + + pdgssvx(&options, A, ScalePermstruct, b, nl, 0, + grid, LUstruct, &SOLVEstruct, berr, &stat, &info); + + if ( info == 0 ) { + ; + } else { + printf("pdgssvx() error returns INFO= %d\n", info); + if ( info <= n ) { /* factorization completes */ + ; + } + } + if (options.SolveInitialized) { + dSolveFinalize(&options,&SOLVEstruct); + } + + + /* Save the LU factors in the factors handle */ + LUfactors = (factors_t *) SUPERLU_MALLOC(sizeof(factors_t)); + LUfactors->LUstruct = LUstruct; + LUfactors->grid = grid; + LUfactors->A = A; + LUfactors->ScalePermstruct = ScalePermstruct; +/* fprintf(stderr,"slud factor: LUFactors %p \n",LUfactors); */ +/* fprintf(stderr,"slud factor: A %p %p\n",A,LUfactors->A); */ +/* fprintf(stderr,"slud factor: grid %p %p\n",grid,LUfactors->grid); */ +/* fprintf(stderr,"slud factor: LUstruct %p %p\n",LUstruct,LUfactors->LUstruct); */ + *f_factors = (void *) LUfactors; + PStatFree(&stat); + return(info); +#else + fprintf(stderr," SLUDist Not Configured, fix make.inc and recompile\n"); + return(-1); +#endif +} + + +int amg_dsludist_solve(int itrans, int n, int nrhs, + double *b, int ldb, void *f_factors) + +{ +/* + * This routine can be called from Fortran. + * performs triangular solve + * + */ +#ifdef Have_SLUDist_ + SuperMatrix *A; +#if defined(SLUD_VERSION_63) + dScalePermstruct_t *ScalePermstruct; + dLUstruct_t *LUstruct; + dSOLVEstruct_t SOLVEstruct; +#else + ScalePermstruct_t *ScalePermstruct; + LUstruct_t *LUstruct; + SOLVEstruct_t SOLVEstruct; +#endif + gridinfo_t *grid; + int i, panel_size, permc_spec, relax, info; + trans_t trans; + double drop_tol = 0.0; + double *berr; +#if defined(SLUD_VERSION_63) || defined(SLUD_VERSION_6) ||defined(SLUD_VERSION_5) + superlu_dist_options_t options; +#elif defined(SLUD_VERSION_4)|| defined(SLUD_VERSION_3) + superlu_options_t options; +#else + choke_on_me; +#endif + SuperLUStat_t stat; + factors_t *LUfactors; + + LUfactors = (factors_t *) f_factors ; + A = LUfactors->A ; + LUstruct = LUfactors->LUstruct ; + grid = LUfactors->grid ; + + ScalePermstruct = LUfactors->ScalePermstruct; +/* fprintf(stderr,"slud solve: LUFactors %p \n",LUfactors); */ +/* fprintf(stderr,"slud solve: A %p %p\n",A,LUfactors->A); */ +/* fprintf(stderr,"slud solve: grid %p %p\n",grid,LUfactors->grid); */ +/* fprintf(stderr,"slud solve: LUstruct %p %p\n",LUstruct,LUfactors->LUstruct); */ + + + if (itrans == 0) { + trans = NOTRANS; + } else if (itrans ==1) { + trans = TRANS; + } else if (itrans ==2) { + trans = CONJ; + } else { + trans = NOTRANS; + } + +/* fprintf(stderr,"Entry to sludist_solve\n"); */ + berr = (double *) malloc((nrhs) *sizeof(double)); + + /* Initialize the statistics variables. */ + PStatInit(&stat); + + /* Set the default input options. */ + set_default_options_dist(&options); + options.IterRefine = NO; + options.Fact = FACTORED; + options.PrintStat = NO; + + pdgssvx(&options, A, ScalePermstruct, b, ldb, nrhs, + grid, LUstruct, &SOLVEstruct, berr, &stat, &info); + +/* fprintf(stderr,"Double check: after solve %d %lf\n",*info,berr[0]); */ + if (options.SolveInitialized) { + dSolveFinalize(&options,&SOLVEstruct); + } + PStatFree(&stat); + free(berr); + return(info); +#else + fprintf(stderr," SLUDist Not Configured, fix make.inc and recompile\n"); + return(-1); +#endif + +} + + +int amg_dsludist_free(void *f_factors) +{ +/* + * This routine can be called from Fortran. + * + * free all storage in the end +* + */ +#ifdef Have_SLUDist_ + SuperMatrix *A; +#if defined(SLUD_VERSION_63) + dScalePermstruct_t *ScalePermstruct; + dLUstruct_t *LUstruct; + dSOLVEstruct_t SOLVEstruct; +#else + ScalePermstruct_t *ScalePermstruct; + LUstruct_t *LUstruct; + SOLVEstruct_t SOLVEstruct; +#endif + gridinfo_t *grid; + int i, panel_size, permc_spec, relax; + trans_t trans; + double drop_tol = 0.0; + double *berr; +#if defined(SLUD_VERSION_63)||defined(SLUD_VERSION_6)||defined(SLUD_VERSION_5) + superlu_dist_options_t options; +#elif defined(SLUD_VERSION_4)||defined(SLUD_VERSION_3) + superlu_options_t options; +#else + choke_on_me; +#endif + SuperLUStat_t stat; + factors_t *LUfactors; + + + if (f_factors == NULL) + return(0); + LUfactors = (factors_t *) f_factors ; + A = LUfactors->A ; + LUstruct = LUfactors->LUstruct ; + grid = LUfactors->grid ; + ScalePermstruct = LUfactors->ScalePermstruct; + + // Memory leak: with SuperLU_Dist 3.3 + // we either have a leak or a segfault here. + // To be investigated further. + //Destroy_CompRowLoc_Matrix_dist(A); +#if defined(SLUD_VERSION_63) + dScalePermstructFree(ScalePermstruct); + dLUstructFree(LUstruct); +#else + ScalePermstructFree(ScalePermstruct); + LUstructFree(LUstruct); +#endif + superlu_gridexit(grid); + + free(grid); + free(LUstruct); + free(LUfactors); + return(0); + +#else + fprintf(stderr," SLUDist Not Configured, fix make.inc and recompile\n"); + return(-1); +#endif +} + + diff --git a/mlprec/impl/amg_dumf_interface.c b/mlprec/impl/amg_dumf_interface.c new file mode 100644 index 00000000..50ac4b9a --- /dev/null +++ b/mlprec/impl/amg_dumf_interface.c @@ -0,0 +1,195 @@ +/* + * + * MLD2P4 version 2.1 + * MultiLevel Domain Decomposition Parallel Preconditioners Package + * based on PSBLAS (Parallel Sparse BLAS version 3.5) + * + * (C) Copyright 2008-2018 + * + * Salvatore Filippone + * Pasqua D'Ambra + * Daniela di Serafino + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions, and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the MLD2P4 group or the names of its contributors may + * not be used to endorse or promote products derived from this + * software without specific written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * + * File: amg_umf_interface.c + * + * Functions: amg_dumf_fact_, amg_dumf_solve_, amg_umf_free_. + * + * This file is an interface to the UMFPACK routines for sparse factorization and + * solve. It was obtained by adapting umfpack_di_demo under the original UMFPACK + * copyright terms reproduced below. + * + */ + +/* ===================== +UMFPACK Version 4.4 (Jan. 28, 2005), Copyright (c) 2005 by Timothy A. +Davis. All Rights Reserved. + +UMFPACK License: + + Your use or distribution of UMFPACK or any modified version of + UMFPACK implies that you agree to this License. + + THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY + EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + + Permission is hereby granted to use or copy this program, provided + that the Copyright, this License, and the Availability of the original + version is retained on all copies. User documentation of any code that + uses UMFPACK or any modified version of UMFPACK code must cite the + Copyright, this License, the Availability note, and "Used by permission." + Permission to modify the code and to distribute modified code is granted, + provided the Copyright, this License, and the Availability note are + retained, and a notice that the code was modified is included. This + software was developed with support from the National Science Foundation, + and is provided to you free of charge. + +Availability: + + http://www.cise.ufl.edu/research/sparse/umfpack + +*/ + + +#include +#ifdef Have_UMF_ +#include "umfpack.h" +#endif + +int amg_dumf_fact(int n, int nnz, + double *values, int *rowind, int *colptr, + void **symptr, void **numptr, + long long int *ssize, + long long int *nsize) + +{ + +#ifdef Have_UMF_ + double Info [UMFPACK_INFO], Control [UMFPACK_CONTROL]; + void *Symbolic, *Numeric ; + int i, info; + + + umfpack_di_defaults(Control); + + info = umfpack_di_symbolic (n, n, colptr, rowind, values, &Symbolic, + Control, Info); + + + if ( info == UMFPACK_OK ) { + info = 0; + } else { + printf("umfpack_di_symbolic() error returns INFO= %d\n", info); + umfpack_di_report_status(Control,info); + *symptr = (void *) NULL; + *numptr = (void *) NULL; + return -11; + } + + *symptr = Symbolic; + *ssize = Info[UMFPACK_SYMBOLIC_SIZE]; + *ssize *= Info[UMFPACK_SIZE_OF_UNIT]; + + info = umfpack_di_numeric (colptr, rowind, values, Symbolic, &Numeric, + Control, Info) ; + + + if ( info == UMFPACK_OK ) { + info = 0; + *numptr = Numeric; + *nsize = Info[UMFPACK_NUMERIC_SIZE]; + *nsize *= Info[UMFPACK_SIZE_OF_UNIT]; + + } else { + printf("umfpack_di_numeric() error returns INFO= %d\n", info); + umfpack_di_report_status(Control,info); + info = -12; + *numptr = NULL; + } + + + return info; + +#else + fprintf(stderr," UMF Not Configured, fix make.inc and recompile\n"); + return -1; +#endif +} + + +int amg_dumf_solve(int itrans, int n, + double *x, double *b, int ldb, + void *numptr) + +{ +#ifdef Have_UMF_ + double Info [UMFPACK_INFO], Control [UMFPACK_CONTROL]; + void *Symbolic, *Numeric ; + int i,trans, info; + + + umfpack_di_defaults(Control); + Control[UMFPACK_IRSTEP]=0; + + + if (itrans == 0) { + trans = UMFPACK_A; + } else if (itrans ==1) { + trans = UMFPACK_At; + } else { + trans = UMFPACK_A; + } + + info = umfpack_di_solve(trans,NULL,NULL,NULL, + x,b,numptr,Control,Info); + return info; +#else + fprintf(stderr," UMF Not Configured, fix make.inc and recompile\n"); + return -1; +#endif + +} + + +int amg_dumf_free(void *symptr, void *numptr) + +{ +#ifdef Have_UMF_ + void *Symbolic, *Numeric ; + Symbolic = symptr; + Numeric = numptr; + + if (numptr != NULL) umfpack_di_free_numeric(&Numeric); + if (symptr != NULL) umfpack_di_free_symbolic(&Symbolic); + return 0; +#else + fprintf(stderr," UMF Not Configured, fix make.inc and recompile\n"); + return -1; +#endif +} + + diff --git a/mlprec/impl/amg_s_extprol_bld.F90 b/mlprec/impl/amg_s_extprol_bld.F90 new file mode 100644 index 00000000..39379e03 --- /dev/null +++ b/mlprec/impl/amg_s_extprol_bld.F90 @@ -0,0 +1,534 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_s_extprol_bld.f90 +! +! Subroutine: amg_s_extprol_bld +! Version: real +! +! This routine builds the preconditioner according to the requirements made by +! the user trough the subroutines amg_precinit and amg_precset. +! +! A multilevel preconditioner is regarded as an array of 'one-level' data structures, +! each containing the part of the preconditioner associated to a certain level, +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level. No transfer operators are associated to level 1. +! +! +! Arguments: +! a - type(psb_sspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_sprec_type), input/output. +! The preconditioner data structure containing the local part +! of the preconditioner to be built. +! info - integer, output. +! Error code. +! +! amold - class(psb_s_base_sparse_mat), input, optional +! Mold for the inner format of matrices contained in the +! preconditioner +! +! +! vmold - class(psb_s_base_vect_type), input, optional +! Mold for the inner format of vectors contained in the +! preconditioner +! +! +! +subroutine amg_s_extprol_bld(a,desc_a,p,prolv,restrv,info,amold,vmold,imold) + + use psb_base_mod + use amg_s_inner_mod + use amg_s_prec_mod, amg_protect_name => amg_s_extprol_bld + + Implicit None + + ! Arguments + type(psb_sspmat_type),intent(in), target :: a + type(psb_sspmat_type),intent(inout), target :: prolv(:) + type(psb_sspmat_type),intent(inout), target :: restrv(:) + type(psb_desc_type), intent(inout), target :: desc_a + type(amg_sprec_type),intent(inout),target :: p + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! !$ character, intent(in), optional :: upd + + ! Local Variables + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, casize, nplevs, mxplevs + integer(psb_ipk_) :: nprolv, nrestrv + real(psb_spk_) :: mnaggratio + integer(psb_ipk_) :: ipv(amg_ifpsz_), val + class(amg_s_base_smoother_type), allocatable :: coarse_sm, base_sm, med_sm + type(amg_sml_parms) :: baseparms, medparms, coarseparms + type(amg_s_onelev_type), allocatable :: tprecv(:) + integer(psb_ipk_) :: int_err(5) + character :: upd_ + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + logical, parameter :: debug=.false. + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_s_extprol_bld' + info = psb_success_ + int_err(1) = 0 + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + p%ictxt = ictxt + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' +#if defined(LPK8) + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Need fix for LPK8') + goto 9999 +#else + + ! + ! For the time being we are commenting out the UPDATE argument + ! we plan to resurrect it later. + ! !$ if (present(upd)) then + ! !$ if (debug_level >= psb_debug_outer_) & + ! !$ & write(debug_unit,*) me,' ',trim(name),'UPD ', upd + ! !$ + ! !$ if ((psb_toupper(upd).eq.'F').or.(psb_toupper(upd).eq.'T')) then + ! !$ upd_=psb_toupper(upd) + ! !$ else + ! !$ upd_='F' + ! !$ endif + ! !$ else + ! !$ upd_='F' + ! !$ endif + upd_ = 'F' + + if (.not.allocated(p%precv)) then + !! Error: should have called amg_sprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + ! + ! Check to ensure all procs have the same + ! + newsz = -1 + mxplevs = p%ag_data%max_levs + mnaggratio = p%ag_data%min_cr_ratio + casize = p%ag_data%min_coarse_size + iszv = size(p%precv) + nprolv = size(prolv) + nrestrv = size(restrv) + call psb_bcast(ictxt,iszv) + call psb_bcast(ictxt,casize) + call psb_bcast(ictxt,mxplevs) + call psb_bcast(ictxt,mnaggratio) + call psb_bcast(ictxt,nprolv) + call psb_bcast(ictxt,nrestrv) + if (casize /= p%ag_data%min_coarse_size) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent min_coarse_size') + goto 9999 + end if + if (mxplevs /= p%ag_data%max_levs) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent max_levs') + goto 9999 + end if + if (mnaggratio /= p%ag_data%min_cr_ratio) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent min_cr_ratio') + goto 9999 + end if + if (iszv /= size(p%precv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of precv') + goto 9999 + end if + if (nprolv /= size(prolv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of prolv') + goto 9999 + end if + if (nrestrv /= size(restrv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of restrv') + goto 9999 + end if + if (nrestrv /= nprolv) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size prolv vs restrv') + goto 9999 + end if + + if (iszv <= 1) then + ! We should only ever get here for multilevel. + info=psb_err_from_subroutine_ + ch_err='size bpv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + endif + + if (nrestrv < 1) then + ! We should only ever get here for multilevel. + info=psb_err_from_subroutine_ + ch_err='size restrv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + endif + + ! + nplevs = nrestrv + 1 + p%ag_data%max_levs = nplevs + + ! + ! Fixed number of levels. + ! + nplevs = max(itwo,mxplevs) + + coarseparms = p%precv(iszv)%parms + baseparms = p%precv(1)%parms + medparms = p%precv(2)%parms + + allocate(coarse_sm, source=p%precv(iszv)%sm,stat=info) + if (info == psb_success_) & + & allocate(med_sm, source=p%precv(2)%sm,stat=info) + if (info == psb_success_) & + & allocate(base_sm, source=p%precv(1)%sm,stat=info) + if (info /= psb_success_) then + write(0,*) 'Error in saving smoothers',info + call psb_errpush(psb_err_internal_error_,name,a_err='Base level precbuild.') + goto 9999 + end if + + if (iszv /= nplevs) then + allocate(tprecv(nplevs),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + tprecv(1)%parms = baseparms + allocate(tprecv(1)%sm,source=base_sm,stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + do i=2,nplevs-1 + tprecv(i)%parms = medparms + allocate(tprecv(i)%sm,source=med_sm,stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + end do + tprecv(nplevs)%parms = coarseparms + allocate(tprecv(nplevs)%sm,source=coarse_sm,stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + do i=1,iszv + call p%precv(i)%free(info) + end do + call move_alloc(tprecv,p%precv) + iszv = size(p%precv) + end if + ! + ! Finest level first; remember to fix base_a and base_desc + ! + p%precv(1)%base_a => a + p%precv(1)%base_desc => desc_a + newsz = 0 + array_build_loop: do i=2, iszv + + ! + ! Sanity checks on the parameters + ! + if (i p%precv(i)%ac + p%precv(i)%base_desc => p%precv(i)%desc_ac + + + if (i>2) then + if (all(p%precv(i)%map%naggr == p%precv(i-1)%map%naggr)) then + newsz=i-1 + end if + call psb_bcast(ictxt,newsz) + if (newsz > 0) exit array_build_loop + end if + end do array_build_loop + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Internal extprol build' ) + goto 9999 + endif + + iszv = size(p%precv) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Exiting with',iszv,' levels' +#endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + + subroutine amg_s_extaggr_bld(a,desc_a,p,op_restr,op_prol,info) + use psb_base_mod + use amg_s_inner_mod + + implicit none + + ! Arguments + type(psb_sspmat_type), intent(in), target :: a + type(psb_sspmat_type), intent(inout) :: op_restr,op_prol + type(psb_desc_type), intent(in), target :: desc_a + type(amg_s_onelev_type), intent(inout),target :: p + integer(psb_ipk_), intent(out) :: info + + ! Local variables + character(len=20) :: name + integer(psb_mpk_) :: ictxt, np, me, ncol + integer(psb_ipk_) :: err_act,ntaggr,nzl + integer(psb_ipk_), allocatable :: ilaggr(:), nlaggr(:) + type(psb_sspmat_type) :: ac, am2, am3, am4 + type(psb_s_coo_sparse_mat) :: acoo, bcoo + type(psb_s_csr_sparse_mat) :: acsr1 + logical, parameter :: debug=.false. + + name='amg_s_extaggr_bld' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) +#if defined(LPK8) + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Need fix for LPK8') + goto 9999 +#else + allocate(nlaggr(np),ilaggr(1)) + nlaggr = 0 + ilaggr = 0 + p%parms%par_aggr_alg = amg_ext_aggr_ + call amg_check_def(p%parms%ml_cycle,'Multilevel cycle',& + & amg_mult_ml_,is_legal_ml_cycle) + call amg_check_def(p%parms%coarse_mat,'Coarse matrix',& + & amg_distr_mat_,is_legal_ml_coarse_mat) + + nlaggr(me+1) = op_restr%get_nrows() + if (op_restr%get_nrows() /= op_prol%get_ncols()) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent restr/prol sizes') + goto 9999 + end if + call psb_sum(ictxt,nlaggr) + ntaggr = sum(nlaggr) + ncol = desc_a%get_local_cols() + if (debug) write(0,*)me,' Sizes:',op_restr%get_nrows(),op_restr%get_ncols(),& + & op_prol%get_nrows(),op_prol%get_ncols(), a%get_nrows(),a%get_ncols() + ! + ! Compute local part of AC + ! + call op_prol%clone(am2,info) + if (info == psb_success_) call psb_sphalo(am2,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.) + if (info == psb_success_) call psb_rwextd(ncol,am2,info,b=am4) + if (info == psb_success_) call am4%free() + call psb_spspmm(a,am2,am3,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 2') + goto 9999 + end if + call psb_sphalo(am3,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.) + if (info == psb_success_) call psb_rwextd(ncol,am3,info,b=am4) + if (info == psb_success_) call am4%free() + if(info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Extend am3') + goto 9999 + end if + call psb_spspmm(op_restr,am3,ac,info) + if (info == psb_success_) call am3%free() + if (info == psb_success_) call ac%cscnv(info,type='csr',dupl=psb_dupl_add_) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Build ac = op_restr x am3') + goto 9999 + end if + + select case(p%parms%coarse_mat) + + case(amg_distr_mat_) + + call ac%mv_to(bcoo) + nzl = bcoo%get_nzeros() + + if (info == psb_success_) call psb_cdall(ictxt,p%desc_ac,info,nl=nlaggr(me+1)) + if (info == psb_success_) call psb_cdins(nzl,bcoo%ia,bcoo%ja,p%desc_ac,info) + if (info == psb_success_) call psb_cdasb(p%desc_ac,info) + if (info == psb_success_) call psb_glob_to_loc(bcoo%ia(1:nzl),p%desc_ac,info,iact='I') + if (info == psb_success_) call psb_glob_to_loc(bcoo%ja(1:nzl),p%desc_ac,info,iact='I') + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Creating p%desc_ac and converting ac') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Assembld aux descr. distr.' + call p%ac%mv_from(bcoo) + + call p%ac%set_nrows(p%desc_ac%get_local_rows()) + call p%ac%set_ncols(p%desc_ac%get_local_cols()) + call p%ac%set_asb() + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_sp_free') + goto 9999 + end if + + if (np>1) then + call op_prol%mv_to(acsr1) + nzl = acsr1%get_nzeros() + call psb_glob_to_loc(acsr1%ja(1:nzl),p%desc_ac,info,'I') + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_glob_to_loc') + goto 9999 + end if + call op_prol%mv_from(acsr1) + endif + call op_prol%set_ncols(p%desc_ac%get_local_cols()) + + if (np>1) then + call op_restr%cscnv(info,type='coo',dupl=psb_dupl_add_) + call op_restr%mv_to(acoo) + nzl = acoo%get_nzeros() + if (info == psb_success_) call psb_glob_to_loc(acoo%ia(1:nzl),p%desc_ac,info,'I') + call acoo%set_dupl(psb_dupl_add_) + if (info == psb_success_) call op_restr%mv_from(acoo) + if (info == psb_success_) call op_restr%cscnv(info,type='csr') + if(info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Converting op_restr to local') + goto 9999 + end if + end if + call op_restr%set_nrows(p%desc_ac%get_local_cols()) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ac ' + + case(amg_repl_mat_) + ! + ! + call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) + if (info == psb_success_) call psb_cdasb(p%desc_ac,info) + if (info == psb_success_) & + & call psb_gather(p%ac,ac,p%desc_ac,info,dupl=psb_dupl_add_,keeploc=.false.) + + if (info /= psb_success_) goto 9999 + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_coarse_mat_') + goto 9999 + end select + + call p%ac%cscnv(info,type='csr',dupl=psb_dupl_add_) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv') + goto 9999 + end if + + ! + ! Copy the prolongation/restriction matrices into the descriptor map. + ! op_restr => PR^T i.e. restriction operator + ! op_prol => PR i.e. prolongation operator + ! + + p%map = psb_linmap(psb_map_aggr_,desc_a,& + & p%desc_ac,op_restr,op_prol,ilaggr,nlaggr) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_Free') + goto 9999 + end if +#endif + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + end subroutine amg_s_extaggr_bld + +end subroutine amg_s_extprol_bld diff --git a/mlprec/impl/amg_s_hierarchy_bld.f90 b/mlprec/impl/amg_s_hierarchy_bld.f90 new file mode 100644 index 00000000..6a46b0da --- /dev/null +++ b/mlprec/impl/amg_s_hierarchy_bld.f90 @@ -0,0 +1,539 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_s_hierarchy_bld.f90 +! +! Subroutine: amg_s_hierarchy_bld +! Version: real +! +! This routine builds the preconditioner according to the requirements made by +! the user trough the subroutines amg_precinit and amg_precset. +! +! A multilevel preconditioner is regarded as an array of 'one-level' data structures, +! each containing the part of the preconditioner associated to a certain level, +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level. No transfer operators are associated to level 1. +! +! +! Arguments: +! a - type(psb_sspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_sprec_type), input/output. +! The preconditioner data structure; upon exit it contains +! the multilevel hierarchy of prolongators, restrictors +! and coarse matrices. +! info - integer, output. +! Error code. +! +subroutine amg_s_hierarchy_bld(a,desc_a,prec,info) + + use psb_base_mod + use amg_s_inner_mod + use amg_s_prec_mod, amg_protect_name => amg_s_hierarchy_bld + + Implicit None + + ! Arguments + type(psb_sspmat_type),intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_sprec_type),intent(inout),target :: prec + integer(psb_ipk_), intent(out) :: info + + ! Local Variables + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz,& + & nplevs, mxplevs + integer(psb_lpk_) :: iaggsize, casize + real(psb_spk_) :: mnaggratio, sizeratio, athresh, aomega + class(amg_s_base_smoother_type), allocatable :: coarse_sm, med_sm, & + & med_sm2, coarse_sm2 + class(amg_s_base_aggregator_type), allocatable :: tmp_aggr + type(amg_sml_parms) :: medparms, coarseparms + integer(psb_lpk_), allocatable :: ilaggr(:), nlaggr(:) + type(psb_lsspmat_type) :: op_prol + type(amg_s_onelev_type), allocatable :: tprecv(:) + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + integer(psb_ipk_), save :: idx_bldtp=-1, idx_matasb=-1 + logical, parameter :: do_timings=.false. + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_s_hierarchy_bld' + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + prec%ictxt = ictxt + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' + if ((do_timings).and.(idx_bldtp==-1)) & + & idx_bldtp = psb_get_timer_idx("BLD_HIER: bld_tprol") + if ((do_timings).and.(idx_matasb==-1)) & + & idx_matasb = psb_get_timer_idx("BLD_HIER: mmat_asb") + ! + + if (.not.allocated(prec%precv)) then + !! Error: should have called amg_sprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + ! + ! Check to ensure all procs have the same + ! + newsz = -1 + mxplevs = prec%ag_data%max_levs + mnaggratio = prec%ag_data%min_cr_ratio + casize = prec%ag_data%min_coarse_size + iszv = size(prec%precv) + call psb_bcast(ictxt,iszv) + call psb_bcast(ictxt,casize) + call psb_bcast(ictxt,mxplevs) + call psb_bcast(ictxt,mnaggratio) + if (casize /= prec%ag_data%min_coarse_size) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent min_coarse_size') + goto 9999 + end if + if (mxplevs /= prec%ag_data%max_levs) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent max_levs') + goto 9999 + end if + if (mnaggratio /= prec%ag_data%min_cr_ratio) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent min_cr_ratio') + goto 9999 + end if + if (iszv /= size(prec%precv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of precv') + goto 9999 + end if + + if (iszv < 1) then + ! + ! This is wrong, cannot be size <1 + ! + info=psb_err_from_subroutine_ + ch_err='size bpv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + endif + if (iszv == 1) then + ! + ! This is OK, since it may be called by the user even if there + ! is only one level + ! + prec%precv(1)%base_a => a + prec%precv(1)%base_desc => desc_a + + call psb_erractionrestore(err_act) + return + endif + + ! + ! The strategy: + ! 1. The maximum number of levels should be already encoded in the + ! size of the array; + ! 2. If the user did not specify anything, then a default coarse size + ! is generated, and the number of levels is set to the maximum; + ! 3. If the size of the array is different from target number of levels, + ! reallocate; + ! 4. Build the matrix hierarchy, stopping early if either the target + ! coarse size is hit, or the gain falls below the min_cr_ratio + ! threshold. + ! + + if (casize < 0) then + ! + ! Default to the cubic root of the size at base level. + ! + casize = desc_a%get_global_rows() + casize = int((sone*casize)**(sone/(sone*3)),psb_lpk_) + casize = max(casize,lone) + casize = casize*40_psb_lpk_ + call psb_bcast(ictxt,casize) + if (casize > huge(prec%ag_data%min_coarse_size)) then + ! + ! computed coarse size does not fit in IPK_. + ! This is very unlikely, but make sure to put a positive number + ! + prec%ag_data%min_coarse_size = huge(prec%ag_data%min_coarse_size) + else + prec%ag_data%min_coarse_size = casize + end if + end if + nplevs = max(itwo,mxplevs) + + ! + ! The coarse parameters will be needed later + ! + coarseparms = prec%precv(iszv)%parms + call save_smoothers(prec%precv(iszv),coarse_sm,coarse_sm2,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Base level precbuild.') + goto 9999 + end if + ! + ! First set desired number of levels + ! + if (iszv /= nplevs) then + allocate(tprecv(nplevs),stat=info) + ! First all existing levels + do i=1, min(iszv,nplevs) - 1 + if (info == 0) tprecv(i)%parms = prec%precv(i)%parms + if (info == 0) call restore_smoothers(tprecv(i),& + & prec%precv(i)%sm,prec%precv(i)%sm2a,info) + if (info == 0) call move_alloc(prec%precv(i)%aggr,tprecv(i)%aggr) + end do + if (iszv < nplevs) then + ! Further intermediates, if needed + allocate(tmp_aggr,source=tprecv(iszv-1)%aggr,stat=info) + medparms = prec%precv(iszv-1)%parms + call save_smoothers(prec%precv(iszv-1),med_sm,med_sm2,info) + do i=iszv, nplevs - 1 + if (info == 0) tprecv(i)%parms = medparms + if (info == 0) call restore_smoothers(tprecv(i),med_sm,med_sm2,info) + if ((info == 0).and..not.allocated(tprecv(i)%aggr))& + & allocate(tprecv(i)%aggr,source=tmp_aggr,stat=info) + end do + deallocate(tmp_aggr,stat=info) + end if + + ! Then coarse + if (info == 0) tprecv(nplevs)%parms = coarseparms + if (info == 0) call restore_smoothers(tprecv(nplevs),coarse_sm,coarse_sm2,info) + if (info == 0) then + if (nplevs <= iszv) then + allocate(tprecv(nplevs)%aggr,source=prec%precv(nplevs)%aggr,stat=info) + else + allocate(tmp_aggr,source=tprecv(nplevs-1)%aggr,stat=info) + call move_alloc(tmp_aggr,tprecv(nplevs)%aggr) + end if + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + + do i=1,iszv + call prec%precv(i)%free(info) + end do + call move_alloc(tprecv,prec%precv) + iszv = size(prec%precv) + end if + + ! + ! Finest level first; create a GEN_BLOCK + ! copy of the descriptor. + ! + prec%precv(1)%base_a => a + call psb_cd_renum_block(desc_a,prec%precv(1)%desc_ac,info) + prec%precv(1)%base_desc => prec%precv(1)%desc_ac + newsz = 0 + array_build_loop: do i=2, iszv + ! + ! Check on the iprcparm contents: they should be the same + ! on all processes. + ! + call psb_bcast(ictxt,prec%precv(i)%parms) + + ! + ! Sanity checks on the parameters + ! + if (i= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Calling mlprcbld at level ',i + ! + ! Build the mapping between levels i-1 and i and the matrix + ! at level i + ! + if (do_timings) call psb_tic(idx_bldtp) + if (info == psb_success_)& + & call prec%precv(i)%bld_tprol(prec%precv(i-1)%base_a,& + & prec%precv(i-1)%base_desc,& + & ilaggr,nlaggr,op_prol,prec%ag_data,info) + if (do_timings) call psb_toc(idx_bldtp) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Map build') + goto 9999 + endif + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Return from ',i,' call to bld_tprol', info + ! + ! Save op_prol just in case + ! + call op_prol%clone(prec%precv(i)%tprol,info) + ! + ! Check for early termination of aggregation loop. + ! + iaggsize = sum(nlaggr) + + sizeratio = iaggsize + if (i==2) then + sizeratio = desc_a%get_global_rows()/sizeratio + else + sizeratio = sum(prec%precv(i-1)%map%naggr)/sizeratio + end if + prec%precv(i)%szratio = sizeratio + + if (iaggsize <= casize) newsz = i + if (i == iszv) newsz = i + + if (i>2) then + if (sizeratio < mnaggratio) then + if (sizeratio > 1) then + newsz = i + else + ! + ! We are not gaining + ! + newsz = i-1 + end if + end if + + if (all(nlaggr == prec%precv(i-1)%map%naggr)) then + newsz=i-1 + if (me == 0) then + write(debug_unit,*) trim(name),& + &': Warning: aggregates from level ',& + & newsz + write(debug_unit,*) trim(name),& + &': to level ',& + & iszv,' coincide.' + write(debug_unit,*) trim(name),& + &': Number of levels actually used :',newsz + write(debug_unit,*) + end if + end if + end if + call psb_bcast(ictxt,newsz) + + if (newsz > 0) then + ! + ! This is awkward, we are saving the aggregation parms, for the sake + ! of distr/repl matrix at coarse level. Should be rethought. + ! + athresh = prec%precv(newsz)%parms%aggr_thresh + aomega = prec%precv(newsz)%parms%aggr_omega_val + if (info == 0) prec%precv(newsz)%parms = coarseparms + prec%precv(newsz)%parms%aggr_thresh = athresh + prec%precv(newsz)%parms%aggr_omega_val = aomega + + if (info == 0) call restore_smoothers(prec%precv(newsz),& + & coarse_sm,coarse_sm2,info) + if (newsz < i) then + ! + ! We are going back and revisit a previous leve; + ! recover the aggregation. + ! + ilaggr = prec%precv(newsz)%map%iaggr + nlaggr = prec%precv(newsz)%map%naggr + call prec%precv(newsz)%tprol%clone(op_prol,info) + end if + if (do_timings) call psb_tic(idx_matasb) + if (info == psb_success_) call prec%precv(newsz)%mat_asb( & + & prec%precv(newsz-1)%base_a,prec%precv(newsz-1)%base_desc,& + & ilaggr,nlaggr,op_prol,info) + if (do_timings) call psb_toc(idx_matasb) + if (info /= 0) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Mat asb') + goto 9999 + endif + exit array_build_loop + else + if (do_timings) call psb_tic(idx_matasb) + if (info == psb_success_) call prec%precv(i)%mat_asb(& + & prec%precv(i-1)%base_a,prec%precv(i-1)%base_desc,& + & ilaggr,nlaggr,op_prol,info) + if (do_timings) call psb_toc(idx_matasb) + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Map build') + goto 9999 + endif + if (i 0) then + ! + ! We exited early from the build loop, need to fix + ! the size. + ! + allocate(tprecv(newsz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + do i=1,newsz + call prec%precv(i)%move_alloc(tprecv(i),info) + end do + do i=newsz+1, iszv + call prec%precv(i)%free(info) + end do + call move_alloc(tprecv,prec%precv) + ! Ignore errors from transfer + info = psb_success_ + ! + ! Restart + iszv = newsz + ! Fix the pointers, but the level 1 should + ! be treated differently + if (.not.associated(prec%precv(1)%base_desc,desc_a)) then + prec%precv(1)%base_desc => prec%precv(1)%desc_ac + end if + do i=2, iszv + prec%precv(i)%base_a => prec%precv(i)%ac + prec%precv(i)%base_desc => prec%precv(i)%desc_ac + prec%precv(i)%map%p_desc_U => prec%precv(i-1)%base_desc + prec%precv(i)%map%p_desc_V => prec%precv(i)%base_desc + end do + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Internal hierarchy build' ) + goto 9999 + endif + + iszv = size(prec%precv) + + call prec%cmp_complexity() + call prec%cmp_avg_cr() + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Exiting with',iszv,' levels' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + subroutine save_smoothers(level,save1, save2,info) + type(amg_s_onelev_type), intent(inout) :: level + class(amg_s_base_smoother_type), allocatable , intent(inout) :: save1, save2 + integer(psb_ipk_), intent(out) :: info + + info = 0 + if (allocated(save1)) then + call save1%free(info) + if (info == 0) deallocate(save1,stat=info) + if (info /= 0) return + end if + if (allocated(save2)) then + call save2%free(info) + if (info == 0) deallocate(save2,stat=info) + if (info /= 0) return + end if + allocate(save1, mold=level%sm,stat=info) + if (info == 0) call level%sm%clone_settings(save1,info) + if ((info == 0).and.allocated(level%sm2a)) then + allocate(save2, mold=level%sm2a,stat=info) + if (info == 0) call level%sm2a%clone_settings(save2,info) + end if + + return + end subroutine save_smoothers + + subroutine restore_smoothers(level,save1, save2,info) + type(amg_s_onelev_type), intent(inout), target :: level + class(amg_s_base_smoother_type), allocatable, intent(inout) :: save1, save2 + integer(psb_ipk_), intent(out) :: info + + info = 0 + + if (allocated(level%sm)) then + if (info == 0) call level%sm%free(info) + if (info == 0) deallocate(level%sm,stat=info) + end if + if (allocated(save1)) then + if (info == 0) allocate(level%sm,mold=save1,stat=info) + if (info == 0) call save1%clone_settings(level%sm,info) + end if + + if (info /= 0) return + + if (allocated(level%sm2a)) then + if (info == 0) call level%sm2a%free(info) + if (info == 0) deallocate(level%sm2a,stat=info) + end if + if (allocated(save2)) then + if (info == 0) allocate(level%sm2a,mold=save2,stat=info) + if (info == 0) call save2%clone_settings(level%sm2a,info) + if (info == 0) level%sm2 => level%sm2a + else + if (allocated(level%sm)) level%sm2 => level%sm + end if + + return + end subroutine restore_smoothers + +end subroutine amg_s_hierarchy_bld diff --git a/mlprec/impl/amg_s_smoothers_bld.f90 b/mlprec/impl/amg_s_smoothers_bld.f90 new file mode 100644 index 00000000..6d9561f5 --- /dev/null +++ b/mlprec/impl/amg_s_smoothers_bld.f90 @@ -0,0 +1,313 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_s_smoothers_bld.f90 +! +! Subroutine: amg_s_smoothers_bld +! Version: real +! +! This routine performs the final phase of the multilevel preconditioner +! build process: builds the "smoother" objects at each level, +! based on the matrix hierarchy prepared by amg_s_hierarchy_bld. +! +! A multilevel preconditioner is regarded as an array of 'one-level' +! data structures, each containing the part of the +! preconditioner associated to a certain level, +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level. No transfer operators are associated to level 1. +! Each level provides a "build" method; for the base type, the "one-level" +! build procedure simply invokes the build method of the first smoother object, +! and also on the second object if allocated. +! +! +! Arguments: +! a - type(psb_sspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_sprec_type), input/output. +! The preconditioner data structure containing the local part +! of the preconditioner to be built. +! info - integer, output. +! Error code. +! +! amold - class(psb_s_base_sparse_mat), input, optional +! Mold for the inner format of matrices contained in the +! preconditioner +! +! +! vmold - class(psb_s_base_vect_type), input, optional +! Mold for the inner format of vectors contained in the +! preconditioner +! +! +! +subroutine amg_s_smoothers_bld(a,desc_a,prec,info,amold,vmold,imold) + + use psb_base_mod + !use amg_s_inner_mod + use amg_s_prec_mod, amg_protect_name => amg_s_smoothers_bld + + Implicit None + + ! Arguments + type(psb_sspmat_type),intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_sprec_type),intent(inout),target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local Variables + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, nplevs, mxplevs + real(psb_spk_) :: mnaggratio + integer(psb_ipk_) :: coarse_solve_id + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_s_smoothers_bld' + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' + ! + if (.not.allocated(prec%precv)) then + !! Error: should have called amg_sprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + ! + ! Check to ensure all procs have the same + ! + iszv = size(prec%precv) + call psb_bcast(ictxt,iszv) + if (iszv /= size(prec%precv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of precv') + goto 9999 + end if + + if (iszv < 1) then + ! We should never get here. + info=psb_err_from_subroutine_ + ch_err='size bpv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + endif + + ! + ! Issue a warning for inconsistent changes to COARSE_SOLVE + ! but only if it really is a multilevel + ! + if ((me == psb_root_).and.(iszv>1)) then + coarse_solve_id = prec%precv(iszv)%parms%coarse_solve + select case (coarse_solve_id) + case(amg_umf_,amg_slu_) + if (prec%precv(iszv)%sm%sv%get_id() /= coarse_solve_id) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id) + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) then + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else if (prec%precv(iszv)%parms%coarse_mat == amg_distr_mat_) then + write(psb_err_unit,*) ' but I am building BJAC with ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + end if + write(psb_err_unit,*) 'This may happen if: ' + write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' + write(psb_err_unit,*) ' 2. the solver ', amg_fact_names(coarse_solve_id),& + & ' was not configured at MLD2P4 build time, or' + write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' + end if + if (prec%precv(iszv)%parms%coarse_mat /= amg_repl_mat_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse matrix was requested as replicated', & + & ' but it has been changed to distributed.' + end if + + case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) + if (prec%precv(iszv)%sm%sv%get_id() /= psb_ilu_n_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id) + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) then + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else if (prec%precv(iszv)%parms%coarse_mat == amg_distr_mat_) then + write(psb_err_unit,*) ' but I am building BJAC with ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + end if + write(psb_err_unit,*) & + &'This may happen if coarse_subsolve has been reset' + end if + if (prec%precv(iszv)%parms%coarse_mat /= amg_repl_mat_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id),& + & ' but the coarse matrix has been changed to distributed' + end if + + case(amg_mumps_) + if (prec%precv(iszv)%sm%sv%get_id() /= amg_mumps_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id) + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) then + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else if (prec%precv(iszv)%parms%coarse_mat == amg_distr_mat_) then + write(psb_err_unit,*) ' but I am building BJAC with ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + end if + write(psb_err_unit,*) 'This may happen if: ' + write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' + write(psb_err_unit,*) ' 2. the solver ', amg_fact_names(coarse_solve_id),& + & ' was not configured at MLD2P4 build time, or' + write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' + end if + + case(amg_sludist_) + if (prec%precv(iszv)%sm%sv%get_id() /= coarse_solve_id) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id) + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) then + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else if (prec%precv(iszv)%parms%coarse_mat == amg_distr_mat_) then + write(psb_err_unit,*) ' but I am building BJAC with ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + end if + write(psb_err_unit,*) 'This may happen if: ' + write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' + write(psb_err_unit,*) ' 2. the solver ', amg_fact_names(coarse_solve_id), & + & ' was not configured at MLD2P4 build time, or' + write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' + end if + if (prec%precv(iszv)%parms%coarse_mat /= amg_distr_mat_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id),& + & ' but the coarse matrix has been changed to replicated' + end if + + case(amg_bjac_,amg_l1_bjac_,amg_jac_, amg_l1_jac_, amg_gs_, amg_fbgs_, amg_l1_gs_,amg_l1_fbgs_) + if (prec%precv(iszv)%parms%coarse_mat /= amg_distr_mat_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id),& + & ' but the coarse matrix has been changed to replicated' + end if + + case default + ! We should never get here. + info=psb_err_from_subroutine_ + ch_err='unkn coarse_solve' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + + end select + end if + + ! Sanity check: need to ensure that the MUMPS local/global NZ + ! are handled correctly; this is controlled by local vs global solver. + ! From this point of view, REPL is LOCAL because it owns everyting. + ! Should really find a better way of handling this. + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) & + & call prec%precv(iszv)%sm%sv%set('MUMPS_LOC_GLOB', amg_local_solver_,info) + ! + ! Now do the real build. + ! + + do i=1, iszv + ! + ! build the base preconditioner at level i + ! + call prec%precv(i)%bld(info,amold=amold,vmold=vmold,imold=imold,ilv=i) + + if (info /= psb_success_) then + write(ch_err,'(a,i7)') 'Error @ level',i + call psb_errpush(psb_err_internal_error_,name,& + & a_err=ch_err) + goto 9999 + endif + + end do + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Exiting with',iszv,' levels' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_smoothers_bld diff --git a/mlprec/impl/amg_scprecset.F90 b/mlprec/impl/amg_scprecset.F90 new file mode 100644 index 00000000..dc9e0333 --- /dev/null +++ b/mlprec/impl/amg_scprecset.F90 @@ -0,0 +1,971 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_sprecset.f90 +! +! Subroutine: amg_sprecseti +! Version: real +! +! This routine sets the integer parameters defining the preconditioner. More +! precisely, the integer parameter identified by 'what' is assigned the value +! contained in 'val'. +! For the multilevel preconditioners, the levels are numbered in increasing +! order starting from the finest one, i.e. level 1 is the finest level. +! +! To set character and real parameters, see amg_sprecsetc and amg_sprecsetr, +! respectively. +! +! +! Arguments: +! p - type(amg_sprec_type), input/output. +! The preconditioner data structure. +! what - integer, input. +! The number identifying the parameter to be set. +! A mnemonic constant has been associated to each of these +! numbers, as reported in the MLD2P4 User's and Reference Guide. +! val - integer, input. +! The value of the parameter to be set. The list of allowed +! values is reported in the MLD2P4 User's and Reference Guide. +! info - integer, output. +! Error code. +! ilev - integer, optional, input. +! For the multilevel preconditioner, the level at which the +! preconditioner parameter has to be set. +! If nlev is not present, the parameter identified by 'what' +! is set at all the appropriate levels. +! +! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to +! MLD2P4 developers. Indeed, by using ilev it is possible to set different values +! of the same parameter at different levels 1,...,nlev-1, even in cases where +! the parameter must have the same value at all the levels but the coarsest one. +! For this reason, the interface amg_precset to this routine has been built in +! such a way that ilev is not visible to the user (see amg_prec_mod.f90). +! +subroutine amg_scprecseti(p,what,val,info,ilev,ilmax,pos,idx) + + use psb_base_mod + use amg_s_prec_mod, amg_protect_name => amg_scprecseti + use amg_s_jac_smoother + use amg_s_as_smoother + use amg_s_diag_solver + use amg_s_l1_diag_solver + use amg_s_ilu_solver + use amg_s_id_solver + use amg_s_gs_solver +#if defined(HAVE_SLU_) + use amg_s_slu_solver +#endif +#if defined(HAVE_MUMPS_) + use amg_s_mumps_solver +#endif + + + implicit none + + ! Arguments + class(amg_sprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_, ilmax_, il + character(len=*), parameter :: name='amg_precseti' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmax_ = nlev_ + end if + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + select case(psb_toupper(what)) + case ('MIN_COARSE_SIZE') + p%ag_data%min_coarse_size = max(val,-1) + return + case('MAX_LEVS') + p%ag_data%max_levs = max(val,1) + return + case ('OUTER_SWEEPS') + p%outer_sweeps = max(val,1) + return + end select + + ! + ! Set preconditioner parameters at level ilev. + ! + if (present(ilev)) then + + select case(psb_toupper(what)) + case('SMOOTHER_TYPE','SUB_SOLVE','SMOOTHER_SWEEPS',& + & 'ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD',& + & 'AGGR_TYPE','AGGR_PROL','AGGR_OMEGA_ALG',& + & 'AGGR_EIG','SUB_RESTR','SUB_PROL', & + & 'SUB_OVR','SUB_FILLIN',& + & 'COARSE_MAT') + do il=ilev_, ilmax_ + call p%precv(il)%set(what,val,info,pos=pos) + end do + + case('COARSE_SUBSOLVE') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + call p%precv(ilev_)%set('SUB_SOLVE',val,info,pos=pos) + case('COARSE_SOLVE') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_SOLVE',val,info,pos=pos) + select case (val) + case(amg_bjac_,amg_l1_bjac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',val,info,pos=pos) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) +#else + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) +#endif + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info) + case(amg_slu_) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) + case(amg_mumps_) +#if defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(amg_umf_) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + + case(amg_sludist_) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(amg_jac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_diag_scale_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + + case(amg_l1_jac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_l1_diag_scale_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_gs_,amg_fbgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_gs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_bwgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_bwgs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_l1_gs_,amg_l1_fbgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_l1_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_gs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + end select + + endif + case('COARSE_SWEEPS') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + call p%precv(nlev_)%set('SMOOTHER_SWEEPS',val,info,pos=pos) + + case('COARSE_FILLIN') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + call p%precv(nlev_)%set('SUB_FILLIN',val,info,pos=pos) + + case default + do il=ilev_, ilmax_ + call p%precv(il)%set(what,val,info,pos=pos,idx=idx) + end do + end select + + + else if (.not.present(ilev)) then + ! + ! ilev not specified: set preconditioner parameters at all the appropriate + ! levels + ! + select case(psb_toupper(trim(what))) + case('SUB_SOLVE','SUB_RESTR','SUB_PROL',& + & 'SUB_OVR','SUB_FILLIN',& + & 'SMOOTHER_SWEEPS','SMOOTHER_TYPE') + do ilev_=1,max(1,nlev_-1) + call p%precv(ilev_)%set(what,val,info,pos=pos) + if (info /= 0) return + end do + + case('ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD','AGGR_PROL','AGGR_TYPE',& + & 'AGGR_OMEGA_ALG','AGGR_EIG','AGGR_FILTER') + do ilev_=1,nlev_ + call p%precv(ilev_)%set(what,val,info,pos=pos) + if (info /= 0) return + end do + + case('COARSE_MAT') + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_MAT',val,info,pos=pos) + end if + + case('COARSE_SOLVE') + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_SOLVE',val,info,pos=pos) + select case (val) + case(amg_bjac_,amg_l1_bjac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',val,info,pos=pos) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) +#else + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) +#endif + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info) + case(amg_slu_) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) + case(amg_mumps_) +#if defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(amg_umf_) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + + case(amg_sludist_) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(amg_jac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_diag_scale_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + + case(amg_l1_jac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_l1_diag_scale_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_gs_,amg_fbgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_gs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_bwgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_bwgs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_l1_gs_,amg_l1_fbgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_l1_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_gs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + end select + endif + + case('COARSE_SUBSOLVE') + if (nlev_ > 1) then + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + endif + + case('COARSE_SWEEPS') + + if (nlev_ > 1) then + call p%precv(nlev_)%set('SMOOTHER_SWEEPS',val,info,pos=pos) + end if + + case('COARSE_FILLIN') + if (nlev_ > 1) then + call p%precv(nlev_)%set('SUB_FILLIN',val,info,pos=pos) + end if + + case default + do ilev_=1,nlev_ + call p%precv(ilev_)%set(what,val,info,pos=pos,idx=idx) + end do + end select + + endif + +end subroutine amg_scprecseti + +! +! Subroutine: amg_sprecsetc +! Version: real +! +! This routine sets the character parameters defining the preconditioner. More +! precisely, the character parameter identified by 'what' is assigned the value +! contained in 'val'. +! For the multilevel preconditioners, the levels are numbered in increasing +! order starting from the finest one, i.e. level 1 is the finest level. +! +! To set integer and real parameters, see amg_sprecseti and amg_sprecsetr, +! respectively. +! +! +! Arguments: +! p - type(amg_sprec_type), input/output. +! The preconditioner data structure. +! what - integer, input. +! The number identifying the parameter to be set. +! A mnemonic constant has been associated to each of these +! numbers, as reported in the MLD2P4 User's and Reference Guide. +! string - character(len=*), input. +! The value of the parameter to be set. The list of allowed +! values is reported in the MLD2P4 User's and Reference Guide. +! info - integer, output. +! Error code. +! ilev - integer, optional, input. +! For the multilevel preconditioner, the level at which the +! preconditioner parameter has to be set. +! If nlev is not present, the parameter identified by 'what' +! is set at all the appropriate levels. +! +! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to +! MLD2P4 developers. Indeed, by using ilev it is possible to set different values +! of the same parameter at different levels 1,...,nlev-1, even in cases where +! the parameter must have the same value at all the levels but the coarsest one. +! For this reason, the interface amg_precset to this routine has been built in +! such a way that ilev is not visible to the user (see amg_prec_mod.f90). +! +subroutine amg_scprecsetc(p,what,string,info,ilev,ilmax,pos,idx) + + use psb_base_mod + use amg_s_prec_mod, amg_protect_name => amg_scprecsetc + use amg_s_jac_smoother + use amg_s_as_smoother + use amg_s_diag_solver + use amg_s_l1_diag_solver + use amg_s_ilu_solver + use amg_s_id_solver + use amg_s_gs_solver +#if defined(HAVE_SLU_) + use amg_s_slu_solver +#endif +#if defined(HAVE_MUMPS_) + use amg_s_mumps_solver +#endif + + + implicit none + + ! Arguments + class(amg_sprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + character(len=*), intent(in) :: string + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_,val,ilmax_, il + character(len=*), parameter :: name='amg_precsetc' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmax_ = nlev_ + end if + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + ! + ! Set preconditioner parameters at level ilev. + ! + if (present(ilev)) then + + select case(psb_toupper(what)) + case('SMOOTHER_TYPE','SUB_SOLVE',& + & 'ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD',& + & 'AGGR_TYPE','AGGR_PROL','AGGR_OMEGA_ALG',& + & 'AGGR_EIG','SUB_RESTR','SUB_PROL', & + & 'COARSE_MAT') + do il=ilev_, ilmax_ + call p%precv(il)%set(what,string,info,pos=pos) + end do + + case('COARSE_SUBSOLVE') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + call p%precv(ilev_)%set('SUB_SOLVE',string,info,pos=pos) + case('COARSE_SOLVE') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_SOLVE',string,info,pos=pos) + select case (psb_toupper(trim(string))) + case('BJAC', 'L1-BJAC') + call p%precv(nlev_)%set('SMOOTHER_TYPE',psb_toupper(trim(string)),info,pos=pos) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) +#else + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) +#endif + call p%precv(nlev_)%set('COARSE_MAT','dist',info) + case('SLU') +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('ILU','MILU','ILUT') + call p%precv(nlev_)%set('SMOOTHER_TYPE','bjac',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) + case('MUMPS') +#if defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('UMF') +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + + case('SLUDIST') +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('JAC','JACOBI') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','DIAG',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + + case('L1-JACOBI') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','L1-DIAG',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('GS','FWGS','FBGS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('BWGS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','BWGS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('L1-GS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','L1-BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + end select + + endif + + case default + do il=ilev_, ilmax_ + call p%precv(il)%set(what,string,info,pos=pos,idx=idx) + end do + end select + + + else if (.not.present(ilev)) then + ! + ! ilev not specified: set preconditioner parameters at all the appropriate + ! levels + ! + select case(psb_toupper(trim(what))) + case('SUB_SOLVE','SUB_RESTR','SUB_PROL',& + & 'SMOOTHER_TYPE') + do ilev_=1,max(1,nlev_-1) + call p%precv(ilev_)%set(what,string,info,pos=pos) + if (info /= 0) return + end do + + case('ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD','AGGR_PROL','AGGR_TYPE',& + & 'AGGR_OMEGA_ALG','AGGR_EIG','AGGR_FILTER') + do ilev_=1,nlev_ + call p%precv(ilev_)%set(what,string,info,pos=pos) + if (info /= 0) return + end do + + case('COARSE_MAT') + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_MAT',string,info,pos=pos) + end if + + case('COARSE_SOLVE') + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_SOLVE',string,info,pos=pos) + select case (psb_toupper(trim(string))) + case('BJAC', 'L1-BJAC') + call p%precv(nlev_)%set('SMOOTHER_TYPE',psb_toupper(trim(string)),info,pos=pos) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) +#else + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) +#endif + call p%precv(nlev_)%set('COARSE_MAT','DIST',info) + case('SLU') +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('ILU', 'ILUT','MILU') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) + case('MUMPS') +#if defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('UMF') +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + + case('SLUDIST') +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('JAC','JACOBI') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','DIAG',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('L1-JACOBI') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','L1-DIAG',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('GS','FWGS','FBGS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('BWGS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','BWGS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('L1-GS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','L1-BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + end select + endif + + case('COARSE_SUBSOLVE') + if (nlev_ > 1) then + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + endif + + case default + do ilev_=1,nlev_ + call p%precv(ilev_)%set(what,string,info,pos=pos,idx=idx) + end do + end select + + endif + + +end subroutine amg_scprecsetc + + +! +! Subroutine: amg_sprecsetr +! Version: real +! +! This routine sets the real parameters defining the preconditioner. More +! precisely, the real parameter identified by 'what' is assigned the value +! contained in 'val'. +! For the multilevel preconditioners, the levels are numbered in increasing +! order starting from the finest one, i.e. level 1 is the finest level. +! +! To set integer and character parameters, see amg_sprecseti and amg_sprecsetc, +! respectively. +! +! Arguments: +! p - type(amg_sprec_type), input/output. +! The preconditioner data structure. +! what - integer, input. +! The number identifying the parameter to be set. +! A mnemonic constant has been associated to each of these +! numbers, as reported in the MLD2P4 User's and Reference Guide. +! val - real(psb_spk_), input. +! The value of the parameter to be set. The list of allowed +! values is reported in the MLD2P4 User's and Reference Guide. +! info - integer, output. +! Error code. +! ilev - integer, optional, input. +! For the multilevel preconditioner, the level at which the +! preconditioner parameter has to be set. +! If nlev is not present, the parameter identified by 'what' +! is set at all the appropriate levels. +! +! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to +! MLD2P4 developers. Indeed, by using ilev it is possible to set different values +! of the same parameter at different levels 1,...,nlev-1, even in cases where +! the parameter must have the same value at all the levels but the coarsest one. +! For this reason, the interface amg_precset to this routine has been built in +! such a way that ilev is not visible to the user (see amg_prec_mod.f90). +! +subroutine amg_scprecsetr(p,what,val,info,ilev,ilmax,pos,idx) + + use psb_base_mod + use amg_s_prec_mod, amg_protect_name => amg_scprecsetr + + implicit none + + ! Arguments + class(amg_sprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + + ! Local variables + integer(psb_ipk_) :: ilev_,nlev_, ilmax_, il + real(psb_spk_) :: thr + character(len=*), parameter :: name='amg_precsetr' + + info = psb_success_ + + if (present(ilev)) then + ilev_ = ilev + else + ilev_ = 1 + end if + + select case(psb_toupper(what)) + case ('MIN_CR_RATIO') + p%ag_data%min_cr_ratio = max(sone,val) + return + end select + + if (.not.allocated(p%precv)) then + write(psb_err_unit,*) name,& + &': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + info = 3111 + return + endif + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmax_ = nlev_ + end if + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + + ! + ! Set preconditioner parameters at level ilev. + ! + if (present(ilev)) then + + do il=ilev_, ilmax_ + call p%precv(il)%set(what,val,info,pos=pos,idx=idx) + end do + + else if (.not.present(ilev)) then + ! + ! ilev not specified: set preconditioner parameters at all the appropriate levels + ! + + select case(psb_toupper(what)) + case('COARSE_ILUTHRS') + ilev_=nlev_ + call p%precv(ilev_)%set('SUB_ILUTHRS',val,info,pos=pos) + + case default + + do il=1,nlev_ + call p%precv(il)%set(what,val,info,pos=pos,idx=idx) + end do + end select + + endif + +end subroutine amg_scprecsetr + + diff --git a/mlprec/impl/amg_sfile_prec_descr.f90 b/mlprec/impl/amg_sfile_prec_descr.f90 new file mode 100644 index 00000000..0c788157 --- /dev/null +++ b/mlprec/impl/amg_sfile_prec_descr.f90 @@ -0,0 +1,199 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_dfile_prec_descr.f90 +! +! +! Subroutine: amg_file_prec_descr +! Version: real +! +! This routine prints a description of the preconditioner to the standard +! output or to a file. It must be called after the preconditioner has been +! built by amg_precbld. +! +! Arguments: +! p - type(amg_Tprec_type), input. +! The preconditioner data structure to be printed out. +! info - integer, output. +! error code. +! iout - integer, input, optional. +! The id of the file where the preconditioner description +! will be printed. If iout is not present, then the standard +! output is condidered. +! root - integer, input, optional. +! The id of the process printing the message; -1 acts as a wildcard. +! Default is psb_root_ +! +subroutine amg_sfile_prec_descr(prec,iout,root) + use psb_base_mod + use amg_s_prec_mod, amg_protect_name => amg_sfile_prec_descr + use amg_s_inner_mod + use amg_s_gs_solver + + implicit none + ! Arguments + class(amg_sprec_type), intent(in) :: prec + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: root + + ! Local variables + integer(psb_ipk_) :: ilev, nlev, ilmin, info, nswps + integer(psb_ipk_) :: ictxt, me, np + logical :: is_symgs + character(len=20), parameter :: name='amg_file_prec_descr' + integer(psb_ipk_) :: iout_ + integer(psb_ipk_) :: root_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + if (iout_ < 0) iout_ = psb_out_unit + + ictxt = prec%ictxt + + if (allocated(prec%precv)) then + + call psb_info(ictxt,me,np) + if (present(root)) then + root_ = root + else + root_ = psb_root_ + end if + if (root_ == -1) root_ = me + + ! + ! The preconditioner description is printed by processor psb_root_. + ! This agrees with the fact that all the parameters defining the + ! preconditioner have the same values on all the procs (this is + ! ensured by amg_precbld). + ! + if (me == root_) then + nlev = size(prec%precv) + do ilev = 1, nlev + if (.not.allocated(prec%precv(ilev)%sm)) then + info = 3111 + write(iout_,*) ' ',name,& + & ': error: inconsistent MLPREC part, should call amg_PRECINIT' + return + endif + end do + + write(iout_,*) + write(iout_,'(a)') 'Preconditioner description' + + if (nlev == 1) then + ! + ! Here we have a gigantic kludge just to handle Symmetrized Gauss-Seidel. + ! Will need rethinking... + ! + if (allocated(prec%precv(1)%sm2a)) then + is_symgs = .false. + select type(sv2 => prec%precv(1)%sm2a%sv) + class is (amg_s_bwgs_solver_type) + select type(sv1 => prec%precv(1)%sm%sv) + class is (amg_s_gs_solver_type) + is_symgs = .true. + end select + end select + if (is_symgs) then + write(iout_,*) ' Forward-Backward (symmetrized) Hybrid Gauss-Seidel' + else + write(iout_,*) 'Pre Smoother: ' + call prec%precv(1)%sm%descr(info,iout=iout_) + write(iout_,*) 'Post smoother:' + call prec%precv(1)%sm2a%descr(info,iout=iout_) + end if + nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) + + else + call prec%precv(1)%sm%descr(info,iout=iout_) + nswps = prec%precv(1)%parms%sweeps_pre + end if + if (nswps > 1) write(iout_,*) ' Number of sweeps : ',nswps + write(iout_,*) + + else if (nlev > 1) then + ! + ! Print description of base preconditioner + ! + write(iout_,*) 'Multilevel Preconditioner' + write(iout_,*) 'Outer sweeps:',prec%outer_sweeps + write(iout_,*) + if (allocated(prec%precv(1)%sm2a)) then + write(iout_,*) 'Pre Smoother: ' + call prec%precv(1)%sm%descr(info,iout=iout_) + write(iout_,*) 'Post smoother:' + call prec%precv(1)%sm2a%descr(info,iout=iout_) + else + write(iout_,*) 'Smoother: ' + call prec%precv(1)%sm%descr(info,iout=iout_) + end if + ! + ! Print multilevel details + ! + write(iout_,*) + write(iout_,*) 'Multilevel hierarchy: ' + write(iout_,*) ' Number of levels : ',nlev + write(iout_,*) ' Operator complexity: ',prec%get_complexity() + write(iout_,*) ' Average coarsening : ',prec%get_avg_cr() + ilmin = 2 + if (nlev == 2) ilmin=1 + do ilev=ilmin,nlev + call prec%precv(ilev)%descr(ilev,nlev,ilmin,info,iout=iout_) + end do + write(iout_,*) + + else + write(iout_,*) trim(name), & + & ': invalid preconditioner array size ?',nlev + info = -2 + return + + end if + end if + + else + write(iout_,*) trim(name), & + & ': Error: no base preconditioner available, something is wrong!' + info = -2 + return + endif + +end subroutine amg_sfile_prec_descr diff --git a/mlprec/impl/amg_smlprec_aply.f90 b/mlprec/impl/amg_smlprec_aply.f90 new file mode 100644 index 00000000..a13fd1bd --- /dev/null +++ b/mlprec/impl/amg_smlprec_aply.f90 @@ -0,0 +1,1669 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_smlprec_aply.f90 +! +! Subroutine: amg_smlprec_aply +! Version: real +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +! This routine computes +! +! Y = beta*Y + alpha*op(ML^(-1))*X, +! where +! - ML is a multilevel preconditioner associated with +! a certain matrix A and stored in p, +! - op(ML^(-1)) is ML^(-1) or its transpose, according to the value of trans, +! - X and Y are vectors, +! - alpha and beta are scalars. +! +! The following multilevel strategies can be applied: +! +! - Additive multilevel Schwarz, +! - classical V-cycle, +! - classical W-cycle, +! - K-cycle both for symmetric and nonsymmetric matrices, where 2 iterations +! of FCG(1) or GCR, respectively, are applied at each level +! except the coarsest. +! +! For each level we have as many submatrices as processes (except for the coarsest +! level where we might have a replicated index space) and each process takes care +! of one submatrix. +! +! A multilevel preconditioner is regarded as an array of 'one-level' data structures, +! each containing the part of the preconditioner associated to a certain level +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! For each level lev, there is a smoother stored in +! p%precv(lev)%sm +! which in turn contains a solver +! p$precv(lev)%sm%sv +! Typically the solver acts only locally, and the smoother applies any required +! parallel communication/action. +! Each level has a matrix A(lev), obtained by 'tranferring' the original +! matrix A (i.e. the matrix to be preconditioned) to the level lev, through smoothed +! aggregation. +! +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level and A(1) is the matrix A. +! +! This routine is formulated in a recursive way, so it is quite compact. +! +! The V-cycle can be described as follows, where +! P(lev) denotes the smoothed prolongator from level lev to level +! lev-1, while R(lev) denotes the corresponding restriction operator +! (normally its transpose) from level lev-1 to level lev. +! M(lev) is the smoother at the current level. +! +! +! 1. Transfer the outer vector Xest to u(1) (inner X at level 1) +! +! 2. Invoke V-cycle(1,M,P,R,A,b,u) +! +! procedure V-cycle(lev,M,P,R,A,b,u) +! +! if (lev < nlev) then +! +! u(lev) = u(lev) + M(lev)*(b(lev)-A(lev)*u(lev)) +! +! b(lev+1) = R(lev+1)*(b(lev)-A(lev)*u(lev)) +! +! u(lev+1) = V-cycle(lev+1,M,P,R,A,b,u) +! +! u(lev) = u(lev) + P(lev+1) * u(lev+1) +! +! u(lev) = u(lev) + M(lev)*(b(lev)-A(lev)*u(lev)) +! +! else +! +! solve A(lev)*u(lev) = b(lev) +! +! end if +! +! return u(lev) +! end +! +! 3. Transfer u(1) to the external: +! Yext = beta*Yext + alpha*u(1) +! +! +! In the implementation, the recursive procedure is inner_ml_aply, which +! in turn uses amg_inner_add (for additive multilevel), +! amg_inner_mult (for V-cycle and W-cycle), and +! amg_inner_k_cycle (for symmetric and non-symmetric K-cycle). +! +! For a detailed description of the algorithms, see: +! +! - B.F. Smith, P.E. Bjorstad, W.D. Gropp, +! Domain decomposition: parallel multilevel methods for elliptic partial +! differential equations, Cambridge University Press, 1996. +! +! - W. L. Briggs, V. E. Henson, S. F. McCormick, +! A Multigrid Tutorial, Second Edition +! SIAM, 2000. +! +! - K. Stuben, +! An Introduction to Algebraic Multigrid, +! in A. Schuller, U. Trottenberg, C. Oosterlee, Multigrid, Academic Press, 2001. +! +! - Y. Notay, P. S. Vassilevski, +! Recursive Krylov-based multigrid cycles +! Numerical Linear Algebra with Applications, 15 (5), 2008, 473--487. +! +! +! Arguments: +! alpha - real(psb_spk_), input. +! The scalar alpha. +! p - type(amg_sprec_type), input. +! The multilevel preconditioner data structure containing the +! local part of the preconditioner to be applied. +! Note that nlev = size(p%precv) = number of levels. +! p%precv(lev)%sm - type(psb_sbaseprec_type) +! The pre-'smoother' for the current level +! p%precv(lev)%sm2 - type(psb_sbaseprec_type) +! The post-'smoother' for the current level +! may be the same or different from %sm +! p%precv(lev)%ac - type(psb_sspmat_type) +! The local part of the matrix A(lev). +! p%precv(lev)%parms - type(psb_sml_parms) +! Parameters controllin the multilevel prec. +! p%precv(lev)%desc_ac - type(psb_desc_type). +! The communication descriptor associated to the sparse +! matrix A(lev) +! p%precv(lev)%map - type(psb_inter_desc_type) +! Stores the linear operators mapping level (lev-1) +! to (lev) and vice versa. These are the restriction +! and prolongation operators described in the sequel. +! p%precv(lev)%base_a - type(psb_sspmat_type), pointer. +! Pointer (really a pointer!) to the base matrix of +! the current level, i.e. the local part of A(lev); +! so we have a unified treatment of residuals. We +! need this to avoid passing explicitly the matrix +! A(lev) to the routine which applies the +! preconditioner. +! p%precv(lev)%base_desc - type(psb_desc_type), pointer. +! Pointer to the communication descriptor associated +! to the sparse matrix pointed by base_a. +! +! x - real(psb_spk_), dimension(:), input. +! The local part of the vector X. +! beta - real(psb_spk_), input. +! The scalar beta. +! y - real(psb_spk_), dimension(:), input/output. +! The local part of the vector Y. +! desc_data - type(psb_desc_type), input. +! The communication descriptor associated to the matrix to be +! preconditioned. +! trans - character, optional. +! If trans='N','n' then op(M^(-1)) = M^(-1); +! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). +! work - real(psb_spk_), dimension (:), optional, target. +! Workspace. Its size must be at least 4*desc_data%get_local_cols(). +! info - integer, output. +! Error code. +! +! Note that when the LU factorization of the matrix A(lev) is computed instead of +! the ILU one, by using UMFPACK or SuperLU or MUMPS, the corresponding +! L and U factors are stored in data structures handled +! by the third party software. +! +subroutine amg_smlprec_aply_vect(alpha,p,x,beta,y,desc_data,trans,work,info) + + use psb_base_mod + use amg_base_prec_type + use amg_s_inner_mod, amg_protect_name => amg_smlprec_aply_vect + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_sprec_type), intent(inout) :: p + real(psb_spk_),intent(in) :: alpha,beta + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + character, intent(in) :: trans + real(psb_spk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: ictxt, np, me + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, nc2l, level, isweep, err_act + character(len=20) :: name + character :: trans_ + real(psb_spk_) :: beta_ + logical :: do_alloc_wrk + type(amg_smlprec_wrk_type), allocatable, target :: mlprec_wrk(:) + + name='amg_smlprec_aply' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (debug_level >= psb_debug_inner_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Entry ', size(p%precv) + + trans_ = psb_toupper(trans) + nlev = size(p%precv) + + do_alloc_wrk = .not.allocated(p%precv(1)%wrk) + + if (do_alloc_wrk) call p%allocate_wrk(info,vmold=x%v) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') + goto 9999 + end if + level = 1 + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & wv => p%precv(level)%wrk%wv(:)) + ! + ! At first iteration we must use the input BETA + ! + beta_ = beta + + + call psb_geaxpby(sone,x,szero,vx2l,base_desc,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='geaxbpy') + goto 9999 + end if + + do isweep = 1, p%outer_sweeps - 1 + ! + ! With the current implementation, y2l is zeroed internally at first smoother. + ! call p%wrk(level)%vy2l%zero() + ! + call inner_ml_aply(level,p,trans_,work,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Inner prec aply') + goto 9999 + end if + call psb_geaxpby(alpha,vy2l,beta_,y,base_desc,info) + ! all iterations after the first must use BETA = 1 + beta_ = sone + ! + ! Next iteration should use the current residual to compute a correction + ! + call psb_geaxpby(sone,x,szero,vx2l,base_desc,info) + call psb_spmm(-sone,base_a,y,sone,vx2l,base_desc,info) + end do + + ! + ! If outer_sweeps == 1 we have just skipped the loop, and it's + ! equivalent to a single application. + ! + + ! + ! With the current implementation, y2l is zeroed internally at first smoother. + ! call p%wrk(level)%vy2l%zero() + ! + call inner_ml_aply(level,p,trans_,work,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Inner prec aply') + goto 9999 + end if + call psb_geaxpby(alpha,vy2l,beta_,y,base_desc,info) + + end associate + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error final update') + goto 9999 + end if + if (do_alloc_wrk) call p%free_wrk(info) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + ! + ! + ! inner_ml_aply: apply AMG at a given level. + ! This routine dispatches the computation according to the type + ! specified at the current level. + ! Each of the corrections will inturn call recursively this routine. + ! + ! Assumptions: + ! On input: + ! mlprec_wkr(level)%vx2l contains the input vector (RHS) + ! mlprec_wkr(level)%vy2l contains the initial guess + ! + ! On output: + ! mlprec_wkr(level)%vy2l contains the solution + ! + ! Constraints: each of the called routines must properly handle + ! the input/output conditions for level+1 (i.e. apply + ! prolongation/restriction). + ! Note: for historical/convenience reasons the prolongator/restrictor + ! between level and level+1 are stored at level+1. + ! + ! + recursive subroutine inner_ml_aply(level,p,trans,work,info) + + implicit none + + ! Arguments + integer(psb_ipk_) :: level + type(amg_sprec_type), target, intent(inout) :: p + character, intent(in) :: trans + real(psb_spk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + + type(psb_s_vect_type) :: res + type(psb_s_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_ml_aply' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_ml') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' Start inner_ml_aply at level ',level, info + end if + + select case(p%precv(level)%parms%ml_cycle) + + case(amg_no_ml_) + ! + ! No preconditioning, should not really get here + ! + call psb_errpush(psb_err_internal_error_,name,& + & a_err='amg_no_ml_ in mlprc_aply?') + goto 9999 + + case(amg_add_ml_) + + call amg_s_inner_add(p, level, trans, work) + + case(amg_mult_ml_,amg_vcycle_ml_, amg_wcycle_ml_) + + call amg_s_inner_mult(p, level, trans, work) + + case(amg_kcycle_ml_, amg_kcyclesym_ml_) + + call amg_s_inner_k_cycle(p, level, trans, work) + + case default + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='invalid ml_cycle',& + & i_Err=(/p%precv(level)%parms%ml_cycle,izero,izero,izero,izero/)) + goto 9999 + + end select + if(debug_level > 1) then + write(debug_unit,*) me,' End inner_ml_aply at level ',level + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine inner_ml_aply + + + recursive subroutine amg_s_inner_add(p, level, trans, work) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_sprec_type), intent(inout) :: p + + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + real(psb_spk_),target :: work(:) + type(psb_s_vect_type) :: res + type(psb_s_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act, k + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_inner_add' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_add') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_add at level ',level + end if + + if ((level<1).or.(level>nlev)) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL>NLEV') + goto 9999 + end if + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & wv => p%precv(level)%wrk%wv) + + if (allocated(p%precv(level)%sm2a)) then + call psb_geaxpby(sone,vx2l,szero,vy2l,base_desc,info) + + sweeps = max(p%precv(level)%parms%sweeps_pre,p%precv(level)%parms%sweeps_post) + do k=1, sweeps + call p%precv(level)%sm%apply(sone,& + & vy2l,szero,vty,& + & base_desc, trans,& + & ione,work,wv,info,init='Z') + + call p%precv(level)%sm2a%apply(sone,& + & vty,szero,vy2l,& + & base_desc, trans,& + & ione,work,wv,info,init='Z') + end do + + else + sweeps = p%precv(level)%parms%sweeps_pre + call p%precv(level)%sm%apply(sone,& + & vx2l,szero,vy2l,& + & base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during ADD smoother_apply') + goto 9999 + end if + + if (level < nlev) then + ! Apply the restriction + call p%precv(level+1)%map%map_U2V(sone,vx2l,& + & szero,p%precv(level+1)%wrk%vx2l,& + & info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + + call inner_ml_aply(level+1,p,trans,work,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in recursive call') + goto 9999 + end if + + ! + ! Apply the prolongator + ! + call p%precv(level+1)%map%map_V2U(sone,& + & p%precv(level+1)%wrk%vy2l, sone,vy2l,& + & info,work=work,& + & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + + end if + end associate + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_s_inner_add + + recursive subroutine amg_s_inner_mult(p, level, trans, work) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_sprec_type), intent(inout) :: p + + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + real(psb_spk_),target :: work(:) + type(psb_s_vect_type) :: res + type(psb_s_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + name = 'inner_inner_mult' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_mult') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_mult at level ',level + end if + + sweeps_post = p%precv(level)%parms%sweeps_post + sweeps_pre = p%precv(level)%parms%sweeps_pre + pre = ((sweeps_pre>0).and.(trans=='N')).or.((sweeps_post>0).and.(trans/='N')) + post = ((sweeps_post>0).and.(trans=='N')).or.((sweeps_pre>0).and.(trans/='N')) + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & wv => p%precv(level)%wrk%wv) + if (level < nlev) then + ! + ! Apply the first smoother + ! The residual has been prepared before the recursive call. + ! + + if (pre) then + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(sone,& + & vx2l,szero,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(sone,& + & vx2l,szero,vy2l, base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during PRE smoother_apply') + goto 9999 + end if + endif + ! + ! Compute the residual for next level and call recursively + ! + if (pre) then + call psb_geaxpby(sone,vx2l,& + & szero,vty,& + & base_desc,info) + + if (info == psb_success_) call psb_spmm(-sone,base_a,& + & vy2l,sone,vty,& + & base_desc,info,work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + call p%precv(level+1)%map%map_U2V(sone,vty,& + & szero,p%precv(level+1)%wrk%vx2l,& + & info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + else + ! Shortcut: just transfer x2l. + call p%precv(level+1)%map%map_U2V(sone,vx2l,& + & szero,p%precv(level+1)%wrk%vx2l,& + & info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + endif + + call inner_ml_aply(level+1,p,trans,work,info) + + ! + ! Apply the prolongator + ! + call p%precv(level+1)%map%map_V2U(sone,& + & p%precv(level+1)%wrk%vy2l,sone,vy2l,& + & info,work=work,& + & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + if (p%precv(level)%parms%ml_cycle == amg_wcycle_ml_) then + + call psb_geaxpby(sone,vx2l, szero,vty,& + & base_desc,info) + if (info == psb_success_) call psb_spmm(-sone,base_a,& + & vy2l,sone,vty,& + & base_desc,info,work=work,trans=trans) + if (info == psb_success_) & + & call p%precv(level+1)%map%map_U2V(sone,vty,& + & szero,p%precv(level+1)%wrk%vx2l,info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during W-cycle restriction') + goto 9999 + end if + + call inner_ml_aply(level+1,p,trans,work,info) + + if (info == psb_success_) call p%precv(level+1)%map%map_V2U(sone, & + & p%precv(level+1)%wrk%vy2l,sone,vy2l,& + & info,work=work,& + & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during W recusion/prolongation') + goto 9999 + end if + + endif + + + if (post) then + call psb_geaxpby(sone,vx2l,& + & szero,vty,& + & base_desc,info) + if (info == psb_success_) call psb_spmm(-sone,base_a,& + & vy2l, sone,vty,base_desc,info,& + & work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + + ! + ! Apply the second smoother + ! + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(sone,& + & vty,sone,vy2l, base_desc, trans,& + & sweeps,work,wv,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(sone,& + & vty,sone,vy2l, base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during POST smoother_apply') + goto 9999 + end if + + endif + + else if (level == nlev) then + + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(sone,& + & vx2l,szero,vy2l,base_desc, trans,& + & sweeps,work,wv,info) + + else + + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL vs NLEV') + goto 9999 + end if + end associate + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_s_inner_mult + + recursive subroutine amg_s_inner_k_cycle(p, level, trans, work,u) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_sprec_type), intent(inout) :: p + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + real(psb_spk_),target :: work(:) + type(psb_s_vect_type),intent(inout), optional :: u + + + + type(psb_s_vect_type) :: res + type(psb_s_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_kcycle' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_add') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,name,' start at level ',level + end if + + if ((level<1).or.(level>nlev)) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL>NLEV') + goto 9999 + end if + + !K cycle + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & wv => p%precv(level)%wrk%wv(8:)) + if (level == nlev) then + ! + ! Apply smoother + ! + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(sone,& + & vx2l,szero,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + + else if (level < nlev) then + + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(sone,& + & vx2l,szero,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(sone,& + & vx2l,szero,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during 2-PRE smoother_apply') + goto 9999 + end if + + + ! + ! Compute the residual and call recursively + ! + + call psb_geaxpby(sone,vx2l,& + & szero,vty,& + & base_desc,info) + + if (info == psb_success_) call psb_spmm(-sone,base_a,& + & vy2l,sone,vty,base_desc,info,work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + + ! Apply the restriction + call p%precv(level + 1)%map%map_U2V(sone,vty,& + & szero,p%precv(level + 1)%wrk%vx2l,& + &info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + + !Set the preconditioner + + if (level <= nlev - 2 ) then + if (p%precv(level)%parms%ml_cycle == amg_kcyclesym_ml_) then + call amg_sinneritkcycle(p, level + 1, trans, work, 'FCG') + elseif (p%precv(level)%parms%ml_cycle == amg_kcycle_ml_) then + call amg_sinneritkcycle(p, level + 1, trans, work, 'GCR') + else + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Bad value for ml_cycle') + goto 9999 + endif + else + call inner_ml_aply(level + 1 ,p,trans,work,info) + endif + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in recursive call') + goto 9999 + end if + + ! + ! Apply the prolongator + ! + call p%precv(level+1)%map%map_V2U(sone,& + & p%precv(level+1)%wrk%vy2l,sone,vy2l,& + & info,work=work,& + & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + ! + ! Compute the residual + ! + call psb_geaxpby(sone,vx2l,& + & szero,vty,base_desc,info) + call psb_spmm(-sone,base_a,vy2l,& + & sone,vty,base_desc,info,& + & work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + ! + ! Apply the smoother + ! + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(sone,& + & vty,sone,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(sone,& + & vty,sone,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during POST smoother_apply') + goto 9999 + end if + else + + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL vs NLEV') + goto 9999 + + endif + end associate + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_s_inner_k_cycle + + + recursive subroutine amg_sinneritkcycle(p, level, trans, work, innersolv) + use psb_base_mod + use amg_prec_mod + use amg_s_inner_mod, amg_protect_name => amg_smlprec_aply + + implicit none + + !Input/Oputput variables + type(amg_sprec_type), intent(inout) :: p + + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + character(len=*), intent(in) :: innersolv + real(psb_spk_),target :: work(:) + + !Other variables + type(psb_s_vect_type) :: v, w, rhs, v1, x + type(psb_s_vect_type) :: d0, d1 + real(psb_spk_) :: delta_old, rhs_norm, alpha, tau, tau1, tau2, tau3, tau4, beta + + real(psb_spk_) :: l2_norm, delta, rtol=0.25, delta0, tnrm + real(psb_spk_), allocatable :: temp_v(:) + integer(psb_ipk_) :: info, nlev, i, iter, max_iter=2, idx + character(len=20) :: name = 'innerit_k_cycle' + + + if (size(p%precv(level)%wrk%wv)<7) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size') + goto 9999 + end if + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & v => p%precv(level)%wrk%wv(1), & + & w => p%precv(level)%wrk%wv(2),& + & rhs => p%precv(level)%wrk%wv(3), & + & v1 => p%precv(level)%wrk%wv(4), & + & x => p%precv(level)%wrk%wv(5), & + & d0 => p%precv(level)%wrk%wv(6), & + & d1 => p%precv(level)%wrk%wv(7)) + + call x%zero() + + ! rhs=vx2l and w=rhs + call psb_geaxpby(sone,vx2l,szero,rhs, base_desc,info) + call psb_geaxpby(sone,vx2l,szero,w, base_desc,info) + + if (psb_errstatus_fatal()) then + nc2l = base_desc%get_local_cols() + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + + delta0 = psb_genrm2(w, base_desc, info) + + !Apply the preconditioner + call vy2l%zero() + + idx=0 + call inner_ml_aply(level,p,trans,work,info) + + call psb_geaxpby(sone,vy2l,szero,d0,base_desc,info) + + call psb_spmm(sone,base_a,d0,szero,v,base_desc,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + + !FCG + if (psb_toupper(trim(innersolv)) == 'FCG') then + delta_old = psb_gedot(d0, w, base_desc, info) + tau = psb_gedot(d0, v, base_desc, info) + !GCR + else if (psb_toupper(trim(innersolv)) == 'GCR') then + delta_old = psb_gedot(v, w, base_desc, info) + tau = psb_gedot(v, v, base_desc, info) + else + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid inner solver') + goto 9999 + endif + + alpha = delta_old/tau + !Update residual w + call psb_geaxpby(-alpha, v, sone, w, base_desc, info) + + l2_norm = psb_genrm2(w, base_desc, info) + iter = 0 + + if (l2_norm <= rtol*delta0) then + !Update solution x + call psb_geaxpby(alpha, d0, sone, x, base_desc, info) + else + iter = iter + 1 + idx=mod(iter,2) + + !Apply preconditioner + call psb_geaxpby(sone,w,szero,vx2l,base_desc,info) + call inner_ml_aply(level,p,trans,work,info) + call psb_geaxpby(sone,vy2l,szero,d1,base_desc,info) + + !Sparse matrix vector product + + call psb_spmm(sone,base_a,d1,szero,v1,base_desc,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + + !tau1, tau2, tau3, tau4 + if (psb_toupper(trim(innersolv)) == 'FCG') then + tau1= psb_gedot(d1, v, base_desc, info) + tau2= psb_gedot(d1, v1, base_desc, info) + tau3= psb_gedot(d1, w, base_desc, info) + tau4= tau2 - (tau1*tau1)/tau + else if (psb_toupper(trim(innersolv)) == 'GCR') then + tau1= psb_gedot(v1, v, base_desc, info) + tau2= psb_gedot(v1, v1, base_desc, info) + tau3= psb_gedot(v1, w, base_desc, info) + tau4= tau2 - (tau1*tau1)/tau + else + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid inner solver') + goto 9999 + endif + + !Update solution + alpha=alpha-(tau1*tau3)/(tau*tau4) + call psb_geaxpby(alpha,d0,sone,x,base_desc,info) + alpha=tau3/tau4 + call psb_geaxpby(alpha,d1,sone,x,base_desc,info) + endif + + call psb_geaxpby(sone,x,szero,vy2l,base_desc,info) + end associate + +9999 continue + call psb_erractionrestore(err_act) + if (err_act.eq.psb_act_abort_) then + call psb_error() + return + end if + return + end subroutine amg_sinneritkcycle + +end subroutine amg_smlprec_aply_vect + + +! +! Old routine for arrays instead of psb_X_vector. To be deleted eventually. +! +! +subroutine amg_smlprec_aply(alpha,p,x,beta,y,desc_data,trans,work,info) + + use psb_base_mod + use amg_base_prec_type + use amg_s_inner_mod, amg_protect_name => amg_smlprec_aply + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_sprec_type), intent(inout) :: p + real(psb_spk_),intent(in) :: alpha,beta + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + character, intent(in) :: trans + real(psb_spk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: ictxt, np, me + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: debug_level, debug_unit, nlev,nc2l,nr2l,level + character(len=20) :: name + character :: trans_ + type amg_mlwrk_type + real(psb_spk_), allocatable :: tx(:), ty(:), x2l(:), y2l(:) + end type amg_mlwrk_type + type(amg_mlwrk_type), allocatable, target :: mlwrk(:) + + name='amg_smlprec_aply' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (debug_level >= psb_debug_inner_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Entry ', size(p%precv) + + trans_ = psb_toupper(trans) + + nlev = size(p%precv) + allocate(mlwrk(nlev),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') + goto 9999 + end if + level = 1 + + do level = 1, nlev + call psb_geasb(mlwrk(level)%x2l,& + & p%precv(level)%base_desc,info) + call psb_geasb(mlwrk(level)%y2l,& + & p%precv(level)%base_desc,info) + call psb_geasb(mlwrk(level)%tx,& + & p%precv(level)%base_desc,info) + call psb_geasb(mlwrk(level)%ty,& + & p%precv(level)%base_desc,info) + if (psb_errstatus_fatal()) then + nc2l = p%precv(level)%base_desc%get_local_cols() + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + end do + + mlwrk(level)%x2l(:) = x(:) + mlwrk(level)%y2l(:) = szero + + call inner_ml_aply(level,p,mlwrk,trans_,work,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Inner prec aply') + goto 9999 + end if + + call psb_geaxpby(alpha,mlwrk(level)%y2l,beta,y,& + & p%precv(level)%base_desc,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error final update') + goto 9999 + end if + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + + ! + ! + ! inner_ml_aply: apply AMG at a given level. + ! This routine dispatches the computation according to the type + ! specified at the current level. + ! Each of the corrections will inturn call recursively this routine. + ! + ! Assumptions: + ! On input: + ! mlprec_wkr(level)%vx2l contains the input vector (RHS) + ! mlprec_wkr(level)%vy2l contains the initial guess + ! + ! On output: + ! mlprec_wkr(level)%vy2l contains the solution + ! + ! Constraints: each of the called routines must properly handle + ! the input/output conditions for level+1 (i.e. apply + ! prolongation/restriction). + ! Note: for historical/convenience reasons the prolongator/restrictor + ! between level and level+1 are stored at level+1. + ! + ! + recursive subroutine inner_ml_aply(level,p,mlwrk,trans,work,info) + + implicit none + + ! Arguments + integer(psb_ipk_) :: level + type(amg_sprec_type), target, intent(inout) :: p + type(amg_mlwrk_type), intent(inout), target :: mlwrk(:) + character, intent(in) :: trans + real(psb_spk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + + type(psb_s_vect_type) :: res + type(psb_s_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_ml_aply' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_ml') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_ml_aply at level ',level + end if + + select case(p%precv(level)%parms%ml_cycle) + + case(amg_no_ml_) + ! + ! No preconditioning, should not really get here + ! + call psb_errpush(psb_err_internal_error_,name,& + & a_err='amg_no_ml_ in mlprc_aply?') + goto 9999 + + case(amg_add_ml_) + + call amg_s_inner_add(p, mlwrk, level, trans, work) + + case(amg_mult_ml_, amg_vcycle_ml_, amg_wcycle_ml_) + + call amg_s_inner_mult(p, mlwrk, level, trans, work) + +! !$ case(amg_kcycle_ml_, amg_kcyclesym_ml_) +! !$ +! !$ call amg_s_inner_k_cycle(p, mlwrk, level, trans, work) + + case default + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='invalid ml_cycle',& + & i_Err=(/p%precv(level)%parms%ml_cycle,izero,izero,izero,izero/)) + goto 9999 + + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine inner_ml_aply + + + recursive subroutine amg_s_inner_add(p, mlwrk, level, trans, work) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_sprec_type), intent(inout) :: p + + type(amg_mlwrk_type), target, intent(inout) :: mlwrk(:) + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + real(psb_spk_),target :: work(:) + type(psb_s_vect_type) :: res + type(psb_s_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_inner_add' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_add') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_add at level ',level + end if + + if ((level<1).or.(level>nlev)) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL>NLEV') + goto 9999 + end if + + sweeps = p%precv(level)%parms%sweeps_pre + call p%precv(level)%sm%apply(sone,& + & mlwrk(level)%x2l,szero,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during ADD smoother_apply') + goto 9999 + end if + + if (level < nlev) then + ! Apply the restriction + call p%precv(level+1)%map%map_U2V(sone,mlwrk(level)%x2l,& + & szero,mlwrk(level+1)%x2l,& + & info,work=work) + mlwrk(level+1)%y2l(:) = szero + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + + call inner_ml_aply(level+1,p,mlwrk,trans,work,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in recursive call') + goto 9999 + end if + + ! + ! Apply the prolongator and add correction. + ! + call p%precv(level+1)%map%map_V2U(sone,& + & mlwrk(level+1)%y2l,sone,mlwrk(level)%y2l,& + & info,work=work) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_s_inner_add + + recursive subroutine amg_s_inner_mult(p, mlwrk, level, trans, work) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_sprec_type), intent(inout) :: p + + type(amg_mlwrk_type), target, intent(inout) :: mlwrk(:) + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + real(psb_spk_),target :: work(:) + type(psb_s_vect_type) :: res + type(psb_s_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_inner_mult' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_mult') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_mult at level ',level + end if + + if ((level < nlev).or.(nlev == 1)) then + sweeps_post = p%precv(level)%parms%sweeps_post + sweeps_pre = p%precv(level)%parms%sweeps_pre + else + sweeps_post = p%precv(level-1)%parms%sweeps_post + sweeps_pre = p%precv(level-1)%parms%sweeps_pre + endif + + pre = ((sweeps_pre>0).and.(trans=='N')).or.((sweeps_post>0).and.(trans/='N')) + post = ((sweeps_post>0).and.(trans=='N')).or.((sweeps_pre>0).and.(trans/='N')) + + + if (level < nlev) then + + ! + ! Apply the first smoother + ! + + if (pre) then + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(sone,& + & mlwrk(level)%x2l,szero,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info,init='Y') + else + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(sone,& + & mlwrk(level)%x2l,szero,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info,init='Y') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during PRE smoother_apply') + goto 9999 + end if + endif + + ! + ! Compute the residual and call recursively + ! + if (pre) then + call psb_geaxpby(sone,mlwrk(level)%x2l,& + & szero,mlwrk(level)%ty,& + & p%precv(level)%base_desc,info) + + if (info == psb_success_) call psb_spmm(-sone,p%precv(level)%base_a,& + & mlwrk(level)%y2l,sone,mlwrk(level)%ty,& + & p%precv(level)%base_desc,info,work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + call p%precv(level+1)%map%map_U2V(sone,mlwrk(level)%ty,& + & szero,mlwrk(level+1)%x2l,info,work=work) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + else + ! Shortcut: just transfer x2l. + call p%precv(level+1)%map%map_U2V(sone,mlwrk(level)%x2l,& + & szero,mlwrk(level+1)%x2l,info,work=work) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + endif + ! First guess is zero + mlwrk(level+1)%y2l(:) = szero + + + call inner_ml_aply(level+1,p,mlwrk,trans,work,info) + + if (p%precv(level)%parms%ml_cycle == amg_wcycle_ml_) then + ! On second call will use output y2l as initial guess + if (info == psb_success_) call inner_ml_aply(level+1,p,mlwrk,trans,work,info) + endif + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in recursive call') + goto 9999 + end if + + + ! + ! Apply the prolongator + ! + call p%precv(level+1)%map%map_V2U(sone,mlwrk(level+1)%y2l,& + & sone,mlwrk(level)%y2l,info,work=work) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + ! + ! Compute the residual + ! + if (post) then + call psb_geaxpby(sone,mlwrk(level)%x2l,& + & szero,mlwrk(level)%tx,& + & p%precv(level)%base_desc,info) + call psb_spmm(-sone,p%precv(level)%base_a,mlwrk(level)%y2l,& + & sone,mlwrk(level)%tx,p%precv(level)%base_desc,info,& + & work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + ! + ! Apply the second smoother + ! + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(sone,& + & mlwrk(level)%tx,sone,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(sone,& + & mlwrk(level)%tx,sone,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during POST smoother_apply') + goto 9999 + end if + + endif + + else if (level == nlev) then + + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(sone,& + & mlwrk(level)%x2l,szero,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info) + + else + + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL vs NLEV') + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_s_inner_mult + + +end subroutine amg_smlprec_aply diff --git a/mlprec/impl/amg_smlprec_bld.f90 b/mlprec/impl/amg_smlprec_bld.f90 new file mode 100644 index 00000000..78360df9 --- /dev/null +++ b/mlprec/impl/amg_smlprec_bld.f90 @@ -0,0 +1,152 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_smlprec_bld.f90 +! +! Subroutine: amg_smlprec_bld +! Version: real +! +! This routine builds the preconditioner according to the requirements made by +! the user trough the subroutines amg_precinit and amg_precset. +! +! A multilevel preconditioner is regarded as an array of 'one-level' data structures, +! each containing the part of the preconditioner associated to a certain level, +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level. No transfer operators are associated to level 1. +! +! This routine simply calls amg_s_hierarchy_bld and amg_s_smoothers_bld; they +! can also be called explicitly from the user. +! +! +! Arguments: +! a - type(psb_sspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_sprec_type), input/output. +! The preconditioner data structure containing the local part +! of the preconditioner to be built. +! info - integer, output. +! Error code. +! +! amold - class(psb_s_base_sparse_mat), input, optional +! Mold for the inner format of matrices contained in the +! preconditioner +! +! +! vmold - class(psb_s_base_vect_type), input, optional +! Mold for the inner format of vectors contained in the +! preconditioner +! +! +! +subroutine amg_smlprec_bld(a,desc_a,p,info,amold,vmold,imold) + + use psb_base_mod + use amg_s_inner_mod, amg_protect_name => amg_smlprec_bld + use amg_s_prec_mod + + Implicit None + + ! Arguments + type(psb_sspmat_type),intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + type(amg_sprec_type),intent(inout),target :: p + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local Variables + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, casize, nplevs, mxplevs + real(psb_spk_) :: mnaggratio + integer(psb_ipk_) :: ipv(amg_ifpsz_), val + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_smlprec_bld' + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' + + call p%hierarchy_build(a,desc_a,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Error from hierarchy build') + goto 9999 + end if + + iszv = p%get_nlevs() + + call p%smoothers_build(a,desc_a,info,amold,vmold,imold) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Error from smoothers build') + goto 9999 + end if + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Exiting with',iszv,' levels' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_smlprec_bld diff --git a/mlprec/impl/amg_sprecaply.f90 b/mlprec/impl/amg_sprecaply.f90 new file mode 100644 index 00000000..2f0f8ff9 --- /dev/null +++ b/mlprec/impl/amg_sprecaply.f90 @@ -0,0 +1,600 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_sprecaply.f90 +! +! Subroutine: amg_sprecaply +! Version: real +! +! This routine applies the preconditioner built by amg_sprecbld, i.e. it computes +! +! Y = op(M^(-1)) * X, +! where +! - M is the preconditioner, +! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, +! - X and Y are vectors. +! This operation is performed at each iteration of a preconditioned Krylov solver. +! +! +! Arguments: +! prec - type(amg_sprec_type), input. +! The preconditioner data structure containing the local part +! of the preconditioner to be applied. +! x - real(psb_spk_), dimension(:), input. +! The local part of the vector X in Y=op(M^(-1))*X. +! y - real(psb_spk_), dimension(:), output. +! The local part of the vector Y in Y=op(M^(-1))*X. +! desc_data - type(psb_desc_type), input. +! The communication descriptor associated to the matrix to be +! preconditioned. +! info - integer, output. +! Error code. +! trans - character(len=1), optional. +! If trans='N','n' then op(M^(-1)) = M^(-1); +! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). +! work - real(psb_spk_), dimension (:), optional, target. +! Workspace. Its size must be at +! least 4*desc_data%get_local_cols(). +! +subroutine amg_sprecaply(prec,x,y,desc_data,info,trans,work) + + use psb_base_mod + use amg_s_inner_mod!, amg_protect_name => amg_sprecaply + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_sprec_type), intent(inout) :: prec + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_spk_),intent(inout), optional, target :: work(:) + + ! Local variables + character :: trans_ + real(psb_spk_), pointer :: work_(:) + real(psb_spk_), allocatable :: w1(:), w2(:) + + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: err_act,iwsz, k, nswps + character(len=20) :: name + + name='amg_sprecaply' + info = psb_success_ + call psb_erractionsave(err_act) + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (present(trans)) then + trans_=psb_toupper(trans) + else + trans_='N' + end if + + if (present(work)) then + work_ => work + else + iwsz = max(1,4*desc_data%get_local_cols()) + allocate(work_(iwsz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name, & + & i_err=(/iwsz,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + + end if + + if (.not.(allocated(prec%precv))) then + !! Error 1: should call amg_sprecbld + info=3112 + call psb_errpush(info,name) + goto 9999 + end if + + if (size(prec%precv) >1) then + ! + ! Number of levels > 1: apply the multilevel preconditioner + ! + call amg_mlprec_aply(sone,prec,x,szero,y,desc_data,trans_,work_,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_smlprec_aply') + goto 9999 + end if + + else if (size(prec%precv) == 1) then + ! + ! Number of levels = 1: apply the base preconditioner + ! + if (allocated(prec%precv(1)%sm2a)) then + nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) + ! + ! This is a kludge for handling the symmetrized GS case. + ! Will need some rethinking. + ! + call psb_geasb(w1,desc_data,info,scratch=.true.) + call psb_geasb(w2,desc_data,info,scratch=.true.) + + call psb_geaxpby(sone,x,szero,w1,desc_data,info) + select case(trans_) + case ('N') + do k=1, nswps + call prec%precv(1)%sm%apply(sone,w1,szero,w2,desc_data,trans_,& + & ione, work_,info) + call prec%precv(1)%sm2a%apply(sone,w2,szero,w1,desc_data,trans_,& + & ione, work_,info) + end do + + case('T','C') + do k=1, nswps + call prec%precv(1)%sm2a%apply(sone,w1,szero,w2,desc_data,trans_,& + & ione, work_,info) + call prec%precv(1)%sm%apply(sone,w2,szero,w1,desc_data,trans_,& + & ione, work_,info) + end do + case default + info = psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='Invalid trans') + goto 9999 + end select + call psb_geaxpby(sone,w1,szero,y,desc_data,info) + call psb_gefree(w1,desc_data,info) + call psb_gefree(w2,desc_data,info) + + else + nswps = prec%precv(1)%parms%sweeps_pre + call prec%precv(1)%sm%apply(sone,x,szero,y,desc_data,trans_,& + & nswps, work_,info) + end if + else + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='Invalid size of precv',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + endif + + ! If the original distribution has an overlap we should fix that. + call psb_halo(y,desc_data,info,data=psb_comm_mov_) + + + if (present(work)) then + else + deallocate(work_) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_sprecaply + + +! +! Subroutine: amg_sprecaply1 +! Version: real +! +! Applies the preconditioner built by amg_sprecbld, i.e. computes +! +! X = op(M^(-1)) * X, +! where +! - M is the preconditioner, +! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, +! - X is a vectors. +! This operation is performed at each iteration of a preconditioned Krylov solver. +! +! This routine differs from amg_sprecaply because the preconditioned vector X +! overwrites the original one. +! +! +! Arguments: +! prec - type(amg_sprec_type), input. +! The preconditioner data structure containing the local part +! of the preconditioner to be applied. +! x - real(psb_spk_), dimension(:), input/output. +! The local part of vector X in X := op(M^(-1)) * X. +! desc_data - type(psb_desc_type), input. +! The communication descriptor associated to the matrix to be +! preconditioned. +! info - integer, output. +! Error code. +! trans - character(len=1), optional. +! If trans='N','n' then op(M^(-1)) = M^(-1); +! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). +! +subroutine amg_sprecaply1(prec,x,desc_data,info,trans) + + use psb_base_mod + use amg_s_inner_mod!, amg_protect_name => amg_sprecaply1 + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_sprec_type), intent(inout) :: prec + real(psb_spk_),intent(inout) :: x(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: err_act + real(psb_spk_), pointer :: ww(:), w1(:) + character(len=20) :: name + + name='amg_sprecaply1' + info = psb_success_ + call psb_erractionsave(err_act) + + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + allocate(ww(size(x)),w1(size(x)),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name, & + & i_err=(/itwo*size(x),izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + + call prec%apply(x,ww,desc_data,info,trans=trans,work=w1) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_precaply') + goto 9999 + end if + + x(:) = ww(:) + deallocate(ww,w1,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_sprecaply1 + + + +subroutine amg_sprecaply2_vect(prec,x,y,desc_data,info,trans,work) + + use psb_base_mod + use amg_s_inner_mod!, amg_protect_name => amg_sprecaply2_vect + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_sprec_type), intent(inout) :: prec + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_spk_),intent(inout), optional, target :: work(:) + + ! Local variables + character :: trans_ + real(psb_spk_), pointer :: work_(:) + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: err_act,iwsz, k, nswps + logical :: do_alloc_wrk + character(len=20) :: name + + name='amg_sprecaply' + info = psb_success_ + call psb_erractionsave(err_act) + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (present(trans)) then + trans_=psb_toupper(trans) + else + trans_='N' + end if + + if (present(work)) then + work_ => work + else + iwsz = max(1,4*desc_data%get_local_cols()) + allocate(work_(iwsz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name, & + & i_err=(/iwsz,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + + end if + + if (.not.(allocated(prec%precv))) then + !! Error 1: should call amg_sprecbld + info=3112 + call psb_errpush(info,name) + goto 9999 + end if + + do_alloc_wrk = .not.allocated(prec%precv(1)%wrk) + if (do_alloc_wrk) call prec%allocate_wrk(info,vmold=x%v) + + if (size(prec%precv) >1) then + ! + ! Number of levels > 1: apply the multilevel preconditioner + ! + ! FIXME: generic name causes an ICE with Intel + call amg_smlprec_aply_vect(sone,prec,x,szero,y,desc_data,trans_,work_,info) + + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_smlprec_aply') + goto 9999 + end if + + else if (size(prec%precv) == 1) then + ! + ! Number of levels = 1: apply the base preconditioner + ! + nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) + + associate(w1 => prec%precv(1)%wrk%vx2l, w2 => prec%precv(1)%wrk%vy2l,& + & wv => prec%precv(1)%wrk%wv) + if (allocated(prec%precv(1)%sm2a)) then + ! + ! This is a kludge for handling the symmetrized GS case. + ! Will need some rethinking. + ! + call psb_geaxpby(sone,x,szero,w1,desc_data,info) + select case(trans_) + case ('N') + do k=1, nswps + if (info == 0) call prec%precv(1)%sm%apply(sone,w1,szero,w2,desc_data,trans_,& + & ione, work_,wv,info) + if (info == 0) call prec%precv(1)%sm2a%apply(sone,w2,szero,w1,desc_data,trans_,& + & ione, work_,wv,info) + end do + + case('T','C') + do k=1, nswps + if (info == 0) call prec%precv(1)%sm2a%apply(sone,w1,szero,w2,desc_data,trans_,& + & ione, work_,wv,info) + if (info == 0) call prec%precv(1)%sm%apply(sone,w2,szero,w1,desc_data,trans_,& + & ione, work_,wv,info) + end do + case default + info = psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='Invalid trans') + goto 9999 + end select + if (info == 0) call psb_geaxpby(sone,w1,szero,y,desc_data,info) + else + if (info == 0) call prec%precv(1)%sm%apply(sone,x,szero,y,desc_data,trans_,& + & nswps,work_,wv,info) + end if + end associate + if (psb_errstatus_fatal()) info = psb_err_internal_error_ + if (info /= 0) then + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='Smoother application',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + end if + + else + + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='Invalid size of precv',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + endif + + ! If the original distribution has an overlap we should fix that. + call psb_halo(y,desc_data,info,data=psb_comm_mov_) + + if (do_alloc_wrk) call prec%free_wrk(info) + + if (present(work)) then + else + deallocate(work_) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_sprecaply2_vect + + +subroutine amg_sprecaply1_vect(prec,x,desc_data,info,trans,work) + + use psb_base_mod + use amg_s_inner_mod!, amg_protect_name => amg_sprecaply1_vect + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_sprec_type), intent(inout) :: prec + type(psb_s_vect_type),intent(inout) :: x + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + real(psb_spk_),intent(inout), optional, target :: work(:) + + ! Local variables + character :: trans_ + real(psb_spk_), pointer :: work_(:) + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: err_act,iwsz, k, nswps + logical :: do_alloc_wrk + character(len=20) :: name + + name='amg_sprecaply' + info = psb_success_ + call psb_erractionsave(err_act) + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (present(trans)) then + trans_=psb_toupper(trans) + else + trans_='N' + end if + + if (present(work)) then + work_ => work + else + iwsz = max(1,4*desc_data%get_local_cols()) + allocate(work_(iwsz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name, & + & i_err=(/iwsz,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + + end if + + if (.not.(allocated(prec%precv))) then + !! Error 1: should call amg_sprecbld + info=3112 + call psb_errpush(info,name) + goto 9999 + end if + + do_alloc_wrk = .not.allocated(prec%precv(1)%wrk) + if (do_alloc_wrk) call prec%allocate_wrk(info,vmold=x%v) + + associate(ww => prec%precv(1)%wrk%vtx, wv => prec%precv(1)%wrk%wv) + + if (size(prec%precv) >1) then + ! + ! Number of levels > 1: apply the multilevel preconditioner + ! + ! FIXME: generic name causes an ICE with Intel + call amg_smlprec_aply_vect(sone,prec,x,szero,ww,desc_data,trans_,work_,info) + if (info == 0) call psb_geaxpby(sone,ww,szero,x,desc_data,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_smlprec_aply') + goto 9999 + end if + + else if (size(prec%precv) == 1) then + ! + ! Number of levels = 1: apply the base preconditioner + ! + nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) + if (allocated(prec%precv(1)%sm2a)) then + ! + ! This is a kludge for handling the symmetrized GS case. + ! Will need some rethinking. + ! + select case(trans_) + case ('N') + do k=1, nswps + if (info == 0) call prec%precv(1)%sm%apply(sone,x,szero,ww,desc_data,trans_,& + & ione, work_,wv,info) + if (info == 0) call prec%precv(1)%sm2a%apply(sone,ww,szero,x,desc_data,trans_,& + & ione, work_,wv,info) + end do + case('T','C') + do k=1, nswps + if (info == 0) call prec%precv(1)%sm2a%apply(sone,x,szero,ww,desc_data,trans_,& + & ione, work_,wv,info) + if (info == 0) call prec%precv(1)%sm%apply(sone,ww,szero,x,desc_data,trans_,& + & ione, work_,wv,info) + end do + case default + info = psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='Invalid trans') + goto 9999 + end select + + else + if (info == 0) call prec%precv(1)%sm%apply(sone,x,szero,ww,desc_data,trans_,& + & nswps, work_,wv,info) + if (info == 0) call psb_geaxpby(sone,ww,szero,x,desc_data,info) + end if + + if (psb_errstatus_fatal()) info = psb_err_internal_error_ + if (info /=0) then + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='Smoother application',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + end if + + else + + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='Invalid size of precv',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + endif + end associate + + ! If the original distribution has an overlap we should fix that. + call psb_halo(x,desc_data,info,data=psb_comm_mov_) + + if (do_alloc_wrk) call prec%free_wrk(info) + + if (present(work)) then + else + deallocate(work_) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_sprecaply1_vect diff --git a/mlprec/impl/amg_sprecbld.f90 b/mlprec/impl/amg_sprecbld.f90 new file mode 100644 index 00000000..5e9c9450 --- /dev/null +++ b/mlprec/impl/amg_sprecbld.f90 @@ -0,0 +1,161 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_sprecbld.f90 +! +! Subroutine: amg_sprecbld +! Version: real +! Contains: subroutine init_baseprec_av +! +! This routine builds the preconditioner according to the requirements made by +! the user through the subroutines amg_precinit and amg_precset. +! +! +! Arguments: +! a - type(psb_sspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_sprec_type), input/output. +! The preconditioner data structure containing the local part +! of the preconditioner to be built. +! info - integer, output. +! Error code. +! +subroutine amg_sprecbld(a,desc_a,prec,info,amold,vmold,imold) + + use psb_base_mod + use amg_s_prec_mod, amg_protect_name => amg_sprecbld + + Implicit None + + ! Arguments + type(psb_sspmat_type),intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_sprec_type),intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local Variables + type(amg_sprec_type) :: t_prec + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k,err_act, iszv, newsz + integer(psb_ipk_) :: ipv(amg_ifpsz_), val + integer(psb_ipk_) :: int_err(5) + type(amg_dml_parms) :: prm + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_sprecbld' + info = psb_success_ + int_err(1) = 0 + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + prec%ictxt = ictxt + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' + ! + + if (.not.allocated(prec%precv)) then + !! Error: should have called amg_sprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + ! + ! Check to ensure all procs have the same + ! + newsz = -1 + iszv = size(prec%precv) + call psb_bcast(ictxt,iszv) + if (iszv /= size(prec%precv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of precv') + goto 9999 + end if + + if (iszv <= 0) then + ! Is this really possible? probably not. + info=psb_err_from_subroutine_ + ch_err='size bpv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + ! + ! Build the preconditioner + ! + call prec%hierarchy_build(a,desc_a,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Error from hierarchy build') + goto 9999 + end if + + call prec%smoothers_build(a,desc_a,info,amold,vmold,imold) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Error from smoothers build') + goto 9999 + end if + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_sprecbld diff --git a/mlprec/impl/amg_sprecinit.F90 b/mlprec/impl/amg_sprecinit.F90 new file mode 100644 index 00000000..6a113466 --- /dev/null +++ b/mlprec/impl/amg_sprecinit.F90 @@ -0,0 +1,237 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_sprecinit.f90 +! +! Subroutine: amg_sprecinit +! Version: real +! +! This routine allocates and initializes the preconditioner data structure, +! according to the preconditioner type chosen by the user. +! +! A default preconditioner is set for each preconditioner type +! specified by the user: +! +! 'NOPREC' - no preconditioner +! +! 'DIAG', 'JACOBI' - diagonal/Jacobi +! +! 'L1-DIAG', 'L1-JACOBI' - diagonal/Jacobi with L1 norm correction +! +! 'GS', 'FBGS' - Hybrid Gauss-Seidel, also symmetrized +! +! 'BJAC' - block Jacobi preconditioner, with ILU(0) +! on the local blocks +! +! 'L1-BJAC' - block Jacobi preconditioner, with ILU(0) +! on the local blocks and L1 correction for off-diag blocks +! +! 'AS' - Additive Schwarz (AS), with +! overlap 1 and ILU(0) on the local submatrices +! +! 'ML' - Multilevel hybrid preconditioner (additive on the +! same level and multiplicative through the levels), +! with 2 levels, pre and post-smoothing, RAS with +! overlap 1 and ILU(0) on the local blocks is +! applied as post-smoother at each level, but the +! coarsest one; four sweeps of the block-Jacobi solver, +! with LU from UMFPACK on the blocks, are applied at +! the coarsest level, on the distributed coarse matrix. +! The smoothed aggregation algorithm with threshold 0 +! is used to build the coarse matrix. +! +! For the multilevel preconditioners, the levels are numbered in increasing +! order starting from the finest one, i.e. level 1 is the finest level. +! +! +! Arguments: +! p - type(amg_sprec_type), input/output. +! The preconditioner data structure. +! ptype - character(len=*), input. +! The type of preconditioner. Its values are 'NOPREC', +! 'DIAG', 'BJAC', 'AS', 'ML' (and the corresponding +! lowercase strings). +! info - integer, output. +! Error code. +! +subroutine amg_sprecinit(ictxt,prec,ptype,info) + + use psb_base_mod + use amg_s_prec_mod, amg_protect_name => amg_sprecinit + use amg_s_jac_smoother + use amg_s_as_smoother + use amg_s_id_solver + use amg_s_diag_solver + use amg_s_ilu_solver + use amg_s_gs_solver +#if defined(HAVE_SLU_) + use amg_s_slu_solver +#endif + + + implicit none + + ! Arguments + integer(psb_ipk_), intent(in) :: ictxt + class(amg_sprec_type), intent(inout) :: prec + character(len=*), intent(in) :: ptype + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: nlev_, ilev_ + real(psb_spk_) :: thr + character(len=*), parameter :: name='amg_precinit' + info = psb_success_ + + if (allocated(prec%precv)) then + call prec%free(info) + if (info /= psb_success_) then + ! Do we want to do something? + endif + endif + prec%ictxt = ictxt + prec%ag_data%min_coarse_size = -1 + + select case(psb_toupper(trim(ptype))) + case ('NOPREC','NONE') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_s_base_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_s_id_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('JAC','DIAG','JACOBI') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_s_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_s_diag_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('L1-DIAG','L1-JACOBI','L1_DIAG','L1_JACOBI') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_s_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_s_l1_diag_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('GS','FWGS') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_s_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_s_gs_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('BWGS') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_s_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_s_bwgs_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('FBGS') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + call prec%set('SMOOTHER_TYPE','FBGS',info) + call prec%precv(ilev_)%default() + + case ('BJAC') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_s_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_s_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('L1-BJAC','L1_BJAC') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_s_l1_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_s_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('AS') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_s_as_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_s_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + + case ('ML') + + nlev_ = prec%ag_data%max_levs + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + + do ilev_ = 1, nlev_ + call prec%precv(ilev_)%default() + end do + call prec%set('ML_CYCLE','VCYCLE',info) + call prec%set('SMOOTHER_TYPE','FBGS',info) +#if defined(HAVE_MUMPS_) + call prec%set('COARSE_SOLVE','MUMPS',info) +#elif defined(HAVE_SLU_) + call prec%set('COARSE_SOLVE','SLU',info) +#else + call prec%set('COARSE_SOLVE','ILU',info) +#endif + + case default + write(psb_err_unit,*) name,& + &': Warning: Unknown preconditioner type request "',ptype,'"' + info = psb_err_pivot_too_small_ + + end select + + +end subroutine amg_sprecinit diff --git a/mlprec/impl/amg_sprecset.F90 b/mlprec/impl/amg_sprecset.F90 new file mode 100644 index 00000000..a5f1ce68 --- /dev/null +++ b/mlprec/impl/amg_sprecset.F90 @@ -0,0 +1,229 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_sprecset.f90 +! +subroutine amg_sprecsetsm(p,val,info,ilev,ilmax,pos) + + use psb_base_mod + use amg_s_prec_mod, amg_protect_name => amg_sprecsetsm + + implicit none + + ! Arguments + class(amg_sprec_type), intent(inout) :: p + class(amg_s_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ + character(len=*), parameter :: name='amg_precsetsm' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + ilmin_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmin_ = 1 + ilmax_ = nlev_ + end if + + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + do ilev_ = ilmin_, ilmax_ + call p%precv(ilev_)%set(val,info,pos=pos) + if (info /= 0) return + end do + +end subroutine amg_sprecsetsm + +subroutine amg_sprecsetsv(p,val,info,ilev,ilmax,pos) + + use psb_base_mod + use amg_s_prec_mod, amg_protect_name => amg_sprecsetsv + + implicit none + + ! Arguments + class(amg_sprec_type), intent(inout) :: p + class(amg_s_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ + character(len=*), parameter :: name='amg_precsetsv' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + ilmin_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmin_ = 1 + ilmax_ = nlev_ + end if + + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + do ilev_ = ilmin_, ilmax_ + call p%precv(ilev_)%set(val,info,pos=pos) + if (info /= 0) return + end do + +end subroutine amg_sprecsetsv + +subroutine amg_sprecsetag(p,val,info,ilev,ilmax,pos) + + use psb_base_mod + use amg_s_prec_mod, amg_protect_name => amg_sprecsetag + + implicit none + + ! Arguments + class(amg_sprec_type), intent(inout) :: p + class(amg_s_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev, ilmax + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ + character(len=*), parameter :: name='amg_precsetag' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + ilmin_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmin_ = 1 + ilmax_ = nlev_ + end if + + + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + do ilev_ = ilmin_, ilmax_ + call p%precv(ilev_)%set(val,info,pos=pos) + if (info /= 0) return + end do + +end subroutine amg_sprecsetag + diff --git a/mlprec/impl/amg_sslu_interface.c b/mlprec/impl/amg_sslu_interface.c new file mode 100644 index 00000000..49eba922 --- /dev/null +++ b/mlprec/impl/amg_sslu_interface.c @@ -0,0 +1,309 @@ +/* + * + * MLD2P4 version 2.1 + * MultiLevel Domain Decomposition Parallel Preconditioners Package + * based on PSBLAS (Parallel Sparse BLAS version 3.5) + * + * (C) Copyright 2008-2018 + * + * Salvatore Filippone + * Pasqua D'Ambra + * Daniela di Serafino + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions, and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the MLD2P4 group or the names of its contributors may + * not be used to endorse or promote products derived from this + * software without specific written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * + * File: amg_slu_interface.c + * + * Functions: amg_sslu_fact, amg_sslu_solve, amg_sslu_free. + * + * This file is an interface to the SuperLU routines for sparse factorization and + * solve. It was obtained by modifying the c_fortran_dgssv.c file from the SuperLU + * source distribution; original copyright terms are reproduced below. + * + */ + + +/* ===================== + +Copyright (c) 2003, The Regents of the University of California, through +Lawrence Berkeley National Laboratory (subject to receipt of any required +approvals from U.S. Dept. of Energy) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +(1) Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +(2) Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. +(3) Neither the name of Lawrence Berkeley National Laboratory, U.S. Dept. of +Energy nor the names of its contributors may be used to endorse or promote +products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +/* + * -- SuperLU routine (version 3.0) -- + * Univ. of California Berkeley, Xerox Palo Alto Research Center, + * and Lawrence Berkeley National Lab. + * October 15, 2003 + * + */ + +#ifdef Have_SLU_ +#include "slu_sdefs.h" + +#define HANDLE_SIZE 8 + +typedef struct { + SuperMatrix *L; + SuperMatrix *U; + int *perm_c; + int *perm_r; +} factors_t; + + +#else + +#include + +#endif + + + +int amg_sslu_fact(int n, int nnz, float *values, + int *colptr, int *rowind, void **f_factors) +{ +/* + * This routine can be called from Fortran. + * performs LU decomposition. + * + * f_factors (input/output) + * On output contains the pointer pointing to + * the structure of the factored matrices. + * + */ + +#ifdef Have_SLU_ + SuperMatrix A, AC; + SuperMatrix *L, *U; + int *perm_r; /* row permutations from partial pivoting */ + int *perm_c; /* column permutation vector */ + int *etree; /* column elimination tree */ + SCformat *Lstore; + NCformat *Ustore; + int i, panel_size, permc_spec, relax; + trans_t trans; + mem_usage_t mem_usage; + superlu_options_t options; + SuperLUStat_t stat; + factors_t *LUfactors; + GlobalLU_t Glu; /* Not needed on return. */ + int info; + + trans = NOTRANS; + + + /* Set the default input options. */ + set_default_options(&options); + + /* Initialize the statistics variables. */ + StatInit(&stat); + + sCreate_CompRow_Matrix(&A, n, n, nnz, values, rowind, colptr, + SLU_NR, SLU_S, SLU_GE); + L = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) ); + U = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) ); + if ( !(perm_r = intMalloc(n)) ) ABORT("Malloc fails for perm_r[]."); + if ( !(perm_c = intMalloc(n)) ) ABORT("Malloc fails for perm_c[]."); + if ( !(etree = intMalloc(n)) ) ABORT("Malloc fails for etree[]."); + + /* + * Get column permutation vector perm_c[], according to permc_spec: + * permc_spec = 0: natural ordering + * permc_spec = 1: minimum degree on structure of A'*A + * permc_spec = 2: minimum degree on structure of A'+A + * permc_spec = 3: approximate minimum degree for unsymmetric matrices + */ + options.ColPerm=2; + permc_spec = options.ColPerm; + get_perm_c(permc_spec, &A, perm_c); + + sp_preorder(&options, &A, perm_c, etree, &AC); + + panel_size = sp_ienv(1); + relax = sp_ienv(2); +#if defined(SLU_VERSION_5) + sgstrf(&options, &AC, relax, panel_size, + etree, NULL, 0, perm_c, perm_r, L, U, &Glu, &stat, &info); +#elif defined(SLU_VERSION_4) + sgstrf(&options, &AC, relax, panel_size, + etree, NULL, 0, perm_c, perm_r, L, U, &stat, &info); +#else + choke_on_me; +#endif + + if ( info == 0 ) { + Lstore = (SCformat *) L->Store; + Ustore = (NCformat *) U->Store; + sQuerySpace(L, U, &mem_usage); +#if 0 + printf("No of nonzeros in factor L = %d\n", Lstore->nnz); + printf("No of nonzeros in factor U = %d\n", Ustore->nnz); + printf("No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz); + printf("L\\U MB %.3f\ttotal MB needed %.3f\n", + mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); +#endif + } else { + printf("sgstrf() error returns INFO= %d\n", info); + if ( info <= n ) { /* factorization completes */ + sQuerySpace(L, U, &mem_usage); + printf("L\\U MB %.3f\ttotal MB needed %.3f\n", + mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); + } + } + + /* Save the LU factors in the factors handle */ + LUfactors = (factors_t*) SUPERLU_MALLOC(sizeof(factors_t)); + LUfactors->L = L; + LUfactors->U = U; + LUfactors->perm_c = perm_c; + LUfactors->perm_r = perm_r; + *f_factors = (void *) LUfactors; + + /* Free un-wanted storage */ + SUPERLU_FREE(etree); + Destroy_SuperMatrix_Store(&A); + Destroy_CompCol_Permuted(&AC); + StatFree(&stat); + return(info); +#else + fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); + return(-1); +#endif +} + + +int amg_sslu_solve(int itrans, int n, int nrhs, float *b, int ldb, + void *f_factors) +{ + /* + * This routine can be called from Fortran. + * performs triangular solve + * + */ + int info; +#ifdef Have_SLU_ + SuperMatrix B; + SuperMatrix *L, *U; + int *perm_r; /* row permutations from partial pivoting */ + int *perm_c; /* column permutation vector */ + int *etree; /* column elimination tree */ + SCformat *Lstore; + NCformat *Ustore; + int i, panel_size, permc_spec, relax; + trans_t trans; + SuperLUStat_t stat; + factors_t *LUfactors; + + if (itrans == 0) { + trans = NOTRANS; + } else if (itrans ==1) { + trans = TRANS; + } else if (itrans ==2) { + trans = CONJ; + } else { + trans = NOTRANS; + } + /* Initialize the statistics variables. */ + StatInit(&stat); + + /* Extract the LU factors in the factors handle */ + LUfactors = (factors_t*) f_factors; + L = LUfactors->L; + U = LUfactors->U; + perm_c = LUfactors->perm_c; + perm_r = LUfactors->perm_r; + + sCreate_Dense_Matrix(&B, n, nrhs, b, ldb, SLU_DN, SLU_S, SLU_GE); + /* Solve the system A*X=B, overwriting B with X. */ + sgstrs (trans, L, U, perm_c, perm_r, &B, &stat, &info); + + Destroy_SuperMatrix_Store(&B); + StatFree(&stat); +#else + fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); + info=-1; +#endif + return(info); +} + + +int amg_sslu_free(void *f_factors) +{ +/* + * This routine can be called from Fortran. + * + * free all storage in the end + * + */ +#ifdef Have_SLU_ + factors_t *LUfactors; + + /* Free the LU factors in the factors handle */ + LUfactors = (factors_t*) f_factors; + if (LUfactors != NULL) { + SUPERLU_FREE (LUfactors->perm_r); + SUPERLU_FREE (LUfactors->perm_c); + Destroy_SuperNode_Matrix(LUfactors->L); + Destroy_CompCol_Matrix(LUfactors->U); + SUPERLU_FREE (LUfactors->L); + SUPERLU_FREE (LUfactors->U); + SUPERLU_FREE (LUfactors); + } + return(0); +#else + fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); + return(-1); +#endif +} + + diff --git a/mlprec/impl/amg_z_extprol_bld.F90 b/mlprec/impl/amg_z_extprol_bld.F90 new file mode 100644 index 00000000..938a9eba --- /dev/null +++ b/mlprec/impl/amg_z_extprol_bld.F90 @@ -0,0 +1,534 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_z_extprol_bld.f90 +! +! Subroutine: amg_z_extprol_bld +! Version: real +! +! This routine builds the preconditioner according to the requirements made by +! the user trough the subroutines amg_precinit and amg_precset. +! +! A multilevel preconditioner is regarded as an array of 'one-level' data structures, +! each containing the part of the preconditioner associated to a certain level, +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level. No transfer operators are associated to level 1. +! +! +! Arguments: +! a - type(psb_zspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_zprec_type), input/output. +! The preconditioner data structure containing the local part +! of the preconditioner to be built. +! info - integer, output. +! Error code. +! +! amold - class(psb_z_base_sparse_mat), input, optional +! Mold for the inner format of matrices contained in the +! preconditioner +! +! +! vmold - class(psb_z_base_vect_type), input, optional +! Mold for the inner format of vectors contained in the +! preconditioner +! +! +! +subroutine amg_z_extprol_bld(a,desc_a,p,prolv,restrv,info,amold,vmold,imold) + + use psb_base_mod + use amg_z_inner_mod + use amg_z_prec_mod, amg_protect_name => amg_z_extprol_bld + + Implicit None + + ! Arguments + type(psb_zspmat_type),intent(in), target :: a + type(psb_zspmat_type),intent(inout), target :: prolv(:) + type(psb_zspmat_type),intent(inout), target :: restrv(:) + type(psb_desc_type), intent(inout), target :: desc_a + type(amg_zprec_type),intent(inout),target :: p + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! !$ character, intent(in), optional :: upd + + ! Local Variables + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, casize, nplevs, mxplevs + integer(psb_ipk_) :: nprolv, nrestrv + real(psb_dpk_) :: mnaggratio + integer(psb_ipk_) :: ipv(amg_ifpsz_), val + class(amg_z_base_smoother_type), allocatable :: coarse_sm, base_sm, med_sm + type(amg_dml_parms) :: baseparms, medparms, coarseparms + type(amg_z_onelev_type), allocatable :: tprecv(:) + integer(psb_ipk_) :: int_err(5) + character :: upd_ + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + logical, parameter :: debug=.false. + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_z_extprol_bld' + info = psb_success_ + int_err(1) = 0 + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + p%ictxt = ictxt + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' +#if defined(LPK8) + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Need fix for LPK8') + goto 9999 +#else + + ! + ! For the time being we are commenting out the UPDATE argument + ! we plan to resurrect it later. + ! !$ if (present(upd)) then + ! !$ if (debug_level >= psb_debug_outer_) & + ! !$ & write(debug_unit,*) me,' ',trim(name),'UPD ', upd + ! !$ + ! !$ if ((psb_toupper(upd).eq.'F').or.(psb_toupper(upd).eq.'T')) then + ! !$ upd_=psb_toupper(upd) + ! !$ else + ! !$ upd_='F' + ! !$ endif + ! !$ else + ! !$ upd_='F' + ! !$ endif + upd_ = 'F' + + if (.not.allocated(p%precv)) then + !! Error: should have called amg_zprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + ! + ! Check to ensure all procs have the same + ! + newsz = -1 + mxplevs = p%ag_data%max_levs + mnaggratio = p%ag_data%min_cr_ratio + casize = p%ag_data%min_coarse_size + iszv = size(p%precv) + nprolv = size(prolv) + nrestrv = size(restrv) + call psb_bcast(ictxt,iszv) + call psb_bcast(ictxt,casize) + call psb_bcast(ictxt,mxplevs) + call psb_bcast(ictxt,mnaggratio) + call psb_bcast(ictxt,nprolv) + call psb_bcast(ictxt,nrestrv) + if (casize /= p%ag_data%min_coarse_size) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent min_coarse_size') + goto 9999 + end if + if (mxplevs /= p%ag_data%max_levs) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent max_levs') + goto 9999 + end if + if (mnaggratio /= p%ag_data%min_cr_ratio) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent min_cr_ratio') + goto 9999 + end if + if (iszv /= size(p%precv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of precv') + goto 9999 + end if + if (nprolv /= size(prolv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of prolv') + goto 9999 + end if + if (nrestrv /= size(restrv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of restrv') + goto 9999 + end if + if (nrestrv /= nprolv) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size prolv vs restrv') + goto 9999 + end if + + if (iszv <= 1) then + ! We should only ever get here for multilevel. + info=psb_err_from_subroutine_ + ch_err='size bpv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + endif + + if (nrestrv < 1) then + ! We should only ever get here for multilevel. + info=psb_err_from_subroutine_ + ch_err='size restrv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + endif + + ! + nplevs = nrestrv + 1 + p%ag_data%max_levs = nplevs + + ! + ! Fixed number of levels. + ! + nplevs = max(itwo,mxplevs) + + coarseparms = p%precv(iszv)%parms + baseparms = p%precv(1)%parms + medparms = p%precv(2)%parms + + allocate(coarse_sm, source=p%precv(iszv)%sm,stat=info) + if (info == psb_success_) & + & allocate(med_sm, source=p%precv(2)%sm,stat=info) + if (info == psb_success_) & + & allocate(base_sm, source=p%precv(1)%sm,stat=info) + if (info /= psb_success_) then + write(0,*) 'Error in saving smoothers',info + call psb_errpush(psb_err_internal_error_,name,a_err='Base level precbuild.') + goto 9999 + end if + + if (iszv /= nplevs) then + allocate(tprecv(nplevs),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + tprecv(1)%parms = baseparms + allocate(tprecv(1)%sm,source=base_sm,stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + do i=2,nplevs-1 + tprecv(i)%parms = medparms + allocate(tprecv(i)%sm,source=med_sm,stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + end do + tprecv(nplevs)%parms = coarseparms + allocate(tprecv(nplevs)%sm,source=coarse_sm,stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + do i=1,iszv + call p%precv(i)%free(info) + end do + call move_alloc(tprecv,p%precv) + iszv = size(p%precv) + end if + ! + ! Finest level first; remember to fix base_a and base_desc + ! + p%precv(1)%base_a => a + p%precv(1)%base_desc => desc_a + newsz = 0 + array_build_loop: do i=2, iszv + + ! + ! Sanity checks on the parameters + ! + if (i p%precv(i)%ac + p%precv(i)%base_desc => p%precv(i)%desc_ac + + + if (i>2) then + if (all(p%precv(i)%map%naggr == p%precv(i-1)%map%naggr)) then + newsz=i-1 + end if + call psb_bcast(ictxt,newsz) + if (newsz > 0) exit array_build_loop + end if + end do array_build_loop + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Internal extprol build' ) + goto 9999 + endif + + iszv = size(p%precv) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Exiting with',iszv,' levels' +#endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + + subroutine amg_z_extaggr_bld(a,desc_a,p,op_restr,op_prol,info) + use psb_base_mod + use amg_z_inner_mod + + implicit none + + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + type(psb_zspmat_type), intent(inout) :: op_restr,op_prol + type(psb_desc_type), intent(in), target :: desc_a + type(amg_z_onelev_type), intent(inout),target :: p + integer(psb_ipk_), intent(out) :: info + + ! Local variables + character(len=20) :: name + integer(psb_mpk_) :: ictxt, np, me, ncol + integer(psb_ipk_) :: err_act,ntaggr,nzl + integer(psb_ipk_), allocatable :: ilaggr(:), nlaggr(:) + type(psb_zspmat_type) :: ac, am2, am3, am4 + type(psb_z_coo_sparse_mat) :: acoo, bcoo + type(psb_z_csr_sparse_mat) :: acsr1 + logical, parameter :: debug=.false. + + name='amg_z_extaggr_bld' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) +#if defined(LPK8) + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Need fix for LPK8') + goto 9999 +#else + allocate(nlaggr(np),ilaggr(1)) + nlaggr = 0 + ilaggr = 0 + p%parms%par_aggr_alg = amg_ext_aggr_ + call amg_check_def(p%parms%ml_cycle,'Multilevel cycle',& + & amg_mult_ml_,is_legal_ml_cycle) + call amg_check_def(p%parms%coarse_mat,'Coarse matrix',& + & amg_distr_mat_,is_legal_ml_coarse_mat) + + nlaggr(me+1) = op_restr%get_nrows() + if (op_restr%get_nrows() /= op_prol%get_ncols()) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent restr/prol sizes') + goto 9999 + end if + call psb_sum(ictxt,nlaggr) + ntaggr = sum(nlaggr) + ncol = desc_a%get_local_cols() + if (debug) write(0,*)me,' Sizes:',op_restr%get_nrows(),op_restr%get_ncols(),& + & op_prol%get_nrows(),op_prol%get_ncols(), a%get_nrows(),a%get_ncols() + ! + ! Compute local part of AC + ! + call op_prol%clone(am2,info) + if (info == psb_success_) call psb_sphalo(am2,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.) + if (info == psb_success_) call psb_rwextd(ncol,am2,info,b=am4) + if (info == psb_success_) call am4%free() + call psb_spspmm(a,am2,am3,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 2') + goto 9999 + end if + call psb_sphalo(am3,desc_a,am4,info,& + & colcnv=.false.,rowscale=.true.) + if (info == psb_success_) call psb_rwextd(ncol,am3,info,b=am4) + if (info == psb_success_) call am4%free() + if(info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Extend am3') + goto 9999 + end if + call psb_spspmm(op_restr,am3,ac,info) + if (info == psb_success_) call am3%free() + if (info == psb_success_) call ac%cscnv(info,type='csr',dupl=psb_dupl_add_) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Build ac = op_restr x am3') + goto 9999 + end if + + select case(p%parms%coarse_mat) + + case(amg_distr_mat_) + + call ac%mv_to(bcoo) + nzl = bcoo%get_nzeros() + + if (info == psb_success_) call psb_cdall(ictxt,p%desc_ac,info,nl=nlaggr(me+1)) + if (info == psb_success_) call psb_cdins(nzl,bcoo%ia,bcoo%ja,p%desc_ac,info) + if (info == psb_success_) call psb_cdasb(p%desc_ac,info) + if (info == psb_success_) call psb_glob_to_loc(bcoo%ia(1:nzl),p%desc_ac,info,iact='I') + if (info == psb_success_) call psb_glob_to_loc(bcoo%ja(1:nzl),p%desc_ac,info,iact='I') + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Creating p%desc_ac and converting ac') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Assembld aux descr. distr.' + call p%ac%mv_from(bcoo) + + call p%ac%set_nrows(p%desc_ac%get_local_rows()) + call p%ac%set_ncols(p%desc_ac%get_local_cols()) + call p%ac%set_asb() + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_sp_free') + goto 9999 + end if + + if (np>1) then + call op_prol%mv_to(acsr1) + nzl = acsr1%get_nzeros() + call psb_glob_to_loc(acsr1%ja(1:nzl),p%desc_ac,info,'I') + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_glob_to_loc') + goto 9999 + end if + call op_prol%mv_from(acsr1) + endif + call op_prol%set_ncols(p%desc_ac%get_local_cols()) + + if (np>1) then + call op_restr%cscnv(info,type='coo',dupl=psb_dupl_add_) + call op_restr%mv_to(acoo) + nzl = acoo%get_nzeros() + if (info == psb_success_) call psb_glob_to_loc(acoo%ia(1:nzl),p%desc_ac,info,'I') + call acoo%set_dupl(psb_dupl_add_) + if (info == psb_success_) call op_restr%mv_from(acoo) + if (info == psb_success_) call op_restr%cscnv(info,type='csr') + if(info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Converting op_restr to local') + goto 9999 + end if + end if + call op_restr%set_nrows(p%desc_ac%get_local_cols()) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Done ac ' + + case(amg_repl_mat_) + ! + ! + call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) + if (info == psb_success_) call psb_cdasb(p%desc_ac,info) + if (info == psb_success_) & + & call psb_gather(p%ac,ac,p%desc_ac,info,dupl=psb_dupl_add_,keeploc=.false.) + + if (info /= psb_success_) goto 9999 + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='invalid amg_coarse_mat_') + goto 9999 + end select + + call p%ac%cscnv(info,type='csr',dupl=psb_dupl_add_) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv') + goto 9999 + end if + + ! + ! Copy the prolongation/restriction matrices into the descriptor map. + ! op_restr => PR^T i.e. restriction operator + ! op_prol => PR i.e. prolongation operator + ! + + p%map = psb_linmap(psb_map_aggr_,desc_a,& + & p%desc_ac,op_restr,op_prol,ilaggr,nlaggr) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_Free') + goto 9999 + end if +#endif + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + end subroutine amg_z_extaggr_bld + +end subroutine amg_z_extprol_bld diff --git a/mlprec/impl/amg_z_hierarchy_bld.f90 b/mlprec/impl/amg_z_hierarchy_bld.f90 new file mode 100644 index 00000000..108581d1 --- /dev/null +++ b/mlprec/impl/amg_z_hierarchy_bld.f90 @@ -0,0 +1,539 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_z_hierarchy_bld.f90 +! +! Subroutine: amg_z_hierarchy_bld +! Version: complex +! +! This routine builds the preconditioner according to the requirements made by +! the user trough the subroutines amg_precinit and amg_precset. +! +! A multilevel preconditioner is regarded as an array of 'one-level' data structures, +! each containing the part of the preconditioner associated to a certain level, +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level. No transfer operators are associated to level 1. +! +! +! Arguments: +! a - type(psb_zspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_zprec_type), input/output. +! The preconditioner data structure; upon exit it contains +! the multilevel hierarchy of prolongators, restrictors +! and coarse matrices. +! info - integer, output. +! Error code. +! +subroutine amg_z_hierarchy_bld(a,desc_a,prec,info) + + use psb_base_mod + use amg_z_inner_mod + use amg_z_prec_mod, amg_protect_name => amg_z_hierarchy_bld + + Implicit None + + ! Arguments + type(psb_zspmat_type),intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_zprec_type),intent(inout),target :: prec + integer(psb_ipk_), intent(out) :: info + + ! Local Variables + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz,& + & nplevs, mxplevs + integer(psb_lpk_) :: iaggsize, casize + real(psb_dpk_) :: mnaggratio, sizeratio, athresh, aomega + class(amg_z_base_smoother_type), allocatable :: coarse_sm, med_sm, & + & med_sm2, coarse_sm2 + class(amg_z_base_aggregator_type), allocatable :: tmp_aggr + type(amg_dml_parms) :: medparms, coarseparms + integer(psb_lpk_), allocatable :: ilaggr(:), nlaggr(:) + type(psb_lzspmat_type) :: op_prol + type(amg_z_onelev_type), allocatable :: tprecv(:) + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + integer(psb_ipk_), save :: idx_bldtp=-1, idx_matasb=-1 + logical, parameter :: do_timings=.false. + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_z_hierarchy_bld' + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + prec%ictxt = ictxt + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' + if ((do_timings).and.(idx_bldtp==-1)) & + & idx_bldtp = psb_get_timer_idx("BLD_HIER: bld_tprol") + if ((do_timings).and.(idx_matasb==-1)) & + & idx_matasb = psb_get_timer_idx("BLD_HIER: mmat_asb") + ! + + if (.not.allocated(prec%precv)) then + !! Error: should have called amg_zprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + ! + ! Check to ensure all procs have the same + ! + newsz = -1 + mxplevs = prec%ag_data%max_levs + mnaggratio = prec%ag_data%min_cr_ratio + casize = prec%ag_data%min_coarse_size + iszv = size(prec%precv) + call psb_bcast(ictxt,iszv) + call psb_bcast(ictxt,casize) + call psb_bcast(ictxt,mxplevs) + call psb_bcast(ictxt,mnaggratio) + if (casize /= prec%ag_data%min_coarse_size) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent min_coarse_size') + goto 9999 + end if + if (mxplevs /= prec%ag_data%max_levs) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent max_levs') + goto 9999 + end if + if (mnaggratio /= prec%ag_data%min_cr_ratio) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent min_cr_ratio') + goto 9999 + end if + if (iszv /= size(prec%precv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of precv') + goto 9999 + end if + + if (iszv < 1) then + ! + ! This is wrong, cannot be size <1 + ! + info=psb_err_from_subroutine_ + ch_err='size bpv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + endif + if (iszv == 1) then + ! + ! This is OK, since it may be called by the user even if there + ! is only one level + ! + prec%precv(1)%base_a => a + prec%precv(1)%base_desc => desc_a + + call psb_erractionrestore(err_act) + return + endif + + ! + ! The strategy: + ! 1. The maximum number of levels should be already encoded in the + ! size of the array; + ! 2. If the user did not specify anything, then a default coarse size + ! is generated, and the number of levels is set to the maximum; + ! 3. If the size of the array is different from target number of levels, + ! reallocate; + ! 4. Build the matrix hierarchy, stopping early if either the target + ! coarse size is hit, or the gain falls below the min_cr_ratio + ! threshold. + ! + + if (casize < 0) then + ! + ! Default to the cubic root of the size at base level. + ! + casize = desc_a%get_global_rows() + casize = int((done*casize)**(done/(done*3)),psb_lpk_) + casize = max(casize,lone) + casize = casize*40_psb_lpk_ + call psb_bcast(ictxt,casize) + if (casize > huge(prec%ag_data%min_coarse_size)) then + ! + ! computed coarse size does not fit in IPK_. + ! This is very unlikely, but make sure to put a positive number + ! + prec%ag_data%min_coarse_size = huge(prec%ag_data%min_coarse_size) + else + prec%ag_data%min_coarse_size = casize + end if + end if + nplevs = max(itwo,mxplevs) + + ! + ! The coarse parameters will be needed later + ! + coarseparms = prec%precv(iszv)%parms + call save_smoothers(prec%precv(iszv),coarse_sm,coarse_sm2,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,a_err='Base level precbuild.') + goto 9999 + end if + ! + ! First set desired number of levels + ! + if (iszv /= nplevs) then + allocate(tprecv(nplevs),stat=info) + ! First all existing levels + do i=1, min(iszv,nplevs) - 1 + if (info == 0) tprecv(i)%parms = prec%precv(i)%parms + if (info == 0) call restore_smoothers(tprecv(i),& + & prec%precv(i)%sm,prec%precv(i)%sm2a,info) + if (info == 0) call move_alloc(prec%precv(i)%aggr,tprecv(i)%aggr) + end do + if (iszv < nplevs) then + ! Further intermediates, if needed + allocate(tmp_aggr,source=tprecv(iszv-1)%aggr,stat=info) + medparms = prec%precv(iszv-1)%parms + call save_smoothers(prec%precv(iszv-1),med_sm,med_sm2,info) + do i=iszv, nplevs - 1 + if (info == 0) tprecv(i)%parms = medparms + if (info == 0) call restore_smoothers(tprecv(i),med_sm,med_sm2,info) + if ((info == 0).and..not.allocated(tprecv(i)%aggr))& + & allocate(tprecv(i)%aggr,source=tmp_aggr,stat=info) + end do + deallocate(tmp_aggr,stat=info) + end if + + ! Then coarse + if (info == 0) tprecv(nplevs)%parms = coarseparms + if (info == 0) call restore_smoothers(tprecv(nplevs),coarse_sm,coarse_sm2,info) + if (info == 0) then + if (nplevs <= iszv) then + allocate(tprecv(nplevs)%aggr,source=prec%precv(nplevs)%aggr,stat=info) + else + allocate(tmp_aggr,source=tprecv(nplevs-1)%aggr,stat=info) + call move_alloc(tmp_aggr,tprecv(nplevs)%aggr) + end if + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + + do i=1,iszv + call prec%precv(i)%free(info) + end do + call move_alloc(tprecv,prec%precv) + iszv = size(prec%precv) + end if + + ! + ! Finest level first; create a GEN_BLOCK + ! copy of the descriptor. + ! + prec%precv(1)%base_a => a + call psb_cd_renum_block(desc_a,prec%precv(1)%desc_ac,info) + prec%precv(1)%base_desc => prec%precv(1)%desc_ac + newsz = 0 + array_build_loop: do i=2, iszv + ! + ! Check on the iprcparm contents: they should be the same + ! on all processes. + ! + call psb_bcast(ictxt,prec%precv(i)%parms) + + ! + ! Sanity checks on the parameters + ! + if (i= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Calling mlprcbld at level ',i + ! + ! Build the mapping between levels i-1 and i and the matrix + ! at level i + ! + if (do_timings) call psb_tic(idx_bldtp) + if (info == psb_success_)& + & call prec%precv(i)%bld_tprol(prec%precv(i-1)%base_a,& + & prec%precv(i-1)%base_desc,& + & ilaggr,nlaggr,op_prol,prec%ag_data,info) + if (do_timings) call psb_toc(idx_bldtp) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Map build') + goto 9999 + endif + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Return from ',i,' call to bld_tprol', info + ! + ! Save op_prol just in case + ! + call op_prol%clone(prec%precv(i)%tprol,info) + ! + ! Check for early termination of aggregation loop. + ! + iaggsize = sum(nlaggr) + + sizeratio = iaggsize + if (i==2) then + sizeratio = desc_a%get_global_rows()/sizeratio + else + sizeratio = sum(prec%precv(i-1)%map%naggr)/sizeratio + end if + prec%precv(i)%szratio = sizeratio + + if (iaggsize <= casize) newsz = i + if (i == iszv) newsz = i + + if (i>2) then + if (sizeratio < mnaggratio) then + if (sizeratio > 1) then + newsz = i + else + ! + ! We are not gaining + ! + newsz = i-1 + end if + end if + + if (all(nlaggr == prec%precv(i-1)%map%naggr)) then + newsz=i-1 + if (me == 0) then + write(debug_unit,*) trim(name),& + &': Warning: aggregates from level ',& + & newsz + write(debug_unit,*) trim(name),& + &': to level ',& + & iszv,' coincide.' + write(debug_unit,*) trim(name),& + &': Number of levels actually used :',newsz + write(debug_unit,*) + end if + end if + end if + call psb_bcast(ictxt,newsz) + + if (newsz > 0) then + ! + ! This is awkward, we are saving the aggregation parms, for the sake + ! of distr/repl matrix at coarse level. Should be rethought. + ! + athresh = prec%precv(newsz)%parms%aggr_thresh + aomega = prec%precv(newsz)%parms%aggr_omega_val + if (info == 0) prec%precv(newsz)%parms = coarseparms + prec%precv(newsz)%parms%aggr_thresh = athresh + prec%precv(newsz)%parms%aggr_omega_val = aomega + + if (info == 0) call restore_smoothers(prec%precv(newsz),& + & coarse_sm,coarse_sm2,info) + if (newsz < i) then + ! + ! We are going back and revisit a previous leve; + ! recover the aggregation. + ! + ilaggr = prec%precv(newsz)%map%iaggr + nlaggr = prec%precv(newsz)%map%naggr + call prec%precv(newsz)%tprol%clone(op_prol,info) + end if + if (do_timings) call psb_tic(idx_matasb) + if (info == psb_success_) call prec%precv(newsz)%mat_asb( & + & prec%precv(newsz-1)%base_a,prec%precv(newsz-1)%base_desc,& + & ilaggr,nlaggr,op_prol,info) + if (do_timings) call psb_toc(idx_matasb) + if (info /= 0) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Mat asb') + goto 9999 + endif + exit array_build_loop + else + if (do_timings) call psb_tic(idx_matasb) + if (info == psb_success_) call prec%precv(i)%mat_asb(& + & prec%precv(i-1)%base_a,prec%precv(i-1)%base_desc,& + & ilaggr,nlaggr,op_prol,info) + if (do_timings) call psb_toc(idx_matasb) + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Map build') + goto 9999 + endif + if (i 0) then + ! + ! We exited early from the build loop, need to fix + ! the size. + ! + allocate(tprecv(newsz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='prec reallocation') + goto 9999 + endif + do i=1,newsz + call prec%precv(i)%move_alloc(tprecv(i),info) + end do + do i=newsz+1, iszv + call prec%precv(i)%free(info) + end do + call move_alloc(tprecv,prec%precv) + ! Ignore errors from transfer + info = psb_success_ + ! + ! Restart + iszv = newsz + ! Fix the pointers, but the level 1 should + ! be treated differently + if (.not.associated(prec%precv(1)%base_desc,desc_a)) then + prec%precv(1)%base_desc => prec%precv(1)%desc_ac + end if + do i=2, iszv + prec%precv(i)%base_a => prec%precv(i)%ac + prec%precv(i)%base_desc => prec%precv(i)%desc_ac + prec%precv(i)%map%p_desc_U => prec%precv(i-1)%base_desc + prec%precv(i)%map%p_desc_V => prec%precv(i)%base_desc + end do + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Internal hierarchy build' ) + goto 9999 + endif + + iszv = size(prec%precv) + + call prec%cmp_complexity() + call prec%cmp_avg_cr() + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Exiting with',iszv,' levels' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + subroutine save_smoothers(level,save1, save2,info) + type(amg_z_onelev_type), intent(inout) :: level + class(amg_z_base_smoother_type), allocatable , intent(inout) :: save1, save2 + integer(psb_ipk_), intent(out) :: info + + info = 0 + if (allocated(save1)) then + call save1%free(info) + if (info == 0) deallocate(save1,stat=info) + if (info /= 0) return + end if + if (allocated(save2)) then + call save2%free(info) + if (info == 0) deallocate(save2,stat=info) + if (info /= 0) return + end if + allocate(save1, mold=level%sm,stat=info) + if (info == 0) call level%sm%clone_settings(save1,info) + if ((info == 0).and.allocated(level%sm2a)) then + allocate(save2, mold=level%sm2a,stat=info) + if (info == 0) call level%sm2a%clone_settings(save2,info) + end if + + return + end subroutine save_smoothers + + subroutine restore_smoothers(level,save1, save2,info) + type(amg_z_onelev_type), intent(inout), target :: level + class(amg_z_base_smoother_type), allocatable, intent(inout) :: save1, save2 + integer(psb_ipk_), intent(out) :: info + + info = 0 + + if (allocated(level%sm)) then + if (info == 0) call level%sm%free(info) + if (info == 0) deallocate(level%sm,stat=info) + end if + if (allocated(save1)) then + if (info == 0) allocate(level%sm,mold=save1,stat=info) + if (info == 0) call save1%clone_settings(level%sm,info) + end if + + if (info /= 0) return + + if (allocated(level%sm2a)) then + if (info == 0) call level%sm2a%free(info) + if (info == 0) deallocate(level%sm2a,stat=info) + end if + if (allocated(save2)) then + if (info == 0) allocate(level%sm2a,mold=save2,stat=info) + if (info == 0) call save2%clone_settings(level%sm2a,info) + if (info == 0) level%sm2 => level%sm2a + else + if (allocated(level%sm)) level%sm2 => level%sm + end if + + return + end subroutine restore_smoothers + +end subroutine amg_z_hierarchy_bld diff --git a/mlprec/impl/amg_z_smoothers_bld.f90 b/mlprec/impl/amg_z_smoothers_bld.f90 new file mode 100644 index 00000000..2af7ac71 --- /dev/null +++ b/mlprec/impl/amg_z_smoothers_bld.f90 @@ -0,0 +1,313 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_z_smoothers_bld.f90 +! +! Subroutine: amg_z_smoothers_bld +! Version: complex +! +! This routine performs the final phase of the multilevel preconditioner +! build process: builds the "smoother" objects at each level, +! based on the matrix hierarchy prepared by amg_z_hierarchy_bld. +! +! A multilevel preconditioner is regarded as an array of 'one-level' +! data structures, each containing the part of the +! preconditioner associated to a certain level, +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level. No transfer operators are associated to level 1. +! Each level provides a "build" method; for the base type, the "one-level" +! build procedure simply invokes the build method of the first smoother object, +! and also on the second object if allocated. +! +! +! Arguments: +! a - type(psb_zspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_zprec_type), input/output. +! The preconditioner data structure containing the local part +! of the preconditioner to be built. +! info - integer, output. +! Error code. +! +! amold - class(psb_z_base_sparse_mat), input, optional +! Mold for the inner format of matrices contained in the +! preconditioner +! +! +! vmold - class(psb_z_base_vect_type), input, optional +! Mold for the inner format of vectors contained in the +! preconditioner +! +! +! +subroutine amg_z_smoothers_bld(a,desc_a,prec,info,amold,vmold,imold) + + use psb_base_mod + !use amg_z_inner_mod + use amg_z_prec_mod, amg_protect_name => amg_z_smoothers_bld + + Implicit None + + ! Arguments + type(psb_zspmat_type),intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_zprec_type),intent(inout),target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local Variables + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, nplevs, mxplevs + real(psb_dpk_) :: mnaggratio + integer(psb_ipk_) :: coarse_solve_id + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_z_smoothers_bld' + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' + ! + if (.not.allocated(prec%precv)) then + !! Error: should have called amg_zprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + ! + ! Check to ensure all procs have the same + ! + iszv = size(prec%precv) + call psb_bcast(ictxt,iszv) + if (iszv /= size(prec%precv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of precv') + goto 9999 + end if + + if (iszv < 1) then + ! We should never get here. + info=psb_err_from_subroutine_ + ch_err='size bpv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + endif + + ! + ! Issue a warning for inconsistent changes to COARSE_SOLVE + ! but only if it really is a multilevel + ! + if ((me == psb_root_).and.(iszv>1)) then + coarse_solve_id = prec%precv(iszv)%parms%coarse_solve + select case (coarse_solve_id) + case(amg_umf_,amg_slu_) + if (prec%precv(iszv)%sm%sv%get_id() /= coarse_solve_id) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id) + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) then + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else if (prec%precv(iszv)%parms%coarse_mat == amg_distr_mat_) then + write(psb_err_unit,*) ' but I am building BJAC with ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + end if + write(psb_err_unit,*) 'This may happen if: ' + write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' + write(psb_err_unit,*) ' 2. the solver ', amg_fact_names(coarse_solve_id),& + & ' was not configured at MLD2P4 build time, or' + write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' + end if + if (prec%precv(iszv)%parms%coarse_mat /= amg_repl_mat_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse matrix was requested as replicated', & + & ' but it has been changed to distributed.' + end if + + case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) + if (prec%precv(iszv)%sm%sv%get_id() /= psb_ilu_n_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id) + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) then + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else if (prec%precv(iszv)%parms%coarse_mat == amg_distr_mat_) then + write(psb_err_unit,*) ' but I am building BJAC with ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + end if + write(psb_err_unit,*) & + &'This may happen if coarse_subsolve has been reset' + end if + if (prec%precv(iszv)%parms%coarse_mat /= amg_repl_mat_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id),& + & ' but the coarse matrix has been changed to distributed' + end if + + case(amg_mumps_) + if (prec%precv(iszv)%sm%sv%get_id() /= amg_mumps_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id) + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) then + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else if (prec%precv(iszv)%parms%coarse_mat == amg_distr_mat_) then + write(psb_err_unit,*) ' but I am building BJAC with ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + end if + write(psb_err_unit,*) 'This may happen if: ' + write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' + write(psb_err_unit,*) ' 2. the solver ', amg_fact_names(coarse_solve_id),& + & ' was not configured at MLD2P4 build time, or' + write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' + end if + + case(amg_sludist_) + if (prec%precv(iszv)%sm%sv%get_id() /= coarse_solve_id) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id) + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) then + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else if (prec%precv(iszv)%parms%coarse_mat == amg_distr_mat_) then + write(psb_err_unit,*) ' but I am building BJAC with ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + else + write(psb_err_unit,*) ' but I am building ',& + & amg_fact_names(prec%precv(iszv)%sm%sv%get_id()) + end if + write(psb_err_unit,*) 'This may happen if: ' + write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' + write(psb_err_unit,*) ' 2. the solver ', amg_fact_names(coarse_solve_id), & + & ' was not configured at MLD2P4 build time, or' + write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' + end if + if (prec%precv(iszv)%parms%coarse_mat /= amg_distr_mat_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id),& + & ' but the coarse matrix has been changed to replicated' + end if + + case(amg_bjac_,amg_l1_bjac_,amg_jac_, amg_l1_jac_, amg_gs_, amg_fbgs_, amg_l1_gs_,amg_l1_fbgs_) + if (prec%precv(iszv)%parms%coarse_mat /= amg_distr_mat_) then + write(psb_err_unit,*) & + & 'MLD2P4: Warning: original coarse solver was requested as ',& + & amg_fact_names(coarse_solve_id),& + & ' but the coarse matrix has been changed to replicated' + end if + + case default + ! We should never get here. + info=psb_err_from_subroutine_ + ch_err='unkn coarse_solve' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + + end select + end if + + ! Sanity check: need to ensure that the MUMPS local/global NZ + ! are handled correctly; this is controlled by local vs global solver. + ! From this point of view, REPL is LOCAL because it owns everyting. + ! Should really find a better way of handling this. + if (prec%precv(iszv)%parms%coarse_mat == amg_repl_mat_) & + & call prec%precv(iszv)%sm%sv%set('MUMPS_LOC_GLOB', amg_local_solver_,info) + ! + ! Now do the real build. + ! + + do i=1, iszv + ! + ! build the base preconditioner at level i + ! + call prec%precv(i)%bld(info,amold=amold,vmold=vmold,imold=imold,ilv=i) + + if (info /= psb_success_) then + write(ch_err,'(a,i7)') 'Error @ level',i + call psb_errpush(psb_err_internal_error_,name,& + & a_err=ch_err) + goto 9999 + endif + + end do + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Exiting with',iszv,' levels' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_smoothers_bld diff --git a/mlprec/impl/amg_zcprecset.F90 b/mlprec/impl/amg_zcprecset.F90 new file mode 100644 index 00000000..d27e5a57 --- /dev/null +++ b/mlprec/impl/amg_zcprecset.F90 @@ -0,0 +1,1038 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_zprecset.f90 +! +! Subroutine: amg_zprecseti +! Version: complex +! +! This routine sets the integer parameters defining the preconditioner. More +! precisely, the integer parameter identified by 'what' is assigned the value +! contained in 'val'. +! For the multilevel preconditioners, the levels are numbered in increasing +! order starting from the finest one, i.e. level 1 is the finest level. +! +! To set character and complex parameters, see amg_zprecsetc and amg_zprecsetr, +! respectively. +! +! +! Arguments: +! p - type(amg_zprec_type), input/output. +! The preconditioner data structure. +! what - integer, input. +! The number identifying the parameter to be set. +! A mnemonic constant has been associated to each of these +! numbers, as reported in the MLD2P4 User's and Reference Guide. +! val - integer, input. +! The value of the parameter to be set. The list of allowed +! values is reported in the MLD2P4 User's and Reference Guide. +! info - integer, output. +! Error code. +! ilev - integer, optional, input. +! For the multilevel preconditioner, the level at which the +! preconditioner parameter has to be set. +! If nlev is not present, the parameter identified by 'what' +! is set at all the appropriate levels. +! +! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to +! MLD2P4 developers. Indeed, by using ilev it is possible to set different values +! of the same parameter at different levels 1,...,nlev-1, even in cases where +! the parameter must have the same value at all the levels but the coarsest one. +! For this reason, the interface amg_precset to this routine has been built in +! such a way that ilev is not visible to the user (see amg_prec_mod.f90). +! +subroutine amg_zcprecseti(p,what,val,info,ilev,ilmax,pos,idx) + + use psb_base_mod + use amg_z_prec_mod, amg_protect_name => amg_zcprecseti + use amg_z_jac_smoother + use amg_z_as_smoother + use amg_z_diag_solver + use amg_z_l1_diag_solver + use amg_z_ilu_solver + use amg_z_id_solver + use amg_z_gs_solver +#if defined(HAVE_UMF_) + use amg_z_umf_solver +#endif +#if defined(HAVE_SLUDIST_) + use amg_z_sludist_solver +#endif +#if defined(HAVE_SLU_) + use amg_z_slu_solver +#endif +#if defined(HAVE_MUMPS_) + use amg_z_mumps_solver +#endif + + + implicit none + + ! Arguments + class(amg_zprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_, ilmax_, il + character(len=*), parameter :: name='amg_precseti' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmax_ = nlev_ + end if + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + select case(psb_toupper(what)) + case ('MIN_COARSE_SIZE') + p%ag_data%min_coarse_size = max(val,-1) + return + case('MAX_LEVS') + p%ag_data%max_levs = max(val,1) + return + case ('OUTER_SWEEPS') + p%outer_sweeps = max(val,1) + return + end select + + ! + ! Set preconditioner parameters at level ilev. + ! + if (present(ilev)) then + + select case(psb_toupper(what)) + case('SMOOTHER_TYPE','SUB_SOLVE','SMOOTHER_SWEEPS',& + & 'ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD',& + & 'AGGR_TYPE','AGGR_PROL','AGGR_OMEGA_ALG',& + & 'AGGR_EIG','SUB_RESTR','SUB_PROL', & + & 'SUB_OVR','SUB_FILLIN',& + & 'COARSE_MAT') + do il=ilev_, ilmax_ + call p%precv(il)%set(what,val,info,pos=pos) + end do + + case('COARSE_SUBSOLVE') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + call p%precv(ilev_)%set('SUB_SOLVE',val,info,pos=pos) + case('COARSE_SOLVE') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_SOLVE',val,info,pos=pos) + select case (val) + case(amg_bjac_,amg_l1_bjac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',val,info,pos=pos) +#if defined(HAVE_UMF_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_umf_,info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) +#else + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) +#endif + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info) + case(amg_slu_) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) + case(amg_mumps_) +#if defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(amg_umf_) +#if defined(HAVE_UMF_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + + case(amg_sludist_) +#if defined(HAVE_SLUDIST_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#elif defined(HAVE_UMF_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_umf_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(amg_jac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_diag_scale_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + + case(amg_l1_jac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_l1_diag_scale_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_gs_,amg_fbgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_gs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_bwgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_bwgs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_l1_gs_,amg_l1_fbgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_l1_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_gs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + end select + + endif + case('COARSE_SWEEPS') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + call p%precv(nlev_)%set('SMOOTHER_SWEEPS',val,info,pos=pos) + + case('COARSE_FILLIN') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + call p%precv(nlev_)%set('SUB_FILLIN',val,info,pos=pos) + + case default + do il=ilev_, ilmax_ + call p%precv(il)%set(what,val,info,pos=pos,idx=idx) + end do + end select + + + else if (.not.present(ilev)) then + ! + ! ilev not specified: set preconditioner parameters at all the appropriate + ! levels + ! + select case(psb_toupper(trim(what))) + case('SUB_SOLVE','SUB_RESTR','SUB_PROL',& + & 'SUB_OVR','SUB_FILLIN',& + & 'SMOOTHER_SWEEPS','SMOOTHER_TYPE') + do ilev_=1,max(1,nlev_-1) + call p%precv(ilev_)%set(what,val,info,pos=pos) + if (info /= 0) return + end do + + case('ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD','AGGR_PROL','AGGR_TYPE',& + & 'AGGR_OMEGA_ALG','AGGR_EIG','AGGR_FILTER') + do ilev_=1,nlev_ + call p%precv(ilev_)%set(what,val,info,pos=pos) + if (info /= 0) return + end do + + case('COARSE_MAT') + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_MAT',val,info,pos=pos) + end if + + case('COARSE_SOLVE') + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_SOLVE',val,info,pos=pos) + select case (val) + case(amg_bjac_,amg_l1_bjac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',val,info,pos=pos) +#if defined(HAVE_UMF_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_umf_,info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) +#else + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) +#endif + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info) + case(amg_slu_) +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) + case(amg_mumps_) +#if defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(amg_umf_) +#if defined(HAVE_UMF_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + + case(amg_sludist_) +#if defined(HAVE_SLUDIST_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#elif defined(HAVE_UMF_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_umf_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_slu_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_repl_mat_,info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_mumps_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) +#endif + case(amg_jac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_diag_scale_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + + case(amg_l1_jac_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_l1_diag_scale_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_gs_,amg_fbgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_gs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_bwgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_bwgs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + case(amg_l1_gs_,amg_l1_fbgs_) + call p%precv(nlev_)%set('SMOOTHER_TYPE',amg_l1_bjac_,info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',amg_gs_,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT',amg_distr_mat_,info,pos=pos) + end select + endif + + case('COARSE_SUBSOLVE') + if (nlev_ > 1) then + call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) + endif + + case('COARSE_SWEEPS') + + if (nlev_ > 1) then + call p%precv(nlev_)%set('SMOOTHER_SWEEPS',val,info,pos=pos) + end if + + case('COARSE_FILLIN') + if (nlev_ > 1) then + call p%precv(nlev_)%set('SUB_FILLIN',val,info,pos=pos) + end if + + case default + do ilev_=1,nlev_ + call p%precv(ilev_)%set(what,val,info,pos=pos,idx=idx) + end do + end select + + endif + +end subroutine amg_zcprecseti + +! +! Subroutine: amg_zprecsetc +! Version: complex +! +! This routine sets the character parameters defining the preconditioner. More +! precisely, the character parameter identified by 'what' is assigned the value +! contained in 'val'. +! For the multilevel preconditioners, the levels are numbered in increasing +! order starting from the finest one, i.e. level 1 is the finest level. +! +! To set integer and complex parameters, see amg_zprecseti and amg_zprecsetr, +! respectively. +! +! +! Arguments: +! p - type(amg_zprec_type), input/output. +! The preconditioner data structure. +! what - integer, input. +! The number identifying the parameter to be set. +! A mnemonic constant has been associated to each of these +! numbers, as reported in the MLD2P4 User's and Reference Guide. +! string - character(len=*), input. +! The value of the parameter to be set. The list of allowed +! values is reported in the MLD2P4 User's and Reference Guide. +! info - integer, output. +! Error code. +! ilev - integer, optional, input. +! For the multilevel preconditioner, the level at which the +! preconditioner parameter has to be set. +! If nlev is not present, the parameter identified by 'what' +! is set at all the appropriate levels. +! +! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to +! MLD2P4 developers. Indeed, by using ilev it is possible to set different values +! of the same parameter at different levels 1,...,nlev-1, even in cases where +! the parameter must have the same value at all the levels but the coarsest one. +! For this reason, the interface amg_precset to this routine has been built in +! such a way that ilev is not visible to the user (see amg_prec_mod.f90). +! +subroutine amg_zcprecsetc(p,what,string,info,ilev,ilmax,pos,idx) + + use psb_base_mod + use amg_z_prec_mod, amg_protect_name => amg_zcprecsetc + use amg_z_jac_smoother + use amg_z_as_smoother + use amg_z_diag_solver + use amg_z_l1_diag_solver + use amg_z_ilu_solver + use amg_z_id_solver + use amg_z_gs_solver +#if defined(HAVE_UMF_) + use amg_z_umf_solver +#endif +#if defined(HAVE_SLUDIST_) + use amg_z_sludist_solver +#endif +#if defined(HAVE_SLU_) + use amg_z_slu_solver +#endif +#if defined(HAVE_MUMPS_) + use amg_z_mumps_solver +#endif + + + implicit none + + ! Arguments + class(amg_zprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + character(len=*), intent(in) :: string + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_,val,ilmax_, il + character(len=*), parameter :: name='amg_precsetc' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmax_ = nlev_ + end if + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + ! + ! Set preconditioner parameters at level ilev. + ! + if (present(ilev)) then + + select case(psb_toupper(what)) + case('SMOOTHER_TYPE','SUB_SOLVE',& + & 'ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD',& + & 'AGGR_TYPE','AGGR_PROL','AGGR_OMEGA_ALG',& + & 'AGGR_EIG','SUB_RESTR','SUB_PROL', & + & 'COARSE_MAT') + do il=ilev_, ilmax_ + call p%precv(il)%set(what,string,info,pos=pos) + end do + + case('COARSE_SUBSOLVE') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + call p%precv(ilev_)%set('SUB_SOLVE',string,info,pos=pos) + case('COARSE_SOLVE') + if (ilev_ /= nlev_) then + write(psb_err_unit,*) name,& + & ': Error: Inconsistent specification of WHAT vs. ILEV' + info = -2 + return + end if + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_SOLVE',string,info,pos=pos) + select case (psb_toupper(trim(string))) + case('BJAC', 'L1-BJAC') + call p%precv(nlev_)%set('SMOOTHER_TYPE',psb_toupper(trim(string)),info,pos=pos) +#if defined(HAVE_UMF_) + call p%precv(nlev_)%set('SUB_SOLVE','UMF',info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) +#else + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) +#endif + call p%precv(nlev_)%set('COARSE_MAT','dist',info) + case('SLU') +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('ILU','MILU','ILUT') + call p%precv(nlev_)%set('SMOOTHER_TYPE','bjac',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) + case('MUMPS') +#if defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('UMF') +#if defined(HAVE_UMF_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('SLUDIST') +#if defined(HAVE_SLUDIST_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#elif defined(HAVE_UMF_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','UMF',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('JAC','JACOBI') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','DIAG',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + + case('L1-JACOBI') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','L1-DIAG',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('GS','FWGS','FBGS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('BWGS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','BWGS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('L1-GS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','L1-BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + end select + + endif + + case default + do il=ilev_, ilmax_ + call p%precv(il)%set(what,string,info,pos=pos,idx=idx) + end do + end select + + + else if (.not.present(ilev)) then + ! + ! ilev not specified: set preconditioner parameters at all the appropriate + ! levels + ! + select case(psb_toupper(trim(what))) + case('SUB_SOLVE','SUB_RESTR','SUB_PROL',& + & 'SMOOTHER_TYPE') + do ilev_=1,max(1,nlev_-1) + call p%precv(ilev_)%set(what,string,info,pos=pos) + if (info /= 0) return + end do + + case('ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD','AGGR_PROL','AGGR_TYPE',& + & 'AGGR_OMEGA_ALG','AGGR_EIG','AGGR_FILTER') + do ilev_=1,nlev_ + call p%precv(ilev_)%set(what,string,info,pos=pos) + if (info /= 0) return + end do + + case('COARSE_MAT') + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_MAT',string,info,pos=pos) + end if + + case('COARSE_SOLVE') + if (nlev_ > 1) then + call p%precv(nlev_)%set('COARSE_SOLVE',string,info,pos=pos) + select case (psb_toupper(trim(string))) + case('BJAC', 'L1-BJAC') + call p%precv(nlev_)%set('SMOOTHER_TYPE',psb_toupper(trim(string)),info,pos=pos) +#if defined(HAVE_UMF_) + call p%precv(nlev_)%set('SUB_SOLVE','UMF',info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) +#else + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) +#endif + call p%precv(nlev_)%set('COARSE_MAT','DIST',info) + case('SLU') +#if defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('ILU', 'ILUT','MILU') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) + case('MUMPS') +#if defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('UMF') +#if defined(HAVE_UMF_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + + case('SLUDIST') +#if defined(HAVE_SLUDIST_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#elif defined(HAVE_UMF_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','UMF',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_SLU_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) +#elif defined(HAVE_MUMPS_) + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#else + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) +#endif + case('JAC','JACOBI') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','DIAG',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('L1-JACOBI') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','L1-DIAG',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('GS','FWGS','FBGS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('BWGS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','BWGS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + case('L1-GS') + call p%precv(nlev_)%set('SMOOTHER_TYPE','L1-BJAC',info,pos=pos) + call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) + call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) + end select + endif + + case('COARSE_SUBSOLVE') + if (nlev_ > 1) then + call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) + endif + + case default + do ilev_=1,nlev_ + call p%precv(ilev_)%set(what,string,info,pos=pos,idx=idx) + end do + end select + + endif + + +end subroutine amg_zcprecsetc + + +! +! Subroutine: amg_zprecsetr +! Version: complex +! +! This routine sets the complex parameters defining the preconditioner. More +! precisely, the complex parameter identified by 'what' is assigned the value +! contained in 'val'. +! For the multilevel preconditioners, the levels are numbered in increasing +! order starting from the finest one, i.e. level 1 is the finest level. +! +! To set integer and character parameters, see amg_zprecseti and amg_zprecsetc, +! respectively. +! +! Arguments: +! p - type(amg_zprec_type), input/output. +! The preconditioner data structure. +! what - integer, input. +! The number identifying the parameter to be set. +! A mnemonic constant has been associated to each of these +! numbers, as reported in the MLD2P4 User's and Reference Guide. +! val - real(psb_dpk_), input. +! The value of the parameter to be set. The list of allowed +! values is reported in the MLD2P4 User's and Reference Guide. +! info - integer, output. +! Error code. +! ilev - integer, optional, input. +! For the multilevel preconditioner, the level at which the +! preconditioner parameter has to be set. +! If nlev is not present, the parameter identified by 'what' +! is set at all the appropriate levels. +! +! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to +! MLD2P4 developers. Indeed, by using ilev it is possible to set different values +! of the same parameter at different levels 1,...,nlev-1, even in cases where +! the parameter must have the same value at all the levels but the coarsest one. +! For this reason, the interface amg_precset to this routine has been built in +! such a way that ilev is not visible to the user (see amg_prec_mod.f90). +! +subroutine amg_zcprecsetr(p,what,val,info,ilev,ilmax,pos,idx) + + use psb_base_mod + use amg_z_prec_mod, amg_protect_name => amg_zcprecsetr + + implicit none + + ! Arguments + class(amg_zprec_type), intent(inout) :: p + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + + ! Local variables + integer(psb_ipk_) :: ilev_,nlev_, ilmax_, il + real(psb_dpk_) :: thr + character(len=*), parameter :: name='amg_precsetr' + + info = psb_success_ + + if (present(ilev)) then + ilev_ = ilev + else + ilev_ = 1 + end if + + select case(psb_toupper(what)) + case ('MIN_CR_RATIO') + p%ag_data%min_cr_ratio = max(done,val) + return + end select + + if (.not.allocated(p%precv)) then + write(psb_err_unit,*) name,& + &': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + info = 3111 + return + endif + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmax_ = nlev_ + end if + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + + ! + ! Set preconditioner parameters at level ilev. + ! + if (present(ilev)) then + + do il=ilev_, ilmax_ + call p%precv(il)%set(what,val,info,pos=pos,idx=idx) + end do + + else if (.not.present(ilev)) then + ! + ! ilev not specified: set preconditioner parameters at all the appropriate levels + ! + + select case(psb_toupper(what)) + case('COARSE_ILUTHRS') + ilev_=nlev_ + call p%precv(ilev_)%set('SUB_ILUTHRS',val,info,pos=pos) + + case default + + do il=1,nlev_ + call p%precv(il)%set(what,val,info,pos=pos,idx=idx) + end do + end select + + endif + +end subroutine amg_zcprecsetr + + diff --git a/mlprec/impl/amg_zfile_prec_descr.f90 b/mlprec/impl/amg_zfile_prec_descr.f90 new file mode 100644 index 00000000..44af8a2c --- /dev/null +++ b/mlprec/impl/amg_zfile_prec_descr.f90 @@ -0,0 +1,199 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_dfile_prec_descr.f90 +! +! +! Subroutine: amg_file_prec_descr +! Version: complex +! +! This routine prints a description of the preconditioner to the standard +! output or to a file. It must be called after the preconditioner has been +! built by amg_precbld. +! +! Arguments: +! p - type(amg_Tprec_type), input. +! The preconditioner data structure to be printed out. +! info - integer, output. +! error code. +! iout - integer, input, optional. +! The id of the file where the preconditioner description +! will be printed. If iout is not present, then the standard +! output is condidered. +! root - integer, input, optional. +! The id of the process printing the message; -1 acts as a wildcard. +! Default is psb_root_ +! +subroutine amg_zfile_prec_descr(prec,iout,root) + use psb_base_mod + use amg_z_prec_mod, amg_protect_name => amg_zfile_prec_descr + use amg_z_inner_mod + use amg_z_gs_solver + + implicit none + ! Arguments + class(amg_zprec_type), intent(in) :: prec + integer(psb_ipk_), intent(in), optional :: iout + integer(psb_ipk_), intent(in), optional :: root + + ! Local variables + integer(psb_ipk_) :: ilev, nlev, ilmin, info, nswps + integer(psb_ipk_) :: ictxt, me, np + logical :: is_symgs + character(len=20), parameter :: name='amg_file_prec_descr' + integer(psb_ipk_) :: iout_ + integer(psb_ipk_) :: root_ + + info = psb_success_ + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + if (iout_ < 0) iout_ = psb_out_unit + + ictxt = prec%ictxt + + if (allocated(prec%precv)) then + + call psb_info(ictxt,me,np) + if (present(root)) then + root_ = root + else + root_ = psb_root_ + end if + if (root_ == -1) root_ = me + + ! + ! The preconditioner description is printed by processor psb_root_. + ! This agrees with the fact that all the parameters defining the + ! preconditioner have the same values on all the procs (this is + ! ensured by amg_precbld). + ! + if (me == root_) then + nlev = size(prec%precv) + do ilev = 1, nlev + if (.not.allocated(prec%precv(ilev)%sm)) then + info = 3111 + write(iout_,*) ' ',name,& + & ': error: inconsistent MLPREC part, should call amg_PRECINIT' + return + endif + end do + + write(iout_,*) + write(iout_,'(a)') 'Preconditioner description' + + if (nlev == 1) then + ! + ! Here we have a gigantic kludge just to handle Symmetrized Gauss-Seidel. + ! Will need rethinking... + ! + if (allocated(prec%precv(1)%sm2a)) then + is_symgs = .false. + select type(sv2 => prec%precv(1)%sm2a%sv) + class is (amg_z_bwgs_solver_type) + select type(sv1 => prec%precv(1)%sm%sv) + class is (amg_z_gs_solver_type) + is_symgs = .true. + end select + end select + if (is_symgs) then + write(iout_,*) ' Forward-Backward (symmetrized) Hybrid Gauss-Seidel' + else + write(iout_,*) 'Pre Smoother: ' + call prec%precv(1)%sm%descr(info,iout=iout_) + write(iout_,*) 'Post smoother:' + call prec%precv(1)%sm2a%descr(info,iout=iout_) + end if + nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) + + else + call prec%precv(1)%sm%descr(info,iout=iout_) + nswps = prec%precv(1)%parms%sweeps_pre + end if + if (nswps > 1) write(iout_,*) ' Number of sweeps : ',nswps + write(iout_,*) + + else if (nlev > 1) then + ! + ! Print description of base preconditioner + ! + write(iout_,*) 'Multilevel Preconditioner' + write(iout_,*) 'Outer sweeps:',prec%outer_sweeps + write(iout_,*) + if (allocated(prec%precv(1)%sm2a)) then + write(iout_,*) 'Pre Smoother: ' + call prec%precv(1)%sm%descr(info,iout=iout_) + write(iout_,*) 'Post smoother:' + call prec%precv(1)%sm2a%descr(info,iout=iout_) + else + write(iout_,*) 'Smoother: ' + call prec%precv(1)%sm%descr(info,iout=iout_) + end if + ! + ! Print multilevel details + ! + write(iout_,*) + write(iout_,*) 'Multilevel hierarchy: ' + write(iout_,*) ' Number of levels : ',nlev + write(iout_,*) ' Operator complexity: ',prec%get_complexity() + write(iout_,*) ' Average coarsening : ',prec%get_avg_cr() + ilmin = 2 + if (nlev == 2) ilmin=1 + do ilev=ilmin,nlev + call prec%precv(ilev)%descr(ilev,nlev,ilmin,info,iout=iout_) + end do + write(iout_,*) + + else + write(iout_,*) trim(name), & + & ': invalid preconditioner array size ?',nlev + info = -2 + return + + end if + end if + + else + write(iout_,*) trim(name), & + & ': Error: no base preconditioner available, something is wrong!' + info = -2 + return + endif + +end subroutine amg_zfile_prec_descr diff --git a/mlprec/impl/amg_zmlprec_aply.f90 b/mlprec/impl/amg_zmlprec_aply.f90 new file mode 100644 index 00000000..85c3d672 --- /dev/null +++ b/mlprec/impl/amg_zmlprec_aply.f90 @@ -0,0 +1,1669 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_zmlprec_aply.f90 +! +! Subroutine: amg_zmlprec_aply +! Version: real +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +! This routine computes +! +! Y = beta*Y + alpha*op(ML^(-1))*X, +! where +! - ML is a multilevel preconditioner associated with +! a certain matrix A and stored in p, +! - op(ML^(-1)) is ML^(-1) or its transpose, according to the value of trans, +! - X and Y are vectors, +! - alpha and beta are scalars. +! +! The following multilevel strategies can be applied: +! +! - Additive multilevel Schwarz, +! - classical V-cycle, +! - classical W-cycle, +! - K-cycle both for symmetric and nonsymmetric matrices, where 2 iterations +! of FCG(1) or GCR, respectively, are applied at each level +! except the coarsest. +! +! For each level we have as many submatrices as processes (except for the coarsest +! level where we might have a replicated index space) and each process takes care +! of one submatrix. +! +! A multilevel preconditioner is regarded as an array of 'one-level' data structures, +! each containing the part of the preconditioner associated to a certain level +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! For each level lev, there is a smoother stored in +! p%precv(lev)%sm +! which in turn contains a solver +! p$precv(lev)%sm%sv +! Typically the solver acts only locally, and the smoother applies any required +! parallel communication/action. +! Each level has a matrix A(lev), obtained by 'tranferring' the original +! matrix A (i.e. the matrix to be preconditioned) to the level lev, through smoothed +! aggregation. +! +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level and A(1) is the matrix A. +! +! This routine is formulated in a recursive way, so it is quite compact. +! +! The V-cycle can be described as follows, where +! P(lev) denotes the smoothed prolongator from level lev to level +! lev-1, while R(lev) denotes the corresponding restriction operator +! (normally its transpose) from level lev-1 to level lev. +! M(lev) is the smoother at the current level. +! +! +! 1. Transfer the outer vector Xest to u(1) (inner X at level 1) +! +! 2. Invoke V-cycle(1,M,P,R,A,b,u) +! +! procedure V-cycle(lev,M,P,R,A,b,u) +! +! if (lev < nlev) then +! +! u(lev) = u(lev) + M(lev)*(b(lev)-A(lev)*u(lev)) +! +! b(lev+1) = R(lev+1)*(b(lev)-A(lev)*u(lev)) +! +! u(lev+1) = V-cycle(lev+1,M,P,R,A,b,u) +! +! u(lev) = u(lev) + P(lev+1) * u(lev+1) +! +! u(lev) = u(lev) + M(lev)*(b(lev)-A(lev)*u(lev)) +! +! else +! +! solve A(lev)*u(lev) = b(lev) +! +! end if +! +! return u(lev) +! end +! +! 3. Transfer u(1) to the external: +! Yext = beta*Yext + alpha*u(1) +! +! +! In the implementation, the recursive procedure is inner_ml_aply, which +! in turn uses amg_inner_add (for additive multilevel), +! amg_inner_mult (for V-cycle and W-cycle), and +! amg_inner_k_cycle (for symmetric and non-symmetric K-cycle). +! +! For a detailed description of the algorithms, see: +! +! - B.F. Smith, P.E. Bjorstad, W.D. Gropp, +! Domain decomposition: parallel multilevel methods for elliptic partial +! differential equations, Cambridge University Press, 1996. +! +! - W. L. Briggs, V. E. Henson, S. F. McCormick, +! A Multigrid Tutorial, Second Edition +! SIAM, 2000. +! +! - K. Stuben, +! An Introduction to Algebraic Multigrid, +! in A. Schuller, U. Trottenberg, C. Oosterlee, Multigrid, Academic Press, 2001. +! +! - Y. Notay, P. S. Vassilevski, +! Recursive Krylov-based multigrid cycles +! Numerical Linear Algebra with Applications, 15 (5), 2008, 473--487. +! +! +! Arguments: +! alpha - complex(psb_dpk_), input. +! The scalar alpha. +! p - type(amg_zprec_type), input. +! The multilevel preconditioner data structure containing the +! local part of the preconditioner to be applied. +! Note that nlev = size(p%precv) = number of levels. +! p%precv(lev)%sm - type(psb_zbaseprec_type) +! The pre-'smoother' for the current level +! p%precv(lev)%sm2 - type(psb_zbaseprec_type) +! The post-'smoother' for the current level +! may be the same or different from %sm +! p%precv(lev)%ac - type(psb_zspmat_type) +! The local part of the matrix A(lev). +! p%precv(lev)%parms - type(psb_dml_parms) +! Parameters controllin the multilevel prec. +! p%precv(lev)%desc_ac - type(psb_desc_type). +! The communication descriptor associated to the sparse +! matrix A(lev) +! p%precv(lev)%map - type(psb_inter_desc_type) +! Stores the linear operators mapping level (lev-1) +! to (lev) and vice versa. These are the restriction +! and prolongation operators described in the sequel. +! p%precv(lev)%base_a - type(psb_zspmat_type), pointer. +! Pointer (really a pointer!) to the base matrix of +! the current level, i.e. the local part of A(lev); +! so we have a unified treatment of residuals. We +! need this to avoid passing explicitly the matrix +! A(lev) to the routine which applies the +! preconditioner. +! p%precv(lev)%base_desc - type(psb_desc_type), pointer. +! Pointer to the communication descriptor associated +! to the sparse matrix pointed by base_a. +! +! x - complex(psb_dpk_), dimension(:), input. +! The local part of the vector X. +! beta - complex(psb_dpk_), input. +! The scalar beta. +! y - complex(psb_dpk_), dimension(:), input/output. +! The local part of the vector Y. +! desc_data - type(psb_desc_type), input. +! The communication descriptor associated to the matrix to be +! preconditioned. +! trans - character, optional. +! If trans='N','n' then op(M^(-1)) = M^(-1); +! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). +! work - complex(psb_dpk_), dimension (:), optional, target. +! Workspace. Its size must be at least 4*desc_data%get_local_cols(). +! info - integer, output. +! Error code. +! +! Note that when the LU factorization of the matrix A(lev) is computed instead of +! the ILU one, by using UMFPACK or SuperLU or MUMPS, the corresponding +! L and U factors are stored in data structures handled +! by the third party software. +! +subroutine amg_zmlprec_aply_vect(alpha,p,x,beta,y,desc_data,trans,work,info) + + use psb_base_mod + use amg_base_prec_type + use amg_z_inner_mod, amg_protect_name => amg_zmlprec_aply_vect + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_zprec_type), intent(inout) :: p + complex(psb_dpk_),intent(in) :: alpha,beta + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + character, intent(in) :: trans + complex(psb_dpk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: ictxt, np, me + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, nc2l, level, isweep, err_act + character(len=20) :: name + character :: trans_ + complex(psb_dpk_) :: beta_ + logical :: do_alloc_wrk + type(amg_zmlprec_wrk_type), allocatable, target :: mlprec_wrk(:) + + name='amg_zmlprec_aply' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (debug_level >= psb_debug_inner_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Entry ', size(p%precv) + + trans_ = psb_toupper(trans) + nlev = size(p%precv) + + do_alloc_wrk = .not.allocated(p%precv(1)%wrk) + + if (do_alloc_wrk) call p%allocate_wrk(info,vmold=x%v) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') + goto 9999 + end if + level = 1 + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & wv => p%precv(level)%wrk%wv(:)) + ! + ! At first iteration we must use the input BETA + ! + beta_ = beta + + + call psb_geaxpby(zone,x,zzero,vx2l,base_desc,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='geaxbpy') + goto 9999 + end if + + do isweep = 1, p%outer_sweeps - 1 + ! + ! With the current implementation, y2l is zeroed internally at first smoother. + ! call p%wrk(level)%vy2l%zero() + ! + call inner_ml_aply(level,p,trans_,work,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Inner prec aply') + goto 9999 + end if + call psb_geaxpby(alpha,vy2l,beta_,y,base_desc,info) + ! all iterations after the first must use BETA = 1 + beta_ = zone + ! + ! Next iteration should use the current residual to compute a correction + ! + call psb_geaxpby(zone,x,zzero,vx2l,base_desc,info) + call psb_spmm(-zone,base_a,y,zone,vx2l,base_desc,info) + end do + + ! + ! If outer_sweeps == 1 we have just skipped the loop, and it's + ! equivalent to a single application. + ! + + ! + ! With the current implementation, y2l is zeroed internally at first smoother. + ! call p%wrk(level)%vy2l%zero() + ! + call inner_ml_aply(level,p,trans_,work,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Inner prec aply') + goto 9999 + end if + call psb_geaxpby(alpha,vy2l,beta_,y,base_desc,info) + + end associate + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error final update') + goto 9999 + end if + if (do_alloc_wrk) call p%free_wrk(info) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + ! + ! + ! inner_ml_aply: apply AMG at a given level. + ! This routine dispatches the computation according to the type + ! specified at the current level. + ! Each of the corrections will inturn call recursively this routine. + ! + ! Assumptions: + ! On input: + ! mlprec_wkr(level)%vx2l contains the input vector (RHS) + ! mlprec_wkr(level)%vy2l contains the initial guess + ! + ! On output: + ! mlprec_wkr(level)%vy2l contains the solution + ! + ! Constraints: each of the called routines must properly handle + ! the input/output conditions for level+1 (i.e. apply + ! prolongation/restriction). + ! Note: for historical/convenience reasons the prolongator/restrictor + ! between level and level+1 are stored at level+1. + ! + ! + recursive subroutine inner_ml_aply(level,p,trans,work,info) + + implicit none + + ! Arguments + integer(psb_ipk_) :: level + type(amg_zprec_type), target, intent(inout) :: p + character, intent(in) :: trans + complex(psb_dpk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + + type(psb_z_vect_type) :: res + type(psb_z_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_ml_aply' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_ml') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' Start inner_ml_aply at level ',level, info + end if + + select case(p%precv(level)%parms%ml_cycle) + + case(amg_no_ml_) + ! + ! No preconditioning, should not really get here + ! + call psb_errpush(psb_err_internal_error_,name,& + & a_err='amg_no_ml_ in mlprc_aply?') + goto 9999 + + case(amg_add_ml_) + + call amg_z_inner_add(p, level, trans, work) + + case(amg_mult_ml_,amg_vcycle_ml_, amg_wcycle_ml_) + + call amg_z_inner_mult(p, level, trans, work) + + case(amg_kcycle_ml_, amg_kcyclesym_ml_) + + call amg_z_inner_k_cycle(p, level, trans, work) + + case default + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='invalid ml_cycle',& + & i_Err=(/p%precv(level)%parms%ml_cycle,izero,izero,izero,izero/)) + goto 9999 + + end select + if(debug_level > 1) then + write(debug_unit,*) me,' End inner_ml_aply at level ',level + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine inner_ml_aply + + + recursive subroutine amg_z_inner_add(p, level, trans, work) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_zprec_type), intent(inout) :: p + + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + complex(psb_dpk_),target :: work(:) + type(psb_z_vect_type) :: res + type(psb_z_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act, k + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_inner_add' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_add') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_add at level ',level + end if + + if ((level<1).or.(level>nlev)) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL>NLEV') + goto 9999 + end if + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & wv => p%precv(level)%wrk%wv) + + if (allocated(p%precv(level)%sm2a)) then + call psb_geaxpby(zone,vx2l,zzero,vy2l,base_desc,info) + + sweeps = max(p%precv(level)%parms%sweeps_pre,p%precv(level)%parms%sweeps_post) + do k=1, sweeps + call p%precv(level)%sm%apply(zone,& + & vy2l,zzero,vty,& + & base_desc, trans,& + & ione,work,wv,info,init='Z') + + call p%precv(level)%sm2a%apply(zone,& + & vty,zzero,vy2l,& + & base_desc, trans,& + & ione,work,wv,info,init='Z') + end do + + else + sweeps = p%precv(level)%parms%sweeps_pre + call p%precv(level)%sm%apply(zone,& + & vx2l,zzero,vy2l,& + & base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during ADD smoother_apply') + goto 9999 + end if + + if (level < nlev) then + ! Apply the restriction + call p%precv(level+1)%map%map_U2V(zone,vx2l,& + & zzero,p%precv(level+1)%wrk%vx2l,& + & info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + + call inner_ml_aply(level+1,p,trans,work,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in recursive call') + goto 9999 + end if + + ! + ! Apply the prolongator + ! + call p%precv(level+1)%map%map_V2U(zone,& + & p%precv(level+1)%wrk%vy2l, zone,vy2l,& + & info,work=work,& + & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + + end if + end associate + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_z_inner_add + + recursive subroutine amg_z_inner_mult(p, level, trans, work) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_zprec_type), intent(inout) :: p + + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + complex(psb_dpk_),target :: work(:) + type(psb_z_vect_type) :: res + type(psb_z_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + name = 'inner_inner_mult' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_mult') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_mult at level ',level + end if + + sweeps_post = p%precv(level)%parms%sweeps_post + sweeps_pre = p%precv(level)%parms%sweeps_pre + pre = ((sweeps_pre>0).and.(trans=='N')).or.((sweeps_post>0).and.(trans/='N')) + post = ((sweeps_post>0).and.(trans=='N')).or.((sweeps_pre>0).and.(trans/='N')) + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & wv => p%precv(level)%wrk%wv) + if (level < nlev) then + ! + ! Apply the first smoother + ! The residual has been prepared before the recursive call. + ! + + if (pre) then + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(zone,& + & vx2l,zzero,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(zone,& + & vx2l,zzero,vy2l, base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during PRE smoother_apply') + goto 9999 + end if + endif + ! + ! Compute the residual for next level and call recursively + ! + if (pre) then + call psb_geaxpby(zone,vx2l,& + & zzero,vty,& + & base_desc,info) + + if (info == psb_success_) call psb_spmm(-zone,base_a,& + & vy2l,zone,vty,& + & base_desc,info,work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + call p%precv(level+1)%map%map_U2V(zone,vty,& + & zzero,p%precv(level+1)%wrk%vx2l,& + & info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + else + ! Shortcut: just transfer x2l. + call p%precv(level+1)%map%map_U2V(zone,vx2l,& + & zzero,p%precv(level+1)%wrk%vx2l,& + & info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + endif + + call inner_ml_aply(level+1,p,trans,work,info) + + ! + ! Apply the prolongator + ! + call p%precv(level+1)%map%map_V2U(zone,& + & p%precv(level+1)%wrk%vy2l,zone,vy2l,& + & info,work=work,& + & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + if (p%precv(level)%parms%ml_cycle == amg_wcycle_ml_) then + + call psb_geaxpby(zone,vx2l, zzero,vty,& + & base_desc,info) + if (info == psb_success_) call psb_spmm(-zone,base_a,& + & vy2l,zone,vty,& + & base_desc,info,work=work,trans=trans) + if (info == psb_success_) & + & call p%precv(level+1)%map%map_U2V(zone,vty,& + & zzero,p%precv(level+1)%wrk%vx2l,info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during W-cycle restriction') + goto 9999 + end if + + call inner_ml_aply(level+1,p,trans,work,info) + + if (info == psb_success_) call p%precv(level+1)%map%map_V2U(zone, & + & p%precv(level+1)%wrk%vy2l,zone,vy2l,& + & info,work=work,& + & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during W recusion/prolongation') + goto 9999 + end if + + endif + + + if (post) then + call psb_geaxpby(zone,vx2l,& + & zzero,vty,& + & base_desc,info) + if (info == psb_success_) call psb_spmm(-zone,base_a,& + & vy2l, zone,vty,base_desc,info,& + & work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + + ! + ! Apply the second smoother + ! + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(zone,& + & vty,zone,vy2l, base_desc, trans,& + & sweeps,work,wv,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(zone,& + & vty,zone,vy2l, base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during POST smoother_apply') + goto 9999 + end if + + endif + + else if (level == nlev) then + + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(zone,& + & vx2l,zzero,vy2l,base_desc, trans,& + & sweeps,work,wv,info) + + else + + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL vs NLEV') + goto 9999 + end if + end associate + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_z_inner_mult + + recursive subroutine amg_z_inner_k_cycle(p, level, trans, work,u) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_zprec_type), intent(inout) :: p + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + complex(psb_dpk_),target :: work(:) + type(psb_z_vect_type),intent(inout), optional :: u + + + + type(psb_z_vect_type) :: res + type(psb_z_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_kcycle' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_add') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,name,' start at level ',level + end if + + if ((level<1).or.(level>nlev)) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL>NLEV') + goto 9999 + end if + + !K cycle + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & wv => p%precv(level)%wrk%wv(8:)) + if (level == nlev) then + ! + ! Apply smoother + ! + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(zone,& + & vx2l,zzero,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + + else if (level < nlev) then + + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(zone,& + & vx2l,zzero,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(zone,& + & vx2l,zzero,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during 2-PRE smoother_apply') + goto 9999 + end if + + + ! + ! Compute the residual and call recursively + ! + + call psb_geaxpby(zone,vx2l,& + & zzero,vty,& + & base_desc,info) + + if (info == psb_success_) call psb_spmm(-zone,base_a,& + & vy2l,zone,vty,base_desc,info,work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + + ! Apply the restriction + call p%precv(level + 1)%map%map_U2V(zone,vty,& + & zzero,p%precv(level + 1)%wrk%vx2l,& + &info,work=work,& + & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + + !Set the preconditioner + + if (level <= nlev - 2 ) then + if (p%precv(level)%parms%ml_cycle == amg_kcyclesym_ml_) then + call amg_zinneritkcycle(p, level + 1, trans, work, 'FCG') + elseif (p%precv(level)%parms%ml_cycle == amg_kcycle_ml_) then + call amg_zinneritkcycle(p, level + 1, trans, work, 'GCR') + else + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Bad value for ml_cycle') + goto 9999 + endif + else + call inner_ml_aply(level + 1 ,p,trans,work,info) + endif + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in recursive call') + goto 9999 + end if + + ! + ! Apply the prolongator + ! + call p%precv(level+1)%map%map_V2U(zone,& + & p%precv(level+1)%wrk%vy2l,zone,vy2l,& + & info,work=work,& + & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + ! + ! Compute the residual + ! + call psb_geaxpby(zone,vx2l,& + & zzero,vty,base_desc,info) + call psb_spmm(-zone,base_a,vy2l,& + & zone,vty,base_desc,info,& + & work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + ! + ! Apply the smoother + ! + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(zone,& + & vty,zone,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(zone,& + & vty,zone,vy2l,base_desc, trans,& + & sweeps,work,wv,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during POST smoother_apply') + goto 9999 + end if + else + + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL vs NLEV') + goto 9999 + + endif + end associate + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_z_inner_k_cycle + + + recursive subroutine amg_zinneritkcycle(p, level, trans, work, innersolv) + use psb_base_mod + use amg_prec_mod + use amg_z_inner_mod, amg_protect_name => amg_zmlprec_aply + + implicit none + + !Input/Oputput variables + type(amg_zprec_type), intent(inout) :: p + + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + character(len=*), intent(in) :: innersolv + complex(psb_dpk_),target :: work(:) + + !Other variables + type(psb_z_vect_type) :: v, w, rhs, v1, x + type(psb_z_vect_type) :: d0, d1 + complex(psb_dpk_) :: delta_old, rhs_norm, alpha, tau, tau1, tau2, tau3, tau4, beta + + real(psb_dpk_) :: l2_norm, delta, rtol=0.25, delta0, tnrm + complex(psb_dpk_), allocatable :: temp_v(:) + integer(psb_ipk_) :: info, nlev, i, iter, max_iter=2, idx + character(len=20) :: name = 'innerit_k_cycle' + + + if (size(p%precv(level)%wrk%wv)<7) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size') + goto 9999 + end if + + associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& + & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& + & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& + & v => p%precv(level)%wrk%wv(1), & + & w => p%precv(level)%wrk%wv(2),& + & rhs => p%precv(level)%wrk%wv(3), & + & v1 => p%precv(level)%wrk%wv(4), & + & x => p%precv(level)%wrk%wv(5), & + & d0 => p%precv(level)%wrk%wv(6), & + & d1 => p%precv(level)%wrk%wv(7)) + + call x%zero() + + ! rhs=vx2l and w=rhs + call psb_geaxpby(zone,vx2l,zzero,rhs, base_desc,info) + call psb_geaxpby(zone,vx2l,zzero,w, base_desc,info) + + if (psb_errstatus_fatal()) then + nc2l = base_desc%get_local_cols() + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + + delta0 = psb_genrm2(w, base_desc, info) + + !Apply the preconditioner + call vy2l%zero() + + idx=0 + call inner_ml_aply(level,p,trans,work,info) + + call psb_geaxpby(zone,vy2l,zzero,d0,base_desc,info) + + call psb_spmm(zone,base_a,d0,zzero,v,base_desc,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + + !FCG + if (psb_toupper(trim(innersolv)) == 'FCG') then + delta_old = psb_gedot(d0, w, base_desc, info) + tau = psb_gedot(d0, v, base_desc, info) + !GCR + else if (psb_toupper(trim(innersolv)) == 'GCR') then + delta_old = psb_gedot(v, w, base_desc, info) + tau = psb_gedot(v, v, base_desc, info) + else + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid inner solver') + goto 9999 + endif + + alpha = delta_old/tau + !Update residual w + call psb_geaxpby(-alpha, v, zone, w, base_desc, info) + + l2_norm = psb_genrm2(w, base_desc, info) + iter = 0 + + if (l2_norm <= rtol*delta0) then + !Update solution x + call psb_geaxpby(alpha, d0, zone, x, base_desc, info) + else + iter = iter + 1 + idx=mod(iter,2) + + !Apply preconditioner + call psb_geaxpby(zone,w,zzero,vx2l,base_desc,info) + call inner_ml_aply(level,p,trans,work,info) + call psb_geaxpby(zone,vy2l,zzero,d1,base_desc,info) + + !Sparse matrix vector product + + call psb_spmm(zone,base_a,d1,zzero,v1,base_desc,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + + !tau1, tau2, tau3, tau4 + if (psb_toupper(trim(innersolv)) == 'FCG') then + tau1= psb_gedot(d1, v, base_desc, info) + tau2= psb_gedot(d1, v1, base_desc, info) + tau3= psb_gedot(d1, w, base_desc, info) + tau4= tau2 - (tau1*tau1)/tau + else if (psb_toupper(trim(innersolv)) == 'GCR') then + tau1= psb_gedot(v1, v, base_desc, info) + tau2= psb_gedot(v1, v1, base_desc, info) + tau3= psb_gedot(v1, w, base_desc, info) + tau4= tau2 - (tau1*tau1)/tau + else + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid inner solver') + goto 9999 + endif + + !Update solution + alpha=alpha-(tau1*tau3)/(tau*tau4) + call psb_geaxpby(alpha,d0,zone,x,base_desc,info) + alpha=tau3/tau4 + call psb_geaxpby(alpha,d1,zone,x,base_desc,info) + endif + + call psb_geaxpby(zone,x,zzero,vy2l,base_desc,info) + end associate + +9999 continue + call psb_erractionrestore(err_act) + if (err_act.eq.psb_act_abort_) then + call psb_error() + return + end if + return + end subroutine amg_zinneritkcycle + +end subroutine amg_zmlprec_aply_vect + + +! +! Old routine for arrays instead of psb_X_vector. To be deleted eventually. +! +! +subroutine amg_zmlprec_aply(alpha,p,x,beta,y,desc_data,trans,work,info) + + use psb_base_mod + use amg_base_prec_type + use amg_z_inner_mod, amg_protect_name => amg_zmlprec_aply + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_zprec_type), intent(inout) :: p + complex(psb_dpk_),intent(in) :: alpha,beta + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + character, intent(in) :: trans + complex(psb_dpk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: ictxt, np, me + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: debug_level, debug_unit, nlev,nc2l,nr2l,level + character(len=20) :: name + character :: trans_ + type amg_mlwrk_type + complex(psb_dpk_), allocatable :: tx(:), ty(:), x2l(:), y2l(:) + end type amg_mlwrk_type + type(amg_mlwrk_type), allocatable, target :: mlwrk(:) + + name='amg_zmlprec_aply' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (debug_level >= psb_debug_inner_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Entry ', size(p%precv) + + trans_ = psb_toupper(trans) + + nlev = size(p%precv) + allocate(mlwrk(nlev),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') + goto 9999 + end if + level = 1 + + do level = 1, nlev + call psb_geasb(mlwrk(level)%x2l,& + & p%precv(level)%base_desc,info) + call psb_geasb(mlwrk(level)%y2l,& + & p%precv(level)%base_desc,info) + call psb_geasb(mlwrk(level)%tx,& + & p%precv(level)%base_desc,info) + call psb_geasb(mlwrk(level)%ty,& + & p%precv(level)%base_desc,info) + if (psb_errstatus_fatal()) then + nc2l = p%precv(level)%base_desc%get_local_cols() + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + end do + + mlwrk(level)%x2l(:) = x(:) + mlwrk(level)%y2l(:) = zzero + + call inner_ml_aply(level,p,mlwrk,trans_,work,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Inner prec aply') + goto 9999 + end if + + call psb_geaxpby(alpha,mlwrk(level)%y2l,beta,y,& + & p%precv(level)%base_desc,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error final update') + goto 9999 + end if + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + + ! + ! + ! inner_ml_aply: apply AMG at a given level. + ! This routine dispatches the computation according to the type + ! specified at the current level. + ! Each of the corrections will inturn call recursively this routine. + ! + ! Assumptions: + ! On input: + ! mlprec_wkr(level)%vx2l contains the input vector (RHS) + ! mlprec_wkr(level)%vy2l contains the initial guess + ! + ! On output: + ! mlprec_wkr(level)%vy2l contains the solution + ! + ! Constraints: each of the called routines must properly handle + ! the input/output conditions for level+1 (i.e. apply + ! prolongation/restriction). + ! Note: for historical/convenience reasons the prolongator/restrictor + ! between level and level+1 are stored at level+1. + ! + ! + recursive subroutine inner_ml_aply(level,p,mlwrk,trans,work,info) + + implicit none + + ! Arguments + integer(psb_ipk_) :: level + type(amg_zprec_type), target, intent(inout) :: p + type(amg_mlwrk_type), intent(inout), target :: mlwrk(:) + character, intent(in) :: trans + complex(psb_dpk_),target :: work(:) + integer(psb_ipk_), intent(out) :: info + + type(psb_z_vect_type) :: res + type(psb_z_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_ml_aply' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_ml') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_ml_aply at level ',level + end if + + select case(p%precv(level)%parms%ml_cycle) + + case(amg_no_ml_) + ! + ! No preconditioning, should not really get here + ! + call psb_errpush(psb_err_internal_error_,name,& + & a_err='amg_no_ml_ in mlprc_aply?') + goto 9999 + + case(amg_add_ml_) + + call amg_z_inner_add(p, mlwrk, level, trans, work) + + case(amg_mult_ml_, amg_vcycle_ml_, amg_wcycle_ml_) + + call amg_z_inner_mult(p, mlwrk, level, trans, work) + +! !$ case(amg_kcycle_ml_, amg_kcyclesym_ml_) +! !$ +! !$ call amg_z_inner_k_cycle(p, mlwrk, level, trans, work) + + case default + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='invalid ml_cycle',& + & i_Err=(/p%precv(level)%parms%ml_cycle,izero,izero,izero,izero/)) + goto 9999 + + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine inner_ml_aply + + + recursive subroutine amg_z_inner_add(p, mlwrk, level, trans, work) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_zprec_type), intent(inout) :: p + + type(amg_mlwrk_type), target, intent(inout) :: mlwrk(:) + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + complex(psb_dpk_),target :: work(:) + type(psb_z_vect_type) :: res + type(psb_z_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_inner_add' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_add') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_add at level ',level + end if + + if ((level<1).or.(level>nlev)) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL>NLEV') + goto 9999 + end if + + sweeps = p%precv(level)%parms%sweeps_pre + call p%precv(level)%sm%apply(zone,& + & mlwrk(level)%x2l,zzero,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during ADD smoother_apply') + goto 9999 + end if + + if (level < nlev) then + ! Apply the restriction + call p%precv(level+1)%map%map_U2V(zone,mlwrk(level)%x2l,& + & zzero,mlwrk(level+1)%x2l,& + & info,work=work) + mlwrk(level+1)%y2l(:) = zzero + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + + call inner_ml_aply(level+1,p,mlwrk,trans,work,info) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in recursive call') + goto 9999 + end if + + ! + ! Apply the prolongator and add correction. + ! + call p%precv(level+1)%map%map_V2U(zone,& + & mlwrk(level+1)%y2l,zone,mlwrk(level)%y2l,& + & info,work=work) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_z_inner_add + + recursive subroutine amg_z_inner_mult(p, mlwrk, level, trans, work) + use psb_base_mod + use amg_prec_mod + + implicit none + + !Input/Oputput variables + type(amg_zprec_type), intent(inout) :: p + + type(amg_mlwrk_type), target, intent(inout) :: mlwrk(:) + integer(psb_ipk_), intent(in) :: level + character, intent(in) :: trans + complex(psb_dpk_),target :: work(:) + type(psb_z_vect_type) :: res + type(psb_z_vect_type), pointer :: current + integer(psb_ipk_) :: sweeps_post, sweeps_pre + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: i, err_act + integer(psb_ipk_) :: debug_level, debug_unit + integer(psb_ipk_) :: nlev, ilev, sweeps + logical :: pre, post + character(len=20) :: name + + + + name = 'inner_inner_mult' + info = psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + nlev = size(p%precv) + if ((level < 1) .or. (level > nlev)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong call level to inner_mult') + goto 9999 + end if + ictxt = p%precv(level)%base_desc%get_context() + call psb_info(ictxt, me, np) + + if(debug_level > 1) then + write(debug_unit,*) me,' inner_mult at level ',level + end if + + if ((level < nlev).or.(nlev == 1)) then + sweeps_post = p%precv(level)%parms%sweeps_post + sweeps_pre = p%precv(level)%parms%sweeps_pre + else + sweeps_post = p%precv(level-1)%parms%sweeps_post + sweeps_pre = p%precv(level-1)%parms%sweeps_pre + endif + + pre = ((sweeps_pre>0).and.(trans=='N')).or.((sweeps_post>0).and.(trans/='N')) + post = ((sweeps_post>0).and.(trans=='N')).or.((sweeps_pre>0).and.(trans/='N')) + + + if (level < nlev) then + + ! + ! Apply the first smoother + ! + + if (pre) then + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(zone,& + & mlwrk(level)%x2l,zzero,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info,init='Y') + else + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(zone,& + & mlwrk(level)%x2l,zzero,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info,init='Y') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during PRE smoother_apply') + goto 9999 + end if + endif + + ! + ! Compute the residual and call recursively + ! + if (pre) then + call psb_geaxpby(zone,mlwrk(level)%x2l,& + & zzero,mlwrk(level)%ty,& + & p%precv(level)%base_desc,info) + + if (info == psb_success_) call psb_spmm(-zone,p%precv(level)%base_a,& + & mlwrk(level)%y2l,zone,mlwrk(level)%ty,& + & p%precv(level)%base_desc,info,work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + call p%precv(level+1)%map%map_U2V(zone,mlwrk(level)%ty,& + & zzero,mlwrk(level+1)%x2l,info,work=work) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + else + ! Shortcut: just transfer x2l. + call p%precv(level+1)%map%map_U2V(zone,mlwrk(level)%x2l,& + & zzero,mlwrk(level+1)%x2l,info,work=work) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during restriction') + goto 9999 + end if + endif + ! First guess is zero + mlwrk(level+1)%y2l(:) = zzero + + + call inner_ml_aply(level+1,p,mlwrk,trans,work,info) + + if (p%precv(level)%parms%ml_cycle == amg_wcycle_ml_) then + ! On second call will use output y2l as initial guess + if (info == psb_success_) call inner_ml_aply(level+1,p,mlwrk,trans,work,info) + endif + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in recursive call') + goto 9999 + end if + + + ! + ! Apply the prolongator + ! + call p%precv(level+1)%map%map_V2U(zone,mlwrk(level+1)%y2l,& + & zone,mlwrk(level)%y2l,info,work=work) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during prolongation') + goto 9999 + end if + + ! + ! Compute the residual + ! + if (post) then + call psb_geaxpby(zone,mlwrk(level)%x2l,& + & zzero,mlwrk(level)%tx,& + & p%precv(level)%base_desc,info) + call psb_spmm(-zone,p%precv(level)%base_a,mlwrk(level)%y2l,& + & zone,mlwrk(level)%tx,p%precv(level)%base_desc,info,& + & work=work,trans=trans) + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during residue') + goto 9999 + end if + ! + ! Apply the second smoother + ! + if (trans == 'N') then + sweeps = p%precv(level)%parms%sweeps_post + if (info == psb_success_) call p%precv(level)%sm2%apply(zone,& + & mlwrk(level)%tx,zone,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info,init='Z') + else + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(zone,& + & mlwrk(level)%tx,zone,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info,init='Z') + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error during POST smoother_apply') + goto 9999 + end if + + endif + + else if (level == nlev) then + + sweeps = p%precv(level)%parms%sweeps_pre + if (info == psb_success_) call p%precv(level)%sm%apply(zone,& + & mlwrk(level)%x2l,zzero,mlwrk(level)%y2l,& + & p%precv(level)%base_desc, trans,& + & sweeps,work,info) + + else + + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid LEVEL vs NLEV') + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_z_inner_mult + + +end subroutine amg_zmlprec_aply diff --git a/mlprec/impl/amg_zmlprec_bld.f90 b/mlprec/impl/amg_zmlprec_bld.f90 new file mode 100644 index 00000000..86b17f23 --- /dev/null +++ b/mlprec/impl/amg_zmlprec_bld.f90 @@ -0,0 +1,152 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_zmlprec_bld.f90 +! +! Subroutine: amg_zmlprec_bld +! Version: complex +! +! This routine builds the preconditioner according to the requirements made by +! the user trough the subroutines amg_precinit and amg_precset. +! +! A multilevel preconditioner is regarded as an array of 'one-level' data structures, +! each containing the part of the preconditioner associated to a certain level, +! (for more details see the description of amg_Tonelev_type in amg_prec_type.f90). +! The levels are numbered in increasing order starting from the finest one, i.e. +! level 1 is the finest level. No transfer operators are associated to level 1. +! +! This routine simply calls amg_z_hierarchy_bld and amg_z_smoothers_bld; they +! can also be called explicitly from the user. +! +! +! Arguments: +! a - type(psb_zspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_zprec_type), input/output. +! The preconditioner data structure containing the local part +! of the preconditioner to be built. +! info - integer, output. +! Error code. +! +! amold - class(psb_z_base_sparse_mat), input, optional +! Mold for the inner format of matrices contained in the +! preconditioner +! +! +! vmold - class(psb_z_base_vect_type), input, optional +! Mold for the inner format of vectors contained in the +! preconditioner +! +! +! +subroutine amg_zmlprec_bld(a,desc_a,p,info,amold,vmold,imold) + + use psb_base_mod + use amg_z_inner_mod, amg_protect_name => amg_zmlprec_bld + use amg_z_prec_mod + + Implicit None + + ! Arguments + type(psb_zspmat_type),intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + type(amg_zprec_type),intent(inout),target :: p + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local Variables + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, casize, nplevs, mxplevs + real(psb_dpk_) :: mnaggratio + integer(psb_ipk_) :: ipv(amg_ifpsz_), val + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_zmlprec_bld' + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' + + call p%hierarchy_build(a,desc_a,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Error from hierarchy build') + goto 9999 + end if + + iszv = p%get_nlevs() + + call p%smoothers_build(a,desc_a,info,amold,vmold,imold) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Error from smoothers build') + goto 9999 + end if + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Exiting with',iszv,' levels' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_zmlprec_bld diff --git a/mlprec/impl/amg_zprecaply.f90 b/mlprec/impl/amg_zprecaply.f90 new file mode 100644 index 00000000..ff6fdc4d --- /dev/null +++ b/mlprec/impl/amg_zprecaply.f90 @@ -0,0 +1,600 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_zprecaply.f90 +! +! Subroutine: amg_zprecaply +! Version: complex +! +! This routine applies the preconditioner built by amg_zprecbld, i.e. it computes +! +! Y = op(M^(-1)) * X, +! where +! - M is the preconditioner, +! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, +! - X and Y are vectors. +! This operation is performed at each iteration of a preconditioned Krylov solver. +! +! +! Arguments: +! prec - type(amg_zprec_type), input. +! The preconditioner data structure containing the local part +! of the preconditioner to be applied. +! x - complex(psb_dpk_), dimension(:), input. +! The local part of the vector X in Y=op(M^(-1))*X. +! y - complex(psb_dpk_), dimension(:), output. +! The local part of the vector Y in Y=op(M^(-1))*X. +! desc_data - type(psb_desc_type), input. +! The communication descriptor associated to the matrix to be +! preconditioned. +! info - integer, output. +! Error code. +! trans - character(len=1), optional. +! If trans='N','n' then op(M^(-1)) = M^(-1); +! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). +! work - complex(psb_dpk_), dimension (:), optional, target. +! Workspace. Its size must be at +! least 4*desc_data%get_local_cols(). +! +subroutine amg_zprecaply(prec,x,y,desc_data,info,trans,work) + + use psb_base_mod + use amg_z_inner_mod!, amg_protect_name => amg_zprecaply + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_zprec_type), intent(inout) :: prec + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_dpk_),intent(inout), optional, target :: work(:) + + ! Local variables + character :: trans_ + complex(psb_dpk_), pointer :: work_(:) + complex(psb_dpk_), allocatable :: w1(:), w2(:) + + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: err_act,iwsz, k, nswps + character(len=20) :: name + + name='amg_zprecaply' + info = psb_success_ + call psb_erractionsave(err_act) + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (present(trans)) then + trans_=psb_toupper(trans) + else + trans_='N' + end if + + if (present(work)) then + work_ => work + else + iwsz = max(1,4*desc_data%get_local_cols()) + allocate(work_(iwsz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name, & + & i_err=(/iwsz,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + + end if + + if (.not.(allocated(prec%precv))) then + !! Error 1: should call amg_zprecbld + info=3112 + call psb_errpush(info,name) + goto 9999 + end if + + if (size(prec%precv) >1) then + ! + ! Number of levels > 1: apply the multilevel preconditioner + ! + call amg_mlprec_aply(zone,prec,x,zzero,y,desc_data,trans_,work_,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_zmlprec_aply') + goto 9999 + end if + + else if (size(prec%precv) == 1) then + ! + ! Number of levels = 1: apply the base preconditioner + ! + if (allocated(prec%precv(1)%sm2a)) then + nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) + ! + ! This is a kludge for handling the symmetrized GS case. + ! Will need some rethinking. + ! + call psb_geasb(w1,desc_data,info,scratch=.true.) + call psb_geasb(w2,desc_data,info,scratch=.true.) + + call psb_geaxpby(zone,x,zzero,w1,desc_data,info) + select case(trans_) + case ('N') + do k=1, nswps + call prec%precv(1)%sm%apply(zone,w1,zzero,w2,desc_data,trans_,& + & ione, work_,info) + call prec%precv(1)%sm2a%apply(zone,w2,zzero,w1,desc_data,trans_,& + & ione, work_,info) + end do + + case('T','C') + do k=1, nswps + call prec%precv(1)%sm2a%apply(zone,w1,zzero,w2,desc_data,trans_,& + & ione, work_,info) + call prec%precv(1)%sm%apply(zone,w2,zzero,w1,desc_data,trans_,& + & ione, work_,info) + end do + case default + info = psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='Invalid trans') + goto 9999 + end select + call psb_geaxpby(zone,w1,zzero,y,desc_data,info) + call psb_gefree(w1,desc_data,info) + call psb_gefree(w2,desc_data,info) + + else + nswps = prec%precv(1)%parms%sweeps_pre + call prec%precv(1)%sm%apply(zone,x,zzero,y,desc_data,trans_,& + & nswps, work_,info) + end if + else + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='Invalid size of precv',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + endif + + ! If the original distribution has an overlap we should fix that. + call psb_halo(y,desc_data,info,data=psb_comm_mov_) + + + if (present(work)) then + else + deallocate(work_) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_zprecaply + + +! +! Subroutine: amg_zprecaply1 +! Version: complex +! +! Applies the preconditioner built by amg_zprecbld, i.e. computes +! +! X = op(M^(-1)) * X, +! where +! - M is the preconditioner, +! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, +! - X is a vectors. +! This operation is performed at each iteration of a preconditioned Krylov solver. +! +! This routine differs from amg_zprecaply because the preconditioned vector X +! overwrites the original one. +! +! +! Arguments: +! prec - type(amg_zprec_type), input. +! The preconditioner data structure containing the local part +! of the preconditioner to be applied. +! x - complex(psb_dpk_), dimension(:), input/output. +! The local part of vector X in X := op(M^(-1)) * X. +! desc_data - type(psb_desc_type), input. +! The communication descriptor associated to the matrix to be +! preconditioned. +! info - integer, output. +! Error code. +! trans - character(len=1), optional. +! If trans='N','n' then op(M^(-1)) = M^(-1); +! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). +! +subroutine amg_zprecaply1(prec,x,desc_data,info,trans) + + use psb_base_mod + use amg_z_inner_mod!, amg_protect_name => amg_zprecaply1 + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_zprec_type), intent(inout) :: prec + complex(psb_dpk_),intent(inout) :: x(:) + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + + ! Local variables + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: err_act + complex(psb_dpk_), pointer :: ww(:), w1(:) + character(len=20) :: name + + name='amg_zprecaply1' + info = psb_success_ + call psb_erractionsave(err_act) + + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + allocate(ww(size(x)),w1(size(x)),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name, & + & i_err=(/itwo*size(x),izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + + call prec%apply(x,ww,desc_data,info,trans=trans,work=w1) + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_precaply') + goto 9999 + end if + + x(:) = ww(:) + deallocate(ww,w1,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_zprecaply1 + + + +subroutine amg_zprecaply2_vect(prec,x,y,desc_data,info,trans,work) + + use psb_base_mod + use amg_z_inner_mod!, amg_protect_name => amg_zprecaply2_vect + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_zprec_type), intent(inout) :: prec + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_dpk_),intent(inout), optional, target :: work(:) + + ! Local variables + character :: trans_ + complex(psb_dpk_), pointer :: work_(:) + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: err_act,iwsz, k, nswps + logical :: do_alloc_wrk + character(len=20) :: name + + name='amg_zprecaply' + info = psb_success_ + call psb_erractionsave(err_act) + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (present(trans)) then + trans_=psb_toupper(trans) + else + trans_='N' + end if + + if (present(work)) then + work_ => work + else + iwsz = max(1,4*desc_data%get_local_cols()) + allocate(work_(iwsz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name, & + & i_err=(/iwsz,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + + end if + + if (.not.(allocated(prec%precv))) then + !! Error 1: should call amg_zprecbld + info=3112 + call psb_errpush(info,name) + goto 9999 + end if + + do_alloc_wrk = .not.allocated(prec%precv(1)%wrk) + if (do_alloc_wrk) call prec%allocate_wrk(info,vmold=x%v) + + if (size(prec%precv) >1) then + ! + ! Number of levels > 1: apply the multilevel preconditioner + ! + ! FIXME: generic name causes an ICE with Intel + call amg_zmlprec_aply_vect(zone,prec,x,zzero,y,desc_data,trans_,work_,info) + + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_zmlprec_aply') + goto 9999 + end if + + else if (size(prec%precv) == 1) then + ! + ! Number of levels = 1: apply the base preconditioner + ! + nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) + + associate(w1 => prec%precv(1)%wrk%vx2l, w2 => prec%precv(1)%wrk%vy2l,& + & wv => prec%precv(1)%wrk%wv) + if (allocated(prec%precv(1)%sm2a)) then + ! + ! This is a kludge for handling the symmetrized GS case. + ! Will need some rethinking. + ! + call psb_geaxpby(zone,x,zzero,w1,desc_data,info) + select case(trans_) + case ('N') + do k=1, nswps + if (info == 0) call prec%precv(1)%sm%apply(zone,w1,zzero,w2,desc_data,trans_,& + & ione, work_,wv,info) + if (info == 0) call prec%precv(1)%sm2a%apply(zone,w2,zzero,w1,desc_data,trans_,& + & ione, work_,wv,info) + end do + + case('T','C') + do k=1, nswps + if (info == 0) call prec%precv(1)%sm2a%apply(zone,w1,zzero,w2,desc_data,trans_,& + & ione, work_,wv,info) + if (info == 0) call prec%precv(1)%sm%apply(zone,w2,zzero,w1,desc_data,trans_,& + & ione, work_,wv,info) + end do + case default + info = psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='Invalid trans') + goto 9999 + end select + if (info == 0) call psb_geaxpby(zone,w1,zzero,y,desc_data,info) + else + if (info == 0) call prec%precv(1)%sm%apply(zone,x,zzero,y,desc_data,trans_,& + & nswps,work_,wv,info) + end if + end associate + if (psb_errstatus_fatal()) info = psb_err_internal_error_ + if (info /= 0) then + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='Smoother application',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + end if + + else + + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='Invalid size of precv',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + endif + + ! If the original distribution has an overlap we should fix that. + call psb_halo(y,desc_data,info,data=psb_comm_mov_) + + if (do_alloc_wrk) call prec%free_wrk(info) + + if (present(work)) then + else + deallocate(work_) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_zprecaply2_vect + + +subroutine amg_zprecaply1_vect(prec,x,desc_data,info,trans,work) + + use psb_base_mod + use amg_z_inner_mod!, amg_protect_name => amg_zprecaply1_vect + + implicit none + + ! Arguments + type(psb_desc_type),intent(in) :: desc_data + type(amg_zprec_type), intent(inout) :: prec + type(psb_z_vect_type),intent(inout) :: x + integer(psb_ipk_), intent(out) :: info + character(len=1), optional :: trans + complex(psb_dpk_),intent(inout), optional, target :: work(:) + + ! Local variables + character :: trans_ + complex(psb_dpk_), pointer :: work_(:) + integer(psb_ipk_) :: ictxt,np,me + integer(psb_ipk_) :: err_act,iwsz, k, nswps + logical :: do_alloc_wrk + character(len=20) :: name + + name='amg_zprecaply' + info = psb_success_ + call psb_erractionsave(err_act) + + ictxt = desc_data%get_context() + call psb_info(ictxt, me, np) + + if (present(trans)) then + trans_=psb_toupper(trans) + else + trans_='N' + end if + + if (present(work)) then + work_ => work + else + iwsz = max(1,4*desc_data%get_local_cols()) + allocate(work_(iwsz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name, & + & i_err=(/iwsz,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + + end if + + if (.not.(allocated(prec%precv))) then + !! Error 1: should call amg_zprecbld + info=3112 + call psb_errpush(info,name) + goto 9999 + end if + + do_alloc_wrk = .not.allocated(prec%precv(1)%wrk) + if (do_alloc_wrk) call prec%allocate_wrk(info,vmold=x%v) + + associate(ww => prec%precv(1)%wrk%vtx, wv => prec%precv(1)%wrk%wv) + + if (size(prec%precv) >1) then + ! + ! Number of levels > 1: apply the multilevel preconditioner + ! + ! FIXME: generic name causes an ICE with Intel + call amg_zmlprec_aply_vect(zone,prec,x,zzero,ww,desc_data,trans_,work_,info) + if (info == 0) call psb_geaxpby(zone,ww,zzero,x,desc_data,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_zmlprec_aply') + goto 9999 + end if + + else if (size(prec%precv) == 1) then + ! + ! Number of levels = 1: apply the base preconditioner + ! + nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) + if (allocated(prec%precv(1)%sm2a)) then + ! + ! This is a kludge for handling the symmetrized GS case. + ! Will need some rethinking. + ! + select case(trans_) + case ('N') + do k=1, nswps + if (info == 0) call prec%precv(1)%sm%apply(zone,x,zzero,ww,desc_data,trans_,& + & ione, work_,wv,info) + if (info == 0) call prec%precv(1)%sm2a%apply(zone,ww,zzero,x,desc_data,trans_,& + & ione, work_,wv,info) + end do + case('T','C') + do k=1, nswps + if (info == 0) call prec%precv(1)%sm2a%apply(zone,x,zzero,ww,desc_data,trans_,& + & ione, work_,wv,info) + if (info == 0) call prec%precv(1)%sm%apply(zone,ww,zzero,x,desc_data,trans_,& + & ione, work_,wv,info) + end do + case default + info = psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='Invalid trans') + goto 9999 + end select + + else + if (info == 0) call prec%precv(1)%sm%apply(zone,x,zzero,ww,desc_data,trans_,& + & nswps, work_,wv,info) + if (info == 0) call psb_geaxpby(zone,ww,zzero,x,desc_data,info) + end if + + if (psb_errstatus_fatal()) info = psb_err_internal_error_ + if (info /=0) then + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='Smoother application',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + end if + + else + + info = psb_err_from_subroutine_ai_ + call psb_errpush(info,name,a_err='Invalid size of precv',& + & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) + goto 9999 + endif + end associate + + ! If the original distribution has an overlap we should fix that. + call psb_halo(x,desc_data,info,data=psb_comm_mov_) + + if (do_alloc_wrk) call prec%free_wrk(info) + + if (present(work)) then + else + deallocate(work_) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_zprecaply1_vect diff --git a/mlprec/impl/amg_zprecbld.f90 b/mlprec/impl/amg_zprecbld.f90 new file mode 100644 index 00000000..31fd4c99 --- /dev/null +++ b/mlprec/impl/amg_zprecbld.f90 @@ -0,0 +1,161 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_zprecbld.f90 +! +! Subroutine: amg_zprecbld +! Version: complex +! Contains: subroutine init_baseprec_av +! +! This routine builds the preconditioner according to the requirements made by +! the user through the subroutines amg_precinit and amg_precset. +! +! +! Arguments: +! a - type(psb_zspmat_type). +! The sparse matrix structure containing the local part of the +! matrix to be preconditioned. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! p - type(amg_zprec_type), input/output. +! The preconditioner data structure containing the local part +! of the preconditioner to be built. +! info - integer, output. +! Error code. +! +subroutine amg_zprecbld(a,desc_a,prec,info,amold,vmold,imold) + + use psb_base_mod + use amg_z_prec_mod, amg_protect_name => amg_zprecbld + + Implicit None + + ! Arguments + type(psb_zspmat_type),intent(in), target :: a + type(psb_desc_type), intent(inout), target :: desc_a + class(amg_zprec_type),intent(inout), target :: prec + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local Variables + type(amg_zprec_type) :: t_prec + integer(psb_ipk_) :: ictxt, me,np + integer(psb_ipk_) :: err,i,k,err_act, iszv, newsz + integer(psb_ipk_) :: ipv(amg_ifpsz_), val + integer(psb_ipk_) :: int_err(5) + type(amg_dml_parms) :: prm + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + name = 'amg_zprecbld' + info = psb_success_ + int_err(1) = 0 + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + prec%ictxt = ictxt + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Entering ' + ! + + if (.not.allocated(prec%precv)) then + !! Error: should have called amg_zprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + ! + ! Check to ensure all procs have the same + ! + newsz = -1 + iszv = size(prec%precv) + call psb_bcast(ictxt,iszv) + if (iszv /= size(prec%precv)) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Inconsistent size of precv') + goto 9999 + end if + + if (iszv <= 0) then + ! Is this really possible? probably not. + info=psb_err_from_subroutine_ + ch_err='size bpv' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + ! + ! Build the preconditioner + ! + call prec%hierarchy_build(a,desc_a,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Error from hierarchy build') + goto 9999 + end if + + call prec%smoothers_build(a,desc_a,info,amold,vmold,imold) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,a_err='Error from smoothers build') + goto 9999 + end if + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_zprecbld diff --git a/mlprec/impl/amg_zprecinit.F90 b/mlprec/impl/amg_zprecinit.F90 new file mode 100644 index 00000000..bda21f22 --- /dev/null +++ b/mlprec/impl/amg_zprecinit.F90 @@ -0,0 +1,242 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_zprecinit.f90 +! +! Subroutine: amg_zprecinit +! Version: complex +! +! This routine allocates and initializes the preconditioner data structure, +! according to the preconditioner type chosen by the user. +! +! A default preconditioner is set for each preconditioner type +! specified by the user: +! +! 'NOPREC' - no preconditioner +! +! 'DIAG', 'JACOBI' - diagonal/Jacobi +! +! 'L1-DIAG', 'L1-JACOBI' - diagonal/Jacobi with L1 norm correction +! +! 'GS', 'FBGS' - Hybrid Gauss-Seidel, also symmetrized +! +! 'BJAC' - block Jacobi preconditioner, with ILU(0) +! on the local blocks +! +! 'L1-BJAC' - block Jacobi preconditioner, with ILU(0) +! on the local blocks and L1 correction for off-diag blocks +! +! 'AS' - Additive Schwarz (AS), with +! overlap 1 and ILU(0) on the local submatrices +! +! 'ML' - Multilevel hybrid preconditioner (additive on the +! same level and multiplicative through the levels), +! with 2 levels, pre and post-smoothing, RAS with +! overlap 1 and ILU(0) on the local blocks is +! applied as post-smoother at each level, but the +! coarsest one; four sweeps of the block-Jacobi solver, +! with LU from UMFPACK on the blocks, are applied at +! the coarsest level, on the distributed coarse matrix. +! The smoothed aggregation algorithm with threshold 0 +! is used to build the coarse matrix. +! +! For the multilevel preconditioners, the levels are numbered in increasing +! order starting from the finest one, i.e. level 1 is the finest level. +! +! +! Arguments: +! p - type(amg_zprec_type), input/output. +! The preconditioner data structure. +! ptype - character(len=*), input. +! The type of preconditioner. Its values are 'NOPREC', +! 'DIAG', 'BJAC', 'AS', 'ML' (and the corresponding +! lowercase strings). +! info - integer, output. +! Error code. +! +subroutine amg_zprecinit(ictxt,prec,ptype,info) + + use psb_base_mod + use amg_z_prec_mod, amg_protect_name => amg_zprecinit + use amg_z_jac_smoother + use amg_z_as_smoother + use amg_z_id_solver + use amg_z_diag_solver + use amg_z_ilu_solver + use amg_z_gs_solver +#if defined(HAVE_UMF_) + use amg_z_umf_solver +#endif +#if defined(HAVE_SLU_) + use amg_z_slu_solver +#endif + + + implicit none + + ! Arguments + integer(psb_ipk_), intent(in) :: ictxt + class(amg_zprec_type), intent(inout) :: prec + character(len=*), intent(in) :: ptype + integer(psb_ipk_), intent(out) :: info + + ! Local variables + integer(psb_ipk_) :: nlev_, ilev_ + real(psb_dpk_) :: thr + character(len=*), parameter :: name='amg_precinit' + info = psb_success_ + + if (allocated(prec%precv)) then + call prec%free(info) + if (info /= psb_success_) then + ! Do we want to do something? + endif + endif + prec%ictxt = ictxt + prec%ag_data%min_coarse_size = -1 + + select case(psb_toupper(trim(ptype))) + case ('NOPREC','NONE') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_z_base_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_z_id_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('JAC','DIAG','JACOBI') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_z_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_z_diag_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('L1-DIAG','L1-JACOBI','L1_DIAG','L1_JACOBI') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_z_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_z_l1_diag_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('GS','FWGS') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_z_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_z_gs_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('BWGS') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_z_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_z_bwgs_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('FBGS') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + call prec%set('SMOOTHER_TYPE','FBGS',info) + call prec%precv(ilev_)%default() + + case ('BJAC') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_z_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_z_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('L1-BJAC','L1_BJAC') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_z_l1_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_z_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + case ('AS') + nlev_ = 1 + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + allocate(amg_z_as_smoother_type :: prec%precv(ilev_)%sm, stat=info) + if (info /= psb_success_) return + allocate(amg_z_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) + call prec%precv(ilev_)%default() + + + case ('ML') + + nlev_ = prec%ag_data%max_levs + ilev_ = 1 + allocate(prec%precv(nlev_),stat=info) + + do ilev_ = 1, nlev_ + call prec%precv(ilev_)%default() + end do + call prec%set('ML_CYCLE','VCYCLE',info) + call prec%set('SMOOTHER_TYPE','FBGS',info) +#if defined(HAVE_UMF_) + call prec%set('COARSE_SOLVE','UMF',info) +#elif defined(HAVE_MUMPS_) + call prec%set('COARSE_SOLVE','MUMPS',info) +#elif defined(HAVE_SLU_) + call prec%set('COARSE_SOLVE','SLU',info) +#else + call prec%set('COARSE_SOLVE','ILU',info) +#endif + + case default + write(psb_err_unit,*) name,& + &': Warning: Unknown preconditioner type request "',ptype,'"' + info = psb_err_pivot_too_small_ + + end select + + +end subroutine amg_zprecinit diff --git a/mlprec/impl/amg_zprecset.F90 b/mlprec/impl/amg_zprecset.F90 new file mode 100644 index 00000000..887d1b6a --- /dev/null +++ b/mlprec/impl/amg_zprecset.F90 @@ -0,0 +1,229 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_zprecset.f90 +! +subroutine amg_zprecsetsm(p,val,info,ilev,ilmax,pos) + + use psb_base_mod + use amg_z_prec_mod, amg_protect_name => amg_zprecsetsm + + implicit none + + ! Arguments + class(amg_zprec_type), intent(inout) :: p + class(amg_z_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ + character(len=*), parameter :: name='amg_precsetsm' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + ilmin_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmin_ = 1 + ilmax_ = nlev_ + end if + + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + do ilev_ = ilmin_, ilmax_ + call p%precv(ilev_)%set(val,info,pos=pos) + if (info /= 0) return + end do + +end subroutine amg_zprecsetsm + +subroutine amg_zprecsetsv(p,val,info,ilev,ilmax,pos) + + use psb_base_mod + use amg_z_prec_mod, amg_protect_name => amg_zprecsetsv + + implicit none + + ! Arguments + class(amg_zprec_type), intent(inout) :: p + class(amg_z_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev,ilmax + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ + character(len=*), parameter :: name='amg_precsetsv' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + ilmin_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmin_ = 1 + ilmax_ = nlev_ + end if + + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + do ilev_ = ilmin_, ilmax_ + call p%precv(ilev_)%set(val,info,pos=pos) + if (info /= 0) return + end do + +end subroutine amg_zprecsetsv + +subroutine amg_zprecsetag(p,val,info,ilev,ilmax,pos) + + use psb_base_mod + use amg_z_prec_mod, amg_protect_name => amg_zprecsetag + + implicit none + + ! Arguments + class(amg_zprec_type), intent(inout) :: p + class(amg_z_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: ilev, ilmax + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ + character(len=*), parameter :: name='amg_precsetag' + + info = psb_success_ + + if (.not.allocated(p%precv)) then + info = 3111 + write(psb_err_unit,*) name,& + & ': Error: uninitialized preconditioner,',& + &' should call amg_PRECINIT' + return + endif + nlev_ = size(p%precv) + + if (present(ilev)) then + ilev_ = ilev + ilmin_ = ilev + if (present(ilmax)) then + ilmax_ = ilmax + else + ilmax_ = ilev_ + end if + else + ilev_ = 1 + ilmin_ = 1 + ilmax_ = nlev_ + end if + + + if ((ilev_<1).or.(ilev_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ + return + endif + if ((ilmax_<1).or.(ilmax_ > nlev_)) then + info = -1 + write(psb_err_unit,*) name,& + &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ + return + endif + + do ilev_ = ilmin_, ilmax_ + call p%precv(ilev_)%set(val,info,pos=pos) + if (info /= 0) return + end do + +end subroutine amg_zprecsetag + diff --git a/mlprec/impl/amg_zslu_interface.c b/mlprec/impl/amg_zslu_interface.c new file mode 100644 index 00000000..2e786103 --- /dev/null +++ b/mlprec/impl/amg_zslu_interface.c @@ -0,0 +1,327 @@ +/* + * + * MLD2P4 version 2.1 + * MultiLevel Domain Decomposition Parallel Preconditioners Package + * based on PSBLAS (Parallel Sparse BLAS version 3.5) + * + * (C) Copyright 2008-2018 + * + * Salvatore Filippone + * Pasqua D'Ambra + * Daniela di Serafino + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions, and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the MLD2P4 group or the names of its contributors may + * not be used to endorse or promote products derived from this + * software without specific written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * + * File: amg_zslu_interface.c + * + * Functions: amg_zslu_fact, amg_zslu_solve, amg_zslu_free. + * + * This file is an interface to the SuperLU routines for sparse factorization and + * solve. It was obtained by modifying the c_fortran_zgssv.c file from the SuperLU + * source distribution; original copyright terms are reproduced below. + * + */ + + +/* ===================== + +Copyright (c) 2003, The Regents of the University of California, through +Lawrence Berkeley National Laboratory (subject to receipt of any required +approvals from U.S. Dept. of Energy) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +(1) Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +(2) Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. +(3) Neither the name of Lawrence Berkeley National Laboratory, U.S. Dept. of +Energy nor the names of its contributors may be used to endorse or promote +products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +/* + * -- SuperLU routine (version 3.0) -- + * Univ. of California Berkeley, Xerox Palo Alto Research Center, + * and Lawrence Berkeley National Lab. + * October 15, 2003 + * + */ + +#ifdef Have_SLU_ +#include "slu_zdefs.h" +#define HANDLE_SIZE 8 + +typedef struct { + SuperMatrix *L; + SuperMatrix *U; + int *perm_c; + int *perm_r; +} factors_t; + + +#else + +#include + +#endif + + + +int amg_zslu_fact(int n, int nnz, +#ifdef HAVE_SLU_ + doublecomplex *values, +#else + void *values, +#endif + int *colptr, int *rowind, void **f_factors) + +{ +/* + * This routine can be called from Fortran. + * performs LU decomposition. + * + * f_factors (input/output) + * On output contains the pointer pointing to + * the structure of the factored matrices. + * + */ + +#ifdef Have_SLU_ + SuperMatrix A, AC; + SuperMatrix *L, *U; + int *perm_r; /* row permutations from partial pivoting */ + int *perm_c; /* column permutation vector */ + int *etree; /* column elimination tree */ + SCformat *Lstore; + NCformat *Ustore; + int i, panel_size, permc_spec, relax; + trans_t trans; + mem_usage_t mem_usage; + superlu_options_t options; + SuperLUStat_t stat; + factors_t *LUfactors; + GlobalLU_t Glu; /* Not needed on return. */ + int info; + + trans = NOTRANS; + + + /* Set the default input options. */ + set_default_options(&options); + + /* Initialize the statistics variables. */ + StatInit(&stat); + + zCreate_CompCol_Matrix(&A, n, n, nnz, values, rowind, colptr, + SLU_NC, SLU_Z, SLU_GE); + L = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) ); + U = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) ); + if ( !(perm_r = intMalloc(n)) ) ABORT("Malloc fails for perm_r[]."); + if ( !(perm_c = intMalloc(n)) ) ABORT("Malloc fails for perm_c[]."); + if ( !(etree = intMalloc(n)) ) ABORT("Malloc fails for etree[]."); + + /* + * Get column permutation vector perm_c[], according to permc_spec: + * permc_spec = 0: natural ordering + * permc_spec = 1: minimum degree on structure of A'*A + * permc_spec = 2: minimum degree on structure of A'+A + * permc_spec = 3: approximate minimum degree for unsymmetric matrices + */ + options.ColPerm=2; + permc_spec = options.ColPerm; + get_perm_c(permc_spec, &A, perm_c); + + sp_preorder(&options, &A, perm_c, etree, &AC); + + panel_size = sp_ienv(1); + relax = sp_ienv(2); +#if defined(SLU_VERSION_5) + zgstrf(&options, &AC, relax, panel_size, etree, + NULL, 0, perm_c, perm_r, L, U, &Glu, &stat, &info); +#elif defined(SLU_VERSION_4) + zgstrf(&options, &AC, relax, panel_size, etree, + NULL, 0, perm_c, perm_r, L, U, &stat, &info); +#else + choke_on_me; +#endif + + if ( info == 0 ) { + Lstore = (SCformat *) L->Store; + Ustore = (NCformat *) U->Store; + zQuerySpace(L, U, &mem_usage); +#if 0 + printf("No of nonzeros in factor L = %d\n", Lstore->nnz); + printf("No of nonzeros in factor U = %d\n", Ustore->nnz); + printf("No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz); + printf("L\\U MB %.3f\ttotal MB needed %.3f\n", + mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); +#endif + } else { + printf("zgstrf() error returns INFO= %d\n", info); + if ( info <= n ) { /* factorization completes */ + zQuerySpace(L, U, &mem_usage); + printf("L\\U MB %.3f\ttotal MB needed %.3f\n", + mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); + } + } + + /* Save the LU factors in the factors handle */ + LUfactors = (factors_t*) SUPERLU_MALLOC(sizeof(factors_t)); + LUfactors->L = L; + LUfactors->U = U; + LUfactors->perm_c = perm_c; + LUfactors->perm_r = perm_r; + *f_factors = (void *) LUfactors; + + /* Free un-wanted storage */ + SUPERLU_FREE(etree); + Destroy_SuperMatrix_Store(&A); + Destroy_CompCol_Permuted(&AC); + StatFree(&stat); + return(info); +#else + fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); + return(-1); +#endif +} + + +int amg_zslu_solve(int itrans, int n, int nrhs, +#ifdef HAVE_SLU_ + doublecomplex *b, +#else + void *b, +#endif + int ldb,void *f_factors) +{ + /* + * This routine can be called from Fortran. + * performs triangular solve + * + */ + int info; +#ifdef Have_SLU_ + SuperMatrix B; + SuperMatrix *L, *U; + int *perm_r; /* row permutations from partial pivoting */ + int *perm_c; /* column permutation vector */ + int *etree; /* column elimination tree */ + SCformat *Lstore; + NCformat *Ustore; + int i, panel_size, permc_spec, relax; + trans_t trans; + double drop_tol = 0.0; + mem_usage_t mem_usage; + superlu_options_t options; + SuperLUStat_t stat; + factors_t *LUfactors; + + if (itrans == 0) { + trans = NOTRANS; + } else if (itrans ==1) { + trans = TRANS; + } else if (itrans ==2) { + trans = CONJ; + } else { + trans = NOTRANS; + } + /* Initialize the statistics variables. */ + StatInit(&stat); + + /* Extract the LU factors in the factors handle */ + LUfactors = (factors_t*) f_factors; + L = LUfactors->L; + U = LUfactors->U; + perm_c = LUfactors->perm_c; + perm_r = LUfactors->perm_r; + + zCreate_Dense_Matrix(&B, n, nrhs, b, ldb, SLU_DN, SLU_Z, SLU_GE); + /* Solve the system A*X=B, overwriting B with X. */ + zgstrs (trans, L, U, perm_c, perm_r, &B, &stat, &info); + if (info != 0) { + if (B.Stype != SLU_DN) fprintf(stderr,"zgstrs error kind 1: SLU_DN\n"); + if (B.Dtype != SLU_Z) fprintf(stderr,"zgstrs error kind 2: SLU_Z\n"); + if (B.Mtype != SLU_GE) fprintf(stderr,"zgstrs error kind 3: SLU_GE\n"); + } + + Destroy_SuperMatrix_Store(&B); + StatFree(&stat); +#else + fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); + info=-1; +#endif + return(info); +} + + +int amg_zslu_free(void *f_factors) +{ +/* + * This routine can be called from Fortran. + * + * free all storage in the end + * + */ +#ifdef Have_SLU_ + factors_t *LUfactors; + + /* Free the LU factors in the factors handle */ + LUfactors = (factors_t*) f_factors; + if (LUfactors != NULL) { + SUPERLU_FREE (LUfactors->perm_r); + SUPERLU_FREE (LUfactors->perm_c); + Destroy_SuperNode_Matrix(LUfactors->L); + Destroy_CompCol_Matrix(LUfactors->U); + SUPERLU_FREE (LUfactors->L); + SUPERLU_FREE (LUfactors->U); + SUPERLU_FREE (LUfactors); + } + return(0); +#else + fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); + return(-1); +#endif +} + + diff --git a/mlprec/impl/amg_zslud_interface.c b/mlprec/impl/amg_zslud_interface.c new file mode 100644 index 00000000..ca2a4faf --- /dev/null +++ b/mlprec/impl/amg_zslud_interface.c @@ -0,0 +1,403 @@ +/* + * + * MLD2P4 version 2.1 + * MultiLevel Domain Decomposition Parallel Preconditioners Package + * based on PSBLAS (Parallel Sparse BLAS version 3.5) + * + * (C) Copyright 2008-2018 + * + * Salvatore Filippone + * Ambra Abdullahi Hassan + * Alfredo Buttari CNRS-IRIT, Toulouse, FR + * Pasqua D'Ambra + * Daniela di Serafino + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions, and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the MLD2P4 group or the names of its contributors may + * not be used to endorse or promote products derived from this + * software without specific written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * + * File: amg_zslud_interface.c + * + * Functions: amg_zsludist_fact, amg_zsludist_solve, amg_zsludist_free. + * + * This file is an interface to the SuperLU_dist routines for sparse factorization and + * solve. It was obtained by modifying the c_fortran_zgssv.c file from the SuperLU_dist + * source distribution; original copyright terms are reproduced below. + * + */ + +/* ===================== + +Copyright (c) 2003, The Regents of the University of California, through +Lawrence Berkeley National Laboratory (subject to receipt of any required +approvals from U.S. Dept. of Energy) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +(1) Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +(2) Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. +(3) Neither the name of Lawrence Berkeley National Laboratory, U.S. Dept. of +Energy nor the names of its contributors may be used to endorse or promote +products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +/* + * -- Distributed SuperLU routine (version 2.0) -- + * Lawrence Berkeley National Lab, Univ. of California Berkeley. + * March 15, 2003 + * + */ + +#ifdef Have_SLUDist_ +#include +#include "superlu_zdefs.h" + +#define HANDLE_SIZE 8 + +#if defined(SLUD_VERSION_63) +typedef struct { + SuperMatrix *A; + zLUstruct_t *LUstruct; + gridinfo_t *grid; + zScalePermstruct_t *ScalePermstruct; +} factors_t; +#else +typedef struct { + SuperMatrix *A; + LUstruct_t *LUstruct; + gridinfo_t *grid; + ScalePermstruct_t *ScalePermstruct; +} factors_t; +#endif + +#else + +#include + +#endif + + +int amg_zsludist_fact(int n, int nl, int nnzl, int ffstr, +#ifdef Have_SLUDist_ + doublecomplex *values, int *rowptr, int *colind, + void **f_factors, +#else + void *values, int *rowptr, int *colind, + void **f_factors, +#endif + int nprow, int npcol) + +{ +/* + * This routine can be called from Fortran. + * performs LU decomposition. + * + * f_factors (input/output) void** + * On output contains the pointer pointing to + * the structure of the factored matrices. + * + */ + +#ifdef Have_SLUDist_ + SuperMatrix *A; + NRformat_loc *Astore; + +#if defined(SLUD_VERSION_63) + zScalePermstruct_t *ScalePermstruct; + zLUstruct_t *LUstruct; + zSOLVEstruct_t SOLVEstruct; +#else + ScalePermstruct_t *ScalePermstruct; + LUstruct_t *LUstruct; + SOLVEstruct_t SOLVEstruct; +#endif + gridinfo_t *grid; + int i, panel_size, permc_spec, relax, info; + trans_t trans; + double drop_tol = 0.0,berr[1]; +#if defined(SLUD_VERSION_63) || defined(SLUD_VERSION_6)||defined(SLUD_VERSION_5) + superlu_dist_options_t options; +#elif defined(SLUD_VERSION_4)||defined(SLUD_VERSION_3) + superlu_options_t options; +#else + choke_on_me; +#endif + SuperLUStat_t stat; + factors_t *LUfactors; + int fst_row; + int *icol,*irpt; + doublecomplex *ival,b[1]; + + trans = NOTRANS; + grid = (gridinfo_t *) SUPERLU_MALLOC(sizeof(gridinfo_t)); + superlu_gridinit(MPI_COMM_WORLD, nprow, npcol, grid); + /* Initialize the statistics variables. */ + PStatInit(&stat); + fst_row = (ffstr); + + A = (SuperMatrix *) malloc(sizeof(SuperMatrix)); + zCreate_CompRowLoc_Matrix_dist(A, n, n, nnzl, nl, fst_row, + values, colind, rowptr, + SLU_NR_loc, SLU_Z, SLU_GE); + + /* Initialize ScalePermstruct and LUstruct. */ +#if defined(SLUD_VERSION_63) + ScalePermstruct = (zScalePermstruct_t *) SUPERLU_MALLOC(sizeof(zScalePermstruct_t)); + LUstruct = (zLUstruct_t *) SUPERLU_MALLOC(sizeof(zLUstruct_t)); + zScalePermstructInit(n,n, ScalePermstruct); +#else + ScalePermstruct = (ScalePermstruct_t *) SUPERLU_MALLOC(sizeof(ScalePermstruct_t)); + LUstruct = (LUstruct_t *) SUPERLU_MALLOC(sizeof(LUstruct_t)); + ScalePermstructInit(n,n, ScalePermstruct); +#endif +#if defined(SLUD_VERSION_63) + zLUstructInit(n, LUstruct); +#elif defined(SLUD_VERSION_4) || defined(SLUD_VERSION_5) || defined(SLUD_VERSION_6) + LUstructInit(n, LUstruct); +#elif defined(SLUD_VERSION_3) + LUstructInit(n,n, LUstruct); +#else + choke_on_me; +#endif + + /* Set the default input options. */ + set_default_options_dist(&options); + options.IterRefine=NO; + options.PrintStat=NO; + + pzgssvx(&options, A, ScalePermstruct, b, nl, 0, + grid, LUstruct, &SOLVEstruct, berr, &stat, &info); + + if ( info == 0 ) { + ; + } else { + printf("pzgssvx() error returns INFO= %d\n", info); + if ( info <= n ) { /* factorization completes */ + ; + } + } + if (options.SolveInitialized) { + zSolveFinalize(&options,&SOLVEstruct); + } + + + /* Save the LU factors in the factors handle */ + LUfactors = (factors_t *) SUPERLU_MALLOC(sizeof(factors_t)); + LUfactors->LUstruct = LUstruct; + LUfactors->grid = grid; + LUfactors->A = A; + LUfactors->ScalePermstruct = ScalePermstruct; +/* fprintf(stderr,"slud factor: LUFactors %p \n",LUfactors); */ +/* fprintf(stderr,"slud factor: A %p %p\n",A,LUfactors->A); */ +/* fprintf(stderr,"slud factor: grid %p %p\n",grid,LUfactors->grid); */ +/* fprintf(stderr,"slud factor: LUstruct %p %p\n",LUstruct,LUfactors->LUstruct); */ + *f_factors = (void *) LUfactors; + PStatFree(&stat); + return(info); +#else + fprintf(stderr," SLUDist Not Configured, fix make.inc and recompile\n"); + return(-1); +#endif +} + + +int amg_zsludist_solve(int itrans, int n, int nrhs, +#ifdef Have_SLUDist_ + doublecomplex *b, +#else + void *b, +#endif + int ldb, void *f_factors) + +{ +/* + * This routine can be called from Fortran. + * performs triangular solve + * + */ +#ifdef Have_SLUDist_ + SuperMatrix *A; +#if defined(SLUD_VERSION_63) + zScalePermstruct_t *ScalePermstruct; + zLUstruct_t *LUstruct; + zSOLVEstruct_t SOLVEstruct; +#else + ScalePermstruct_t *ScalePermstruct; + LUstruct_t *LUstruct; + SOLVEstruct_t SOLVEstruct; +#endif + gridinfo_t *grid; + int i, panel_size, permc_spec, relax, info; + trans_t trans; + double drop_tol = 0.0; + double *berr; +#if defined(SLUD_VERSION_63) || defined(SLUD_VERSION_6) ||defined(SLUD_VERSION_5) + superlu_dist_options_t options; +#elif defined(SLUD_VERSION_4)|| defined(SLUD_VERSION_3) + superlu_options_t options; +#else + choke_on_me; +#endif + SuperLUStat_t stat; + factors_t *LUfactors; + + LUfactors = (factors_t *) f_factors ; + A = LUfactors->A ; + LUstruct = LUfactors->LUstruct ; + grid = LUfactors->grid ; + + ScalePermstruct = LUfactors->ScalePermstruct; +/* fprintf(stderr,"slud solve: LUFactors %p \n",LUfactors); */ +/* fprintf(stderr,"slud solve: A %p %p\n",A,LUfactors->A); */ +/* fprintf(stderr,"slud solve: grid %p %p\n",grid,LUfactors->grid); */ +/* fprintf(stderr,"slud solve: LUstruct %p %p\n",LUstruct,LUfactors->LUstruct); */ + + + if (itrans == 0) { + trans = NOTRANS; + } else if (itrans ==1) { + trans = TRANS; + } else if (itrans ==2) { + trans = CONJ; + } else { + trans = NOTRANS; + } + +/* fprintf(stderr,"Entry to sludist_solve\n"); */ + berr = (double *) malloc((nrhs) *sizeof(double)); + + /* Initialize the statistics variables. */ + PStatInit(&stat); + + /* Set the default input options. */ + set_default_options_dist(&options); + options.IterRefine = NO; + options.Fact = FACTORED; + options.PrintStat = NO; + + pzgssvx(&options, A, ScalePermstruct, b, ldb, nrhs, + grid, LUstruct, &SOLVEstruct, berr, &stat, &info); + +/* fprintf(stderr,"Double check: after solve %d %lf\n",*info,berr[0]); */ + if (options.SolveInitialized) { + zSolveFinalize(&options,&SOLVEstruct); + } + PStatFree(&stat); + free(berr); + return(info); +#else + fprintf(stderr," SLUDist Not Configured, fix make.inc and recompile\n"); + return(-1); +#endif + +} + + +int amg_zsludist_free(void *f_factors) +{ +/* + * This routine can be called from Fortran. + * + * free all storage in the end + * + */ +#ifdef Have_SLUDist_ + SuperMatrix *A; +#if defined(SLUD_VERSION_63) + zScalePermstruct_t *ScalePermstruct; + zLUstruct_t *LUstruct; + zSOLVEstruct_t SOLVEstruct; +#else + ScalePermstruct_t *ScalePermstruct; + LUstruct_t *LUstruct; + SOLVEstruct_t SOLVEstruct; +#endif + gridinfo_t *grid; + int i, panel_size, permc_spec, relax; + trans_t trans; + double drop_tol = 0.0; + double *berr; +#if defined(SLUD_VERSION_63)||defined(SLUD_VERSION_6)||defined(SLUD_VERSION_5) + superlu_dist_options_t options; +#elif defined(SLUD_VERSION_4)||defined(SLUD_VERSION_3) + superlu_options_t options; +#else + choke_on_me; +#endif + SuperLUStat_t stat; + factors_t *LUfactors; + + + if (f_factors == NULL) + return(0); + LUfactors = (factors_t *) f_factors ; + A = LUfactors->A ; + LUstruct = LUfactors->LUstruct ; + grid = LUfactors->grid ; + ScalePermstruct = LUfactors->ScalePermstruct; + + // Memory leak: with SuperLU_Dist 3.3 + // we either have a leak or a segfault here. + // To be investigated further. + //Destroy_CompRowLoc_Matrix_dist(A); +#if defined(SLUD_VERSION_63) + zScalePermstructFree(ScalePermstruct); + zLUstructFree(LUstruct); +#else + ScalePermstructFree(ScalePermstruct); + LUstructFree(LUstruct); +#endif + superlu_gridexit(grid); + + free(grid); + free(LUstruct); + free(LUfactors); + return(0); + +#else + fprintf(stderr," SLUDist Not Configured, fix make.inc and recompile\n"); + return(-1); +#endif +} + + diff --git a/mlprec/impl/amg_zumf_interface.c b/mlprec/impl/amg_zumf_interface.c new file mode 100644 index 00000000..839a15db --- /dev/null +++ b/mlprec/impl/amg_zumf_interface.c @@ -0,0 +1,196 @@ +/* + * + * MLD2P4 version 2.1 + * MultiLevel Domain Decomposition Parallel Preconditioners Package + * based on PSBLAS (Parallel Sparse BLAS version 3.5) + * + * (C) Copyright 2008-2018 + * + * Salvatore Filippone + * Pasqua D'Ambra + * Daniela di Serafino + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions, and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the MLD2P4 group or the names of its contributors may + * not be used to endorse or promote products derived from this + * software without specific written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * + * File: amg_zumf_interface.c + * + * Functions: amg_zumf_fact_, amg_zumf_solve_, amg_zumf_free_. + * + * This file is an interface to the UMFPACK routines for sparse factorization and + * solve. It was obtained by adapting umfpack_zi_demo under the original UMFPACK + * copyright terms reproduced below. + * + */ + +/* ===================== +UMFPACK Version 4.4 (Jan. 28, 2005), Copyright (c) 2005 by Timothy A. +Davis. All Rights Reserved. + +UMFPACK License: + + Your use or distribution of UMFPACK or any modified version of + UMFPACK implies that you agree to this License. + + THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY + EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + + Permission is hereby granted to use or copy this program, provided + that the Copyright, this License, and the Availability of the original + version is retained on all copies. User documentation of any code that + uses UMFPACK or any modified version of UMFPACK code must cite the + Copyright, this License, the Availability note, and "Used by permission." + Permission to modify the code and to distribute modified code is granted, + provided the Copyright, this License, and the Availability note are + retained, and a notice that the code was modified is included. This + software was developed with support from the National Science Foundation, + and is provided to you free of charge. + +Availability: + + http://www.cise.ufl.edu/research/sparse/umfpack + +*/ + + +#include +#ifdef Have_UMF_ +#include "umfpack.h" +#endif + + +int amg_zumf_fact(int n, int nnz, + double *values, int *rowind, int *colptr, + void **symptr, void **numptr, + long long int *ssize, + long long int *nsize) + +{ + +#ifdef Have_UMF_ + double Info [UMFPACK_INFO], Control [UMFPACK_CONTROL]; + void *Symbolic, *Numeric ; + int i, info; + + + umfpack_zi_defaults(Control); + + info = umfpack_zi_symbolic (n, n, colptr, rowind, values, NULL, &Symbolic, + Control, Info); + + + if ( info == UMFPACK_OK ) { + info = 0; + } else { + printf("umfpack_zi_symbolic() error returns INFO= %d\n", info); + umfpack_zi_report_status(Control,info); + *symptr = (void *) NULL; + *numptr = (void *) NULL; + return -11; + } + + *symptr = Symbolic; + *ssize = Info[UMFPACK_SYMBOLIC_SIZE]; + *ssize *= Info[UMFPACK_SIZE_OF_UNIT]; + + info = umfpack_zi_numeric (colptr, rowind, values, NULL, Symbolic, &Numeric, + Control, Info) ; + + + if ( info == UMFPACK_OK ) { + info = 0; + *numptr = Numeric; + *nsize = Info[UMFPACK_NUMERIC_SIZE]; + *nsize *= Info[UMFPACK_SIZE_OF_UNIT]; + + } else { + printf("umfpack_zi_numeric() error returns INFO= %d\n", info); + umfpack_zi_report_status(Control,info); + info = -12; + *numptr = NULL; + } + + + return info; + +#else + fprintf(stderr," UMF Not Configured, fix make.inc and recompile\n"); + return -1; +#endif +} + + +int amg_zumf_solve(int itrans, int n, + double *x, double *b, int ldb, + void *numptr) + +{ +#ifdef Have_UMF_ + double Info [UMFPACK_INFO], Control [UMFPACK_CONTROL]; + void *Symbolic, *Numeric ; + int i,trans, info; + + + umfpack_di_defaults(Control); + Control[UMFPACK_IRSTEP]=0; + + + if (itrans == 0) { + trans = UMFPACK_A; + } else if (itrans ==1) { + trans = UMFPACK_At; + } else { + trans = UMFPACK_A; + } + + info = umfpack_zi_solve(trans,NULL,NULL,NULL,NULL, + x,NULL,b,NULL, numptr,Control,Info); + return info; +#else + fprintf(stderr," UMF Not Configured, fix make.inc and recompile\n"); + return -1; +#endif + +} + + +int amg_zumf_free(void *symptr, void *numptr) + +{ +#ifdef Have_UMF_ + void *Symbolic, *Numeric ; + Symbolic = symptr; + Numeric = numptr; + + umfpack_zi_free_numeric(&Numeric); + umfpack_zi_free_symbolic(&Symbolic); + return 0; +#else + fprintf(stderr," UMF Not Configured, fix make.inc and recompile\n"); + return -1; +#endif +} + + diff --git a/mlprec/impl/level/Makefile b/mlprec/impl/level/Makefile index 8ce9264f..e24159ca 100644 --- a/mlprec/impl/level/Makefile +++ b/mlprec/impl/level/Makefile @@ -8,61 +8,61 @@ FINCLUDES=$(FMFLAG)$(HERE) $(FMFLAG)$(MODDIR) $(FMFLAG)$(INCDIR) $(PSBLAS_INCLUD -OBJS=mld_c_base_onelev_build.o \ -mld_c_base_onelev_check.o \ -mld_c_base_onelev_cnv.o \ -mld_c_base_onelev_csetc.o \ -mld_c_base_onelev_cseti.o \ -mld_c_base_onelev_csetr.o \ -mld_c_base_onelev_descr.o \ -mld_c_base_onelev_dump.o \ -mld_c_base_onelev_free.o \ -mld_c_base_onelev_mat_asb.o \ -mld_c_base_onelev_setag.o \ -mld_c_base_onelev_setsm.o \ -mld_c_base_onelev_setsv.o \ -mld_d_base_onelev_build.o \ -mld_d_base_onelev_check.o \ -mld_d_base_onelev_cnv.o \ -mld_d_base_onelev_csetc.o \ -mld_d_base_onelev_cseti.o \ -mld_d_base_onelev_csetr.o \ -mld_d_base_onelev_descr.o \ -mld_d_base_onelev_dump.o \ -mld_d_base_onelev_free.o \ -mld_d_base_onelev_mat_asb.o \ -mld_d_base_onelev_setag.o \ -mld_d_base_onelev_setsm.o \ -mld_d_base_onelev_setsv.o \ -mld_s_base_onelev_build.o \ -mld_s_base_onelev_check.o \ -mld_s_base_onelev_cnv.o \ -mld_s_base_onelev_csetc.o \ -mld_s_base_onelev_cseti.o \ -mld_s_base_onelev_csetr.o \ -mld_s_base_onelev_descr.o \ -mld_s_base_onelev_dump.o \ -mld_s_base_onelev_free.o \ -mld_s_base_onelev_mat_asb.o \ -mld_s_base_onelev_setag.o \ -mld_s_base_onelev_setsm.o \ -mld_s_base_onelev_setsv.o \ -mld_z_base_onelev_build.o \ -mld_z_base_onelev_check.o \ -mld_z_base_onelev_cnv.o \ -mld_z_base_onelev_csetc.o \ -mld_z_base_onelev_cseti.o \ -mld_z_base_onelev_csetr.o \ -mld_z_base_onelev_descr.o \ -mld_z_base_onelev_dump.o \ -mld_z_base_onelev_free.o \ -mld_z_base_onelev_mat_asb.o \ -mld_z_base_onelev_setag.o \ -mld_z_base_onelev_setsm.o \ -mld_z_base_onelev_setsv.o +OBJS=amg_c_base_onelev_build.o \ +amg_c_base_onelev_check.o \ +amg_c_base_onelev_cnv.o \ +amg_c_base_onelev_csetc.o \ +amg_c_base_onelev_cseti.o \ +amg_c_base_onelev_csetr.o \ +amg_c_base_onelev_descr.o \ +amg_c_base_onelev_dump.o \ +amg_c_base_onelev_free.o \ +amg_c_base_onelev_mat_asb.o \ +amg_c_base_onelev_setag.o \ +amg_c_base_onelev_setsm.o \ +amg_c_base_onelev_setsv.o \ +amg_d_base_onelev_build.o \ +amg_d_base_onelev_check.o \ +amg_d_base_onelev_cnv.o \ +amg_d_base_onelev_csetc.o \ +amg_d_base_onelev_cseti.o \ +amg_d_base_onelev_csetr.o \ +amg_d_base_onelev_descr.o \ +amg_d_base_onelev_dump.o \ +amg_d_base_onelev_free.o \ +amg_d_base_onelev_mat_asb.o \ +amg_d_base_onelev_setag.o \ +amg_d_base_onelev_setsm.o \ +amg_d_base_onelev_setsv.o \ +amg_s_base_onelev_build.o \ +amg_s_base_onelev_check.o \ +amg_s_base_onelev_cnv.o \ +amg_s_base_onelev_csetc.o \ +amg_s_base_onelev_cseti.o \ +amg_s_base_onelev_csetr.o \ +amg_s_base_onelev_descr.o \ +amg_s_base_onelev_dump.o \ +amg_s_base_onelev_free.o \ +amg_s_base_onelev_mat_asb.o \ +amg_s_base_onelev_setag.o \ +amg_s_base_onelev_setsm.o \ +amg_s_base_onelev_setsv.o \ +amg_z_base_onelev_build.o \ +amg_z_base_onelev_check.o \ +amg_z_base_onelev_cnv.o \ +amg_z_base_onelev_csetc.o \ +amg_z_base_onelev_cseti.o \ +amg_z_base_onelev_csetr.o \ +amg_z_base_onelev_descr.o \ +amg_z_base_onelev_dump.o \ +amg_z_base_onelev_free.o \ +amg_z_base_onelev_mat_asb.o \ +amg_z_base_onelev_setag.o \ +amg_z_base_onelev_setsm.o \ +amg_z_base_onelev_setsv.o -LIBNAME=libmld_prec.a +LIBNAME=libamg_prec.a lib: $(OBJS) $(AR) $(HERE)/$(LIBNAME) $(OBJS) diff --git a/mlprec/impl/level/amg_c_base_onelev_build.f90 b/mlprec/impl/level/amg_c_base_onelev_build.f90 new file mode 100644 index 00000000..a560b1c4 --- /dev/null +++ b/mlprec/impl/level/amg_c_base_onelev_build.f90 @@ -0,0 +1,153 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_onelev_build(lv,info,amold,vmold,imold,ilv) + use psb_base_mod + use amg_c_onelev_mod, amg_protect_name => amg_c_base_onelev_build + implicit none + class(amg_c_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + integer(psb_ipk_), intent(in), optional :: ilv + ! Local + integer(psb_ipk_) :: err,i,k, err_act + integer(psb_ipk_) :: ictxt, me, np + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + + name = 'amg_onelev_build' + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + if (.not.associated(lv%base_desc)) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Unassociated base DESC') + goto 9999 + end if + info = psb_success_ + ictxt = lv%base_desc%get_ctxt() + call psb_info(ictxt,me,np) + + if (.not.allocated(lv%sm)) then + !! Error: should have called amg_dprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + if (.not.allocated(lv%sm%sv)) then + !! Error: should have called amg_dprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + lv%ac_nz_loc = lv%ac%get_nzeros() + lv%ac_nz_tot = lv%ac_nz_loc + select case(lv%parms%coarse_mat) + case(amg_distr_mat_) + call psb_sum(ictxt,lv%ac_nz_tot) + case(amg_repl_mat_) + ! Do nothing + case default + ! Should never get here + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='Wrong lv%parms') + goto 9999 + end select + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Calling mlprcbld at level ',i + call amg_check_def(lv%parms%sweeps_pre,& + & 'Jacobi sweeps',izero,is_int_non_negative) + call amg_check_def(lv%parms%sweeps_post,& + & 'Jacobi sweeps',izero,is_int_non_negative) + + call lv%sm%build(lv%base_a,lv%base_desc,info) + if (info == 0) then + if (allocated(lv%sm2a)) then + call lv%sm2a%build(lv%base_a,lv%base_desc,info) + lv%sm2 => lv%sm2a + else + lv%sm2 => lv%sm + end if + end if + if (info /=0 ) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Smoother bld error') + goto 9999 + end if + + if (lv%sm%sv%is_global()) then + if ((lv%parms%sweeps_pre>1).or.(lv%parms%sweeps_post>1)) then + lv%parms%sweeps_pre = 1 + lv%parms%sweeps_post = 1 + if (me == 0) then + write(debug_unit,*) + if (present(ilv)) then + write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),& + & '" at level ',ilv + write(debug_unit,*) ' is configured as a global solver ' + else + write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),& + & '" is configured as a global solver ' + end if + write(debug_unit,*) ' Pre and post sweeps at this level reset to 1' + end if + end if + end if + + if (any((/present(amold),present(vmold),present(imold)/))) & + & call lv%cnv(info,amold=amold,vmold=vmold,imold=imold) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_base_onelev_build diff --git a/mlprec/impl/level/amg_c_base_onelev_check.f90 b/mlprec/impl/level/amg_c_base_onelev_check.f90 new file mode 100644 index 00000000..fece09e8 --- /dev/null +++ b/mlprec/impl/level/amg_c_base_onelev_check.f90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_onelev_check(lv,info) + + use psb_base_mod + use amg_c_onelev_mod, amg_protect_name => amg_c_base_onelev_check + + Implicit None + + ! Arguments + class(amg_c_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_onelev_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + call amg_check_def(lv%parms%sweeps_pre,& + & 'Jacobi sweeps',ione,is_int_non_negative) + call amg_check_def(lv%parms%sweeps_post,& + & 'Jacobi sweeps',ione,is_int_non_negative) + + if (allocated(lv%sm)) then + call lv%sm%check(info) + else + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + if (allocated(lv%sm2a)) then + call lv%sm2a%check(info) + else if (.not.inner_check(lv%sm2,lv%sm)) then + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +contains + function inner_check(smp,sm) result(res) + implicit none + logical :: res + class(amg_c_base_smoother_type), intent(in), pointer :: smp + class(amg_c_base_smoother_type), intent(in), target :: sm + + res = associated(smp, sm) + end function inner_check + +end subroutine amg_c_base_onelev_check diff --git a/mlprec/impl/level/amg_c_base_onelev_cnv.f90 b/mlprec/impl/level/amg_c_base_onelev_cnv.f90 new file mode 100644 index 00000000..0cd09cbf --- /dev/null +++ b/mlprec/impl/level/amg_c_base_onelev_cnv.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_onelev_cnv(lv,info,amold,vmold,imold) + + use psb_base_mod + use amg_c_onelev_mod, amg_protect_name => amg_c_base_onelev_cnv + implicit none + + class(amg_c_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + integer(psb_ipk_) :: i + + info = psb_success_ + + if (any((/present(amold),present(vmold),present(imold)/))) then + if (allocated(lv%sm)) & + & call lv%sm%cnv(info,amold=amold,vmold=vmold,imold=imold) + if (info == psb_success_ .and. allocated(lv%sm2a)) & + & call lv%sm2a%cnv(info,amold=amold,vmold=vmold,imold=imold) + if (info == psb_success_ .and. allocated(lv%wrk)) & + & call lv%wrk%cnv(info,vmold=vmold) + if (info == psb_success_.and. lv%ac%is_asb()) & + & call lv%ac%cscnv(info,mold=amold) + if (info == psb_success_ .and. lv%desc_ac%is_ok() & + & .and. present(imold)) call lv%desc_ac%cnv(imold) + if (info == psb_success_) call lv%map%cnv(info,mold=amold,imold=imold) + end if +end subroutine amg_c_base_onelev_cnv diff --git a/mlprec/impl/level/amg_c_base_onelev_csetc.F90 b/mlprec/impl/level/amg_c_base_onelev_csetc.F90 new file mode 100644 index 00000000..d2104c56 --- /dev/null +++ b/mlprec/impl/level/amg_c_base_onelev_csetc.F90 @@ -0,0 +1,292 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_onelev_csetc(lv,what,val,info,pos,idx) + + use psb_base_mod + use amg_c_onelev_mod, amg_protect_name => amg_c_base_onelev_csetc + use amg_c_base_aggregator_mod + use amg_c_dec_aggregator_mod + use amg_c_symdec_aggregator_mod + use amg_c_jac_smoother + use amg_c_as_smoother + use amg_c_diag_solver + use amg_c_l1_diag_solver + use amg_c_ilu_solver + use amg_c_id_solver + use amg_c_gs_solver +#if defined(HAVE_SLU_) + use amg_c_slu_solver +#endif +#if defined(HAVE_MUMPS_) + use amg_c_mumps_solver +#endif + + Implicit None + + ! Arguments + class(amg_c_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + ! Local + integer(psb_ipk_) :: ipos_, err_act + character(len=20) :: name='c_base_onelev_csetc' + integer(psb_ipk_) :: ival + type(amg_c_base_smoother_type) :: amg_c_base_smoother_mold + type(amg_c_jac_smoother_type) :: amg_c_jac_smoother_mold + type(amg_c_l1_jac_smoother_type) :: amg_c_l1_jac_smoother_mold + type(amg_c_as_smoother_type) :: amg_c_as_smoother_mold + type(amg_c_diag_solver_type) :: amg_c_diag_solver_mold + type(amg_c_l1_diag_solver_type) :: amg_c_l1_diag_solver_mold + type(amg_c_ilu_solver_type) :: amg_c_ilu_solver_mold + type(amg_c_id_solver_type) :: amg_c_id_solver_mold + type(amg_c_gs_solver_type) :: amg_c_gs_solver_mold + type(amg_c_bwgs_solver_type) :: amg_c_bwgs_solver_mold +#if defined(HAVE_SLU_) + type(amg_c_slu_solver_type) :: amg_c_slu_solver_mold +#endif +#if defined(HAVE_MUMPS_) + type(amg_c_mumps_solver_type) :: amg_c_mumps_solver_mold +#endif + + + call psb_erractionsave(err_act) + + info = psb_success_ + + ival = lv%stringval(val) + + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + select case (psb_toupper(trim(what))) + case ('SMOOTHER_TYPE') + select case (psb_toupper(trim(val))) + case ('NOPREC','NONE') + call lv%set(amg_c_base_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_c_id_solver_mold,info,pos=pos) + + case ('JAC','JACOBI') + call lv%set(amg_c_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_c_diag_solver_mold,info,pos=pos) + + case ('L1-JACOBI') + call lv%set(amg_c_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_c_l1_diag_solver_mold,info,pos=pos) + + case ('BJAC') + call lv%set(amg_c_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_c_ilu_solver_mold,info,pos=pos) + + case ('L1-BJAC') + call lv%set(amg_c_l1_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_c_ilu_solver_mold,info,pos=pos) + + case ('AS') + call lv%set(amg_c_as_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_c_ilu_solver_mold,info,pos=pos) + + case ('GS','FWGS') + call lv%set(amg_c_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_c_gs_solver_mold,info,pos='pre') + if (allocated(lv%sm2a)) deallocate(lv%sm2a) + case ('BWGS') + call lv%set(amg_c_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_c_bwgs_solver_mold,info,pos='pre') + if (allocated(lv%sm2a)) deallocate(lv%sm2a) + case ('FBGS') + call lv%set(amg_c_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_c_gs_solver_mold,info,pos='pre') + call lv%set(amg_c_jac_smoother_mold,info,pos='post') + if (info == 0) call lv%set(amg_c_bwgs_solver_mold,info,pos='post') + case ('L1-GS','L1-FWGS') + call lv%set(amg_c_l1_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_c_gs_solver_mold,info,pos='pre') + if (allocated(lv%sm2a)) deallocate(lv%sm2a) + case ('L1-BWGS') + call lv%set(amg_c_l1_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_c_bwgs_solver_mold,info,pos='pre') + if (allocated(lv%sm2a)) deallocate(lv%sm2a) + case ('L1-FBGS') + call lv%set(amg_c_l1_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_c_gs_solver_mold,info,pos='pre') + call lv%set(amg_c_l1_jac_smoother_mold,info,pos='post') + if (info == 0) call lv%set(amg_c_bwgs_solver_mold,info,pos='post') + + case default + ! + ! Do nothing and hope for the best :) + ! + end select + if ((ipos_==amg_smooth_pre_).or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) call lv%sm%default() + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm2a)) call lv%sm2a%default() + end if + + + case('SUB_SOLVE') + select case (psb_toupper(trim(val))) + case ('NONE','NOPREC','FACT_NONE') + call lv%set(amg_c_id_solver_mold,info,pos=pos) + + case ('DIAG') + call lv%set(amg_c_diag_solver_mold,info,pos=pos) + + case ('L1-DIAG') + call lv%set(amg_c_l1_diag_solver_mold,info,pos=pos) + + case ('GS','FGS','FWGS') + call lv%set(amg_c_gs_solver_mold,info,pos=pos) + + case ('BGS','BWGS') + call lv%set(amg_c_bwgs_solver_mold,info,pos=pos) + + case ('ILU','ILUT','MILU') + call lv%set(amg_c_ilu_solver_mold,info,pos=pos) + if (info == 0) then + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + call lv%sm%sv%set('SUB_SOLVE',val,info) + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) call lv%sm2a%sv%set('SUB_SOLVE',val,info) + end if + end if +#ifdef HAVE_SLU_ + case ('SLU') + call lv%set(amg_c_slu_solver_mold,info,pos=pos) +#endif +#ifdef HAVE_MUMPS_ + case ('MUMPS') + call lv%set(amg_c_mumps_solver_mold,info,pos=pos) +#endif + case default + ! + ! Do nothing and hope for the best :) + ! + end select + + case ('ML_CYCLE') + lv%parms%ml_cycle = amg_stringval(val) + + case ('PAR_AGGR_ALG') + ival = amg_stringval(val) + lv%parms%par_aggr_alg = ival + if (allocated(lv%aggr)) then + call lv%aggr%free(info) + if (info == 0) deallocate(lv%aggr,stat=info) + if (info /= 0) then + info = psb_err_internal_error_ + return + end if + end if + + select case(ival) + case(amg_dec_aggr_) + allocate(amg_c_dec_aggregator_type :: lv%aggr, stat=info) + case(amg_sym_dec_aggr_) + allocate(amg_c_symdec_aggregator_type :: lv%aggr, stat=info) + case default + info = psb_err_internal_error_ + end select + if (info == psb_success_) call lv%aggr%default() + + case ('AGGR_ORD') + lv%parms%aggr_ord = amg_stringval(val) + + case ('AGGR_TYPE') + lv%parms%aggr_type = amg_stringval(val) + if (allocated(lv%aggr)) call lv%aggr%set_aggr_type(lv%parms,info) + + case ('AGGR_PROL') + lv%parms%aggr_prol = amg_stringval(val) + + case ('COARSE_MAT') + lv%parms%coarse_mat = amg_stringval(val) + + case ('AGGR_OMEGA_ALG') + lv%parms%aggr_omega_alg= amg_stringval(val) + + case ('AGGR_EIG') + lv%parms%aggr_eig = amg_stringval(val) + + case ('AGGR_FILTER') + lv%parms%aggr_filter = amg_stringval(val) + + case ('COARSE_SOLVE') + lv%parms%coarse_solve = amg_stringval(val) + + case default + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) then + call lv%sm%set(what,val,info,idx=idx) + end if + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) then + call lv%sm2a%set(what,val,info,idx=idx) + end if + end if + if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) + + end select + + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_c_base_onelev_csetc diff --git a/mlprec/impl/level/amg_c_base_onelev_cseti.F90 b/mlprec/impl/level/amg_c_base_onelev_cseti.F90 new file mode 100644 index 00000000..e4c9d29c --- /dev/null +++ b/mlprec/impl/level/amg_c_base_onelev_cseti.F90 @@ -0,0 +1,268 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_onelev_cseti(lv,what,val,info,pos,idx) + + use psb_base_mod + use amg_c_onelev_mod, amg_protect_name => amg_c_base_onelev_cseti + use amg_c_base_aggregator_mod + use amg_c_dec_aggregator_mod + use amg_c_symdec_aggregator_mod + use amg_c_jac_smoother + use amg_c_as_smoother + use amg_c_diag_solver + use amg_c_l1_diag_solver + use amg_c_ilu_solver + use amg_c_id_solver + use amg_c_gs_solver +#if defined(HAVE_SLU_) + use amg_c_slu_solver +#endif +#if defined(HAVE_MUMPS_) + use amg_c_mumps_solver +#endif + + Implicit None + + ! Arguments + class(amg_c_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + ! Local + integer(psb_ipk_) :: ipos_, err_act + character(len=20) :: name='c_base_onelev_cseti' + type(amg_c_base_smoother_type) :: amg_c_base_smoother_mold + type(amg_c_jac_smoother_type) :: amg_c_jac_smoother_mold + type(amg_c_l1_jac_smoother_type) :: amg_c_l1_jac_smoother_mold + type(amg_c_as_smoother_type) :: amg_c_as_smoother_mold + type(amg_c_diag_solver_type) :: amg_c_diag_solver_mold + type(amg_c_l1_diag_solver_type) :: amg_c_l1_diag_solver_mold + type(amg_c_ilu_solver_type) :: amg_c_ilu_solver_mold + type(amg_c_id_solver_type) :: amg_c_id_solver_mold + type(amg_c_gs_solver_type) :: amg_c_gs_solver_mold + type(amg_c_bwgs_solver_type) :: amg_c_bwgs_solver_mold +#if defined(HAVE_SLU_) + type(amg_c_slu_solver_type) :: amg_c_slu_solver_mold +#endif +#if defined(HAVE_MUMPS_) + type(amg_c_mumps_solver_type) :: amg_c_mumps_solver_mold +#endif + + call psb_erractionsave(err_act) + info = psb_success_ + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + select case (psb_toupper(what)) + case ('SMOOTHER_TYPE') + select case (val) + case (amg_noprec_) + call lv%set(amg_c_base_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_c_id_solver_mold,info,pos=pos) + + case (amg_jac_) + call lv%set(amg_c_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_c_diag_solver_mold,info,pos=pos) + + case (amg_l1_jac_) + call lv%set(amg_c_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_c_l1_diag_solver_mold,info,pos=pos) + + case (amg_bjac_) + call lv%set(amg_c_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_c_ilu_solver_mold,info,pos=pos) + + case (amg_l1_bjac_) + call lv%set(amg_c_l1_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_c_ilu_solver_mold,info,pos=pos) + + case (amg_as_) + call lv%set(amg_c_as_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_c_ilu_solver_mold,info,pos=pos) + + case (amg_fbgs_) + call lv%set(amg_c_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_c_gs_solver_mold,info,pos='pre') + call lv%set(amg_c_jac_smoother_mold,info,pos='post') + if (info == 0) call lv%set(amg_c_bwgs_solver_mold,info,pos='post') + + case default + ! + ! Do nothing and hope for the best :) + ! + end select + if ((ipos_==amg_smooth_pre_).or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) call lv%sm%default() + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm2a)) call lv%sm2a%default() + end if + + + case('SUB_SOLVE') + select case (val) + case (amg_f_none_) + call lv%set(amg_c_id_solver_mold,info,pos=pos) + + case (amg_diag_scale_) + call lv%set(amg_c_diag_solver_mold,info,pos=pos) + + case (amg_l1_diag_scale_) + call lv%set(amg_c_l1_diag_solver_mold,info,pos=pos) + + case (amg_gs_) + call lv%set(amg_c_gs_solver_mold,info,pos=pos) + + case (amg_bwgs_) + call lv%set(amg_c_bwgs_solver_mold,info,pos=pos) + + case (psb_ilu_n_,psb_milu_n_,psb_ilu_t_) + call lv%set(amg_c_ilu_solver_mold,info,pos=pos) + if (info == 0) then + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + call lv%sm%sv%set('SUB_SOLVE',val,info) + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) call lv%sm2a%sv%set('SUB_SOLVE',val,info) + end if + end if +#ifdef HAVE_SLU_ + case (amg_slu_) + call lv%set(amg_c_slu_solver_mold,info,pos=pos) +#endif +#ifdef HAVE_MUMPS_ + case (amg_mumps_) + call lv%set(amg_c_mumps_solver_mold,info,pos=pos) +#endif + case default + ! + ! Do nothing and hope for the best :) + ! + end select + + + case ('SMOOTHER_SWEEPS') + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) & + & lv%parms%sweeps_pre = val + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_)) & + & lv%parms%sweeps_post = val + + case ('ML_CYCLE') + lv%parms%ml_cycle = val + + case ('PAR_AGGR_ALG') + lv%parms%par_aggr_alg = val + if (allocated(lv%aggr)) then + call lv%aggr%free(info) + if (info == 0) deallocate(lv%aggr,stat=info) + if (info /= 0) then + info = psb_err_internal_error_ + return + end if + end if + + select case(val) + case(amg_dec_aggr_) + allocate(amg_c_dec_aggregator_type :: lv%aggr, stat=info) + case(amg_sym_dec_aggr_) + allocate(amg_c_symdec_aggregator_type :: lv%aggr, stat=info) + case default + info = psb_err_internal_error_ + end select + if (info == psb_success_) call lv%aggr%default() + + case ('AGGR_ORD') + lv%parms%aggr_ord = val + + case ('AGGR_TYPE') + lv%parms%aggr_type = val + if (allocated(lv%aggr)) call lv%aggr%set_aggr_type(lv%parms,info) + + case ('AGGR_PROL') + lv%parms%aggr_prol = val + + case ('COARSE_MAT') + lv%parms%coarse_mat = val + + case ('AGGR_OMEGA_ALG') + lv%parms%aggr_omega_alg= val + + case ('AGGR_EIG') + lv%parms%aggr_eig = val + + case ('AGGR_FILTER') + lv%parms%aggr_filter = val + + case ('COARSE_SOLVE') + lv%parms%coarse_solve = val + + case default + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) then + call lv%sm%set(what,val,info,idx=idx) + end if + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) then + call lv%sm2a%set(what,val,info,idx=idx) + end if + end if + if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) + + end select + if (info /= psb_success_) goto 9999 + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_c_base_onelev_cseti diff --git a/mlprec/impl/level/amg_c_base_onelev_csetr.f90 b/mlprec/impl/level/amg_c_base_onelev_csetr.f90 new file mode 100644 index 00000000..8b415225 --- /dev/null +++ b/mlprec/impl/level/amg_c_base_onelev_csetr.f90 @@ -0,0 +1,105 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_onelev_csetr(lv,what,val,info,pos,idx) + + use psb_base_mod + use amg_c_onelev_mod, amg_protect_name => amg_c_base_onelev_csetr + + Implicit None + + ! Arguments + class(amg_c_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + ! Local + integer(psb_ipk_) :: ipos_, err_act + character(len=20) :: name='c_base_onelev_csetr' + + call psb_erractionsave(err_act) + + + info = psb_success_ + + select case (psb_toupper(what)) + + case ('AGGR_OMEGA_VAL') + lv%parms%aggr_omega_val= val + + case ('AGGR_THRESH') + lv%parms%aggr_thresh = val + + case default + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) then + call lv%sm%set(what,val,info,idx=idx) + end if + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) then + call lv%sm2a%set(what,val,info,idx=idx) + end if + end if + if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) + + end select + + if (info /= psb_success_) goto 9999 + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_c_base_onelev_csetr diff --git a/mlprec/impl/level/amg_c_base_onelev_descr.f90 b/mlprec/impl/level/amg_c_base_onelev_descr.f90 new file mode 100644 index 00000000..07a11681 --- /dev/null +++ b/mlprec/impl/level/amg_c_base_onelev_descr.f90 @@ -0,0 +1,112 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_onelev_descr(lv,il,nl,ilmin,info,iout) + + use psb_base_mod + use amg_c_onelev_mod, amg_protect_name => amg_c_base_onelev_descr + Implicit None + ! Arguments + class(amg_c_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: il,nl,ilmin + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_c_base_onelev_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse + + + call psb_erractionsave(err_act) + + + coarse = (il==nl) + + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + + write(iout_,*) + if (il == ilmin) then + call lv%parms%mlcycledsc(iout_,info) + if (allocated(lv%aggr)) then + call lv%aggr%descr(lv%parms,iout_,info) + else + write(iout_,*) 'Internal error: unallocated aggregator object' + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + write(iout_,*) + end if + + if (il > 1) then + + if (coarse) then + write(iout_,*) ' Level ',il,' (coarse)' + else + write(iout_,*) ' Level ',il + end if + + call lv%parms%descr(iout_,info,coarse=coarse) + + if (nl > 1) then + if (allocated(lv%map%naggr)) then + write(iout_,*) ' Coarse Matrix: Global size: ', & + & sum((1_psb_lpk_*lv%map%naggr(:))),' Nonzeros: ',lv%ac_nz_tot + write(iout_,*) ' Local matrix sizes: ', & + & lv%map%naggr(:) + write(iout_,*) ' Aggregation ratio: ', & + & lv%szratio + end if + end if + + if (coarse.and.allocated(lv%sm)) & + & call lv%sm%descr(info,iout=iout_,coarse=coarse) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_c_base_onelev_descr diff --git a/mlprec/impl/level/amg_c_base_onelev_dump.f90 b/mlprec/impl/level/amg_c_base_onelev_dump.f90 new file mode 100644 index 00000000..3a230344 --- /dev/null +++ b/mlprec/impl/level/amg_c_base_onelev_dump.f90 @@ -0,0 +1,169 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_onelev_dump(lv,level,info,prefix,head,ac,rp,& + & smoother,solver,tprol,global_num) + + use psb_base_mod + use amg_c_onelev_mod, amg_protect_name => amg_c_base_onelev_dump + implicit none + class(amg_c_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: ac, rp, smoother, solver, tprol, global_num + ! Local variables + integer(psb_ipk_) :: i, j, il1, iln, lname, lev, ni + integer(psb_ipk_) :: icontxt,iam, np + character(len=80) :: prefix_, frmt + character(len=1024) :: fname + logical :: ac_, rp_, tprol_, global_num_ + integer(psb_lpk_), allocatable :: ivr(:), ivc(:) + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_lev_c" + end if + + if (associated(lv%base_desc)) then + icontxt = lv%base_desc%get_context() + call psb_info(icontxt,iam,np) + else + icontxt = -1 + iam = -1 + np = -1 + end if + if (present(ac)) then + ac_ = ac + else + ac_ = .false. + end if + if (present(rp)) then + rp_ = rp + else + rp_ = .false. + end if + if (present(tprol)) then + tprol_ = tprol + else + tprol_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + + if (np > 0) then + ni = floor(log10(1.0*np)) + 1 + write(frmt,'(a,i3.3,a,i3.3,a)') '(a,i',ni,'.',ni,')' + write(fname(lname+1:lname+ni+2),frmt) '_p',iam + lname = lname + ni + 2 + end if + + if (global_num_) then + if (level >= 2) then + if (ac_) then + ivr = lv%desc_ac%get_global_indices(owned=.false.) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx' + call lv%ac%print(fname,head=head,iv=ivr) + end if + if (rp_) then + ivr = lv%map%p_desc_U%get_global_indices(owned=.false.) + ivc = lv%map%p_desc_V%get_global_indices(owned=.false.) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx' + call lv%map%mat_U2V%print(fname,head=head,ivr=ivc,ivc=ivr) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx' + call lv%map%mat_V2U%print(fname,head=head,ivr=ivr,ivc=ivc) + end if + if (tprol_) then + ! Tentative prolongator is stored with column indices already + ! in global numbering, so only IVR is needed. + ivr = lv%map%p_desc_U%get_global_indices(owned=.false.) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_tprol.mtx' + ! + ! This is not implemented yet. + !call lv%tprol%print(fname,head=head,ivr=ivr) + end if + end if + else + if (level >= 2) then + if (ac_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx' + call lv%ac%print(fname,head=head) + end if + if (rp_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx' + call lv%map%mat_U2V%print(fname,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx' + call lv%map%mat_V2U%print(fname,head=head) + end if + if (tprol_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_tprol.mtx' + ! + ! This is not implemented yet. + !call lv%tprol%print(fname,head=head) + end if + end if + end if + + if (level >= 2) then + if (allocated(lv%sm)) then + call lv%sm%dump(lv%desc_ac,level,info,smoother=smoother, & + & solver=solver,prefix=trim(prefix_)//"_sm",global_num=global_num) + end if + if (allocated(lv%sm2a)) then + call lv%sm2a%dump(lv%desc_ac,level,info,smoother=smoother, & + & solver=solver,prefix=trim(prefix_)//"_sm2a",global_num=global_num) + end if + else + if (allocated(lv%sm)) then + call lv%sm%dump(lv%base_desc,level,info,smoother=smoother, & + & solver=solver,prefix=trim(prefix_)//"_sm",global_num=global_num) + end if + if (allocated(lv%sm2a)) then + call lv%sm2a%dump(lv%base_desc,level,info,smoother=smoother, & + & solver=solver,prefix=trim(prefix_)//"_sm2a",global_num=global_num) + end if + end if + +end subroutine amg_c_base_onelev_dump diff --git a/mlprec/impl/level/amg_c_base_onelev_free.f90 b/mlprec/impl/level/amg_c_base_onelev_free.f90 new file mode 100644 index 00000000..c410b911 --- /dev/null +++ b/mlprec/impl/level/amg_c_base_onelev_free.f90 @@ -0,0 +1,75 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_onelev_free(lv,info) + + use psb_base_mod + use amg_c_onelev_mod, amg_protect_name => amg_c_base_onelev_free + implicit none + + class(amg_c_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: i + + info = psb_success_ + + ! We might just deallocate the top level array, except + ! that there may be inner objects containing C pointers, + ! e.g. UMFPACK, SLU or CUDA stuff. + ! We really need FINALs. + if (allocated(lv%sm)) & + & call lv%sm%free(info) + + if (allocated(lv%sm2a)) & + & call lv%sm2a%free(info) + + if (allocated(lv%wrk)) & + & call lv%wrk%free(info) + + call lv%ac%free() + if (lv%desc_ac%is_ok()) & + & call lv%desc_ac%free(info) + call lv%map%free(info) + + ! This is a pointer to something else, must not free it here. + nullify(lv%base_a) + ! This is a pointer to something else, must not free it here. + nullify(lv%base_desc) + + call lv%nullify() + +end subroutine amg_c_base_onelev_free diff --git a/mlprec/impl/level/amg_c_base_onelev_mat_asb.f90 b/mlprec/impl/level/amg_c_base_onelev_mat_asb.f90 new file mode 100644 index 00000000..8f8ac7cf --- /dev/null +++ b/mlprec/impl/level/amg_c_base_onelev_mat_asb.f90 @@ -0,0 +1,178 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_c_onelev_mat_asb.f90 +! +! Subroutine: amg_c_onelev_mat_asb +! Version: complex +! +! This routine builds the matrix associated to the current level of the +! multilevel preconditioner from the matrix associated to the previous level, +! by using the user-specified aggregation technique (therefore, it also builds the +! prolongation and restriction operators mapping the current level to the +! previous one and vice versa). +! The current level is regarded as the coarse one, while the previous as +! the fine one. This is in agreement with the fact that the routine is called, +! by amg_mlprec_bld, only on levels >=2. +! The main structure is: +! 1. Perform sanity checks; +! 2. Call amg_Xaggrmat_asb to compute prolongator/restrictor/AC +! 3. According to the choice of DIST/REPL for AC, build a descriptor DESC_AC, +! and adjust the column numbering of AC/OP_PROL/OP_RESTR +! 4. Pack restrictor and prolongator into p%map +! 5. Fix base_a and base_desc pointers. +! +! +! Arguments: +! p - type(amg_c_onelev_type), input/output. +! The 'one-level' data structure containing the control +! parameters and (eventually) coarse matrix and prolongator/restrictors. +! +! a - type(psb_cspmat_type). +! The sparse matrix structure containing the local part of the +! fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_cspmat_type), input/output +! The tentative prolongator on input, released on output. +! +! info - integer, output. +! Error code. +! +subroutine amg_c_base_onelev_mat_asb(lv,a,desc_a,ilaggr,nlaggr,t_prol,info) + + use psb_base_mod + use amg_base_prec_type + use amg_c_onelev_mod, amg_protect_name => amg_c_base_onelev_mat_asb + + implicit none + + ! Arguments + class(amg_c_onelev_type), intent(inout), target :: lv + type(psb_cspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + integer(psb_lpk_), intent(inout) :: ilaggr(:) + type(psb_lcspmat_type), intent(inout) :: t_prol + integer(psb_ipk_), intent(out) :: info + + + ! Local variables + character(len=24) :: name + integer(psb_ipk_) :: ictxt, np, me + integer(psb_ipk_) :: err_act + type(psb_cspmat_type) :: ac, op_restr, op_prol + integer(psb_ipk_) :: nzl, inl + integer(psb_ipk_) :: debug_level, debug_unit + + name='amg_c_onelev_mat_asb' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + call amg_check_def(lv%parms%aggr_prol,'Smoother',& + & amg_smooth_prol_,is_legal_ml_aggr_prol) + call amg_check_def(lv%parms%coarse_mat,'Coarse matrix',& + & amg_distr_mat_,is_legal_ml_coarse_mat) + call amg_check_def(lv%parms%aggr_filter,'Use filtered matrix',& + & amg_no_filter_mat_,is_legal_aggr_filter) + call amg_check_def(lv%parms%aggr_omega_alg,'Omega Alg.',& + & amg_eig_est_,is_legal_ml_aggr_omega_alg) + call amg_check_def(lv%parms%aggr_eig,'Eigenvalue estimate',& + & amg_max_norm_,is_legal_ml_aggr_eig) + call amg_check_def(lv%parms%aggr_omega_val,'Omega',szero,is_legal_s_omega) + + + ! + ! Build the coarse-level matrix from the fine-level one, starting from + ! the mapping defined by amg_aggrmap_bld and applying the aggregation + ! algorithm specified by lv%iprcparm(amg_aggr_prol_) + ! + call lv%aggr%mat_bld(lv%parms,a,desc_a,ilaggr,nlaggr,& + & lv%ac,lv%desc_ac,op_prol,op_restr,t_prol,info) + + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_aggrmat_asb') + goto 9999 + end if + + ! + ! Now build its descriptor and convert global indices for + ! ac, op_restr and op_prol + ! + if (info == psb_success_) & + & call lv%aggr%mat_asb(lv%parms,a,desc_a,& + & lv%ac,lv%desc_ac,op_prol,op_restr,info) + + if (info == psb_success_) call lv%ac%cscnv(info,type='csr',dupl=psb_dupl_add_) + + if (info == psb_success_) call lv%aggr%bld_map(desc_a, lv%desc_ac,& + & ilaggr,nlaggr,op_restr,op_prol,lv%map,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='mat_asb/map_bld') + goto 9999 + end if + ! + ! Fix the base_a and base_desc pointers for handling of residuals. + ! This is correct because this routine is only called at levels >=2. + ! + lv%base_a => lv%ac + lv%base_desc => lv%desc_ac + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_c_base_onelev_mat_asb diff --git a/mlprec/impl/level/amg_c_base_onelev_setag.f90 b/mlprec/impl/level/amg_c_base_onelev_setag.f90 new file mode 100644 index 00000000..5399bfa2 --- /dev/null +++ b/mlprec/impl/level/amg_c_base_onelev_setag.f90 @@ -0,0 +1,82 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_onelev_setag(lv,val,info,pos) + + use psb_base_mod + use amg_c_onelev_mod, amg_protect_name => amg_c_base_onelev_setag + + implicit none + + ! Arguments + class(amg_c_onelev_type), target, intent(inout) :: lv + class(amg_c_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ipos_ + character(len=*), parameter :: name='amg_base_onelev_setag' + + info = psb_success_ + + ! Ignore pos for aggregator + + if (allocated(lv%aggr)) then + if (.not.same_type_as(lv%aggr,val)) then + call lv%aggr%free(info) + deallocate(lv%aggr,stat=info) + if (info /= 0) then + info = 3111 + return + end if + end if + end if + + if (.not.allocated(lv%aggr)) then + allocate(lv%aggr,mold=val,stat=info) + if (info /= 0) then + info = 3111 + return + end if + lv%parms%par_aggr_alg = amg_ext_aggr_ + lv%parms%aggr_type = amg_noalg_ + call lv%aggr%default() + end if + +end subroutine amg_c_base_onelev_setag + diff --git a/mlprec/impl/level/amg_c_base_onelev_setsm.F90 b/mlprec/impl/level/amg_c_base_onelev_setsm.F90 new file mode 100644 index 00000000..66f64019 --- /dev/null +++ b/mlprec/impl/level/amg_c_base_onelev_setsm.F90 @@ -0,0 +1,114 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_onelev_setsm(lev,val,info,pos) + + use psb_base_mod + use amg_c_prec_mod, amg_protect_name => amg_c_base_onelev_setsm + + implicit none + + ! Arguments + class(amg_c_onelev_type), target, intent(inout) :: lev + class(amg_c_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ipos_ + character(len=*), parameter :: name='amg_base_onelev_setsm' + + info = psb_success_ + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + if (ipos_ == amg_smooth_both_) then + if (allocated(lev%sm2a)) then + call lev%sm2a%free(info) + deallocate(lev%sm2a, stat=info) + lev%sm2 => null() + end if + end if + + select case(ipos_) + case(amg_smooth_pre_, amg_smooth_both_) + if (allocated(lev%sm)) then + if (.not.same_type_as(lev%sm,val)) then + call lev%sm%free(info) + deallocate(lev%sm, stat=info) + end if + endif + if (.not.allocated(lev%sm)) then +#ifdef HAVE_MOLD + allocate(lev%sm,mold=val) +#else + allocate(lev%sm,source=val) +#endif + end if + call lev%sm%default() + if (ipos_ == amg_smooth_both_) lev%sm2 => lev%sm + case(amg_smooth_post_) + if (allocated(lev%sm2a)) then + if (.not.same_type_as(lev%sm2a,val)) then + call lev%sm2a%free(info) + deallocate(lev%sm2a, stat=info) + endif + end if + if (.not.allocated(lev%sm2a)) then +#ifdef HAVE_MOLD + allocate(lev%sm2a,mold=val) +#else + allocate(lev%sm2a,source=val) +#endif + end if + call lev%sm2a%default() + lev%sm2 => lev%sm2a + end select + +end subroutine amg_c_base_onelev_setsm + diff --git a/mlprec/impl/level/amg_c_base_onelev_setsv.F90 b/mlprec/impl/level/amg_c_base_onelev_setsv.F90 new file mode 100644 index 00000000..e4684419 --- /dev/null +++ b/mlprec/impl/level/amg_c_base_onelev_setsv.F90 @@ -0,0 +1,152 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_onelev_setsv(lev,val,info,pos) + + use psb_base_mod + use amg_c_prec_mod, amg_protect_name => amg_c_base_onelev_setsv + + implicit none + + ! Arguments + class(amg_c_onelev_type), target, intent(inout) :: lev + class(amg_c_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ipos_ + character(len=*), parameter :: name='amg_base_onelev_setsv' + + info = psb_success_ + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + if ((ipos_ == amg_smooth_pre_).or.(ipos_ == amg_smooth_both_)) then + if (allocated(lev%sm)) then + if (allocated(lev%sm%sv)) then + if (.not.same_type_as(lev%sm%sv,val)) then + call lev%sm%sv%free(info) + if (info == 0) deallocate(lev%sm%sv,stat=info) + if (info /= 0) then + info = 3111 + return + end if + end if + end if + + if (.not.allocated(lev%sm%sv)) then +#ifdef HAVE_MOLD + allocate(lev%sm%sv,mold=val,stat=info) +#else + allocate(lev%sm%sv,source=val,stat=info) +#endif + if (info /= 0) then + info = 3111 + return + end if + end if + call lev%sm%sv%default() + else + info = 3111 + write(psb_err_unit,*) name,& + &': Error: uninitialized preconditioner component,',& + &' should call amg_PRECINIT/amg_PRECSET' + return + + end if + end if + + ! + ! If POS was not specified and therefore we have amg_smooth_both_ + ! we need to update sm2a *only* if it was already allocated, + ! otherwise it is not needed (since we have just fixed %sm in the + ! pre section). + ! + + if ((ipos_ == amg_smooth_post_).or. & + ((ipos_ == amg_smooth_both_).and.(allocated(lev%sm2a)))) then + + + if (allocated(lev%sm2a)) then + if (allocated(lev%sm2a%sv)) then + if (.not.same_type_as(lev%sm2a%sv,val)) then + call lev%sm2a%sv%free(info) + if (info == 0) deallocate(lev%sm2a%sv,stat=info) + if (info /= 0) then + info = 3111 + return + end if + end if + end if + if (.not.allocated(lev%sm2a%sv)) then +#ifdef HAVE_MOLD + allocate(lev%sm2a%sv,mold=val,stat=info) +#else + allocate(lev%sm2a%sv,source=val,stat=info) +#endif + if (info /= 0) then + info = 3111 + return + end if + end if + call lev%sm2a%sv%default() + + else + info = 3111 + write(psb_err_unit,*) name,& + &': Error: uninitialized preconditioner component,',& + &' should call amg_PRECINIT/amg_PRECSET' + return + + end if + + end if + +end subroutine amg_c_base_onelev_setsv + diff --git a/mlprec/impl/level/amg_d_base_onelev_build.f90 b/mlprec/impl/level/amg_d_base_onelev_build.f90 new file mode 100644 index 00000000..ed78038f --- /dev/null +++ b/mlprec/impl/level/amg_d_base_onelev_build.f90 @@ -0,0 +1,153 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_onelev_build(lv,info,amold,vmold,imold,ilv) + use psb_base_mod + use amg_d_onelev_mod, amg_protect_name => amg_d_base_onelev_build + implicit none + class(amg_d_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + integer(psb_ipk_), intent(in), optional :: ilv + ! Local + integer(psb_ipk_) :: err,i,k, err_act + integer(psb_ipk_) :: ictxt, me, np + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + + name = 'amg_onelev_build' + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + if (.not.associated(lv%base_desc)) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Unassociated base DESC') + goto 9999 + end if + info = psb_success_ + ictxt = lv%base_desc%get_ctxt() + call psb_info(ictxt,me,np) + + if (.not.allocated(lv%sm)) then + !! Error: should have called amg_dprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + if (.not.allocated(lv%sm%sv)) then + !! Error: should have called amg_dprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + lv%ac_nz_loc = lv%ac%get_nzeros() + lv%ac_nz_tot = lv%ac_nz_loc + select case(lv%parms%coarse_mat) + case(amg_distr_mat_) + call psb_sum(ictxt,lv%ac_nz_tot) + case(amg_repl_mat_) + ! Do nothing + case default + ! Should never get here + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='Wrong lv%parms') + goto 9999 + end select + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Calling mlprcbld at level ',i + call amg_check_def(lv%parms%sweeps_pre,& + & 'Jacobi sweeps',izero,is_int_non_negative) + call amg_check_def(lv%parms%sweeps_post,& + & 'Jacobi sweeps',izero,is_int_non_negative) + + call lv%sm%build(lv%base_a,lv%base_desc,info) + if (info == 0) then + if (allocated(lv%sm2a)) then + call lv%sm2a%build(lv%base_a,lv%base_desc,info) + lv%sm2 => lv%sm2a + else + lv%sm2 => lv%sm + end if + end if + if (info /=0 ) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Smoother bld error') + goto 9999 + end if + + if (lv%sm%sv%is_global()) then + if ((lv%parms%sweeps_pre>1).or.(lv%parms%sweeps_post>1)) then + lv%parms%sweeps_pre = 1 + lv%parms%sweeps_post = 1 + if (me == 0) then + write(debug_unit,*) + if (present(ilv)) then + write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),& + & '" at level ',ilv + write(debug_unit,*) ' is configured as a global solver ' + else + write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),& + & '" is configured as a global solver ' + end if + write(debug_unit,*) ' Pre and post sweeps at this level reset to 1' + end if + end if + end if + + if (any((/present(amold),present(vmold),present(imold)/))) & + & call lv%cnv(info,amold=amold,vmold=vmold,imold=imold) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_base_onelev_build diff --git a/mlprec/impl/level/amg_d_base_onelev_check.f90 b/mlprec/impl/level/amg_d_base_onelev_check.f90 new file mode 100644 index 00000000..d37382d9 --- /dev/null +++ b/mlprec/impl/level/amg_d_base_onelev_check.f90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_onelev_check(lv,info) + + use psb_base_mod + use amg_d_onelev_mod, amg_protect_name => amg_d_base_onelev_check + + Implicit None + + ! Arguments + class(amg_d_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_onelev_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + call amg_check_def(lv%parms%sweeps_pre,& + & 'Jacobi sweeps',ione,is_int_non_negative) + call amg_check_def(lv%parms%sweeps_post,& + & 'Jacobi sweeps',ione,is_int_non_negative) + + if (allocated(lv%sm)) then + call lv%sm%check(info) + else + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + if (allocated(lv%sm2a)) then + call lv%sm2a%check(info) + else if (.not.inner_check(lv%sm2,lv%sm)) then + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +contains + function inner_check(smp,sm) result(res) + implicit none + logical :: res + class(amg_d_base_smoother_type), intent(in), pointer :: smp + class(amg_d_base_smoother_type), intent(in), target :: sm + + res = associated(smp, sm) + end function inner_check + +end subroutine amg_d_base_onelev_check diff --git a/mlprec/impl/level/amg_d_base_onelev_cnv.f90 b/mlprec/impl/level/amg_d_base_onelev_cnv.f90 new file mode 100644 index 00000000..aeb65854 --- /dev/null +++ b/mlprec/impl/level/amg_d_base_onelev_cnv.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_onelev_cnv(lv,info,amold,vmold,imold) + + use psb_base_mod + use amg_d_onelev_mod, amg_protect_name => amg_d_base_onelev_cnv + implicit none + + class(amg_d_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + integer(psb_ipk_) :: i + + info = psb_success_ + + if (any((/present(amold),present(vmold),present(imold)/))) then + if (allocated(lv%sm)) & + & call lv%sm%cnv(info,amold=amold,vmold=vmold,imold=imold) + if (info == psb_success_ .and. allocated(lv%sm2a)) & + & call lv%sm2a%cnv(info,amold=amold,vmold=vmold,imold=imold) + if (info == psb_success_ .and. allocated(lv%wrk)) & + & call lv%wrk%cnv(info,vmold=vmold) + if (info == psb_success_.and. lv%ac%is_asb()) & + & call lv%ac%cscnv(info,mold=amold) + if (info == psb_success_ .and. lv%desc_ac%is_ok() & + & .and. present(imold)) call lv%desc_ac%cnv(imold) + if (info == psb_success_) call lv%map%cnv(info,mold=amold,imold=imold) + end if +end subroutine amg_d_base_onelev_cnv diff --git a/mlprec/impl/level/amg_d_base_onelev_csetc.F90 b/mlprec/impl/level/amg_d_base_onelev_csetc.F90 new file mode 100644 index 00000000..5bef97d8 --- /dev/null +++ b/mlprec/impl/level/amg_d_base_onelev_csetc.F90 @@ -0,0 +1,312 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_onelev_csetc(lv,what,val,info,pos,idx) + + use psb_base_mod + use amg_d_onelev_mod, amg_protect_name => amg_d_base_onelev_csetc + use amg_d_base_aggregator_mod + use amg_d_dec_aggregator_mod + use amg_d_symdec_aggregator_mod + use amg_d_jac_smoother + use amg_d_as_smoother + use amg_d_diag_solver + use amg_d_l1_diag_solver + use amg_d_ilu_solver + use amg_d_id_solver + use amg_d_gs_solver +#if defined(HAVE_UMF_) + use amg_d_umf_solver +#endif +#if defined(HAVE_SLUDIST_) + use amg_d_sludist_solver +#endif +#if defined(HAVE_SLU_) + use amg_d_slu_solver +#endif +#if defined(HAVE_MUMPS_) + use amg_d_mumps_solver +#endif + + Implicit None + + ! Arguments + class(amg_d_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + ! Local + integer(psb_ipk_) :: ipos_, err_act + character(len=20) :: name='d_base_onelev_csetc' + integer(psb_ipk_) :: ival + type(amg_d_base_smoother_type) :: amg_d_base_smoother_mold + type(amg_d_jac_smoother_type) :: amg_d_jac_smoother_mold + type(amg_d_l1_jac_smoother_type) :: amg_d_l1_jac_smoother_mold + type(amg_d_as_smoother_type) :: amg_d_as_smoother_mold + type(amg_d_diag_solver_type) :: amg_d_diag_solver_mold + type(amg_d_l1_diag_solver_type) :: amg_d_l1_diag_solver_mold + type(amg_d_ilu_solver_type) :: amg_d_ilu_solver_mold + type(amg_d_id_solver_type) :: amg_d_id_solver_mold + type(amg_d_gs_solver_type) :: amg_d_gs_solver_mold + type(amg_d_bwgs_solver_type) :: amg_d_bwgs_solver_mold +#if defined(HAVE_UMF_) + type(amg_d_umf_solver_type) :: amg_d_umf_solver_mold +#endif +#if defined(HAVE_SLUDIST_) + type(amg_d_sludist_solver_type) :: amg_d_sludist_solver_mold +#endif +#if defined(HAVE_SLU_) + type(amg_d_slu_solver_type) :: amg_d_slu_solver_mold +#endif +#if defined(HAVE_MUMPS_) + type(amg_d_mumps_solver_type) :: amg_d_mumps_solver_mold +#endif + + + call psb_erractionsave(err_act) + + info = psb_success_ + + ival = lv%stringval(val) + + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + select case (psb_toupper(trim(what))) + case ('SMOOTHER_TYPE') + select case (psb_toupper(trim(val))) + case ('NOPREC','NONE') + call lv%set(amg_d_base_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_d_id_solver_mold,info,pos=pos) + + case ('JAC','JACOBI') + call lv%set(amg_d_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_d_diag_solver_mold,info,pos=pos) + + case ('L1-JACOBI') + call lv%set(amg_d_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_d_l1_diag_solver_mold,info,pos=pos) + + case ('BJAC') + call lv%set(amg_d_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_d_ilu_solver_mold,info,pos=pos) + + case ('L1-BJAC') + call lv%set(amg_d_l1_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_d_ilu_solver_mold,info,pos=pos) + + case ('AS') + call lv%set(amg_d_as_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_d_ilu_solver_mold,info,pos=pos) + + case ('GS','FWGS') + call lv%set(amg_d_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_d_gs_solver_mold,info,pos='pre') + if (allocated(lv%sm2a)) deallocate(lv%sm2a) + case ('BWGS') + call lv%set(amg_d_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_d_bwgs_solver_mold,info,pos='pre') + if (allocated(lv%sm2a)) deallocate(lv%sm2a) + case ('FBGS') + call lv%set(amg_d_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_d_gs_solver_mold,info,pos='pre') + call lv%set(amg_d_jac_smoother_mold,info,pos='post') + if (info == 0) call lv%set(amg_d_bwgs_solver_mold,info,pos='post') + case ('L1-GS','L1-FWGS') + call lv%set(amg_d_l1_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_d_gs_solver_mold,info,pos='pre') + if (allocated(lv%sm2a)) deallocate(lv%sm2a) + case ('L1-BWGS') + call lv%set(amg_d_l1_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_d_bwgs_solver_mold,info,pos='pre') + if (allocated(lv%sm2a)) deallocate(lv%sm2a) + case ('L1-FBGS') + call lv%set(amg_d_l1_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_d_gs_solver_mold,info,pos='pre') + call lv%set(amg_d_l1_jac_smoother_mold,info,pos='post') + if (info == 0) call lv%set(amg_d_bwgs_solver_mold,info,pos='post') + + case default + ! + ! Do nothing and hope for the best :) + ! + end select + if ((ipos_==amg_smooth_pre_).or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) call lv%sm%default() + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm2a)) call lv%sm2a%default() + end if + + + case('SUB_SOLVE') + select case (psb_toupper(trim(val))) + case ('NONE','NOPREC','FACT_NONE') + call lv%set(amg_d_id_solver_mold,info,pos=pos) + + case ('DIAG') + call lv%set(amg_d_diag_solver_mold,info,pos=pos) + + case ('L1-DIAG') + call lv%set(amg_d_l1_diag_solver_mold,info,pos=pos) + + case ('GS','FGS','FWGS') + call lv%set(amg_d_gs_solver_mold,info,pos=pos) + + case ('BGS','BWGS') + call lv%set(amg_d_bwgs_solver_mold,info,pos=pos) + + case ('ILU','ILUT','MILU') + call lv%set(amg_d_ilu_solver_mold,info,pos=pos) + if (info == 0) then + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + call lv%sm%sv%set('SUB_SOLVE',val,info) + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) call lv%sm2a%sv%set('SUB_SOLVE',val,info) + end if + end if +#ifdef HAVE_SLU_ + case ('SLU') + call lv%set(amg_d_slu_solver_mold,info,pos=pos) +#endif +#ifdef HAVE_MUMPS_ + case ('MUMPS') + call lv%set(amg_d_mumps_solver_mold,info,pos=pos) +#endif +#ifdef HAVE_SLUDIST_ + case ('SLUDIST') + call lv%set(amg_d_sludist_solver_mold,info,pos=pos) +#endif +#ifdef HAVE_UMF_ + case ('UMF') + call lv%set(amg_d_umf_solver_mold,info,pos=pos) +#endif + case default + ! + ! Do nothing and hope for the best :) + ! + end select + + case ('ML_CYCLE') + lv%parms%ml_cycle = amg_stringval(val) + + case ('PAR_AGGR_ALG') + ival = amg_stringval(val) + lv%parms%par_aggr_alg = ival + if (allocated(lv%aggr)) then + call lv%aggr%free(info) + if (info == 0) deallocate(lv%aggr,stat=info) + if (info /= 0) then + info = psb_err_internal_error_ + return + end if + end if + + select case(ival) + case(amg_dec_aggr_) + allocate(amg_d_dec_aggregator_type :: lv%aggr, stat=info) + case(amg_sym_dec_aggr_) + allocate(amg_d_symdec_aggregator_type :: lv%aggr, stat=info) + case default + info = psb_err_internal_error_ + end select + if (info == psb_success_) call lv%aggr%default() + + case ('AGGR_ORD') + lv%parms%aggr_ord = amg_stringval(val) + + case ('AGGR_TYPE') + lv%parms%aggr_type = amg_stringval(val) + if (allocated(lv%aggr)) call lv%aggr%set_aggr_type(lv%parms,info) + + case ('AGGR_PROL') + lv%parms%aggr_prol = amg_stringval(val) + + case ('COARSE_MAT') + lv%parms%coarse_mat = amg_stringval(val) + + case ('AGGR_OMEGA_ALG') + lv%parms%aggr_omega_alg= amg_stringval(val) + + case ('AGGR_EIG') + lv%parms%aggr_eig = amg_stringval(val) + + case ('AGGR_FILTER') + lv%parms%aggr_filter = amg_stringval(val) + + case ('COARSE_SOLVE') + lv%parms%coarse_solve = amg_stringval(val) + + case default + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) then + call lv%sm%set(what,val,info,idx=idx) + end if + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) then + call lv%sm2a%set(what,val,info,idx=idx) + end if + end if + if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) + + end select + + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_d_base_onelev_csetc diff --git a/mlprec/impl/level/amg_d_base_onelev_cseti.F90 b/mlprec/impl/level/amg_d_base_onelev_cseti.F90 new file mode 100644 index 00000000..a9cabdb8 --- /dev/null +++ b/mlprec/impl/level/amg_d_base_onelev_cseti.F90 @@ -0,0 +1,288 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_onelev_cseti(lv,what,val,info,pos,idx) + + use psb_base_mod + use amg_d_onelev_mod, amg_protect_name => amg_d_base_onelev_cseti + use amg_d_base_aggregator_mod + use amg_d_dec_aggregator_mod + use amg_d_symdec_aggregator_mod + use amg_d_jac_smoother + use amg_d_as_smoother + use amg_d_diag_solver + use amg_d_l1_diag_solver + use amg_d_ilu_solver + use amg_d_id_solver + use amg_d_gs_solver +#if defined(HAVE_UMF_) + use amg_d_umf_solver +#endif +#if defined(HAVE_SLUDIST_) + use amg_d_sludist_solver +#endif +#if defined(HAVE_SLU_) + use amg_d_slu_solver +#endif +#if defined(HAVE_MUMPS_) + use amg_d_mumps_solver +#endif + + Implicit None + + ! Arguments + class(amg_d_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + ! Local + integer(psb_ipk_) :: ipos_, err_act + character(len=20) :: name='d_base_onelev_cseti' + type(amg_d_base_smoother_type) :: amg_d_base_smoother_mold + type(amg_d_jac_smoother_type) :: amg_d_jac_smoother_mold + type(amg_d_l1_jac_smoother_type) :: amg_d_l1_jac_smoother_mold + type(amg_d_as_smoother_type) :: amg_d_as_smoother_mold + type(amg_d_diag_solver_type) :: amg_d_diag_solver_mold + type(amg_d_l1_diag_solver_type) :: amg_d_l1_diag_solver_mold + type(amg_d_ilu_solver_type) :: amg_d_ilu_solver_mold + type(amg_d_id_solver_type) :: amg_d_id_solver_mold + type(amg_d_gs_solver_type) :: amg_d_gs_solver_mold + type(amg_d_bwgs_solver_type) :: amg_d_bwgs_solver_mold +#if defined(HAVE_UMF_) + type(amg_d_umf_solver_type) :: amg_d_umf_solver_mold +#endif +#if defined(HAVE_SLUDIST_) + type(amg_d_sludist_solver_type) :: amg_d_sludist_solver_mold +#endif +#if defined(HAVE_SLU_) + type(amg_d_slu_solver_type) :: amg_d_slu_solver_mold +#endif +#if defined(HAVE_MUMPS_) + type(amg_d_mumps_solver_type) :: amg_d_mumps_solver_mold +#endif + + call psb_erractionsave(err_act) + info = psb_success_ + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + select case (psb_toupper(what)) + case ('SMOOTHER_TYPE') + select case (val) + case (amg_noprec_) + call lv%set(amg_d_base_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_d_id_solver_mold,info,pos=pos) + + case (amg_jac_) + call lv%set(amg_d_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_d_diag_solver_mold,info,pos=pos) + + case (amg_l1_jac_) + call lv%set(amg_d_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_d_l1_diag_solver_mold,info,pos=pos) + + case (amg_bjac_) + call lv%set(amg_d_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_d_ilu_solver_mold,info,pos=pos) + + case (amg_l1_bjac_) + call lv%set(amg_d_l1_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_d_ilu_solver_mold,info,pos=pos) + + case (amg_as_) + call lv%set(amg_d_as_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_d_ilu_solver_mold,info,pos=pos) + + case (amg_fbgs_) + call lv%set(amg_d_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_d_gs_solver_mold,info,pos='pre') + call lv%set(amg_d_jac_smoother_mold,info,pos='post') + if (info == 0) call lv%set(amg_d_bwgs_solver_mold,info,pos='post') + + case default + ! + ! Do nothing and hope for the best :) + ! + end select + if ((ipos_==amg_smooth_pre_).or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) call lv%sm%default() + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm2a)) call lv%sm2a%default() + end if + + + case('SUB_SOLVE') + select case (val) + case (amg_f_none_) + call lv%set(amg_d_id_solver_mold,info,pos=pos) + + case (amg_diag_scale_) + call lv%set(amg_d_diag_solver_mold,info,pos=pos) + + case (amg_l1_diag_scale_) + call lv%set(amg_d_l1_diag_solver_mold,info,pos=pos) + + case (amg_gs_) + call lv%set(amg_d_gs_solver_mold,info,pos=pos) + + case (amg_bwgs_) + call lv%set(amg_d_bwgs_solver_mold,info,pos=pos) + + case (psb_ilu_n_,psb_milu_n_,psb_ilu_t_) + call lv%set(amg_d_ilu_solver_mold,info,pos=pos) + if (info == 0) then + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + call lv%sm%sv%set('SUB_SOLVE',val,info) + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) call lv%sm2a%sv%set('SUB_SOLVE',val,info) + end if + end if +#ifdef HAVE_SLU_ + case (amg_slu_) + call lv%set(amg_d_slu_solver_mold,info,pos=pos) +#endif +#ifdef HAVE_MUMPS_ + case (amg_mumps_) + call lv%set(amg_d_mumps_solver_mold,info,pos=pos) +#endif +#ifdef HAVE_SLUDIST_ + case (amg_sludist_) + call lv%set(amg_d_sludist_solver_mold,info,pos=pos) +#endif +#ifdef HAVE_UMF_ + case (amg_umf_) + call lv%set(amg_d_umf_solver_mold,info,pos=pos) +#endif + case default + ! + ! Do nothing and hope for the best :) + ! + end select + + + case ('SMOOTHER_SWEEPS') + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) & + & lv%parms%sweeps_pre = val + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_)) & + & lv%parms%sweeps_post = val + + case ('ML_CYCLE') + lv%parms%ml_cycle = val + + case ('PAR_AGGR_ALG') + lv%parms%par_aggr_alg = val + if (allocated(lv%aggr)) then + call lv%aggr%free(info) + if (info == 0) deallocate(lv%aggr,stat=info) + if (info /= 0) then + info = psb_err_internal_error_ + return + end if + end if + + select case(val) + case(amg_dec_aggr_) + allocate(amg_d_dec_aggregator_type :: lv%aggr, stat=info) + case(amg_sym_dec_aggr_) + allocate(amg_d_symdec_aggregator_type :: lv%aggr, stat=info) + case default + info = psb_err_internal_error_ + end select + if (info == psb_success_) call lv%aggr%default() + + case ('AGGR_ORD') + lv%parms%aggr_ord = val + + case ('AGGR_TYPE') + lv%parms%aggr_type = val + if (allocated(lv%aggr)) call lv%aggr%set_aggr_type(lv%parms,info) + + case ('AGGR_PROL') + lv%parms%aggr_prol = val + + case ('COARSE_MAT') + lv%parms%coarse_mat = val + + case ('AGGR_OMEGA_ALG') + lv%parms%aggr_omega_alg= val + + case ('AGGR_EIG') + lv%parms%aggr_eig = val + + case ('AGGR_FILTER') + lv%parms%aggr_filter = val + + case ('COARSE_SOLVE') + lv%parms%coarse_solve = val + + case default + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) then + call lv%sm%set(what,val,info,idx=idx) + end if + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) then + call lv%sm2a%set(what,val,info,idx=idx) + end if + end if + if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) + + end select + if (info /= psb_success_) goto 9999 + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_d_base_onelev_cseti diff --git a/mlprec/impl/level/amg_d_base_onelev_csetr.f90 b/mlprec/impl/level/amg_d_base_onelev_csetr.f90 new file mode 100644 index 00000000..3c11bf30 --- /dev/null +++ b/mlprec/impl/level/amg_d_base_onelev_csetr.f90 @@ -0,0 +1,105 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_onelev_csetr(lv,what,val,info,pos,idx) + + use psb_base_mod + use amg_d_onelev_mod, amg_protect_name => amg_d_base_onelev_csetr + + Implicit None + + ! Arguments + class(amg_d_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + ! Local + integer(psb_ipk_) :: ipos_, err_act + character(len=20) :: name='d_base_onelev_csetr' + + call psb_erractionsave(err_act) + + + info = psb_success_ + + select case (psb_toupper(what)) + + case ('AGGR_OMEGA_VAL') + lv%parms%aggr_omega_val= val + + case ('AGGR_THRESH') + lv%parms%aggr_thresh = val + + case default + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) then + call lv%sm%set(what,val,info,idx=idx) + end if + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) then + call lv%sm2a%set(what,val,info,idx=idx) + end if + end if + if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) + + end select + + if (info /= psb_success_) goto 9999 + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_d_base_onelev_csetr diff --git a/mlprec/impl/level/amg_d_base_onelev_descr.f90 b/mlprec/impl/level/amg_d_base_onelev_descr.f90 new file mode 100644 index 00000000..abce7c32 --- /dev/null +++ b/mlprec/impl/level/amg_d_base_onelev_descr.f90 @@ -0,0 +1,112 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_onelev_descr(lv,il,nl,ilmin,info,iout) + + use psb_base_mod + use amg_d_onelev_mod, amg_protect_name => amg_d_base_onelev_descr + Implicit None + ! Arguments + class(amg_d_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: il,nl,ilmin + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_d_base_onelev_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse + + + call psb_erractionsave(err_act) + + + coarse = (il==nl) + + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + + write(iout_,*) + if (il == ilmin) then + call lv%parms%mlcycledsc(iout_,info) + if (allocated(lv%aggr)) then + call lv%aggr%descr(lv%parms,iout_,info) + else + write(iout_,*) 'Internal error: unallocated aggregator object' + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + write(iout_,*) + end if + + if (il > 1) then + + if (coarse) then + write(iout_,*) ' Level ',il,' (coarse)' + else + write(iout_,*) ' Level ',il + end if + + call lv%parms%descr(iout_,info,coarse=coarse) + + if (nl > 1) then + if (allocated(lv%map%naggr)) then + write(iout_,*) ' Coarse Matrix: Global size: ', & + & sum((1_psb_lpk_*lv%map%naggr(:))),' Nonzeros: ',lv%ac_nz_tot + write(iout_,*) ' Local matrix sizes: ', & + & lv%map%naggr(:) + write(iout_,*) ' Aggregation ratio: ', & + & lv%szratio + end if + end if + + if (coarse.and.allocated(lv%sm)) & + & call lv%sm%descr(info,iout=iout_,coarse=coarse) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_d_base_onelev_descr diff --git a/mlprec/impl/level/amg_d_base_onelev_dump.f90 b/mlprec/impl/level/amg_d_base_onelev_dump.f90 new file mode 100644 index 00000000..74b3cf46 --- /dev/null +++ b/mlprec/impl/level/amg_d_base_onelev_dump.f90 @@ -0,0 +1,169 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_onelev_dump(lv,level,info,prefix,head,ac,rp,& + & smoother,solver,tprol,global_num) + + use psb_base_mod + use amg_d_onelev_mod, amg_protect_name => amg_d_base_onelev_dump + implicit none + class(amg_d_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: ac, rp, smoother, solver, tprol, global_num + ! Local variables + integer(psb_ipk_) :: i, j, il1, iln, lname, lev, ni + integer(psb_ipk_) :: icontxt,iam, np + character(len=80) :: prefix_, frmt + character(len=1024) :: fname + logical :: ac_, rp_, tprol_, global_num_ + integer(psb_lpk_), allocatable :: ivr(:), ivc(:) + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_lev_d" + end if + + if (associated(lv%base_desc)) then + icontxt = lv%base_desc%get_context() + call psb_info(icontxt,iam,np) + else + icontxt = -1 + iam = -1 + np = -1 + end if + if (present(ac)) then + ac_ = ac + else + ac_ = .false. + end if + if (present(rp)) then + rp_ = rp + else + rp_ = .false. + end if + if (present(tprol)) then + tprol_ = tprol + else + tprol_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + + if (np > 0) then + ni = floor(log10(1.0*np)) + 1 + write(frmt,'(a,i3.3,a,i3.3,a)') '(a,i',ni,'.',ni,')' + write(fname(lname+1:lname+ni+2),frmt) '_p',iam + lname = lname + ni + 2 + end if + + if (global_num_) then + if (level >= 2) then + if (ac_) then + ivr = lv%desc_ac%get_global_indices(owned=.false.) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx' + call lv%ac%print(fname,head=head,iv=ivr) + end if + if (rp_) then + ivr = lv%map%p_desc_U%get_global_indices(owned=.false.) + ivc = lv%map%p_desc_V%get_global_indices(owned=.false.) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx' + call lv%map%mat_U2V%print(fname,head=head,ivr=ivc,ivc=ivr) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx' + call lv%map%mat_V2U%print(fname,head=head,ivr=ivr,ivc=ivc) + end if + if (tprol_) then + ! Tentative prolongator is stored with column indices already + ! in global numbering, so only IVR is needed. + ivr = lv%map%p_desc_U%get_global_indices(owned=.false.) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_tprol.mtx' + ! + ! This is not implemented yet. + !call lv%tprol%print(fname,head=head,ivr=ivr) + end if + end if + else + if (level >= 2) then + if (ac_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx' + call lv%ac%print(fname,head=head) + end if + if (rp_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx' + call lv%map%mat_U2V%print(fname,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx' + call lv%map%mat_V2U%print(fname,head=head) + end if + if (tprol_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_tprol.mtx' + ! + ! This is not implemented yet. + !call lv%tprol%print(fname,head=head) + end if + end if + end if + + if (level >= 2) then + if (allocated(lv%sm)) then + call lv%sm%dump(lv%desc_ac,level,info,smoother=smoother, & + & solver=solver,prefix=trim(prefix_)//"_sm",global_num=global_num) + end if + if (allocated(lv%sm2a)) then + call lv%sm2a%dump(lv%desc_ac,level,info,smoother=smoother, & + & solver=solver,prefix=trim(prefix_)//"_sm2a",global_num=global_num) + end if + else + if (allocated(lv%sm)) then + call lv%sm%dump(lv%base_desc,level,info,smoother=smoother, & + & solver=solver,prefix=trim(prefix_)//"_sm",global_num=global_num) + end if + if (allocated(lv%sm2a)) then + call lv%sm2a%dump(lv%base_desc,level,info,smoother=smoother, & + & solver=solver,prefix=trim(prefix_)//"_sm2a",global_num=global_num) + end if + end if + +end subroutine amg_d_base_onelev_dump diff --git a/mlprec/impl/level/amg_d_base_onelev_free.f90 b/mlprec/impl/level/amg_d_base_onelev_free.f90 new file mode 100644 index 00000000..4ca68c0b --- /dev/null +++ b/mlprec/impl/level/amg_d_base_onelev_free.f90 @@ -0,0 +1,75 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_onelev_free(lv,info) + + use psb_base_mod + use amg_d_onelev_mod, amg_protect_name => amg_d_base_onelev_free + implicit none + + class(amg_d_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: i + + info = psb_success_ + + ! We might just deallocate the top level array, except + ! that there may be inner objects containing C pointers, + ! e.g. UMFPACK, SLU or CUDA stuff. + ! We really need FINALs. + if (allocated(lv%sm)) & + & call lv%sm%free(info) + + if (allocated(lv%sm2a)) & + & call lv%sm2a%free(info) + + if (allocated(lv%wrk)) & + & call lv%wrk%free(info) + + call lv%ac%free() + if (lv%desc_ac%is_ok()) & + & call lv%desc_ac%free(info) + call lv%map%free(info) + + ! This is a pointer to something else, must not free it here. + nullify(lv%base_a) + ! This is a pointer to something else, must not free it here. + nullify(lv%base_desc) + + call lv%nullify() + +end subroutine amg_d_base_onelev_free diff --git a/mlprec/impl/level/amg_d_base_onelev_mat_asb.f90 b/mlprec/impl/level/amg_d_base_onelev_mat_asb.f90 new file mode 100644 index 00000000..530115f6 --- /dev/null +++ b/mlprec/impl/level/amg_d_base_onelev_mat_asb.f90 @@ -0,0 +1,178 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_d_onelev_mat_asb.f90 +! +! Subroutine: amg_d_onelev_mat_asb +! Version: real +! +! This routine builds the matrix associated to the current level of the +! multilevel preconditioner from the matrix associated to the previous level, +! by using the user-specified aggregation technique (therefore, it also builds the +! prolongation and restriction operators mapping the current level to the +! previous one and vice versa). +! The current level is regarded as the coarse one, while the previous as +! the fine one. This is in agreement with the fact that the routine is called, +! by amg_mlprec_bld, only on levels >=2. +! The main structure is: +! 1. Perform sanity checks; +! 2. Call amg_Xaggrmat_asb to compute prolongator/restrictor/AC +! 3. According to the choice of DIST/REPL for AC, build a descriptor DESC_AC, +! and adjust the column numbering of AC/OP_PROL/OP_RESTR +! 4. Pack restrictor and prolongator into p%map +! 5. Fix base_a and base_desc pointers. +! +! +! Arguments: +! p - type(amg_d_onelev_type), input/output. +! The 'one-level' data structure containing the control +! parameters and (eventually) coarse matrix and prolongator/restrictors. +! +! a - type(psb_dspmat_type). +! The sparse matrix structure containing the local part of the +! fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_dspmat_type), input/output +! The tentative prolongator on input, released on output. +! +! info - integer, output. +! Error code. +! +subroutine amg_d_base_onelev_mat_asb(lv,a,desc_a,ilaggr,nlaggr,t_prol,info) + + use psb_base_mod + use amg_base_prec_type + use amg_d_onelev_mod, amg_protect_name => amg_d_base_onelev_mat_asb + + implicit none + + ! Arguments + class(amg_d_onelev_type), intent(inout), target :: lv + type(psb_dspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + integer(psb_lpk_), intent(inout) :: ilaggr(:) + type(psb_ldspmat_type), intent(inout) :: t_prol + integer(psb_ipk_), intent(out) :: info + + + ! Local variables + character(len=24) :: name + integer(psb_ipk_) :: ictxt, np, me + integer(psb_ipk_) :: err_act + type(psb_dspmat_type) :: ac, op_restr, op_prol + integer(psb_ipk_) :: nzl, inl + integer(psb_ipk_) :: debug_level, debug_unit + + name='amg_d_onelev_mat_asb' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + call amg_check_def(lv%parms%aggr_prol,'Smoother',& + & amg_smooth_prol_,is_legal_ml_aggr_prol) + call amg_check_def(lv%parms%coarse_mat,'Coarse matrix',& + & amg_distr_mat_,is_legal_ml_coarse_mat) + call amg_check_def(lv%parms%aggr_filter,'Use filtered matrix',& + & amg_no_filter_mat_,is_legal_aggr_filter) + call amg_check_def(lv%parms%aggr_omega_alg,'Omega Alg.',& + & amg_eig_est_,is_legal_ml_aggr_omega_alg) + call amg_check_def(lv%parms%aggr_eig,'Eigenvalue estimate',& + & amg_max_norm_,is_legal_ml_aggr_eig) + call amg_check_def(lv%parms%aggr_omega_val,'Omega',dzero,is_legal_d_omega) + + + ! + ! Build the coarse-level matrix from the fine-level one, starting from + ! the mapping defined by amg_aggrmap_bld and applying the aggregation + ! algorithm specified by lv%iprcparm(amg_aggr_prol_) + ! + call lv%aggr%mat_bld(lv%parms,a,desc_a,ilaggr,nlaggr,& + & lv%ac,lv%desc_ac,op_prol,op_restr,t_prol,info) + + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_aggrmat_asb') + goto 9999 + end if + + ! + ! Now build its descriptor and convert global indices for + ! ac, op_restr and op_prol + ! + if (info == psb_success_) & + & call lv%aggr%mat_asb(lv%parms,a,desc_a,& + & lv%ac,lv%desc_ac,op_prol,op_restr,info) + + if (info == psb_success_) call lv%ac%cscnv(info,type='csr',dupl=psb_dupl_add_) + + if (info == psb_success_) call lv%aggr%bld_map(desc_a, lv%desc_ac,& + & ilaggr,nlaggr,op_restr,op_prol,lv%map,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='mat_asb/map_bld') + goto 9999 + end if + ! + ! Fix the base_a and base_desc pointers for handling of residuals. + ! This is correct because this routine is only called at levels >=2. + ! + lv%base_a => lv%ac + lv%base_desc => lv%desc_ac + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_d_base_onelev_mat_asb diff --git a/mlprec/impl/level/amg_d_base_onelev_setag.f90 b/mlprec/impl/level/amg_d_base_onelev_setag.f90 new file mode 100644 index 00000000..64fe46b5 --- /dev/null +++ b/mlprec/impl/level/amg_d_base_onelev_setag.f90 @@ -0,0 +1,82 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_onelev_setag(lv,val,info,pos) + + use psb_base_mod + use amg_d_onelev_mod, amg_protect_name => amg_d_base_onelev_setag + + implicit none + + ! Arguments + class(amg_d_onelev_type), target, intent(inout) :: lv + class(amg_d_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ipos_ + character(len=*), parameter :: name='amg_base_onelev_setag' + + info = psb_success_ + + ! Ignore pos for aggregator + + if (allocated(lv%aggr)) then + if (.not.same_type_as(lv%aggr,val)) then + call lv%aggr%free(info) + deallocate(lv%aggr,stat=info) + if (info /= 0) then + info = 3111 + return + end if + end if + end if + + if (.not.allocated(lv%aggr)) then + allocate(lv%aggr,mold=val,stat=info) + if (info /= 0) then + info = 3111 + return + end if + lv%parms%par_aggr_alg = amg_ext_aggr_ + lv%parms%aggr_type = amg_noalg_ + call lv%aggr%default() + end if + +end subroutine amg_d_base_onelev_setag + diff --git a/mlprec/impl/level/amg_d_base_onelev_setsm.F90 b/mlprec/impl/level/amg_d_base_onelev_setsm.F90 new file mode 100644 index 00000000..874c3dd2 --- /dev/null +++ b/mlprec/impl/level/amg_d_base_onelev_setsm.F90 @@ -0,0 +1,114 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_onelev_setsm(lev,val,info,pos) + + use psb_base_mod + use amg_d_prec_mod, amg_protect_name => amg_d_base_onelev_setsm + + implicit none + + ! Arguments + class(amg_d_onelev_type), target, intent(inout) :: lev + class(amg_d_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ipos_ + character(len=*), parameter :: name='amg_base_onelev_setsm' + + info = psb_success_ + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + if (ipos_ == amg_smooth_both_) then + if (allocated(lev%sm2a)) then + call lev%sm2a%free(info) + deallocate(lev%sm2a, stat=info) + lev%sm2 => null() + end if + end if + + select case(ipos_) + case(amg_smooth_pre_, amg_smooth_both_) + if (allocated(lev%sm)) then + if (.not.same_type_as(lev%sm,val)) then + call lev%sm%free(info) + deallocate(lev%sm, stat=info) + end if + endif + if (.not.allocated(lev%sm)) then +#ifdef HAVE_MOLD + allocate(lev%sm,mold=val) +#else + allocate(lev%sm,source=val) +#endif + end if + call lev%sm%default() + if (ipos_ == amg_smooth_both_) lev%sm2 => lev%sm + case(amg_smooth_post_) + if (allocated(lev%sm2a)) then + if (.not.same_type_as(lev%sm2a,val)) then + call lev%sm2a%free(info) + deallocate(lev%sm2a, stat=info) + endif + end if + if (.not.allocated(lev%sm2a)) then +#ifdef HAVE_MOLD + allocate(lev%sm2a,mold=val) +#else + allocate(lev%sm2a,source=val) +#endif + end if + call lev%sm2a%default() + lev%sm2 => lev%sm2a + end select + +end subroutine amg_d_base_onelev_setsm + diff --git a/mlprec/impl/level/amg_d_base_onelev_setsv.F90 b/mlprec/impl/level/amg_d_base_onelev_setsv.F90 new file mode 100644 index 00000000..82987235 --- /dev/null +++ b/mlprec/impl/level/amg_d_base_onelev_setsv.F90 @@ -0,0 +1,152 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_onelev_setsv(lev,val,info,pos) + + use psb_base_mod + use amg_d_prec_mod, amg_protect_name => amg_d_base_onelev_setsv + + implicit none + + ! Arguments + class(amg_d_onelev_type), target, intent(inout) :: lev + class(amg_d_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ipos_ + character(len=*), parameter :: name='amg_base_onelev_setsv' + + info = psb_success_ + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + if ((ipos_ == amg_smooth_pre_).or.(ipos_ == amg_smooth_both_)) then + if (allocated(lev%sm)) then + if (allocated(lev%sm%sv)) then + if (.not.same_type_as(lev%sm%sv,val)) then + call lev%sm%sv%free(info) + if (info == 0) deallocate(lev%sm%sv,stat=info) + if (info /= 0) then + info = 3111 + return + end if + end if + end if + + if (.not.allocated(lev%sm%sv)) then +#ifdef HAVE_MOLD + allocate(lev%sm%sv,mold=val,stat=info) +#else + allocate(lev%sm%sv,source=val,stat=info) +#endif + if (info /= 0) then + info = 3111 + return + end if + end if + call lev%sm%sv%default() + else + info = 3111 + write(psb_err_unit,*) name,& + &': Error: uninitialized preconditioner component,',& + &' should call amg_PRECINIT/amg_PRECSET' + return + + end if + end if + + ! + ! If POS was not specified and therefore we have amg_smooth_both_ + ! we need to update sm2a *only* if it was already allocated, + ! otherwise it is not needed (since we have just fixed %sm in the + ! pre section). + ! + + if ((ipos_ == amg_smooth_post_).or. & + ((ipos_ == amg_smooth_both_).and.(allocated(lev%sm2a)))) then + + + if (allocated(lev%sm2a)) then + if (allocated(lev%sm2a%sv)) then + if (.not.same_type_as(lev%sm2a%sv,val)) then + call lev%sm2a%sv%free(info) + if (info == 0) deallocate(lev%sm2a%sv,stat=info) + if (info /= 0) then + info = 3111 + return + end if + end if + end if + if (.not.allocated(lev%sm2a%sv)) then +#ifdef HAVE_MOLD + allocate(lev%sm2a%sv,mold=val,stat=info) +#else + allocate(lev%sm2a%sv,source=val,stat=info) +#endif + if (info /= 0) then + info = 3111 + return + end if + end if + call lev%sm2a%sv%default() + + else + info = 3111 + write(psb_err_unit,*) name,& + &': Error: uninitialized preconditioner component,',& + &' should call amg_PRECINIT/amg_PRECSET' + return + + end if + + end if + +end subroutine amg_d_base_onelev_setsv + diff --git a/mlprec/impl/level/amg_s_base_onelev_build.f90 b/mlprec/impl/level/amg_s_base_onelev_build.f90 new file mode 100644 index 00000000..e8e3d5a6 --- /dev/null +++ b/mlprec/impl/level/amg_s_base_onelev_build.f90 @@ -0,0 +1,153 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_onelev_build(lv,info,amold,vmold,imold,ilv) + use psb_base_mod + use amg_s_onelev_mod, amg_protect_name => amg_s_base_onelev_build + implicit none + class(amg_s_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + integer(psb_ipk_), intent(in), optional :: ilv + ! Local + integer(psb_ipk_) :: err,i,k, err_act + integer(psb_ipk_) :: ictxt, me, np + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + + name = 'amg_onelev_build' + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + if (.not.associated(lv%base_desc)) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Unassociated base DESC') + goto 9999 + end if + info = psb_success_ + ictxt = lv%base_desc%get_ctxt() + call psb_info(ictxt,me,np) + + if (.not.allocated(lv%sm)) then + !! Error: should have called amg_dprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + if (.not.allocated(lv%sm%sv)) then + !! Error: should have called amg_dprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + lv%ac_nz_loc = lv%ac%get_nzeros() + lv%ac_nz_tot = lv%ac_nz_loc + select case(lv%parms%coarse_mat) + case(amg_distr_mat_) + call psb_sum(ictxt,lv%ac_nz_tot) + case(amg_repl_mat_) + ! Do nothing + case default + ! Should never get here + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='Wrong lv%parms') + goto 9999 + end select + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Calling mlprcbld at level ',i + call amg_check_def(lv%parms%sweeps_pre,& + & 'Jacobi sweeps',izero,is_int_non_negative) + call amg_check_def(lv%parms%sweeps_post,& + & 'Jacobi sweeps',izero,is_int_non_negative) + + call lv%sm%build(lv%base_a,lv%base_desc,info) + if (info == 0) then + if (allocated(lv%sm2a)) then + call lv%sm2a%build(lv%base_a,lv%base_desc,info) + lv%sm2 => lv%sm2a + else + lv%sm2 => lv%sm + end if + end if + if (info /=0 ) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Smoother bld error') + goto 9999 + end if + + if (lv%sm%sv%is_global()) then + if ((lv%parms%sweeps_pre>1).or.(lv%parms%sweeps_post>1)) then + lv%parms%sweeps_pre = 1 + lv%parms%sweeps_post = 1 + if (me == 0) then + write(debug_unit,*) + if (present(ilv)) then + write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),& + & '" at level ',ilv + write(debug_unit,*) ' is configured as a global solver ' + else + write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),& + & '" is configured as a global solver ' + end if + write(debug_unit,*) ' Pre and post sweeps at this level reset to 1' + end if + end if + end if + + if (any((/present(amold),present(vmold),present(imold)/))) & + & call lv%cnv(info,amold=amold,vmold=vmold,imold=imold) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_base_onelev_build diff --git a/mlprec/impl/level/amg_s_base_onelev_check.f90 b/mlprec/impl/level/amg_s_base_onelev_check.f90 new file mode 100644 index 00000000..0fbdb3ee --- /dev/null +++ b/mlprec/impl/level/amg_s_base_onelev_check.f90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_onelev_check(lv,info) + + use psb_base_mod + use amg_s_onelev_mod, amg_protect_name => amg_s_base_onelev_check + + Implicit None + + ! Arguments + class(amg_s_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_onelev_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + call amg_check_def(lv%parms%sweeps_pre,& + & 'Jacobi sweeps',ione,is_int_non_negative) + call amg_check_def(lv%parms%sweeps_post,& + & 'Jacobi sweeps',ione,is_int_non_negative) + + if (allocated(lv%sm)) then + call lv%sm%check(info) + else + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + if (allocated(lv%sm2a)) then + call lv%sm2a%check(info) + else if (.not.inner_check(lv%sm2,lv%sm)) then + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +contains + function inner_check(smp,sm) result(res) + implicit none + logical :: res + class(amg_s_base_smoother_type), intent(in), pointer :: smp + class(amg_s_base_smoother_type), intent(in), target :: sm + + res = associated(smp, sm) + end function inner_check + +end subroutine amg_s_base_onelev_check diff --git a/mlprec/impl/level/amg_s_base_onelev_cnv.f90 b/mlprec/impl/level/amg_s_base_onelev_cnv.f90 new file mode 100644 index 00000000..32dd2782 --- /dev/null +++ b/mlprec/impl/level/amg_s_base_onelev_cnv.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_onelev_cnv(lv,info,amold,vmold,imold) + + use psb_base_mod + use amg_s_onelev_mod, amg_protect_name => amg_s_base_onelev_cnv + implicit none + + class(amg_s_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + integer(psb_ipk_) :: i + + info = psb_success_ + + if (any((/present(amold),present(vmold),present(imold)/))) then + if (allocated(lv%sm)) & + & call lv%sm%cnv(info,amold=amold,vmold=vmold,imold=imold) + if (info == psb_success_ .and. allocated(lv%sm2a)) & + & call lv%sm2a%cnv(info,amold=amold,vmold=vmold,imold=imold) + if (info == psb_success_ .and. allocated(lv%wrk)) & + & call lv%wrk%cnv(info,vmold=vmold) + if (info == psb_success_.and. lv%ac%is_asb()) & + & call lv%ac%cscnv(info,mold=amold) + if (info == psb_success_ .and. lv%desc_ac%is_ok() & + & .and. present(imold)) call lv%desc_ac%cnv(imold) + if (info == psb_success_) call lv%map%cnv(info,mold=amold,imold=imold) + end if +end subroutine amg_s_base_onelev_cnv diff --git a/mlprec/impl/level/amg_s_base_onelev_csetc.F90 b/mlprec/impl/level/amg_s_base_onelev_csetc.F90 new file mode 100644 index 00000000..c717438c --- /dev/null +++ b/mlprec/impl/level/amg_s_base_onelev_csetc.F90 @@ -0,0 +1,292 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_onelev_csetc(lv,what,val,info,pos,idx) + + use psb_base_mod + use amg_s_onelev_mod, amg_protect_name => amg_s_base_onelev_csetc + use amg_s_base_aggregator_mod + use amg_s_dec_aggregator_mod + use amg_s_symdec_aggregator_mod + use amg_s_jac_smoother + use amg_s_as_smoother + use amg_s_diag_solver + use amg_s_l1_diag_solver + use amg_s_ilu_solver + use amg_s_id_solver + use amg_s_gs_solver +#if defined(HAVE_SLU_) + use amg_s_slu_solver +#endif +#if defined(HAVE_MUMPS_) + use amg_s_mumps_solver +#endif + + Implicit None + + ! Arguments + class(amg_s_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + ! Local + integer(psb_ipk_) :: ipos_, err_act + character(len=20) :: name='s_base_onelev_csetc' + integer(psb_ipk_) :: ival + type(amg_s_base_smoother_type) :: amg_s_base_smoother_mold + type(amg_s_jac_smoother_type) :: amg_s_jac_smoother_mold + type(amg_s_l1_jac_smoother_type) :: amg_s_l1_jac_smoother_mold + type(amg_s_as_smoother_type) :: amg_s_as_smoother_mold + type(amg_s_diag_solver_type) :: amg_s_diag_solver_mold + type(amg_s_l1_diag_solver_type) :: amg_s_l1_diag_solver_mold + type(amg_s_ilu_solver_type) :: amg_s_ilu_solver_mold + type(amg_s_id_solver_type) :: amg_s_id_solver_mold + type(amg_s_gs_solver_type) :: amg_s_gs_solver_mold + type(amg_s_bwgs_solver_type) :: amg_s_bwgs_solver_mold +#if defined(HAVE_SLU_) + type(amg_s_slu_solver_type) :: amg_s_slu_solver_mold +#endif +#if defined(HAVE_MUMPS_) + type(amg_s_mumps_solver_type) :: amg_s_mumps_solver_mold +#endif + + + call psb_erractionsave(err_act) + + info = psb_success_ + + ival = lv%stringval(val) + + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + select case (psb_toupper(trim(what))) + case ('SMOOTHER_TYPE') + select case (psb_toupper(trim(val))) + case ('NOPREC','NONE') + call lv%set(amg_s_base_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_s_id_solver_mold,info,pos=pos) + + case ('JAC','JACOBI') + call lv%set(amg_s_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_s_diag_solver_mold,info,pos=pos) + + case ('L1-JACOBI') + call lv%set(amg_s_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_s_l1_diag_solver_mold,info,pos=pos) + + case ('BJAC') + call lv%set(amg_s_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_s_ilu_solver_mold,info,pos=pos) + + case ('L1-BJAC') + call lv%set(amg_s_l1_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_s_ilu_solver_mold,info,pos=pos) + + case ('AS') + call lv%set(amg_s_as_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_s_ilu_solver_mold,info,pos=pos) + + case ('GS','FWGS') + call lv%set(amg_s_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_s_gs_solver_mold,info,pos='pre') + if (allocated(lv%sm2a)) deallocate(lv%sm2a) + case ('BWGS') + call lv%set(amg_s_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_s_bwgs_solver_mold,info,pos='pre') + if (allocated(lv%sm2a)) deallocate(lv%sm2a) + case ('FBGS') + call lv%set(amg_s_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_s_gs_solver_mold,info,pos='pre') + call lv%set(amg_s_jac_smoother_mold,info,pos='post') + if (info == 0) call lv%set(amg_s_bwgs_solver_mold,info,pos='post') + case ('L1-GS','L1-FWGS') + call lv%set(amg_s_l1_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_s_gs_solver_mold,info,pos='pre') + if (allocated(lv%sm2a)) deallocate(lv%sm2a) + case ('L1-BWGS') + call lv%set(amg_s_l1_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_s_bwgs_solver_mold,info,pos='pre') + if (allocated(lv%sm2a)) deallocate(lv%sm2a) + case ('L1-FBGS') + call lv%set(amg_s_l1_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_s_gs_solver_mold,info,pos='pre') + call lv%set(amg_s_l1_jac_smoother_mold,info,pos='post') + if (info == 0) call lv%set(amg_s_bwgs_solver_mold,info,pos='post') + + case default + ! + ! Do nothing and hope for the best :) + ! + end select + if ((ipos_==amg_smooth_pre_).or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) call lv%sm%default() + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm2a)) call lv%sm2a%default() + end if + + + case('SUB_SOLVE') + select case (psb_toupper(trim(val))) + case ('NONE','NOPREC','FACT_NONE') + call lv%set(amg_s_id_solver_mold,info,pos=pos) + + case ('DIAG') + call lv%set(amg_s_diag_solver_mold,info,pos=pos) + + case ('L1-DIAG') + call lv%set(amg_s_l1_diag_solver_mold,info,pos=pos) + + case ('GS','FGS','FWGS') + call lv%set(amg_s_gs_solver_mold,info,pos=pos) + + case ('BGS','BWGS') + call lv%set(amg_s_bwgs_solver_mold,info,pos=pos) + + case ('ILU','ILUT','MILU') + call lv%set(amg_s_ilu_solver_mold,info,pos=pos) + if (info == 0) then + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + call lv%sm%sv%set('SUB_SOLVE',val,info) + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) call lv%sm2a%sv%set('SUB_SOLVE',val,info) + end if + end if +#ifdef HAVE_SLU_ + case ('SLU') + call lv%set(amg_s_slu_solver_mold,info,pos=pos) +#endif +#ifdef HAVE_MUMPS_ + case ('MUMPS') + call lv%set(amg_s_mumps_solver_mold,info,pos=pos) +#endif + case default + ! + ! Do nothing and hope for the best :) + ! + end select + + case ('ML_CYCLE') + lv%parms%ml_cycle = amg_stringval(val) + + case ('PAR_AGGR_ALG') + ival = amg_stringval(val) + lv%parms%par_aggr_alg = ival + if (allocated(lv%aggr)) then + call lv%aggr%free(info) + if (info == 0) deallocate(lv%aggr,stat=info) + if (info /= 0) then + info = psb_err_internal_error_ + return + end if + end if + + select case(ival) + case(amg_dec_aggr_) + allocate(amg_s_dec_aggregator_type :: lv%aggr, stat=info) + case(amg_sym_dec_aggr_) + allocate(amg_s_symdec_aggregator_type :: lv%aggr, stat=info) + case default + info = psb_err_internal_error_ + end select + if (info == psb_success_) call lv%aggr%default() + + case ('AGGR_ORD') + lv%parms%aggr_ord = amg_stringval(val) + + case ('AGGR_TYPE') + lv%parms%aggr_type = amg_stringval(val) + if (allocated(lv%aggr)) call lv%aggr%set_aggr_type(lv%parms,info) + + case ('AGGR_PROL') + lv%parms%aggr_prol = amg_stringval(val) + + case ('COARSE_MAT') + lv%parms%coarse_mat = amg_stringval(val) + + case ('AGGR_OMEGA_ALG') + lv%parms%aggr_omega_alg= amg_stringval(val) + + case ('AGGR_EIG') + lv%parms%aggr_eig = amg_stringval(val) + + case ('AGGR_FILTER') + lv%parms%aggr_filter = amg_stringval(val) + + case ('COARSE_SOLVE') + lv%parms%coarse_solve = amg_stringval(val) + + case default + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) then + call lv%sm%set(what,val,info,idx=idx) + end if + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) then + call lv%sm2a%set(what,val,info,idx=idx) + end if + end if + if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) + + end select + + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_s_base_onelev_csetc diff --git a/mlprec/impl/level/amg_s_base_onelev_cseti.F90 b/mlprec/impl/level/amg_s_base_onelev_cseti.F90 new file mode 100644 index 00000000..22cb1bfd --- /dev/null +++ b/mlprec/impl/level/amg_s_base_onelev_cseti.F90 @@ -0,0 +1,268 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_onelev_cseti(lv,what,val,info,pos,idx) + + use psb_base_mod + use amg_s_onelev_mod, amg_protect_name => amg_s_base_onelev_cseti + use amg_s_base_aggregator_mod + use amg_s_dec_aggregator_mod + use amg_s_symdec_aggregator_mod + use amg_s_jac_smoother + use amg_s_as_smoother + use amg_s_diag_solver + use amg_s_l1_diag_solver + use amg_s_ilu_solver + use amg_s_id_solver + use amg_s_gs_solver +#if defined(HAVE_SLU_) + use amg_s_slu_solver +#endif +#if defined(HAVE_MUMPS_) + use amg_s_mumps_solver +#endif + + Implicit None + + ! Arguments + class(amg_s_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + ! Local + integer(psb_ipk_) :: ipos_, err_act + character(len=20) :: name='s_base_onelev_cseti' + type(amg_s_base_smoother_type) :: amg_s_base_smoother_mold + type(amg_s_jac_smoother_type) :: amg_s_jac_smoother_mold + type(amg_s_l1_jac_smoother_type) :: amg_s_l1_jac_smoother_mold + type(amg_s_as_smoother_type) :: amg_s_as_smoother_mold + type(amg_s_diag_solver_type) :: amg_s_diag_solver_mold + type(amg_s_l1_diag_solver_type) :: amg_s_l1_diag_solver_mold + type(amg_s_ilu_solver_type) :: amg_s_ilu_solver_mold + type(amg_s_id_solver_type) :: amg_s_id_solver_mold + type(amg_s_gs_solver_type) :: amg_s_gs_solver_mold + type(amg_s_bwgs_solver_type) :: amg_s_bwgs_solver_mold +#if defined(HAVE_SLU_) + type(amg_s_slu_solver_type) :: amg_s_slu_solver_mold +#endif +#if defined(HAVE_MUMPS_) + type(amg_s_mumps_solver_type) :: amg_s_mumps_solver_mold +#endif + + call psb_erractionsave(err_act) + info = psb_success_ + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + select case (psb_toupper(what)) + case ('SMOOTHER_TYPE') + select case (val) + case (amg_noprec_) + call lv%set(amg_s_base_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_s_id_solver_mold,info,pos=pos) + + case (amg_jac_) + call lv%set(amg_s_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_s_diag_solver_mold,info,pos=pos) + + case (amg_l1_jac_) + call lv%set(amg_s_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_s_l1_diag_solver_mold,info,pos=pos) + + case (amg_bjac_) + call lv%set(amg_s_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_s_ilu_solver_mold,info,pos=pos) + + case (amg_l1_bjac_) + call lv%set(amg_s_l1_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_s_ilu_solver_mold,info,pos=pos) + + case (amg_as_) + call lv%set(amg_s_as_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_s_ilu_solver_mold,info,pos=pos) + + case (amg_fbgs_) + call lv%set(amg_s_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_s_gs_solver_mold,info,pos='pre') + call lv%set(amg_s_jac_smoother_mold,info,pos='post') + if (info == 0) call lv%set(amg_s_bwgs_solver_mold,info,pos='post') + + case default + ! + ! Do nothing and hope for the best :) + ! + end select + if ((ipos_==amg_smooth_pre_).or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) call lv%sm%default() + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm2a)) call lv%sm2a%default() + end if + + + case('SUB_SOLVE') + select case (val) + case (amg_f_none_) + call lv%set(amg_s_id_solver_mold,info,pos=pos) + + case (amg_diag_scale_) + call lv%set(amg_s_diag_solver_mold,info,pos=pos) + + case (amg_l1_diag_scale_) + call lv%set(amg_s_l1_diag_solver_mold,info,pos=pos) + + case (amg_gs_) + call lv%set(amg_s_gs_solver_mold,info,pos=pos) + + case (amg_bwgs_) + call lv%set(amg_s_bwgs_solver_mold,info,pos=pos) + + case (psb_ilu_n_,psb_milu_n_,psb_ilu_t_) + call lv%set(amg_s_ilu_solver_mold,info,pos=pos) + if (info == 0) then + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + call lv%sm%sv%set('SUB_SOLVE',val,info) + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) call lv%sm2a%sv%set('SUB_SOLVE',val,info) + end if + end if +#ifdef HAVE_SLU_ + case (amg_slu_) + call lv%set(amg_s_slu_solver_mold,info,pos=pos) +#endif +#ifdef HAVE_MUMPS_ + case (amg_mumps_) + call lv%set(amg_s_mumps_solver_mold,info,pos=pos) +#endif + case default + ! + ! Do nothing and hope for the best :) + ! + end select + + + case ('SMOOTHER_SWEEPS') + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) & + & lv%parms%sweeps_pre = val + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_)) & + & lv%parms%sweeps_post = val + + case ('ML_CYCLE') + lv%parms%ml_cycle = val + + case ('PAR_AGGR_ALG') + lv%parms%par_aggr_alg = val + if (allocated(lv%aggr)) then + call lv%aggr%free(info) + if (info == 0) deallocate(lv%aggr,stat=info) + if (info /= 0) then + info = psb_err_internal_error_ + return + end if + end if + + select case(val) + case(amg_dec_aggr_) + allocate(amg_s_dec_aggregator_type :: lv%aggr, stat=info) + case(amg_sym_dec_aggr_) + allocate(amg_s_symdec_aggregator_type :: lv%aggr, stat=info) + case default + info = psb_err_internal_error_ + end select + if (info == psb_success_) call lv%aggr%default() + + case ('AGGR_ORD') + lv%parms%aggr_ord = val + + case ('AGGR_TYPE') + lv%parms%aggr_type = val + if (allocated(lv%aggr)) call lv%aggr%set_aggr_type(lv%parms,info) + + case ('AGGR_PROL') + lv%parms%aggr_prol = val + + case ('COARSE_MAT') + lv%parms%coarse_mat = val + + case ('AGGR_OMEGA_ALG') + lv%parms%aggr_omega_alg= val + + case ('AGGR_EIG') + lv%parms%aggr_eig = val + + case ('AGGR_FILTER') + lv%parms%aggr_filter = val + + case ('COARSE_SOLVE') + lv%parms%coarse_solve = val + + case default + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) then + call lv%sm%set(what,val,info,idx=idx) + end if + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) then + call lv%sm2a%set(what,val,info,idx=idx) + end if + end if + if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) + + end select + if (info /= psb_success_) goto 9999 + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_s_base_onelev_cseti diff --git a/mlprec/impl/level/amg_s_base_onelev_csetr.f90 b/mlprec/impl/level/amg_s_base_onelev_csetr.f90 new file mode 100644 index 00000000..566d5319 --- /dev/null +++ b/mlprec/impl/level/amg_s_base_onelev_csetr.f90 @@ -0,0 +1,105 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_onelev_csetr(lv,what,val,info,pos,idx) + + use psb_base_mod + use amg_s_onelev_mod, amg_protect_name => amg_s_base_onelev_csetr + + Implicit None + + ! Arguments + class(amg_s_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + ! Local + integer(psb_ipk_) :: ipos_, err_act + character(len=20) :: name='s_base_onelev_csetr' + + call psb_erractionsave(err_act) + + + info = psb_success_ + + select case (psb_toupper(what)) + + case ('AGGR_OMEGA_VAL') + lv%parms%aggr_omega_val= val + + case ('AGGR_THRESH') + lv%parms%aggr_thresh = val + + case default + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) then + call lv%sm%set(what,val,info,idx=idx) + end if + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) then + call lv%sm2a%set(what,val,info,idx=idx) + end if + end if + if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) + + end select + + if (info /= psb_success_) goto 9999 + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_s_base_onelev_csetr diff --git a/mlprec/impl/level/amg_s_base_onelev_descr.f90 b/mlprec/impl/level/amg_s_base_onelev_descr.f90 new file mode 100644 index 00000000..0c7f072f --- /dev/null +++ b/mlprec/impl/level/amg_s_base_onelev_descr.f90 @@ -0,0 +1,112 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_onelev_descr(lv,il,nl,ilmin,info,iout) + + use psb_base_mod + use amg_s_onelev_mod, amg_protect_name => amg_s_base_onelev_descr + Implicit None + ! Arguments + class(amg_s_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: il,nl,ilmin + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_s_base_onelev_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse + + + call psb_erractionsave(err_act) + + + coarse = (il==nl) + + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + + write(iout_,*) + if (il == ilmin) then + call lv%parms%mlcycledsc(iout_,info) + if (allocated(lv%aggr)) then + call lv%aggr%descr(lv%parms,iout_,info) + else + write(iout_,*) 'Internal error: unallocated aggregator object' + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + write(iout_,*) + end if + + if (il > 1) then + + if (coarse) then + write(iout_,*) ' Level ',il,' (coarse)' + else + write(iout_,*) ' Level ',il + end if + + call lv%parms%descr(iout_,info,coarse=coarse) + + if (nl > 1) then + if (allocated(lv%map%naggr)) then + write(iout_,*) ' Coarse Matrix: Global size: ', & + & sum((1_psb_lpk_*lv%map%naggr(:))),' Nonzeros: ',lv%ac_nz_tot + write(iout_,*) ' Local matrix sizes: ', & + & lv%map%naggr(:) + write(iout_,*) ' Aggregation ratio: ', & + & lv%szratio + end if + end if + + if (coarse.and.allocated(lv%sm)) & + & call lv%sm%descr(info,iout=iout_,coarse=coarse) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_s_base_onelev_descr diff --git a/mlprec/impl/level/amg_s_base_onelev_dump.f90 b/mlprec/impl/level/amg_s_base_onelev_dump.f90 new file mode 100644 index 00000000..6a9b1ece --- /dev/null +++ b/mlprec/impl/level/amg_s_base_onelev_dump.f90 @@ -0,0 +1,169 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_onelev_dump(lv,level,info,prefix,head,ac,rp,& + & smoother,solver,tprol,global_num) + + use psb_base_mod + use amg_s_onelev_mod, amg_protect_name => amg_s_base_onelev_dump + implicit none + class(amg_s_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: ac, rp, smoother, solver, tprol, global_num + ! Local variables + integer(psb_ipk_) :: i, j, il1, iln, lname, lev, ni + integer(psb_ipk_) :: icontxt,iam, np + character(len=80) :: prefix_, frmt + character(len=1024) :: fname + logical :: ac_, rp_, tprol_, global_num_ + integer(psb_lpk_), allocatable :: ivr(:), ivc(:) + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_lev_s" + end if + + if (associated(lv%base_desc)) then + icontxt = lv%base_desc%get_context() + call psb_info(icontxt,iam,np) + else + icontxt = -1 + iam = -1 + np = -1 + end if + if (present(ac)) then + ac_ = ac + else + ac_ = .false. + end if + if (present(rp)) then + rp_ = rp + else + rp_ = .false. + end if + if (present(tprol)) then + tprol_ = tprol + else + tprol_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + + if (np > 0) then + ni = floor(log10(1.0*np)) + 1 + write(frmt,'(a,i3.3,a,i3.3,a)') '(a,i',ni,'.',ni,')' + write(fname(lname+1:lname+ni+2),frmt) '_p',iam + lname = lname + ni + 2 + end if + + if (global_num_) then + if (level >= 2) then + if (ac_) then + ivr = lv%desc_ac%get_global_indices(owned=.false.) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx' + call lv%ac%print(fname,head=head,iv=ivr) + end if + if (rp_) then + ivr = lv%map%p_desc_U%get_global_indices(owned=.false.) + ivc = lv%map%p_desc_V%get_global_indices(owned=.false.) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx' + call lv%map%mat_U2V%print(fname,head=head,ivr=ivc,ivc=ivr) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx' + call lv%map%mat_V2U%print(fname,head=head,ivr=ivr,ivc=ivc) + end if + if (tprol_) then + ! Tentative prolongator is stored with column indices already + ! in global numbering, so only IVR is needed. + ivr = lv%map%p_desc_U%get_global_indices(owned=.false.) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_tprol.mtx' + ! + ! This is not implemented yet. + !call lv%tprol%print(fname,head=head,ivr=ivr) + end if + end if + else + if (level >= 2) then + if (ac_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx' + call lv%ac%print(fname,head=head) + end if + if (rp_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx' + call lv%map%mat_U2V%print(fname,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx' + call lv%map%mat_V2U%print(fname,head=head) + end if + if (tprol_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_tprol.mtx' + ! + ! This is not implemented yet. + !call lv%tprol%print(fname,head=head) + end if + end if + end if + + if (level >= 2) then + if (allocated(lv%sm)) then + call lv%sm%dump(lv%desc_ac,level,info,smoother=smoother, & + & solver=solver,prefix=trim(prefix_)//"_sm",global_num=global_num) + end if + if (allocated(lv%sm2a)) then + call lv%sm2a%dump(lv%desc_ac,level,info,smoother=smoother, & + & solver=solver,prefix=trim(prefix_)//"_sm2a",global_num=global_num) + end if + else + if (allocated(lv%sm)) then + call lv%sm%dump(lv%base_desc,level,info,smoother=smoother, & + & solver=solver,prefix=trim(prefix_)//"_sm",global_num=global_num) + end if + if (allocated(lv%sm2a)) then + call lv%sm2a%dump(lv%base_desc,level,info,smoother=smoother, & + & solver=solver,prefix=trim(prefix_)//"_sm2a",global_num=global_num) + end if + end if + +end subroutine amg_s_base_onelev_dump diff --git a/mlprec/impl/level/amg_s_base_onelev_free.f90 b/mlprec/impl/level/amg_s_base_onelev_free.f90 new file mode 100644 index 00000000..1e83c04a --- /dev/null +++ b/mlprec/impl/level/amg_s_base_onelev_free.f90 @@ -0,0 +1,75 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_onelev_free(lv,info) + + use psb_base_mod + use amg_s_onelev_mod, amg_protect_name => amg_s_base_onelev_free + implicit none + + class(amg_s_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: i + + info = psb_success_ + + ! We might just deallocate the top level array, except + ! that there may be inner objects containing C pointers, + ! e.g. UMFPACK, SLU or CUDA stuff. + ! We really need FINALs. + if (allocated(lv%sm)) & + & call lv%sm%free(info) + + if (allocated(lv%sm2a)) & + & call lv%sm2a%free(info) + + if (allocated(lv%wrk)) & + & call lv%wrk%free(info) + + call lv%ac%free() + if (lv%desc_ac%is_ok()) & + & call lv%desc_ac%free(info) + call lv%map%free(info) + + ! This is a pointer to something else, must not free it here. + nullify(lv%base_a) + ! This is a pointer to something else, must not free it here. + nullify(lv%base_desc) + + call lv%nullify() + +end subroutine amg_s_base_onelev_free diff --git a/mlprec/impl/level/amg_s_base_onelev_mat_asb.f90 b/mlprec/impl/level/amg_s_base_onelev_mat_asb.f90 new file mode 100644 index 00000000..926232a6 --- /dev/null +++ b/mlprec/impl/level/amg_s_base_onelev_mat_asb.f90 @@ -0,0 +1,178 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_s_onelev_mat_asb.f90 +! +! Subroutine: amg_s_onelev_mat_asb +! Version: real +! +! This routine builds the matrix associated to the current level of the +! multilevel preconditioner from the matrix associated to the previous level, +! by using the user-specified aggregation technique (therefore, it also builds the +! prolongation and restriction operators mapping the current level to the +! previous one and vice versa). +! The current level is regarded as the coarse one, while the previous as +! the fine one. This is in agreement with the fact that the routine is called, +! by amg_mlprec_bld, only on levels >=2. +! The main structure is: +! 1. Perform sanity checks; +! 2. Call amg_Xaggrmat_asb to compute prolongator/restrictor/AC +! 3. According to the choice of DIST/REPL for AC, build a descriptor DESC_AC, +! and adjust the column numbering of AC/OP_PROL/OP_RESTR +! 4. Pack restrictor and prolongator into p%map +! 5. Fix base_a and base_desc pointers. +! +! +! Arguments: +! p - type(amg_s_onelev_type), input/output. +! The 'one-level' data structure containing the control +! parameters and (eventually) coarse matrix and prolongator/restrictors. +! +! a - type(psb_sspmat_type). +! The sparse matrix structure containing the local part of the +! fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_sspmat_type), input/output +! The tentative prolongator on input, released on output. +! +! info - integer, output. +! Error code. +! +subroutine amg_s_base_onelev_mat_asb(lv,a,desc_a,ilaggr,nlaggr,t_prol,info) + + use psb_base_mod + use amg_base_prec_type + use amg_s_onelev_mod, amg_protect_name => amg_s_base_onelev_mat_asb + + implicit none + + ! Arguments + class(amg_s_onelev_type), intent(inout), target :: lv + type(psb_sspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + integer(psb_lpk_), intent(inout) :: ilaggr(:) + type(psb_lsspmat_type), intent(inout) :: t_prol + integer(psb_ipk_), intent(out) :: info + + + ! Local variables + character(len=24) :: name + integer(psb_ipk_) :: ictxt, np, me + integer(psb_ipk_) :: err_act + type(psb_sspmat_type) :: ac, op_restr, op_prol + integer(psb_ipk_) :: nzl, inl + integer(psb_ipk_) :: debug_level, debug_unit + + name='amg_s_onelev_mat_asb' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + call amg_check_def(lv%parms%aggr_prol,'Smoother',& + & amg_smooth_prol_,is_legal_ml_aggr_prol) + call amg_check_def(lv%parms%coarse_mat,'Coarse matrix',& + & amg_distr_mat_,is_legal_ml_coarse_mat) + call amg_check_def(lv%parms%aggr_filter,'Use filtered matrix',& + & amg_no_filter_mat_,is_legal_aggr_filter) + call amg_check_def(lv%parms%aggr_omega_alg,'Omega Alg.',& + & amg_eig_est_,is_legal_ml_aggr_omega_alg) + call amg_check_def(lv%parms%aggr_eig,'Eigenvalue estimate',& + & amg_max_norm_,is_legal_ml_aggr_eig) + call amg_check_def(lv%parms%aggr_omega_val,'Omega',szero,is_legal_s_omega) + + + ! + ! Build the coarse-level matrix from the fine-level one, starting from + ! the mapping defined by amg_aggrmap_bld and applying the aggregation + ! algorithm specified by lv%iprcparm(amg_aggr_prol_) + ! + call lv%aggr%mat_bld(lv%parms,a,desc_a,ilaggr,nlaggr,& + & lv%ac,lv%desc_ac,op_prol,op_restr,t_prol,info) + + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_aggrmat_asb') + goto 9999 + end if + + ! + ! Now build its descriptor and convert global indices for + ! ac, op_restr and op_prol + ! + if (info == psb_success_) & + & call lv%aggr%mat_asb(lv%parms,a,desc_a,& + & lv%ac,lv%desc_ac,op_prol,op_restr,info) + + if (info == psb_success_) call lv%ac%cscnv(info,type='csr',dupl=psb_dupl_add_) + + if (info == psb_success_) call lv%aggr%bld_map(desc_a, lv%desc_ac,& + & ilaggr,nlaggr,op_restr,op_prol,lv%map,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='mat_asb/map_bld') + goto 9999 + end if + ! + ! Fix the base_a and base_desc pointers for handling of residuals. + ! This is correct because this routine is only called at levels >=2. + ! + lv%base_a => lv%ac + lv%base_desc => lv%desc_ac + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_s_base_onelev_mat_asb diff --git a/mlprec/impl/level/amg_s_base_onelev_setag.f90 b/mlprec/impl/level/amg_s_base_onelev_setag.f90 new file mode 100644 index 00000000..9f442a6a --- /dev/null +++ b/mlprec/impl/level/amg_s_base_onelev_setag.f90 @@ -0,0 +1,82 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_onelev_setag(lv,val,info,pos) + + use psb_base_mod + use amg_s_onelev_mod, amg_protect_name => amg_s_base_onelev_setag + + implicit none + + ! Arguments + class(amg_s_onelev_type), target, intent(inout) :: lv + class(amg_s_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ipos_ + character(len=*), parameter :: name='amg_base_onelev_setag' + + info = psb_success_ + + ! Ignore pos for aggregator + + if (allocated(lv%aggr)) then + if (.not.same_type_as(lv%aggr,val)) then + call lv%aggr%free(info) + deallocate(lv%aggr,stat=info) + if (info /= 0) then + info = 3111 + return + end if + end if + end if + + if (.not.allocated(lv%aggr)) then + allocate(lv%aggr,mold=val,stat=info) + if (info /= 0) then + info = 3111 + return + end if + lv%parms%par_aggr_alg = amg_ext_aggr_ + lv%parms%aggr_type = amg_noalg_ + call lv%aggr%default() + end if + +end subroutine amg_s_base_onelev_setag + diff --git a/mlprec/impl/level/amg_s_base_onelev_setsm.F90 b/mlprec/impl/level/amg_s_base_onelev_setsm.F90 new file mode 100644 index 00000000..e28775fb --- /dev/null +++ b/mlprec/impl/level/amg_s_base_onelev_setsm.F90 @@ -0,0 +1,114 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_onelev_setsm(lev,val,info,pos) + + use psb_base_mod + use amg_s_prec_mod, amg_protect_name => amg_s_base_onelev_setsm + + implicit none + + ! Arguments + class(amg_s_onelev_type), target, intent(inout) :: lev + class(amg_s_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ipos_ + character(len=*), parameter :: name='amg_base_onelev_setsm' + + info = psb_success_ + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + if (ipos_ == amg_smooth_both_) then + if (allocated(lev%sm2a)) then + call lev%sm2a%free(info) + deallocate(lev%sm2a, stat=info) + lev%sm2 => null() + end if + end if + + select case(ipos_) + case(amg_smooth_pre_, amg_smooth_both_) + if (allocated(lev%sm)) then + if (.not.same_type_as(lev%sm,val)) then + call lev%sm%free(info) + deallocate(lev%sm, stat=info) + end if + endif + if (.not.allocated(lev%sm)) then +#ifdef HAVE_MOLD + allocate(lev%sm,mold=val) +#else + allocate(lev%sm,source=val) +#endif + end if + call lev%sm%default() + if (ipos_ == amg_smooth_both_) lev%sm2 => lev%sm + case(amg_smooth_post_) + if (allocated(lev%sm2a)) then + if (.not.same_type_as(lev%sm2a,val)) then + call lev%sm2a%free(info) + deallocate(lev%sm2a, stat=info) + endif + end if + if (.not.allocated(lev%sm2a)) then +#ifdef HAVE_MOLD + allocate(lev%sm2a,mold=val) +#else + allocate(lev%sm2a,source=val) +#endif + end if + call lev%sm2a%default() + lev%sm2 => lev%sm2a + end select + +end subroutine amg_s_base_onelev_setsm + diff --git a/mlprec/impl/level/amg_s_base_onelev_setsv.F90 b/mlprec/impl/level/amg_s_base_onelev_setsv.F90 new file mode 100644 index 00000000..0c1cb3c2 --- /dev/null +++ b/mlprec/impl/level/amg_s_base_onelev_setsv.F90 @@ -0,0 +1,152 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_onelev_setsv(lev,val,info,pos) + + use psb_base_mod + use amg_s_prec_mod, amg_protect_name => amg_s_base_onelev_setsv + + implicit none + + ! Arguments + class(amg_s_onelev_type), target, intent(inout) :: lev + class(amg_s_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ipos_ + character(len=*), parameter :: name='amg_base_onelev_setsv' + + info = psb_success_ + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + if ((ipos_ == amg_smooth_pre_).or.(ipos_ == amg_smooth_both_)) then + if (allocated(lev%sm)) then + if (allocated(lev%sm%sv)) then + if (.not.same_type_as(lev%sm%sv,val)) then + call lev%sm%sv%free(info) + if (info == 0) deallocate(lev%sm%sv,stat=info) + if (info /= 0) then + info = 3111 + return + end if + end if + end if + + if (.not.allocated(lev%sm%sv)) then +#ifdef HAVE_MOLD + allocate(lev%sm%sv,mold=val,stat=info) +#else + allocate(lev%sm%sv,source=val,stat=info) +#endif + if (info /= 0) then + info = 3111 + return + end if + end if + call lev%sm%sv%default() + else + info = 3111 + write(psb_err_unit,*) name,& + &': Error: uninitialized preconditioner component,',& + &' should call amg_PRECINIT/amg_PRECSET' + return + + end if + end if + + ! + ! If POS was not specified and therefore we have amg_smooth_both_ + ! we need to update sm2a *only* if it was already allocated, + ! otherwise it is not needed (since we have just fixed %sm in the + ! pre section). + ! + + if ((ipos_ == amg_smooth_post_).or. & + ((ipos_ == amg_smooth_both_).and.(allocated(lev%sm2a)))) then + + + if (allocated(lev%sm2a)) then + if (allocated(lev%sm2a%sv)) then + if (.not.same_type_as(lev%sm2a%sv,val)) then + call lev%sm2a%sv%free(info) + if (info == 0) deallocate(lev%sm2a%sv,stat=info) + if (info /= 0) then + info = 3111 + return + end if + end if + end if + if (.not.allocated(lev%sm2a%sv)) then +#ifdef HAVE_MOLD + allocate(lev%sm2a%sv,mold=val,stat=info) +#else + allocate(lev%sm2a%sv,source=val,stat=info) +#endif + if (info /= 0) then + info = 3111 + return + end if + end if + call lev%sm2a%sv%default() + + else + info = 3111 + write(psb_err_unit,*) name,& + &': Error: uninitialized preconditioner component,',& + &' should call amg_PRECINIT/amg_PRECSET' + return + + end if + + end if + +end subroutine amg_s_base_onelev_setsv + diff --git a/mlprec/impl/level/amg_z_base_onelev_build.f90 b/mlprec/impl/level/amg_z_base_onelev_build.f90 new file mode 100644 index 00000000..ef69cecc --- /dev/null +++ b/mlprec/impl/level/amg_z_base_onelev_build.f90 @@ -0,0 +1,153 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_onelev_build(lv,info,amold,vmold,imold,ilv) + use psb_base_mod + use amg_z_onelev_mod, amg_protect_name => amg_z_base_onelev_build + implicit none + class(amg_z_onelev_type), target, intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + integer(psb_ipk_), intent(in), optional :: ilv + ! Local + integer(psb_ipk_) :: err,i,k, err_act + integer(psb_ipk_) :: ictxt, me, np + integer(psb_ipk_) :: debug_level, debug_unit + character(len=20) :: name, ch_err + + name = 'amg_onelev_build' + info=psb_success_ + err=0 + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + if (.not.associated(lv%base_desc)) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Unassociated base DESC') + goto 9999 + end if + info = psb_success_ + ictxt = lv%base_desc%get_ctxt() + call psb_info(ictxt,me,np) + + if (.not.allocated(lv%sm)) then + !! Error: should have called amg_dprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + if (.not.allocated(lv%sm%sv)) then + !! Error: should have called amg_dprecinit + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + lv%ac_nz_loc = lv%ac%get_nzeros() + lv%ac_nz_tot = lv%ac_nz_loc + select case(lv%parms%coarse_mat) + case(amg_distr_mat_) + call psb_sum(ictxt,lv%ac_nz_tot) + case(amg_repl_mat_) + ! Do nothing + case default + ! Should never get here + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='Wrong lv%parms') + goto 9999 + end select + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Calling mlprcbld at level ',i + call amg_check_def(lv%parms%sweeps_pre,& + & 'Jacobi sweeps',izero,is_int_non_negative) + call amg_check_def(lv%parms%sweeps_post,& + & 'Jacobi sweeps',izero,is_int_non_negative) + + call lv%sm%build(lv%base_a,lv%base_desc,info) + if (info == 0) then + if (allocated(lv%sm2a)) then + call lv%sm2a%build(lv%base_a,lv%base_desc,info) + lv%sm2 => lv%sm2a + else + lv%sm2 => lv%sm + end if + end if + if (info /=0 ) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Smoother bld error') + goto 9999 + end if + + if (lv%sm%sv%is_global()) then + if ((lv%parms%sweeps_pre>1).or.(lv%parms%sweeps_post>1)) then + lv%parms%sweeps_pre = 1 + lv%parms%sweeps_post = 1 + if (me == 0) then + write(debug_unit,*) + if (present(ilv)) then + write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),& + & '" at level ',ilv + write(debug_unit,*) ' is configured as a global solver ' + else + write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),& + & '" is configured as a global solver ' + end if + write(debug_unit,*) ' Pre and post sweeps at this level reset to 1' + end if + end if + end if + + if (any((/present(amold),present(vmold),present(imold)/))) & + & call lv%cnv(info,amold=amold,vmold=vmold,imold=imold) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_base_onelev_build diff --git a/mlprec/impl/level/amg_z_base_onelev_check.f90 b/mlprec/impl/level/amg_z_base_onelev_check.f90 new file mode 100644 index 00000000..45422b70 --- /dev/null +++ b/mlprec/impl/level/amg_z_base_onelev_check.f90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_onelev_check(lv,info) + + use psb_base_mod + use amg_z_onelev_mod, amg_protect_name => amg_z_base_onelev_check + + Implicit None + + ! Arguments + class(amg_z_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_onelev_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + call amg_check_def(lv%parms%sweeps_pre,& + & 'Jacobi sweeps',ione,is_int_non_negative) + call amg_check_def(lv%parms%sweeps_post,& + & 'Jacobi sweeps',ione,is_int_non_negative) + + if (allocated(lv%sm)) then + call lv%sm%check(info) + else + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + if (allocated(lv%sm2a)) then + call lv%sm2a%check(info) + else if (.not.inner_check(lv%sm2,lv%sm)) then + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +contains + function inner_check(smp,sm) result(res) + implicit none + logical :: res + class(amg_z_base_smoother_type), intent(in), pointer :: smp + class(amg_z_base_smoother_type), intent(in), target :: sm + + res = associated(smp, sm) + end function inner_check + +end subroutine amg_z_base_onelev_check diff --git a/mlprec/impl/level/amg_z_base_onelev_cnv.f90 b/mlprec/impl/level/amg_z_base_onelev_cnv.f90 new file mode 100644 index 00000000..f1337669 --- /dev/null +++ b/mlprec/impl/level/amg_z_base_onelev_cnv.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_onelev_cnv(lv,info,amold,vmold,imold) + + use psb_base_mod + use amg_z_onelev_mod, amg_protect_name => amg_z_base_onelev_cnv + implicit none + + class(amg_z_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + integer(psb_ipk_) :: i + + info = psb_success_ + + if (any((/present(amold),present(vmold),present(imold)/))) then + if (allocated(lv%sm)) & + & call lv%sm%cnv(info,amold=amold,vmold=vmold,imold=imold) + if (info == psb_success_ .and. allocated(lv%sm2a)) & + & call lv%sm2a%cnv(info,amold=amold,vmold=vmold,imold=imold) + if (info == psb_success_ .and. allocated(lv%wrk)) & + & call lv%wrk%cnv(info,vmold=vmold) + if (info == psb_success_.and. lv%ac%is_asb()) & + & call lv%ac%cscnv(info,mold=amold) + if (info == psb_success_ .and. lv%desc_ac%is_ok() & + & .and. present(imold)) call lv%desc_ac%cnv(imold) + if (info == psb_success_) call lv%map%cnv(info,mold=amold,imold=imold) + end if +end subroutine amg_z_base_onelev_cnv diff --git a/mlprec/impl/level/amg_z_base_onelev_csetc.F90 b/mlprec/impl/level/amg_z_base_onelev_csetc.F90 new file mode 100644 index 00000000..aab12526 --- /dev/null +++ b/mlprec/impl/level/amg_z_base_onelev_csetc.F90 @@ -0,0 +1,312 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_onelev_csetc(lv,what,val,info,pos,idx) + + use psb_base_mod + use amg_z_onelev_mod, amg_protect_name => amg_z_base_onelev_csetc + use amg_z_base_aggregator_mod + use amg_z_dec_aggregator_mod + use amg_z_symdec_aggregator_mod + use amg_z_jac_smoother + use amg_z_as_smoother + use amg_z_diag_solver + use amg_z_l1_diag_solver + use amg_z_ilu_solver + use amg_z_id_solver + use amg_z_gs_solver +#if defined(HAVE_UMF_) + use amg_z_umf_solver +#endif +#if defined(HAVE_SLUDIST_) + use amg_z_sludist_solver +#endif +#if defined(HAVE_SLU_) + use amg_z_slu_solver +#endif +#if defined(HAVE_MUMPS_) + use amg_z_mumps_solver +#endif + + Implicit None + + ! Arguments + class(amg_z_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + ! Local + integer(psb_ipk_) :: ipos_, err_act + character(len=20) :: name='z_base_onelev_csetc' + integer(psb_ipk_) :: ival + type(amg_z_base_smoother_type) :: amg_z_base_smoother_mold + type(amg_z_jac_smoother_type) :: amg_z_jac_smoother_mold + type(amg_z_l1_jac_smoother_type) :: amg_z_l1_jac_smoother_mold + type(amg_z_as_smoother_type) :: amg_z_as_smoother_mold + type(amg_z_diag_solver_type) :: amg_z_diag_solver_mold + type(amg_z_l1_diag_solver_type) :: amg_z_l1_diag_solver_mold + type(amg_z_ilu_solver_type) :: amg_z_ilu_solver_mold + type(amg_z_id_solver_type) :: amg_z_id_solver_mold + type(amg_z_gs_solver_type) :: amg_z_gs_solver_mold + type(amg_z_bwgs_solver_type) :: amg_z_bwgs_solver_mold +#if defined(HAVE_UMF_) + type(amg_z_umf_solver_type) :: amg_z_umf_solver_mold +#endif +#if defined(HAVE_SLUDIST_) + type(amg_z_sludist_solver_type) :: amg_z_sludist_solver_mold +#endif +#if defined(HAVE_SLU_) + type(amg_z_slu_solver_type) :: amg_z_slu_solver_mold +#endif +#if defined(HAVE_MUMPS_) + type(amg_z_mumps_solver_type) :: amg_z_mumps_solver_mold +#endif + + + call psb_erractionsave(err_act) + + info = psb_success_ + + ival = lv%stringval(val) + + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + select case (psb_toupper(trim(what))) + case ('SMOOTHER_TYPE') + select case (psb_toupper(trim(val))) + case ('NOPREC','NONE') + call lv%set(amg_z_base_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_z_id_solver_mold,info,pos=pos) + + case ('JAC','JACOBI') + call lv%set(amg_z_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_z_diag_solver_mold,info,pos=pos) + + case ('L1-JACOBI') + call lv%set(amg_z_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_z_l1_diag_solver_mold,info,pos=pos) + + case ('BJAC') + call lv%set(amg_z_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_z_ilu_solver_mold,info,pos=pos) + + case ('L1-BJAC') + call lv%set(amg_z_l1_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_z_ilu_solver_mold,info,pos=pos) + + case ('AS') + call lv%set(amg_z_as_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_z_ilu_solver_mold,info,pos=pos) + + case ('GS','FWGS') + call lv%set(amg_z_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_z_gs_solver_mold,info,pos='pre') + if (allocated(lv%sm2a)) deallocate(lv%sm2a) + case ('BWGS') + call lv%set(amg_z_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_z_bwgs_solver_mold,info,pos='pre') + if (allocated(lv%sm2a)) deallocate(lv%sm2a) + case ('FBGS') + call lv%set(amg_z_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_z_gs_solver_mold,info,pos='pre') + call lv%set(amg_z_jac_smoother_mold,info,pos='post') + if (info == 0) call lv%set(amg_z_bwgs_solver_mold,info,pos='post') + case ('L1-GS','L1-FWGS') + call lv%set(amg_z_l1_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_z_gs_solver_mold,info,pos='pre') + if (allocated(lv%sm2a)) deallocate(lv%sm2a) + case ('L1-BWGS') + call lv%set(amg_z_l1_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_z_bwgs_solver_mold,info,pos='pre') + if (allocated(lv%sm2a)) deallocate(lv%sm2a) + case ('L1-FBGS') + call lv%set(amg_z_l1_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_z_gs_solver_mold,info,pos='pre') + call lv%set(amg_z_l1_jac_smoother_mold,info,pos='post') + if (info == 0) call lv%set(amg_z_bwgs_solver_mold,info,pos='post') + + case default + ! + ! Do nothing and hope for the best :) + ! + end select + if ((ipos_==amg_smooth_pre_).or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) call lv%sm%default() + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm2a)) call lv%sm2a%default() + end if + + + case('SUB_SOLVE') + select case (psb_toupper(trim(val))) + case ('NONE','NOPREC','FACT_NONE') + call lv%set(amg_z_id_solver_mold,info,pos=pos) + + case ('DIAG') + call lv%set(amg_z_diag_solver_mold,info,pos=pos) + + case ('L1-DIAG') + call lv%set(amg_z_l1_diag_solver_mold,info,pos=pos) + + case ('GS','FGS','FWGS') + call lv%set(amg_z_gs_solver_mold,info,pos=pos) + + case ('BGS','BWGS') + call lv%set(amg_z_bwgs_solver_mold,info,pos=pos) + + case ('ILU','ILUT','MILU') + call lv%set(amg_z_ilu_solver_mold,info,pos=pos) + if (info == 0) then + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + call lv%sm%sv%set('SUB_SOLVE',val,info) + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) call lv%sm2a%sv%set('SUB_SOLVE',val,info) + end if + end if +#ifdef HAVE_SLU_ + case ('SLU') + call lv%set(amg_z_slu_solver_mold,info,pos=pos) +#endif +#ifdef HAVE_MUMPS_ + case ('MUMPS') + call lv%set(amg_z_mumps_solver_mold,info,pos=pos) +#endif +#ifdef HAVE_SLUDIST_ + case ('SLUDIST') + call lv%set(amg_z_sludist_solver_mold,info,pos=pos) +#endif +#ifdef HAVE_UMF_ + case ('UMF') + call lv%set(amg_z_umf_solver_mold,info,pos=pos) +#endif + case default + ! + ! Do nothing and hope for the best :) + ! + end select + + case ('ML_CYCLE') + lv%parms%ml_cycle = amg_stringval(val) + + case ('PAR_AGGR_ALG') + ival = amg_stringval(val) + lv%parms%par_aggr_alg = ival + if (allocated(lv%aggr)) then + call lv%aggr%free(info) + if (info == 0) deallocate(lv%aggr,stat=info) + if (info /= 0) then + info = psb_err_internal_error_ + return + end if + end if + + select case(ival) + case(amg_dec_aggr_) + allocate(amg_z_dec_aggregator_type :: lv%aggr, stat=info) + case(amg_sym_dec_aggr_) + allocate(amg_z_symdec_aggregator_type :: lv%aggr, stat=info) + case default + info = psb_err_internal_error_ + end select + if (info == psb_success_) call lv%aggr%default() + + case ('AGGR_ORD') + lv%parms%aggr_ord = amg_stringval(val) + + case ('AGGR_TYPE') + lv%parms%aggr_type = amg_stringval(val) + if (allocated(lv%aggr)) call lv%aggr%set_aggr_type(lv%parms,info) + + case ('AGGR_PROL') + lv%parms%aggr_prol = amg_stringval(val) + + case ('COARSE_MAT') + lv%parms%coarse_mat = amg_stringval(val) + + case ('AGGR_OMEGA_ALG') + lv%parms%aggr_omega_alg= amg_stringval(val) + + case ('AGGR_EIG') + lv%parms%aggr_eig = amg_stringval(val) + + case ('AGGR_FILTER') + lv%parms%aggr_filter = amg_stringval(val) + + case ('COARSE_SOLVE') + lv%parms%coarse_solve = amg_stringval(val) + + case default + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) then + call lv%sm%set(what,val,info,idx=idx) + end if + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) then + call lv%sm2a%set(what,val,info,idx=idx) + end if + end if + if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) + + end select + + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_z_base_onelev_csetc diff --git a/mlprec/impl/level/amg_z_base_onelev_cseti.F90 b/mlprec/impl/level/amg_z_base_onelev_cseti.F90 new file mode 100644 index 00000000..a8b36e88 --- /dev/null +++ b/mlprec/impl/level/amg_z_base_onelev_cseti.F90 @@ -0,0 +1,288 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_onelev_cseti(lv,what,val,info,pos,idx) + + use psb_base_mod + use amg_z_onelev_mod, amg_protect_name => amg_z_base_onelev_cseti + use amg_z_base_aggregator_mod + use amg_z_dec_aggregator_mod + use amg_z_symdec_aggregator_mod + use amg_z_jac_smoother + use amg_z_as_smoother + use amg_z_diag_solver + use amg_z_l1_diag_solver + use amg_z_ilu_solver + use amg_z_id_solver + use amg_z_gs_solver +#if defined(HAVE_UMF_) + use amg_z_umf_solver +#endif +#if defined(HAVE_SLUDIST_) + use amg_z_sludist_solver +#endif +#if defined(HAVE_SLU_) + use amg_z_slu_solver +#endif +#if defined(HAVE_MUMPS_) + use amg_z_mumps_solver +#endif + + Implicit None + + ! Arguments + class(amg_z_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + ! Local + integer(psb_ipk_) :: ipos_, err_act + character(len=20) :: name='z_base_onelev_cseti' + type(amg_z_base_smoother_type) :: amg_z_base_smoother_mold + type(amg_z_jac_smoother_type) :: amg_z_jac_smoother_mold + type(amg_z_l1_jac_smoother_type) :: amg_z_l1_jac_smoother_mold + type(amg_z_as_smoother_type) :: amg_z_as_smoother_mold + type(amg_z_diag_solver_type) :: amg_z_diag_solver_mold + type(amg_z_l1_diag_solver_type) :: amg_z_l1_diag_solver_mold + type(amg_z_ilu_solver_type) :: amg_z_ilu_solver_mold + type(amg_z_id_solver_type) :: amg_z_id_solver_mold + type(amg_z_gs_solver_type) :: amg_z_gs_solver_mold + type(amg_z_bwgs_solver_type) :: amg_z_bwgs_solver_mold +#if defined(HAVE_UMF_) + type(amg_z_umf_solver_type) :: amg_z_umf_solver_mold +#endif +#if defined(HAVE_SLUDIST_) + type(amg_z_sludist_solver_type) :: amg_z_sludist_solver_mold +#endif +#if defined(HAVE_SLU_) + type(amg_z_slu_solver_type) :: amg_z_slu_solver_mold +#endif +#if defined(HAVE_MUMPS_) + type(amg_z_mumps_solver_type) :: amg_z_mumps_solver_mold +#endif + + call psb_erractionsave(err_act) + info = psb_success_ + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + select case (psb_toupper(what)) + case ('SMOOTHER_TYPE') + select case (val) + case (amg_noprec_) + call lv%set(amg_z_base_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_z_id_solver_mold,info,pos=pos) + + case (amg_jac_) + call lv%set(amg_z_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_z_diag_solver_mold,info,pos=pos) + + case (amg_l1_jac_) + call lv%set(amg_z_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_z_l1_diag_solver_mold,info,pos=pos) + + case (amg_bjac_) + call lv%set(amg_z_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_z_ilu_solver_mold,info,pos=pos) + + case (amg_l1_bjac_) + call lv%set(amg_z_l1_jac_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_z_ilu_solver_mold,info,pos=pos) + + case (amg_as_) + call lv%set(amg_z_as_smoother_mold,info,pos=pos) + if (info == 0) call lv%set(amg_z_ilu_solver_mold,info,pos=pos) + + case (amg_fbgs_) + call lv%set(amg_z_jac_smoother_mold,info,pos='pre') + if (info == 0) call lv%set(amg_z_gs_solver_mold,info,pos='pre') + call lv%set(amg_z_jac_smoother_mold,info,pos='post') + if (info == 0) call lv%set(amg_z_bwgs_solver_mold,info,pos='post') + + case default + ! + ! Do nothing and hope for the best :) + ! + end select + if ((ipos_==amg_smooth_pre_).or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) call lv%sm%default() + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm2a)) call lv%sm2a%default() + end if + + + case('SUB_SOLVE') + select case (val) + case (amg_f_none_) + call lv%set(amg_z_id_solver_mold,info,pos=pos) + + case (amg_diag_scale_) + call lv%set(amg_z_diag_solver_mold,info,pos=pos) + + case (amg_l1_diag_scale_) + call lv%set(amg_z_l1_diag_solver_mold,info,pos=pos) + + case (amg_gs_) + call lv%set(amg_z_gs_solver_mold,info,pos=pos) + + case (amg_bwgs_) + call lv%set(amg_z_bwgs_solver_mold,info,pos=pos) + + case (psb_ilu_n_,psb_milu_n_,psb_ilu_t_) + call lv%set(amg_z_ilu_solver_mold,info,pos=pos) + if (info == 0) then + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + call lv%sm%sv%set('SUB_SOLVE',val,info) + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) call lv%sm2a%sv%set('SUB_SOLVE',val,info) + end if + end if +#ifdef HAVE_SLU_ + case (amg_slu_) + call lv%set(amg_z_slu_solver_mold,info,pos=pos) +#endif +#ifdef HAVE_MUMPS_ + case (amg_mumps_) + call lv%set(amg_z_mumps_solver_mold,info,pos=pos) +#endif +#ifdef HAVE_SLUDIST_ + case (amg_sludist_) + call lv%set(amg_z_sludist_solver_mold,info,pos=pos) +#endif +#ifdef HAVE_UMF_ + case (amg_umf_) + call lv%set(amg_z_umf_solver_mold,info,pos=pos) +#endif + case default + ! + ! Do nothing and hope for the best :) + ! + end select + + + case ('SMOOTHER_SWEEPS') + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) & + & lv%parms%sweeps_pre = val + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_)) & + & lv%parms%sweeps_post = val + + case ('ML_CYCLE') + lv%parms%ml_cycle = val + + case ('PAR_AGGR_ALG') + lv%parms%par_aggr_alg = val + if (allocated(lv%aggr)) then + call lv%aggr%free(info) + if (info == 0) deallocate(lv%aggr,stat=info) + if (info /= 0) then + info = psb_err_internal_error_ + return + end if + end if + + select case(val) + case(amg_dec_aggr_) + allocate(amg_z_dec_aggregator_type :: lv%aggr, stat=info) + case(amg_sym_dec_aggr_) + allocate(amg_z_symdec_aggregator_type :: lv%aggr, stat=info) + case default + info = psb_err_internal_error_ + end select + if (info == psb_success_) call lv%aggr%default() + + case ('AGGR_ORD') + lv%parms%aggr_ord = val + + case ('AGGR_TYPE') + lv%parms%aggr_type = val + if (allocated(lv%aggr)) call lv%aggr%set_aggr_type(lv%parms,info) + + case ('AGGR_PROL') + lv%parms%aggr_prol = val + + case ('COARSE_MAT') + lv%parms%coarse_mat = val + + case ('AGGR_OMEGA_ALG') + lv%parms%aggr_omega_alg= val + + case ('AGGR_EIG') + lv%parms%aggr_eig = val + + case ('AGGR_FILTER') + lv%parms%aggr_filter = val + + case ('COARSE_SOLVE') + lv%parms%coarse_solve = val + + case default + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) then + call lv%sm%set(what,val,info,idx=idx) + end if + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) then + call lv%sm2a%set(what,val,info,idx=idx) + end if + end if + if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) + + end select + if (info /= psb_success_) goto 9999 + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_z_base_onelev_cseti diff --git a/mlprec/impl/level/amg_z_base_onelev_csetr.f90 b/mlprec/impl/level/amg_z_base_onelev_csetr.f90 new file mode 100644 index 00000000..ca3d92e5 --- /dev/null +++ b/mlprec/impl/level/amg_z_base_onelev_csetr.f90 @@ -0,0 +1,105 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_onelev_csetr(lv,what,val,info,pos,idx) + + use psb_base_mod + use amg_z_onelev_mod, amg_protect_name => amg_z_base_onelev_csetr + + Implicit None + + ! Arguments + class(amg_z_onelev_type), intent(inout) :: lv + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + integer(psb_ipk_), intent(in), optional :: idx + ! Local + integer(psb_ipk_) :: ipos_, err_act + character(len=20) :: name='z_base_onelev_csetr' + + call psb_erractionsave(err_act) + + + info = psb_success_ + + select case (psb_toupper(what)) + + case ('AGGR_OMEGA_VAL') + lv%parms%aggr_omega_val= val + + case ('AGGR_THRESH') + lv%parms%aggr_thresh = val + + case default + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + if ((ipos_==amg_smooth_pre_) .or.(ipos_==amg_smooth_both_)) then + if (allocated(lv%sm)) then + call lv%sm%set(what,val,info,idx=idx) + end if + end if + if ((ipos_==amg_smooth_post_).or.(ipos_==amg_smooth_both_))then + if (allocated(lv%sm2a)) then + call lv%sm2a%set(what,val,info,idx=idx) + end if + end if + if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) + + end select + + if (info /= psb_success_) goto 9999 + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_z_base_onelev_csetr diff --git a/mlprec/impl/level/amg_z_base_onelev_descr.f90 b/mlprec/impl/level/amg_z_base_onelev_descr.f90 new file mode 100644 index 00000000..bf6d3b0f --- /dev/null +++ b/mlprec/impl/level/amg_z_base_onelev_descr.f90 @@ -0,0 +1,112 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_onelev_descr(lv,il,nl,ilmin,info,iout) + + use psb_base_mod + use amg_z_onelev_mod, amg_protect_name => amg_z_base_onelev_descr + Implicit None + ! Arguments + class(amg_z_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: il,nl,ilmin + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_z_base_onelev_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse + + + call psb_erractionsave(err_act) + + + coarse = (il==nl) + + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + + write(iout_,*) + if (il == ilmin) then + call lv%parms%mlcycledsc(iout_,info) + if (allocated(lv%aggr)) then + call lv%aggr%descr(lv%parms,iout_,info) + else + write(iout_,*) 'Internal error: unallocated aggregator object' + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + write(iout_,*) + end if + + if (il > 1) then + + if (coarse) then + write(iout_,*) ' Level ',il,' (coarse)' + else + write(iout_,*) ' Level ',il + end if + + call lv%parms%descr(iout_,info,coarse=coarse) + + if (nl > 1) then + if (allocated(lv%map%naggr)) then + write(iout_,*) ' Coarse Matrix: Global size: ', & + & sum((1_psb_lpk_*lv%map%naggr(:))),' Nonzeros: ',lv%ac_nz_tot + write(iout_,*) ' Local matrix sizes: ', & + & lv%map%naggr(:) + write(iout_,*) ' Aggregation ratio: ', & + & lv%szratio + end if + end if + + if (coarse.and.allocated(lv%sm)) & + & call lv%sm%descr(info,iout=iout_,coarse=coarse) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_z_base_onelev_descr diff --git a/mlprec/impl/level/amg_z_base_onelev_dump.f90 b/mlprec/impl/level/amg_z_base_onelev_dump.f90 new file mode 100644 index 00000000..d0e44a18 --- /dev/null +++ b/mlprec/impl/level/amg_z_base_onelev_dump.f90 @@ -0,0 +1,169 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_onelev_dump(lv,level,info,prefix,head,ac,rp,& + & smoother,solver,tprol,global_num) + + use psb_base_mod + use amg_z_onelev_mod, amg_protect_name => amg_z_base_onelev_dump + implicit none + class(amg_z_onelev_type), intent(in) :: lv + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: ac, rp, smoother, solver, tprol, global_num + ! Local variables + integer(psb_ipk_) :: i, j, il1, iln, lname, lev, ni + integer(psb_ipk_) :: icontxt,iam, np + character(len=80) :: prefix_, frmt + character(len=1024) :: fname + logical :: ac_, rp_, tprol_, global_num_ + integer(psb_lpk_), allocatable :: ivr(:), ivc(:) + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_lev_z" + end if + + if (associated(lv%base_desc)) then + icontxt = lv%base_desc%get_context() + call psb_info(icontxt,iam,np) + else + icontxt = -1 + iam = -1 + np = -1 + end if + if (present(ac)) then + ac_ = ac + else + ac_ = .false. + end if + if (present(rp)) then + rp_ = rp + else + rp_ = .false. + end if + if (present(tprol)) then + tprol_ = tprol + else + tprol_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + + if (np > 0) then + ni = floor(log10(1.0*np)) + 1 + write(frmt,'(a,i3.3,a,i3.3,a)') '(a,i',ni,'.',ni,')' + write(fname(lname+1:lname+ni+2),frmt) '_p',iam + lname = lname + ni + 2 + end if + + if (global_num_) then + if (level >= 2) then + if (ac_) then + ivr = lv%desc_ac%get_global_indices(owned=.false.) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx' + call lv%ac%print(fname,head=head,iv=ivr) + end if + if (rp_) then + ivr = lv%map%p_desc_U%get_global_indices(owned=.false.) + ivc = lv%map%p_desc_V%get_global_indices(owned=.false.) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx' + call lv%map%mat_U2V%print(fname,head=head,ivr=ivc,ivc=ivr) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx' + call lv%map%mat_V2U%print(fname,head=head,ivr=ivr,ivc=ivc) + end if + if (tprol_) then + ! Tentative prolongator is stored with column indices already + ! in global numbering, so only IVR is needed. + ivr = lv%map%p_desc_U%get_global_indices(owned=.false.) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_tprol.mtx' + ! + ! This is not implemented yet. + !call lv%tprol%print(fname,head=head,ivr=ivr) + end if + end if + else + if (level >= 2) then + if (ac_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx' + call lv%ac%print(fname,head=head) + end if + if (rp_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx' + call lv%map%mat_U2V%print(fname,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx' + call lv%map%mat_V2U%print(fname,head=head) + end if + if (tprol_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_tprol.mtx' + ! + ! This is not implemented yet. + !call lv%tprol%print(fname,head=head) + end if + end if + end if + + if (level >= 2) then + if (allocated(lv%sm)) then + call lv%sm%dump(lv%desc_ac,level,info,smoother=smoother, & + & solver=solver,prefix=trim(prefix_)//"_sm",global_num=global_num) + end if + if (allocated(lv%sm2a)) then + call lv%sm2a%dump(lv%desc_ac,level,info,smoother=smoother, & + & solver=solver,prefix=trim(prefix_)//"_sm2a",global_num=global_num) + end if + else + if (allocated(lv%sm)) then + call lv%sm%dump(lv%base_desc,level,info,smoother=smoother, & + & solver=solver,prefix=trim(prefix_)//"_sm",global_num=global_num) + end if + if (allocated(lv%sm2a)) then + call lv%sm2a%dump(lv%base_desc,level,info,smoother=smoother, & + & solver=solver,prefix=trim(prefix_)//"_sm2a",global_num=global_num) + end if + end if + +end subroutine amg_z_base_onelev_dump diff --git a/mlprec/impl/level/amg_z_base_onelev_free.f90 b/mlprec/impl/level/amg_z_base_onelev_free.f90 new file mode 100644 index 00000000..4ff69df8 --- /dev/null +++ b/mlprec/impl/level/amg_z_base_onelev_free.f90 @@ -0,0 +1,75 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_onelev_free(lv,info) + + use psb_base_mod + use amg_z_onelev_mod, amg_protect_name => amg_z_base_onelev_free + implicit none + + class(amg_z_onelev_type), intent(inout) :: lv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: i + + info = psb_success_ + + ! We might just deallocate the top level array, except + ! that there may be inner objects containing C pointers, + ! e.g. UMFPACK, SLU or CUDA stuff. + ! We really need FINALs. + if (allocated(lv%sm)) & + & call lv%sm%free(info) + + if (allocated(lv%sm2a)) & + & call lv%sm2a%free(info) + + if (allocated(lv%wrk)) & + & call lv%wrk%free(info) + + call lv%ac%free() + if (lv%desc_ac%is_ok()) & + & call lv%desc_ac%free(info) + call lv%map%free(info) + + ! This is a pointer to something else, must not free it here. + nullify(lv%base_a) + ! This is a pointer to something else, must not free it here. + nullify(lv%base_desc) + + call lv%nullify() + +end subroutine amg_z_base_onelev_free diff --git a/mlprec/impl/level/amg_z_base_onelev_mat_asb.f90 b/mlprec/impl/level/amg_z_base_onelev_mat_asb.f90 new file mode 100644 index 00000000..bf3189c2 --- /dev/null +++ b/mlprec/impl/level/amg_z_base_onelev_mat_asb.f90 @@ -0,0 +1,178 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! File: amg_z_onelev_mat_asb.f90 +! +! Subroutine: amg_z_onelev_mat_asb +! Version: complex +! +! This routine builds the matrix associated to the current level of the +! multilevel preconditioner from the matrix associated to the previous level, +! by using the user-specified aggregation technique (therefore, it also builds the +! prolongation and restriction operators mapping the current level to the +! previous one and vice versa). +! The current level is regarded as the coarse one, while the previous as +! the fine one. This is in agreement with the fact that the routine is called, +! by amg_mlprec_bld, only on levels >=2. +! The main structure is: +! 1. Perform sanity checks; +! 2. Call amg_Xaggrmat_asb to compute prolongator/restrictor/AC +! 3. According to the choice of DIST/REPL for AC, build a descriptor DESC_AC, +! and adjust the column numbering of AC/OP_PROL/OP_RESTR +! 4. Pack restrictor and prolongator into p%map +! 5. Fix base_a and base_desc pointers. +! +! +! Arguments: +! p - type(amg_z_onelev_type), input/output. +! The 'one-level' data structure containing the control +! parameters and (eventually) coarse matrix and prolongator/restrictors. +! +! a - type(psb_zspmat_type). +! The sparse matrix structure containing the local part of the +! fine-level matrix. +! desc_a - type(psb_desc_type), input. +! The communication descriptor of a. +! ilaggr - integer, dimension(:), input +! The mapping between the row indices of the coarse-level +! matrix and the row indices of the fine-level matrix. +! ilaggr(i)=j means that node i in the adjacency graph +! of the fine-level matrix is mapped onto node j in the +! adjacency graph of the coarse-level matrix. Note that the indices +! are assumed to be shifted so as to make sure the ranges on +! the various processes do not overlap. +! nlaggr - integer, dimension(:) input +! nlaggr(i) contains the aggregates held by process i. +! op_prol - type(psb_zspmat_type), input/output +! The tentative prolongator on input, released on output. +! +! info - integer, output. +! Error code. +! +subroutine amg_z_base_onelev_mat_asb(lv,a,desc_a,ilaggr,nlaggr,t_prol,info) + + use psb_base_mod + use amg_base_prec_type + use amg_z_onelev_mod, amg_protect_name => amg_z_base_onelev_mat_asb + + implicit none + + ! Arguments + class(amg_z_onelev_type), intent(inout), target :: lv + type(psb_zspmat_type), intent(in) :: a + type(psb_desc_type), intent(inout) :: desc_a + integer(psb_lpk_), intent(inout) :: nlaggr(:) + integer(psb_lpk_), intent(inout) :: ilaggr(:) + type(psb_lzspmat_type), intent(inout) :: t_prol + integer(psb_ipk_), intent(out) :: info + + + ! Local variables + character(len=24) :: name + integer(psb_ipk_) :: ictxt, np, me + integer(psb_ipk_) :: err_act + type(psb_zspmat_type) :: ac, op_restr, op_prol + integer(psb_ipk_) :: nzl, inl + integer(psb_ipk_) :: debug_level, debug_unit + + name='amg_z_onelev_mat_asb' + call psb_erractionsave(err_act) + if (psb_errstatus_fatal()) then + info = psb_err_internal_error_; goto 9999 + end if + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = psb_success_ + ictxt = desc_a%get_context() + call psb_info(ictxt,me,np) + + call amg_check_def(lv%parms%aggr_prol,'Smoother',& + & amg_smooth_prol_,is_legal_ml_aggr_prol) + call amg_check_def(lv%parms%coarse_mat,'Coarse matrix',& + & amg_distr_mat_,is_legal_ml_coarse_mat) + call amg_check_def(lv%parms%aggr_filter,'Use filtered matrix',& + & amg_no_filter_mat_,is_legal_aggr_filter) + call amg_check_def(lv%parms%aggr_omega_alg,'Omega Alg.',& + & amg_eig_est_,is_legal_ml_aggr_omega_alg) + call amg_check_def(lv%parms%aggr_eig,'Eigenvalue estimate',& + & amg_max_norm_,is_legal_ml_aggr_eig) + call amg_check_def(lv%parms%aggr_omega_val,'Omega',dzero,is_legal_d_omega) + + + ! + ! Build the coarse-level matrix from the fine-level one, starting from + ! the mapping defined by amg_aggrmap_bld and applying the aggregation + ! algorithm specified by lv%iprcparm(amg_aggr_prol_) + ! + call lv%aggr%mat_bld(lv%parms,a,desc_a,ilaggr,nlaggr,& + & lv%ac,lv%desc_ac,op_prol,op_restr,t_prol,info) + + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='amg_aggrmat_asb') + goto 9999 + end if + + ! + ! Now build its descriptor and convert global indices for + ! ac, op_restr and op_prol + ! + if (info == psb_success_) & + & call lv%aggr%mat_asb(lv%parms,a,desc_a,& + & lv%ac,lv%desc_ac,op_prol,op_restr,info) + + if (info == psb_success_) call lv%ac%cscnv(info,type='csr',dupl=psb_dupl_add_) + + if (info == psb_success_) call lv%aggr%bld_map(desc_a, lv%desc_ac,& + & ilaggr,nlaggr,op_restr,op_prol,lv%map,info) + if(info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='mat_asb/map_bld') + goto 9999 + end if + ! + ! Fix the base_a and base_desc pointers for handling of residuals. + ! This is correct because this routine is only called at levels >=2. + ! + lv%base_a => lv%ac + lv%base_desc => lv%desc_ac + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + +end subroutine amg_z_base_onelev_mat_asb diff --git a/mlprec/impl/level/amg_z_base_onelev_setag.f90 b/mlprec/impl/level/amg_z_base_onelev_setag.f90 new file mode 100644 index 00000000..4a64ff74 --- /dev/null +++ b/mlprec/impl/level/amg_z_base_onelev_setag.f90 @@ -0,0 +1,82 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_onelev_setag(lv,val,info,pos) + + use psb_base_mod + use amg_z_onelev_mod, amg_protect_name => amg_z_base_onelev_setag + + implicit none + + ! Arguments + class(amg_z_onelev_type), target, intent(inout) :: lv + class(amg_z_base_aggregator_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ipos_ + character(len=*), parameter :: name='amg_base_onelev_setag' + + info = psb_success_ + + ! Ignore pos for aggregator + + if (allocated(lv%aggr)) then + if (.not.same_type_as(lv%aggr,val)) then + call lv%aggr%free(info) + deallocate(lv%aggr,stat=info) + if (info /= 0) then + info = 3111 + return + end if + end if + end if + + if (.not.allocated(lv%aggr)) then + allocate(lv%aggr,mold=val,stat=info) + if (info /= 0) then + info = 3111 + return + end if + lv%parms%par_aggr_alg = amg_ext_aggr_ + lv%parms%aggr_type = amg_noalg_ + call lv%aggr%default() + end if + +end subroutine amg_z_base_onelev_setag + diff --git a/mlprec/impl/level/amg_z_base_onelev_setsm.F90 b/mlprec/impl/level/amg_z_base_onelev_setsm.F90 new file mode 100644 index 00000000..9c770d93 --- /dev/null +++ b/mlprec/impl/level/amg_z_base_onelev_setsm.F90 @@ -0,0 +1,114 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_onelev_setsm(lev,val,info,pos) + + use psb_base_mod + use amg_z_prec_mod, amg_protect_name => amg_z_base_onelev_setsm + + implicit none + + ! Arguments + class(amg_z_onelev_type), target, intent(inout) :: lev + class(amg_z_base_smoother_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ipos_ + character(len=*), parameter :: name='amg_base_onelev_setsm' + + info = psb_success_ + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + if (ipos_ == amg_smooth_both_) then + if (allocated(lev%sm2a)) then + call lev%sm2a%free(info) + deallocate(lev%sm2a, stat=info) + lev%sm2 => null() + end if + end if + + select case(ipos_) + case(amg_smooth_pre_, amg_smooth_both_) + if (allocated(lev%sm)) then + if (.not.same_type_as(lev%sm,val)) then + call lev%sm%free(info) + deallocate(lev%sm, stat=info) + end if + endif + if (.not.allocated(lev%sm)) then +#ifdef HAVE_MOLD + allocate(lev%sm,mold=val) +#else + allocate(lev%sm,source=val) +#endif + end if + call lev%sm%default() + if (ipos_ == amg_smooth_both_) lev%sm2 => lev%sm + case(amg_smooth_post_) + if (allocated(lev%sm2a)) then + if (.not.same_type_as(lev%sm2a,val)) then + call lev%sm2a%free(info) + deallocate(lev%sm2a, stat=info) + endif + end if + if (.not.allocated(lev%sm2a)) then +#ifdef HAVE_MOLD + allocate(lev%sm2a,mold=val) +#else + allocate(lev%sm2a,source=val) +#endif + end if + call lev%sm2a%default() + lev%sm2 => lev%sm2a + end select + +end subroutine amg_z_base_onelev_setsm + diff --git a/mlprec/impl/level/amg_z_base_onelev_setsv.F90 b/mlprec/impl/level/amg_z_base_onelev_setsv.F90 new file mode 100644 index 00000000..dba00377 --- /dev/null +++ b/mlprec/impl/level/amg_z_base_onelev_setsv.F90 @@ -0,0 +1,152 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_onelev_setsv(lev,val,info,pos) + + use psb_base_mod + use amg_z_prec_mod, amg_protect_name => amg_z_base_onelev_setsv + + implicit none + + ! Arguments + class(amg_z_onelev_type), target, intent(inout) :: lev + class(amg_z_base_solver_type), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + character(len=*), optional, intent(in) :: pos + + ! Local variables + integer(psb_ipk_) :: ipos_ + character(len=*), parameter :: name='amg_base_onelev_setsv' + + info = psb_success_ + + if (present(pos)) then + select case(psb_toupper(trim(pos))) + case('PRE') + ipos_ = amg_smooth_pre_ + case('POST') + ipos_ = amg_smooth_post_ + case default + ipos_ = amg_smooth_both_ + end select + else + ipos_ = amg_smooth_both_ + end if + + if ((ipos_ == amg_smooth_pre_).or.(ipos_ == amg_smooth_both_)) then + if (allocated(lev%sm)) then + if (allocated(lev%sm%sv)) then + if (.not.same_type_as(lev%sm%sv,val)) then + call lev%sm%sv%free(info) + if (info == 0) deallocate(lev%sm%sv,stat=info) + if (info /= 0) then + info = 3111 + return + end if + end if + end if + + if (.not.allocated(lev%sm%sv)) then +#ifdef HAVE_MOLD + allocate(lev%sm%sv,mold=val,stat=info) +#else + allocate(lev%sm%sv,source=val,stat=info) +#endif + if (info /= 0) then + info = 3111 + return + end if + end if + call lev%sm%sv%default() + else + info = 3111 + write(psb_err_unit,*) name,& + &': Error: uninitialized preconditioner component,',& + &' should call amg_PRECINIT/amg_PRECSET' + return + + end if + end if + + ! + ! If POS was not specified and therefore we have amg_smooth_both_ + ! we need to update sm2a *only* if it was already allocated, + ! otherwise it is not needed (since we have just fixed %sm in the + ! pre section). + ! + + if ((ipos_ == amg_smooth_post_).or. & + ((ipos_ == amg_smooth_both_).and.(allocated(lev%sm2a)))) then + + + if (allocated(lev%sm2a)) then + if (allocated(lev%sm2a%sv)) then + if (.not.same_type_as(lev%sm2a%sv,val)) then + call lev%sm2a%sv%free(info) + if (info == 0) deallocate(lev%sm2a%sv,stat=info) + if (info /= 0) then + info = 3111 + return + end if + end if + end if + if (.not.allocated(lev%sm2a%sv)) then +#ifdef HAVE_MOLD + allocate(lev%sm2a%sv,mold=val,stat=info) +#else + allocate(lev%sm2a%sv,source=val,stat=info) +#endif + if (info /= 0) then + info = 3111 + return + end if + end if + call lev%sm2a%sv%default() + + else + info = 3111 + write(psb_err_unit,*) name,& + &': Error: uninitialized preconditioner component,',& + &' should call amg_PRECINIT/amg_PRECSET' + return + + end if + + end if + +end subroutine amg_z_base_onelev_setsv + diff --git a/mlprec/impl/level/mld_c_base_onelev_build.f90 b/mlprec/impl/level/mld_c_base_onelev_build.f90 deleted file mode 100644 index 9f1363a0..00000000 --- a/mlprec/impl/level/mld_c_base_onelev_build.f90 +++ /dev/null @@ -1,153 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_onelev_build(lv,info,amold,vmold,imold,ilv) - use psb_base_mod - use mld_c_onelev_mod, mld_protect_name => mld_c_base_onelev_build - implicit none - class(mld_c_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - integer(psb_ipk_), intent(in), optional :: ilv - ! Local - integer(psb_ipk_) :: err,i,k, err_act - integer(psb_ipk_) :: ictxt, me, np - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - - name = 'mld_onelev_build' - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - if (.not.associated(lv%base_desc)) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Unassociated base DESC') - goto 9999 - end if - info = psb_success_ - ictxt = lv%base_desc%get_ctxt() - call psb_info(ictxt,me,np) - - if (.not.allocated(lv%sm)) then - !! Error: should have called mld_dprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - if (.not.allocated(lv%sm%sv)) then - !! Error: should have called mld_dprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - lv%ac_nz_loc = lv%ac%get_nzeros() - lv%ac_nz_tot = lv%ac_nz_loc - select case(lv%parms%coarse_mat) - case(mld_distr_mat_) - call psb_sum(ictxt,lv%ac_nz_tot) - case(mld_repl_mat_) - ! Do nothing - case default - ! Should never get here - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='Wrong lv%parms') - goto 9999 - end select - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Calling mlprcbld at level ',i - call mld_check_def(lv%parms%sweeps_pre,& - & 'Jacobi sweeps',izero,is_int_non_negative) - call mld_check_def(lv%parms%sweeps_post,& - & 'Jacobi sweeps',izero,is_int_non_negative) - - call lv%sm%build(lv%base_a,lv%base_desc,info) - if (info == 0) then - if (allocated(lv%sm2a)) then - call lv%sm2a%build(lv%base_a,lv%base_desc,info) - lv%sm2 => lv%sm2a - else - lv%sm2 => lv%sm - end if - end if - if (info /=0 ) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Smoother bld error') - goto 9999 - end if - - if (lv%sm%sv%is_global()) then - if ((lv%parms%sweeps_pre>1).or.(lv%parms%sweeps_post>1)) then - lv%parms%sweeps_pre = 1 - lv%parms%sweeps_post = 1 - if (me == 0) then - write(debug_unit,*) - if (present(ilv)) then - write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),& - & '" at level ',ilv - write(debug_unit,*) ' is configured as a global solver ' - else - write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),& - & '" is configured as a global solver ' - end if - write(debug_unit,*) ' Pre and post sweeps at this level reset to 1' - end if - end if - end if - - if (any((/present(amold),present(vmold),present(imold)/))) & - & call lv%cnv(info,amold=amold,vmold=vmold,imold=imold) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_base_onelev_build diff --git a/mlprec/impl/level/mld_c_base_onelev_check.f90 b/mlprec/impl/level/mld_c_base_onelev_check.f90 deleted file mode 100644 index c47747b5..00000000 --- a/mlprec/impl/level/mld_c_base_onelev_check.f90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_onelev_check(lv,info) - - use psb_base_mod - use mld_c_onelev_mod, mld_protect_name => mld_c_base_onelev_check - - Implicit None - - ! Arguments - class(mld_c_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_onelev_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - call mld_check_def(lv%parms%sweeps_pre,& - & 'Jacobi sweeps',ione,is_int_non_negative) - call mld_check_def(lv%parms%sweeps_post,& - & 'Jacobi sweeps',ione,is_int_non_negative) - - if (allocated(lv%sm)) then - call lv%sm%check(info) - else - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - if (allocated(lv%sm2a)) then - call lv%sm2a%check(info) - else if (.not.inner_check(lv%sm2,lv%sm)) then - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -contains - function inner_check(smp,sm) result(res) - implicit none - logical :: res - class(mld_c_base_smoother_type), intent(in), pointer :: smp - class(mld_c_base_smoother_type), intent(in), target :: sm - - res = associated(smp, sm) - end function inner_check - -end subroutine mld_c_base_onelev_check diff --git a/mlprec/impl/level/mld_c_base_onelev_cnv.f90 b/mlprec/impl/level/mld_c_base_onelev_cnv.f90 deleted file mode 100644 index cdc48dad..00000000 --- a/mlprec/impl/level/mld_c_base_onelev_cnv.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_onelev_cnv(lv,info,amold,vmold,imold) - - use psb_base_mod - use mld_c_onelev_mod, mld_protect_name => mld_c_base_onelev_cnv - implicit none - - class(mld_c_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - integer(psb_ipk_) :: i - - info = psb_success_ - - if (any((/present(amold),present(vmold),present(imold)/))) then - if (allocated(lv%sm)) & - & call lv%sm%cnv(info,amold=amold,vmold=vmold,imold=imold) - if (info == psb_success_ .and. allocated(lv%sm2a)) & - & call lv%sm2a%cnv(info,amold=amold,vmold=vmold,imold=imold) - if (info == psb_success_ .and. allocated(lv%wrk)) & - & call lv%wrk%cnv(info,vmold=vmold) - if (info == psb_success_.and. lv%ac%is_asb()) & - & call lv%ac%cscnv(info,mold=amold) - if (info == psb_success_ .and. lv%desc_ac%is_ok() & - & .and. present(imold)) call lv%desc_ac%cnv(imold) - if (info == psb_success_) call lv%map%cnv(info,mold=amold,imold=imold) - end if -end subroutine mld_c_base_onelev_cnv diff --git a/mlprec/impl/level/mld_c_base_onelev_csetc.F90 b/mlprec/impl/level/mld_c_base_onelev_csetc.F90 deleted file mode 100644 index 262c20aa..00000000 --- a/mlprec/impl/level/mld_c_base_onelev_csetc.F90 +++ /dev/null @@ -1,292 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_onelev_csetc(lv,what,val,info,pos,idx) - - use psb_base_mod - use mld_c_onelev_mod, mld_protect_name => mld_c_base_onelev_csetc - use mld_c_base_aggregator_mod - use mld_c_dec_aggregator_mod - use mld_c_symdec_aggregator_mod - use mld_c_jac_smoother - use mld_c_as_smoother - use mld_c_diag_solver - use mld_c_l1_diag_solver - use mld_c_ilu_solver - use mld_c_id_solver - use mld_c_gs_solver -#if defined(HAVE_SLU_) - use mld_c_slu_solver -#endif -#if defined(HAVE_MUMPS_) - use mld_c_mumps_solver -#endif - - Implicit None - - ! Arguments - class(mld_c_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - ! Local - integer(psb_ipk_) :: ipos_, err_act - character(len=20) :: name='c_base_onelev_csetc' - integer(psb_ipk_) :: ival - type(mld_c_base_smoother_type) :: mld_c_base_smoother_mold - type(mld_c_jac_smoother_type) :: mld_c_jac_smoother_mold - type(mld_c_l1_jac_smoother_type) :: mld_c_l1_jac_smoother_mold - type(mld_c_as_smoother_type) :: mld_c_as_smoother_mold - type(mld_c_diag_solver_type) :: mld_c_diag_solver_mold - type(mld_c_l1_diag_solver_type) :: mld_c_l1_diag_solver_mold - type(mld_c_ilu_solver_type) :: mld_c_ilu_solver_mold - type(mld_c_id_solver_type) :: mld_c_id_solver_mold - type(mld_c_gs_solver_type) :: mld_c_gs_solver_mold - type(mld_c_bwgs_solver_type) :: mld_c_bwgs_solver_mold -#if defined(HAVE_SLU_) - type(mld_c_slu_solver_type) :: mld_c_slu_solver_mold -#endif -#if defined(HAVE_MUMPS_) - type(mld_c_mumps_solver_type) :: mld_c_mumps_solver_mold -#endif - - - call psb_erractionsave(err_act) - - info = psb_success_ - - ival = lv%stringval(val) - - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - select case (psb_toupper(trim(what))) - case ('SMOOTHER_TYPE') - select case (psb_toupper(trim(val))) - case ('NOPREC','NONE') - call lv%set(mld_c_base_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_c_id_solver_mold,info,pos=pos) - - case ('JAC','JACOBI') - call lv%set(mld_c_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_c_diag_solver_mold,info,pos=pos) - - case ('L1-JACOBI') - call lv%set(mld_c_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_c_l1_diag_solver_mold,info,pos=pos) - - case ('BJAC') - call lv%set(mld_c_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_c_ilu_solver_mold,info,pos=pos) - - case ('L1-BJAC') - call lv%set(mld_c_l1_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_c_ilu_solver_mold,info,pos=pos) - - case ('AS') - call lv%set(mld_c_as_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_c_ilu_solver_mold,info,pos=pos) - - case ('GS','FWGS') - call lv%set(mld_c_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_c_gs_solver_mold,info,pos='pre') - if (allocated(lv%sm2a)) deallocate(lv%sm2a) - case ('BWGS') - call lv%set(mld_c_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_c_bwgs_solver_mold,info,pos='pre') - if (allocated(lv%sm2a)) deallocate(lv%sm2a) - case ('FBGS') - call lv%set(mld_c_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_c_gs_solver_mold,info,pos='pre') - call lv%set(mld_c_jac_smoother_mold,info,pos='post') - if (info == 0) call lv%set(mld_c_bwgs_solver_mold,info,pos='post') - case ('L1-GS','L1-FWGS') - call lv%set(mld_c_l1_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_c_gs_solver_mold,info,pos='pre') - if (allocated(lv%sm2a)) deallocate(lv%sm2a) - case ('L1-BWGS') - call lv%set(mld_c_l1_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_c_bwgs_solver_mold,info,pos='pre') - if (allocated(lv%sm2a)) deallocate(lv%sm2a) - case ('L1-FBGS') - call lv%set(mld_c_l1_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_c_gs_solver_mold,info,pos='pre') - call lv%set(mld_c_l1_jac_smoother_mold,info,pos='post') - if (info == 0) call lv%set(mld_c_bwgs_solver_mold,info,pos='post') - - case default - ! - ! Do nothing and hope for the best :) - ! - end select - if ((ipos_==mld_smooth_pre_).or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) call lv%sm%default() - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm2a)) call lv%sm2a%default() - end if - - - case('SUB_SOLVE') - select case (psb_toupper(trim(val))) - case ('NONE','NOPREC','FACT_NONE') - call lv%set(mld_c_id_solver_mold,info,pos=pos) - - case ('DIAG') - call lv%set(mld_c_diag_solver_mold,info,pos=pos) - - case ('L1-DIAG') - call lv%set(mld_c_l1_diag_solver_mold,info,pos=pos) - - case ('GS','FGS','FWGS') - call lv%set(mld_c_gs_solver_mold,info,pos=pos) - - case ('BGS','BWGS') - call lv%set(mld_c_bwgs_solver_mold,info,pos=pos) - - case ('ILU','ILUT','MILU') - call lv%set(mld_c_ilu_solver_mold,info,pos=pos) - if (info == 0) then - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - call lv%sm%sv%set('SUB_SOLVE',val,info) - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) call lv%sm2a%sv%set('SUB_SOLVE',val,info) - end if - end if -#ifdef HAVE_SLU_ - case ('SLU') - call lv%set(mld_c_slu_solver_mold,info,pos=pos) -#endif -#ifdef HAVE_MUMPS_ - case ('MUMPS') - call lv%set(mld_c_mumps_solver_mold,info,pos=pos) -#endif - case default - ! - ! Do nothing and hope for the best :) - ! - end select - - case ('ML_CYCLE') - lv%parms%ml_cycle = mld_stringval(val) - - case ('PAR_AGGR_ALG') - ival = mld_stringval(val) - lv%parms%par_aggr_alg = ival - if (allocated(lv%aggr)) then - call lv%aggr%free(info) - if (info == 0) deallocate(lv%aggr,stat=info) - if (info /= 0) then - info = psb_err_internal_error_ - return - end if - end if - - select case(ival) - case(mld_dec_aggr_) - allocate(mld_c_dec_aggregator_type :: lv%aggr, stat=info) - case(mld_sym_dec_aggr_) - allocate(mld_c_symdec_aggregator_type :: lv%aggr, stat=info) - case default - info = psb_err_internal_error_ - end select - if (info == psb_success_) call lv%aggr%default() - - case ('AGGR_ORD') - lv%parms%aggr_ord = mld_stringval(val) - - case ('AGGR_TYPE') - lv%parms%aggr_type = mld_stringval(val) - if (allocated(lv%aggr)) call lv%aggr%set_aggr_type(lv%parms,info) - - case ('AGGR_PROL') - lv%parms%aggr_prol = mld_stringval(val) - - case ('COARSE_MAT') - lv%parms%coarse_mat = mld_stringval(val) - - case ('AGGR_OMEGA_ALG') - lv%parms%aggr_omega_alg= mld_stringval(val) - - case ('AGGR_EIG') - lv%parms%aggr_eig = mld_stringval(val) - - case ('AGGR_FILTER') - lv%parms%aggr_filter = mld_stringval(val) - - case ('COARSE_SOLVE') - lv%parms%coarse_solve = mld_stringval(val) - - case default - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) then - call lv%sm%set(what,val,info,idx=idx) - end if - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) then - call lv%sm2a%set(what,val,info,idx=idx) - end if - end if - if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) - - end select - - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_c_base_onelev_csetc diff --git a/mlprec/impl/level/mld_c_base_onelev_cseti.F90 b/mlprec/impl/level/mld_c_base_onelev_cseti.F90 deleted file mode 100644 index f628868e..00000000 --- a/mlprec/impl/level/mld_c_base_onelev_cseti.F90 +++ /dev/null @@ -1,268 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_onelev_cseti(lv,what,val,info,pos,idx) - - use psb_base_mod - use mld_c_onelev_mod, mld_protect_name => mld_c_base_onelev_cseti - use mld_c_base_aggregator_mod - use mld_c_dec_aggregator_mod - use mld_c_symdec_aggregator_mod - use mld_c_jac_smoother - use mld_c_as_smoother - use mld_c_diag_solver - use mld_c_l1_diag_solver - use mld_c_ilu_solver - use mld_c_id_solver - use mld_c_gs_solver -#if defined(HAVE_SLU_) - use mld_c_slu_solver -#endif -#if defined(HAVE_MUMPS_) - use mld_c_mumps_solver -#endif - - Implicit None - - ! Arguments - class(mld_c_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - ! Local - integer(psb_ipk_) :: ipos_, err_act - character(len=20) :: name='c_base_onelev_cseti' - type(mld_c_base_smoother_type) :: mld_c_base_smoother_mold - type(mld_c_jac_smoother_type) :: mld_c_jac_smoother_mold - type(mld_c_l1_jac_smoother_type) :: mld_c_l1_jac_smoother_mold - type(mld_c_as_smoother_type) :: mld_c_as_smoother_mold - type(mld_c_diag_solver_type) :: mld_c_diag_solver_mold - type(mld_c_l1_diag_solver_type) :: mld_c_l1_diag_solver_mold - type(mld_c_ilu_solver_type) :: mld_c_ilu_solver_mold - type(mld_c_id_solver_type) :: mld_c_id_solver_mold - type(mld_c_gs_solver_type) :: mld_c_gs_solver_mold - type(mld_c_bwgs_solver_type) :: mld_c_bwgs_solver_mold -#if defined(HAVE_SLU_) - type(mld_c_slu_solver_type) :: mld_c_slu_solver_mold -#endif -#if defined(HAVE_MUMPS_) - type(mld_c_mumps_solver_type) :: mld_c_mumps_solver_mold -#endif - - call psb_erractionsave(err_act) - info = psb_success_ - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - select case (psb_toupper(what)) - case ('SMOOTHER_TYPE') - select case (val) - case (mld_noprec_) - call lv%set(mld_c_base_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_c_id_solver_mold,info,pos=pos) - - case (mld_jac_) - call lv%set(mld_c_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_c_diag_solver_mold,info,pos=pos) - - case (mld_l1_jac_) - call lv%set(mld_c_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_c_l1_diag_solver_mold,info,pos=pos) - - case (mld_bjac_) - call lv%set(mld_c_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_c_ilu_solver_mold,info,pos=pos) - - case (mld_l1_bjac_) - call lv%set(mld_c_l1_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_c_ilu_solver_mold,info,pos=pos) - - case (mld_as_) - call lv%set(mld_c_as_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_c_ilu_solver_mold,info,pos=pos) - - case (mld_fbgs_) - call lv%set(mld_c_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_c_gs_solver_mold,info,pos='pre') - call lv%set(mld_c_jac_smoother_mold,info,pos='post') - if (info == 0) call lv%set(mld_c_bwgs_solver_mold,info,pos='post') - - case default - ! - ! Do nothing and hope for the best :) - ! - end select - if ((ipos_==mld_smooth_pre_).or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) call lv%sm%default() - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm2a)) call lv%sm2a%default() - end if - - - case('SUB_SOLVE') - select case (val) - case (mld_f_none_) - call lv%set(mld_c_id_solver_mold,info,pos=pos) - - case (mld_diag_scale_) - call lv%set(mld_c_diag_solver_mold,info,pos=pos) - - case (mld_l1_diag_scale_) - call lv%set(mld_c_l1_diag_solver_mold,info,pos=pos) - - case (mld_gs_) - call lv%set(mld_c_gs_solver_mold,info,pos=pos) - - case (mld_bwgs_) - call lv%set(mld_c_bwgs_solver_mold,info,pos=pos) - - case (psb_ilu_n_,psb_milu_n_,psb_ilu_t_) - call lv%set(mld_c_ilu_solver_mold,info,pos=pos) - if (info == 0) then - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - call lv%sm%sv%set('SUB_SOLVE',val,info) - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) call lv%sm2a%sv%set('SUB_SOLVE',val,info) - end if - end if -#ifdef HAVE_SLU_ - case (mld_slu_) - call lv%set(mld_c_slu_solver_mold,info,pos=pos) -#endif -#ifdef HAVE_MUMPS_ - case (mld_mumps_) - call lv%set(mld_c_mumps_solver_mold,info,pos=pos) -#endif - case default - ! - ! Do nothing and hope for the best :) - ! - end select - - - case ('SMOOTHER_SWEEPS') - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) & - & lv%parms%sweeps_pre = val - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_)) & - & lv%parms%sweeps_post = val - - case ('ML_CYCLE') - lv%parms%ml_cycle = val - - case ('PAR_AGGR_ALG') - lv%parms%par_aggr_alg = val - if (allocated(lv%aggr)) then - call lv%aggr%free(info) - if (info == 0) deallocate(lv%aggr,stat=info) - if (info /= 0) then - info = psb_err_internal_error_ - return - end if - end if - - select case(val) - case(mld_dec_aggr_) - allocate(mld_c_dec_aggregator_type :: lv%aggr, stat=info) - case(mld_sym_dec_aggr_) - allocate(mld_c_symdec_aggregator_type :: lv%aggr, stat=info) - case default - info = psb_err_internal_error_ - end select - if (info == psb_success_) call lv%aggr%default() - - case ('AGGR_ORD') - lv%parms%aggr_ord = val - - case ('AGGR_TYPE') - lv%parms%aggr_type = val - if (allocated(lv%aggr)) call lv%aggr%set_aggr_type(lv%parms,info) - - case ('AGGR_PROL') - lv%parms%aggr_prol = val - - case ('COARSE_MAT') - lv%parms%coarse_mat = val - - case ('AGGR_OMEGA_ALG') - lv%parms%aggr_omega_alg= val - - case ('AGGR_EIG') - lv%parms%aggr_eig = val - - case ('AGGR_FILTER') - lv%parms%aggr_filter = val - - case ('COARSE_SOLVE') - lv%parms%coarse_solve = val - - case default - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) then - call lv%sm%set(what,val,info,idx=idx) - end if - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) then - call lv%sm2a%set(what,val,info,idx=idx) - end if - end if - if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) - - end select - if (info /= psb_success_) goto 9999 - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_c_base_onelev_cseti diff --git a/mlprec/impl/level/mld_c_base_onelev_csetr.f90 b/mlprec/impl/level/mld_c_base_onelev_csetr.f90 deleted file mode 100644 index 4e69ac5e..00000000 --- a/mlprec/impl/level/mld_c_base_onelev_csetr.f90 +++ /dev/null @@ -1,105 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_onelev_csetr(lv,what,val,info,pos,idx) - - use psb_base_mod - use mld_c_onelev_mod, mld_protect_name => mld_c_base_onelev_csetr - - Implicit None - - ! Arguments - class(mld_c_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - ! Local - integer(psb_ipk_) :: ipos_, err_act - character(len=20) :: name='c_base_onelev_csetr' - - call psb_erractionsave(err_act) - - - info = psb_success_ - - select case (psb_toupper(what)) - - case ('AGGR_OMEGA_VAL') - lv%parms%aggr_omega_val= val - - case ('AGGR_THRESH') - lv%parms%aggr_thresh = val - - case default - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) then - call lv%sm%set(what,val,info,idx=idx) - end if - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) then - call lv%sm2a%set(what,val,info,idx=idx) - end if - end if - if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) - - end select - - if (info /= psb_success_) goto 9999 - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_c_base_onelev_csetr diff --git a/mlprec/impl/level/mld_c_base_onelev_descr.f90 b/mlprec/impl/level/mld_c_base_onelev_descr.f90 deleted file mode 100644 index aef7c868..00000000 --- a/mlprec/impl/level/mld_c_base_onelev_descr.f90 +++ /dev/null @@ -1,112 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_onelev_descr(lv,il,nl,ilmin,info,iout) - - use psb_base_mod - use mld_c_onelev_mod, mld_protect_name => mld_c_base_onelev_descr - Implicit None - ! Arguments - class(mld_c_onelev_type), intent(in) :: lv - integer(psb_ipk_), intent(in) :: il,nl,ilmin - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_c_base_onelev_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse - - - call psb_erractionsave(err_act) - - - coarse = (il==nl) - - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - end if - - write(iout_,*) - if (il == ilmin) then - call lv%parms%mlcycledsc(iout_,info) - if (allocated(lv%aggr)) then - call lv%aggr%descr(lv%parms,iout_,info) - else - write(iout_,*) 'Internal error: unallocated aggregator object' - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - write(iout_,*) - end if - - if (il > 1) then - - if (coarse) then - write(iout_,*) ' Level ',il,' (coarse)' - else - write(iout_,*) ' Level ',il - end if - - call lv%parms%descr(iout_,info,coarse=coarse) - - if (nl > 1) then - if (allocated(lv%map%naggr)) then - write(iout_,*) ' Coarse Matrix: Global size: ', & - & sum((1_psb_lpk_*lv%map%naggr(:))),' Nonzeros: ',lv%ac_nz_tot - write(iout_,*) ' Local matrix sizes: ', & - & lv%map%naggr(:) - write(iout_,*) ' Aggregation ratio: ', & - & lv%szratio - end if - end if - - if (coarse.and.allocated(lv%sm)) & - & call lv%sm%descr(info,iout=iout_,coarse=coarse) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_c_base_onelev_descr diff --git a/mlprec/impl/level/mld_c_base_onelev_dump.f90 b/mlprec/impl/level/mld_c_base_onelev_dump.f90 deleted file mode 100644 index a4751e5c..00000000 --- a/mlprec/impl/level/mld_c_base_onelev_dump.f90 +++ /dev/null @@ -1,169 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_onelev_dump(lv,level,info,prefix,head,ac,rp,& - & smoother,solver,tprol,global_num) - - use psb_base_mod - use mld_c_onelev_mod, mld_protect_name => mld_c_base_onelev_dump - implicit none - class(mld_c_onelev_type), intent(in) :: lv - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: ac, rp, smoother, solver, tprol, global_num - ! Local variables - integer(psb_ipk_) :: i, j, il1, iln, lname, lev, ni - integer(psb_ipk_) :: icontxt,iam, np - character(len=80) :: prefix_, frmt - character(len=1024) :: fname - logical :: ac_, rp_, tprol_, global_num_ - integer(psb_lpk_), allocatable :: ivr(:), ivc(:) - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_lev_c" - end if - - if (associated(lv%base_desc)) then - icontxt = lv%base_desc%get_context() - call psb_info(icontxt,iam,np) - else - icontxt = -1 - iam = -1 - np = -1 - end if - if (present(ac)) then - ac_ = ac - else - ac_ = .false. - end if - if (present(rp)) then - rp_ = rp - else - rp_ = .false. - end if - if (present(tprol)) then - tprol_ = tprol - else - tprol_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - - if (np > 0) then - ni = floor(log10(1.0*np)) + 1 - write(frmt,'(a,i3.3,a,i3.3,a)') '(a,i',ni,'.',ni,')' - write(fname(lname+1:lname+ni+2),frmt) '_p',iam - lname = lname + ni + 2 - end if - - if (global_num_) then - if (level >= 2) then - if (ac_) then - ivr = lv%desc_ac%get_global_indices(owned=.false.) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx' - call lv%ac%print(fname,head=head,iv=ivr) - end if - if (rp_) then - ivr = lv%map%p_desc_U%get_global_indices(owned=.false.) - ivc = lv%map%p_desc_V%get_global_indices(owned=.false.) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx' - call lv%map%mat_U2V%print(fname,head=head,ivr=ivc,ivc=ivr) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx' - call lv%map%mat_V2U%print(fname,head=head,ivr=ivr,ivc=ivc) - end if - if (tprol_) then - ! Tentative prolongator is stored with column indices already - ! in global numbering, so only IVR is needed. - ivr = lv%map%p_desc_U%get_global_indices(owned=.false.) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_tprol.mtx' - ! - ! This is not implemented yet. - !call lv%tprol%print(fname,head=head,ivr=ivr) - end if - end if - else - if (level >= 2) then - if (ac_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx' - call lv%ac%print(fname,head=head) - end if - if (rp_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx' - call lv%map%mat_U2V%print(fname,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx' - call lv%map%mat_V2U%print(fname,head=head) - end if - if (tprol_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_tprol.mtx' - ! - ! This is not implemented yet. - !call lv%tprol%print(fname,head=head) - end if - end if - end if - - if (level >= 2) then - if (allocated(lv%sm)) then - call lv%sm%dump(lv%desc_ac,level,info,smoother=smoother, & - & solver=solver,prefix=trim(prefix_)//"_sm",global_num=global_num) - end if - if (allocated(lv%sm2a)) then - call lv%sm2a%dump(lv%desc_ac,level,info,smoother=smoother, & - & solver=solver,prefix=trim(prefix_)//"_sm2a",global_num=global_num) - end if - else - if (allocated(lv%sm)) then - call lv%sm%dump(lv%base_desc,level,info,smoother=smoother, & - & solver=solver,prefix=trim(prefix_)//"_sm",global_num=global_num) - end if - if (allocated(lv%sm2a)) then - call lv%sm2a%dump(lv%base_desc,level,info,smoother=smoother, & - & solver=solver,prefix=trim(prefix_)//"_sm2a",global_num=global_num) - end if - end if - -end subroutine mld_c_base_onelev_dump diff --git a/mlprec/impl/level/mld_c_base_onelev_free.f90 b/mlprec/impl/level/mld_c_base_onelev_free.f90 deleted file mode 100644 index c1f71ad1..00000000 --- a/mlprec/impl/level/mld_c_base_onelev_free.f90 +++ /dev/null @@ -1,75 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_onelev_free(lv,info) - - use psb_base_mod - use mld_c_onelev_mod, mld_protect_name => mld_c_base_onelev_free - implicit none - - class(mld_c_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: i - - info = psb_success_ - - ! We might just deallocate the top level array, except - ! that there may be inner objects containing C pointers, - ! e.g. UMFPACK, SLU or CUDA stuff. - ! We really need FINALs. - if (allocated(lv%sm)) & - & call lv%sm%free(info) - - if (allocated(lv%sm2a)) & - & call lv%sm2a%free(info) - - if (allocated(lv%wrk)) & - & call lv%wrk%free(info) - - call lv%ac%free() - if (lv%desc_ac%is_ok()) & - & call lv%desc_ac%free(info) - call lv%map%free(info) - - ! This is a pointer to something else, must not free it here. - nullify(lv%base_a) - ! This is a pointer to something else, must not free it here. - nullify(lv%base_desc) - - call lv%nullify() - -end subroutine mld_c_base_onelev_free diff --git a/mlprec/impl/level/mld_c_base_onelev_mat_asb.f90 b/mlprec/impl/level/mld_c_base_onelev_mat_asb.f90 deleted file mode 100644 index 0fa9d5c4..00000000 --- a/mlprec/impl/level/mld_c_base_onelev_mat_asb.f90 +++ /dev/null @@ -1,178 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_c_onelev_mat_asb.f90 -! -! Subroutine: mld_c_onelev_mat_asb -! Version: complex -! -! This routine builds the matrix associated to the current level of the -! multilevel preconditioner from the matrix associated to the previous level, -! by using the user-specified aggregation technique (therefore, it also builds the -! prolongation and restriction operators mapping the current level to the -! previous one and vice versa). -! The current level is regarded as the coarse one, while the previous as -! the fine one. This is in agreement with the fact that the routine is called, -! by mld_mlprec_bld, only on levels >=2. -! The main structure is: -! 1. Perform sanity checks; -! 2. Call mld_Xaggrmat_asb to compute prolongator/restrictor/AC -! 3. According to the choice of DIST/REPL for AC, build a descriptor DESC_AC, -! and adjust the column numbering of AC/OP_PROL/OP_RESTR -! 4. Pack restrictor and prolongator into p%map -! 5. Fix base_a and base_desc pointers. -! -! -! Arguments: -! p - type(mld_c_onelev_type), input/output. -! The 'one-level' data structure containing the control -! parameters and (eventually) coarse matrix and prolongator/restrictors. -! -! a - type(psb_cspmat_type). -! The sparse matrix structure containing the local part of the -! fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_cspmat_type), input/output -! The tentative prolongator on input, released on output. -! -! info - integer, output. -! Error code. -! -subroutine mld_c_base_onelev_mat_asb(lv,a,desc_a,ilaggr,nlaggr,t_prol,info) - - use psb_base_mod - use mld_base_prec_type - use mld_c_onelev_mod, mld_protect_name => mld_c_base_onelev_mat_asb - - implicit none - - ! Arguments - class(mld_c_onelev_type), intent(inout), target :: lv - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - integer(psb_lpk_), intent(inout) :: ilaggr(:) - type(psb_lcspmat_type), intent(inout) :: t_prol - integer(psb_ipk_), intent(out) :: info - - - ! Local variables - character(len=24) :: name - integer(psb_ipk_) :: ictxt, np, me - integer(psb_ipk_) :: err_act - type(psb_cspmat_type) :: ac, op_restr, op_prol - integer(psb_ipk_) :: nzl, inl - integer(psb_ipk_) :: debug_level, debug_unit - - name='mld_c_onelev_mat_asb' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - call mld_check_def(lv%parms%aggr_prol,'Smoother',& - & mld_smooth_prol_,is_legal_ml_aggr_prol) - call mld_check_def(lv%parms%coarse_mat,'Coarse matrix',& - & mld_distr_mat_,is_legal_ml_coarse_mat) - call mld_check_def(lv%parms%aggr_filter,'Use filtered matrix',& - & mld_no_filter_mat_,is_legal_aggr_filter) - call mld_check_def(lv%parms%aggr_omega_alg,'Omega Alg.',& - & mld_eig_est_,is_legal_ml_aggr_omega_alg) - call mld_check_def(lv%parms%aggr_eig,'Eigenvalue estimate',& - & mld_max_norm_,is_legal_ml_aggr_eig) - call mld_check_def(lv%parms%aggr_omega_val,'Omega',szero,is_legal_s_omega) - - - ! - ! Build the coarse-level matrix from the fine-level one, starting from - ! the mapping defined by mld_aggrmap_bld and applying the aggregation - ! algorithm specified by lv%iprcparm(mld_aggr_prol_) - ! - call lv%aggr%mat_bld(lv%parms,a,desc_a,ilaggr,nlaggr,& - & lv%ac,lv%desc_ac,op_prol,op_restr,t_prol,info) - - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_aggrmat_asb') - goto 9999 - end if - - ! - ! Now build its descriptor and convert global indices for - ! ac, op_restr and op_prol - ! - if (info == psb_success_) & - & call lv%aggr%mat_asb(lv%parms,a,desc_a,& - & lv%ac,lv%desc_ac,op_prol,op_restr,info) - - if (info == psb_success_) call lv%ac%cscnv(info,type='csr',dupl=psb_dupl_add_) - - if (info == psb_success_) call lv%aggr%bld_map(desc_a, lv%desc_ac,& - & ilaggr,nlaggr,op_restr,op_prol,lv%map,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mat_asb/map_bld') - goto 9999 - end if - ! - ! Fix the base_a and base_desc pointers for handling of residuals. - ! This is correct because this routine is only called at levels >=2. - ! - lv%base_a => lv%ac - lv%base_desc => lv%desc_ac - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_c_base_onelev_mat_asb diff --git a/mlprec/impl/level/mld_c_base_onelev_setag.f90 b/mlprec/impl/level/mld_c_base_onelev_setag.f90 deleted file mode 100644 index 37b0d1de..00000000 --- a/mlprec/impl/level/mld_c_base_onelev_setag.f90 +++ /dev/null @@ -1,82 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_onelev_setag(lv,val,info,pos) - - use psb_base_mod - use mld_c_onelev_mod, mld_protect_name => mld_c_base_onelev_setag - - implicit none - - ! Arguments - class(mld_c_onelev_type), target, intent(inout) :: lv - class(mld_c_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ipos_ - character(len=*), parameter :: name='mld_base_onelev_setag' - - info = psb_success_ - - ! Ignore pos for aggregator - - if (allocated(lv%aggr)) then - if (.not.same_type_as(lv%aggr,val)) then - call lv%aggr%free(info) - deallocate(lv%aggr,stat=info) - if (info /= 0) then - info = 3111 - return - end if - end if - end if - - if (.not.allocated(lv%aggr)) then - allocate(lv%aggr,mold=val,stat=info) - if (info /= 0) then - info = 3111 - return - end if - lv%parms%par_aggr_alg = mld_ext_aggr_ - lv%parms%aggr_type = mld_noalg_ - call lv%aggr%default() - end if - -end subroutine mld_c_base_onelev_setag - diff --git a/mlprec/impl/level/mld_c_base_onelev_setsm.F90 b/mlprec/impl/level/mld_c_base_onelev_setsm.F90 deleted file mode 100644 index 5f95daf7..00000000 --- a/mlprec/impl/level/mld_c_base_onelev_setsm.F90 +++ /dev/null @@ -1,114 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_onelev_setsm(lev,val,info,pos) - - use psb_base_mod - use mld_c_prec_mod, mld_protect_name => mld_c_base_onelev_setsm - - implicit none - - ! Arguments - class(mld_c_onelev_type), target, intent(inout) :: lev - class(mld_c_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ipos_ - character(len=*), parameter :: name='mld_base_onelev_setsm' - - info = psb_success_ - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - if (ipos_ == mld_smooth_both_) then - if (allocated(lev%sm2a)) then - call lev%sm2a%free(info) - deallocate(lev%sm2a, stat=info) - lev%sm2 => null() - end if - end if - - select case(ipos_) - case(mld_smooth_pre_, mld_smooth_both_) - if (allocated(lev%sm)) then - if (.not.same_type_as(lev%sm,val)) then - call lev%sm%free(info) - deallocate(lev%sm, stat=info) - end if - endif - if (.not.allocated(lev%sm)) then -#ifdef HAVE_MOLD - allocate(lev%sm,mold=val) -#else - allocate(lev%sm,source=val) -#endif - end if - call lev%sm%default() - if (ipos_ == mld_smooth_both_) lev%sm2 => lev%sm - case(mld_smooth_post_) - if (allocated(lev%sm2a)) then - if (.not.same_type_as(lev%sm2a,val)) then - call lev%sm2a%free(info) - deallocate(lev%sm2a, stat=info) - endif - end if - if (.not.allocated(lev%sm2a)) then -#ifdef HAVE_MOLD - allocate(lev%sm2a,mold=val) -#else - allocate(lev%sm2a,source=val) -#endif - end if - call lev%sm2a%default() - lev%sm2 => lev%sm2a - end select - -end subroutine mld_c_base_onelev_setsm - diff --git a/mlprec/impl/level/mld_c_base_onelev_setsv.F90 b/mlprec/impl/level/mld_c_base_onelev_setsv.F90 deleted file mode 100644 index f73c7348..00000000 --- a/mlprec/impl/level/mld_c_base_onelev_setsv.F90 +++ /dev/null @@ -1,152 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_onelev_setsv(lev,val,info,pos) - - use psb_base_mod - use mld_c_prec_mod, mld_protect_name => mld_c_base_onelev_setsv - - implicit none - - ! Arguments - class(mld_c_onelev_type), target, intent(inout) :: lev - class(mld_c_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ipos_ - character(len=*), parameter :: name='mld_base_onelev_setsv' - - info = psb_success_ - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - if ((ipos_ == mld_smooth_pre_).or.(ipos_ == mld_smooth_both_)) then - if (allocated(lev%sm)) then - if (allocated(lev%sm%sv)) then - if (.not.same_type_as(lev%sm%sv,val)) then - call lev%sm%sv%free(info) - if (info == 0) deallocate(lev%sm%sv,stat=info) - if (info /= 0) then - info = 3111 - return - end if - end if - end if - - if (.not.allocated(lev%sm%sv)) then -#ifdef HAVE_MOLD - allocate(lev%sm%sv,mold=val,stat=info) -#else - allocate(lev%sm%sv,source=val,stat=info) -#endif - if (info /= 0) then - info = 3111 - return - end if - end if - call lev%sm%sv%default() - else - info = 3111 - write(psb_err_unit,*) name,& - &': Error: uninitialized preconditioner component,',& - &' should call MLD_PRECINIT/MLD_PRECSET' - return - - end if - end if - - ! - ! If POS was not specified and therefore we have mld_smooth_both_ - ! we need to update sm2a *only* if it was already allocated, - ! otherwise it is not needed (since we have just fixed %sm in the - ! pre section). - ! - - if ((ipos_ == mld_smooth_post_).or. & - ((ipos_ == mld_smooth_both_).and.(allocated(lev%sm2a)))) then - - - if (allocated(lev%sm2a)) then - if (allocated(lev%sm2a%sv)) then - if (.not.same_type_as(lev%sm2a%sv,val)) then - call lev%sm2a%sv%free(info) - if (info == 0) deallocate(lev%sm2a%sv,stat=info) - if (info /= 0) then - info = 3111 - return - end if - end if - end if - if (.not.allocated(lev%sm2a%sv)) then -#ifdef HAVE_MOLD - allocate(lev%sm2a%sv,mold=val,stat=info) -#else - allocate(lev%sm2a%sv,source=val,stat=info) -#endif - if (info /= 0) then - info = 3111 - return - end if - end if - call lev%sm2a%sv%default() - - else - info = 3111 - write(psb_err_unit,*) name,& - &': Error: uninitialized preconditioner component,',& - &' should call MLD_PRECINIT/MLD_PRECSET' - return - - end if - - end if - -end subroutine mld_c_base_onelev_setsv - diff --git a/mlprec/impl/level/mld_d_base_onelev_build.f90 b/mlprec/impl/level/mld_d_base_onelev_build.f90 deleted file mode 100644 index 7b358e3a..00000000 --- a/mlprec/impl/level/mld_d_base_onelev_build.f90 +++ /dev/null @@ -1,153 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_onelev_build(lv,info,amold,vmold,imold,ilv) - use psb_base_mod - use mld_d_onelev_mod, mld_protect_name => mld_d_base_onelev_build - implicit none - class(mld_d_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - integer(psb_ipk_), intent(in), optional :: ilv - ! Local - integer(psb_ipk_) :: err,i,k, err_act - integer(psb_ipk_) :: ictxt, me, np - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - - name = 'mld_onelev_build' - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - if (.not.associated(lv%base_desc)) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Unassociated base DESC') - goto 9999 - end if - info = psb_success_ - ictxt = lv%base_desc%get_ctxt() - call psb_info(ictxt,me,np) - - if (.not.allocated(lv%sm)) then - !! Error: should have called mld_dprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - if (.not.allocated(lv%sm%sv)) then - !! Error: should have called mld_dprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - lv%ac_nz_loc = lv%ac%get_nzeros() - lv%ac_nz_tot = lv%ac_nz_loc - select case(lv%parms%coarse_mat) - case(mld_distr_mat_) - call psb_sum(ictxt,lv%ac_nz_tot) - case(mld_repl_mat_) - ! Do nothing - case default - ! Should never get here - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='Wrong lv%parms') - goto 9999 - end select - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Calling mlprcbld at level ',i - call mld_check_def(lv%parms%sweeps_pre,& - & 'Jacobi sweeps',izero,is_int_non_negative) - call mld_check_def(lv%parms%sweeps_post,& - & 'Jacobi sweeps',izero,is_int_non_negative) - - call lv%sm%build(lv%base_a,lv%base_desc,info) - if (info == 0) then - if (allocated(lv%sm2a)) then - call lv%sm2a%build(lv%base_a,lv%base_desc,info) - lv%sm2 => lv%sm2a - else - lv%sm2 => lv%sm - end if - end if - if (info /=0 ) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Smoother bld error') - goto 9999 - end if - - if (lv%sm%sv%is_global()) then - if ((lv%parms%sweeps_pre>1).or.(lv%parms%sweeps_post>1)) then - lv%parms%sweeps_pre = 1 - lv%parms%sweeps_post = 1 - if (me == 0) then - write(debug_unit,*) - if (present(ilv)) then - write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),& - & '" at level ',ilv - write(debug_unit,*) ' is configured as a global solver ' - else - write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),& - & '" is configured as a global solver ' - end if - write(debug_unit,*) ' Pre and post sweeps at this level reset to 1' - end if - end if - end if - - if (any((/present(amold),present(vmold),present(imold)/))) & - & call lv%cnv(info,amold=amold,vmold=vmold,imold=imold) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_base_onelev_build diff --git a/mlprec/impl/level/mld_d_base_onelev_check.f90 b/mlprec/impl/level/mld_d_base_onelev_check.f90 deleted file mode 100644 index 65c58a16..00000000 --- a/mlprec/impl/level/mld_d_base_onelev_check.f90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_onelev_check(lv,info) - - use psb_base_mod - use mld_d_onelev_mod, mld_protect_name => mld_d_base_onelev_check - - Implicit None - - ! Arguments - class(mld_d_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_onelev_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - call mld_check_def(lv%parms%sweeps_pre,& - & 'Jacobi sweeps',ione,is_int_non_negative) - call mld_check_def(lv%parms%sweeps_post,& - & 'Jacobi sweeps',ione,is_int_non_negative) - - if (allocated(lv%sm)) then - call lv%sm%check(info) - else - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - if (allocated(lv%sm2a)) then - call lv%sm2a%check(info) - else if (.not.inner_check(lv%sm2,lv%sm)) then - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -contains - function inner_check(smp,sm) result(res) - implicit none - logical :: res - class(mld_d_base_smoother_type), intent(in), pointer :: smp - class(mld_d_base_smoother_type), intent(in), target :: sm - - res = associated(smp, sm) - end function inner_check - -end subroutine mld_d_base_onelev_check diff --git a/mlprec/impl/level/mld_d_base_onelev_cnv.f90 b/mlprec/impl/level/mld_d_base_onelev_cnv.f90 deleted file mode 100644 index a43054a6..00000000 --- a/mlprec/impl/level/mld_d_base_onelev_cnv.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_onelev_cnv(lv,info,amold,vmold,imold) - - use psb_base_mod - use mld_d_onelev_mod, mld_protect_name => mld_d_base_onelev_cnv - implicit none - - class(mld_d_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - integer(psb_ipk_) :: i - - info = psb_success_ - - if (any((/present(amold),present(vmold),present(imold)/))) then - if (allocated(lv%sm)) & - & call lv%sm%cnv(info,amold=amold,vmold=vmold,imold=imold) - if (info == psb_success_ .and. allocated(lv%sm2a)) & - & call lv%sm2a%cnv(info,amold=amold,vmold=vmold,imold=imold) - if (info == psb_success_ .and. allocated(lv%wrk)) & - & call lv%wrk%cnv(info,vmold=vmold) - if (info == psb_success_.and. lv%ac%is_asb()) & - & call lv%ac%cscnv(info,mold=amold) - if (info == psb_success_ .and. lv%desc_ac%is_ok() & - & .and. present(imold)) call lv%desc_ac%cnv(imold) - if (info == psb_success_) call lv%map%cnv(info,mold=amold,imold=imold) - end if -end subroutine mld_d_base_onelev_cnv diff --git a/mlprec/impl/level/mld_d_base_onelev_csetc.F90 b/mlprec/impl/level/mld_d_base_onelev_csetc.F90 deleted file mode 100644 index 69d7d7f8..00000000 --- a/mlprec/impl/level/mld_d_base_onelev_csetc.F90 +++ /dev/null @@ -1,312 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_onelev_csetc(lv,what,val,info,pos,idx) - - use psb_base_mod - use mld_d_onelev_mod, mld_protect_name => mld_d_base_onelev_csetc - use mld_d_base_aggregator_mod - use mld_d_dec_aggregator_mod - use mld_d_symdec_aggregator_mod - use mld_d_jac_smoother - use mld_d_as_smoother - use mld_d_diag_solver - use mld_d_l1_diag_solver - use mld_d_ilu_solver - use mld_d_id_solver - use mld_d_gs_solver -#if defined(HAVE_UMF_) - use mld_d_umf_solver -#endif -#if defined(HAVE_SLUDIST_) - use mld_d_sludist_solver -#endif -#if defined(HAVE_SLU_) - use mld_d_slu_solver -#endif -#if defined(HAVE_MUMPS_) - use mld_d_mumps_solver -#endif - - Implicit None - - ! Arguments - class(mld_d_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - ! Local - integer(psb_ipk_) :: ipos_, err_act - character(len=20) :: name='d_base_onelev_csetc' - integer(psb_ipk_) :: ival - type(mld_d_base_smoother_type) :: mld_d_base_smoother_mold - type(mld_d_jac_smoother_type) :: mld_d_jac_smoother_mold - type(mld_d_l1_jac_smoother_type) :: mld_d_l1_jac_smoother_mold - type(mld_d_as_smoother_type) :: mld_d_as_smoother_mold - type(mld_d_diag_solver_type) :: mld_d_diag_solver_mold - type(mld_d_l1_diag_solver_type) :: mld_d_l1_diag_solver_mold - type(mld_d_ilu_solver_type) :: mld_d_ilu_solver_mold - type(mld_d_id_solver_type) :: mld_d_id_solver_mold - type(mld_d_gs_solver_type) :: mld_d_gs_solver_mold - type(mld_d_bwgs_solver_type) :: mld_d_bwgs_solver_mold -#if defined(HAVE_UMF_) - type(mld_d_umf_solver_type) :: mld_d_umf_solver_mold -#endif -#if defined(HAVE_SLUDIST_) - type(mld_d_sludist_solver_type) :: mld_d_sludist_solver_mold -#endif -#if defined(HAVE_SLU_) - type(mld_d_slu_solver_type) :: mld_d_slu_solver_mold -#endif -#if defined(HAVE_MUMPS_) - type(mld_d_mumps_solver_type) :: mld_d_mumps_solver_mold -#endif - - - call psb_erractionsave(err_act) - - info = psb_success_ - - ival = lv%stringval(val) - - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - select case (psb_toupper(trim(what))) - case ('SMOOTHER_TYPE') - select case (psb_toupper(trim(val))) - case ('NOPREC','NONE') - call lv%set(mld_d_base_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_d_id_solver_mold,info,pos=pos) - - case ('JAC','JACOBI') - call lv%set(mld_d_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_d_diag_solver_mold,info,pos=pos) - - case ('L1-JACOBI') - call lv%set(mld_d_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_d_l1_diag_solver_mold,info,pos=pos) - - case ('BJAC') - call lv%set(mld_d_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_d_ilu_solver_mold,info,pos=pos) - - case ('L1-BJAC') - call lv%set(mld_d_l1_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_d_ilu_solver_mold,info,pos=pos) - - case ('AS') - call lv%set(mld_d_as_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_d_ilu_solver_mold,info,pos=pos) - - case ('GS','FWGS') - call lv%set(mld_d_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_d_gs_solver_mold,info,pos='pre') - if (allocated(lv%sm2a)) deallocate(lv%sm2a) - case ('BWGS') - call lv%set(mld_d_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_d_bwgs_solver_mold,info,pos='pre') - if (allocated(lv%sm2a)) deallocate(lv%sm2a) - case ('FBGS') - call lv%set(mld_d_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_d_gs_solver_mold,info,pos='pre') - call lv%set(mld_d_jac_smoother_mold,info,pos='post') - if (info == 0) call lv%set(mld_d_bwgs_solver_mold,info,pos='post') - case ('L1-GS','L1-FWGS') - call lv%set(mld_d_l1_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_d_gs_solver_mold,info,pos='pre') - if (allocated(lv%sm2a)) deallocate(lv%sm2a) - case ('L1-BWGS') - call lv%set(mld_d_l1_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_d_bwgs_solver_mold,info,pos='pre') - if (allocated(lv%sm2a)) deallocate(lv%sm2a) - case ('L1-FBGS') - call lv%set(mld_d_l1_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_d_gs_solver_mold,info,pos='pre') - call lv%set(mld_d_l1_jac_smoother_mold,info,pos='post') - if (info == 0) call lv%set(mld_d_bwgs_solver_mold,info,pos='post') - - case default - ! - ! Do nothing and hope for the best :) - ! - end select - if ((ipos_==mld_smooth_pre_).or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) call lv%sm%default() - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm2a)) call lv%sm2a%default() - end if - - - case('SUB_SOLVE') - select case (psb_toupper(trim(val))) - case ('NONE','NOPREC','FACT_NONE') - call lv%set(mld_d_id_solver_mold,info,pos=pos) - - case ('DIAG') - call lv%set(mld_d_diag_solver_mold,info,pos=pos) - - case ('L1-DIAG') - call lv%set(mld_d_l1_diag_solver_mold,info,pos=pos) - - case ('GS','FGS','FWGS') - call lv%set(mld_d_gs_solver_mold,info,pos=pos) - - case ('BGS','BWGS') - call lv%set(mld_d_bwgs_solver_mold,info,pos=pos) - - case ('ILU','ILUT','MILU') - call lv%set(mld_d_ilu_solver_mold,info,pos=pos) - if (info == 0) then - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - call lv%sm%sv%set('SUB_SOLVE',val,info) - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) call lv%sm2a%sv%set('SUB_SOLVE',val,info) - end if - end if -#ifdef HAVE_SLU_ - case ('SLU') - call lv%set(mld_d_slu_solver_mold,info,pos=pos) -#endif -#ifdef HAVE_MUMPS_ - case ('MUMPS') - call lv%set(mld_d_mumps_solver_mold,info,pos=pos) -#endif -#ifdef HAVE_SLUDIST_ - case ('SLUDIST') - call lv%set(mld_d_sludist_solver_mold,info,pos=pos) -#endif -#ifdef HAVE_UMF_ - case ('UMF') - call lv%set(mld_d_umf_solver_mold,info,pos=pos) -#endif - case default - ! - ! Do nothing and hope for the best :) - ! - end select - - case ('ML_CYCLE') - lv%parms%ml_cycle = mld_stringval(val) - - case ('PAR_AGGR_ALG') - ival = mld_stringval(val) - lv%parms%par_aggr_alg = ival - if (allocated(lv%aggr)) then - call lv%aggr%free(info) - if (info == 0) deallocate(lv%aggr,stat=info) - if (info /= 0) then - info = psb_err_internal_error_ - return - end if - end if - - select case(ival) - case(mld_dec_aggr_) - allocate(mld_d_dec_aggregator_type :: lv%aggr, stat=info) - case(mld_sym_dec_aggr_) - allocate(mld_d_symdec_aggregator_type :: lv%aggr, stat=info) - case default - info = psb_err_internal_error_ - end select - if (info == psb_success_) call lv%aggr%default() - - case ('AGGR_ORD') - lv%parms%aggr_ord = mld_stringval(val) - - case ('AGGR_TYPE') - lv%parms%aggr_type = mld_stringval(val) - if (allocated(lv%aggr)) call lv%aggr%set_aggr_type(lv%parms,info) - - case ('AGGR_PROL') - lv%parms%aggr_prol = mld_stringval(val) - - case ('COARSE_MAT') - lv%parms%coarse_mat = mld_stringval(val) - - case ('AGGR_OMEGA_ALG') - lv%parms%aggr_omega_alg= mld_stringval(val) - - case ('AGGR_EIG') - lv%parms%aggr_eig = mld_stringval(val) - - case ('AGGR_FILTER') - lv%parms%aggr_filter = mld_stringval(val) - - case ('COARSE_SOLVE') - lv%parms%coarse_solve = mld_stringval(val) - - case default - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) then - call lv%sm%set(what,val,info,idx=idx) - end if - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) then - call lv%sm2a%set(what,val,info,idx=idx) - end if - end if - if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) - - end select - - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_d_base_onelev_csetc diff --git a/mlprec/impl/level/mld_d_base_onelev_cseti.F90 b/mlprec/impl/level/mld_d_base_onelev_cseti.F90 deleted file mode 100644 index 015d3421..00000000 --- a/mlprec/impl/level/mld_d_base_onelev_cseti.F90 +++ /dev/null @@ -1,288 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_onelev_cseti(lv,what,val,info,pos,idx) - - use psb_base_mod - use mld_d_onelev_mod, mld_protect_name => mld_d_base_onelev_cseti - use mld_d_base_aggregator_mod - use mld_d_dec_aggregator_mod - use mld_d_symdec_aggregator_mod - use mld_d_jac_smoother - use mld_d_as_smoother - use mld_d_diag_solver - use mld_d_l1_diag_solver - use mld_d_ilu_solver - use mld_d_id_solver - use mld_d_gs_solver -#if defined(HAVE_UMF_) - use mld_d_umf_solver -#endif -#if defined(HAVE_SLUDIST_) - use mld_d_sludist_solver -#endif -#if defined(HAVE_SLU_) - use mld_d_slu_solver -#endif -#if defined(HAVE_MUMPS_) - use mld_d_mumps_solver -#endif - - Implicit None - - ! Arguments - class(mld_d_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - ! Local - integer(psb_ipk_) :: ipos_, err_act - character(len=20) :: name='d_base_onelev_cseti' - type(mld_d_base_smoother_type) :: mld_d_base_smoother_mold - type(mld_d_jac_smoother_type) :: mld_d_jac_smoother_mold - type(mld_d_l1_jac_smoother_type) :: mld_d_l1_jac_smoother_mold - type(mld_d_as_smoother_type) :: mld_d_as_smoother_mold - type(mld_d_diag_solver_type) :: mld_d_diag_solver_mold - type(mld_d_l1_diag_solver_type) :: mld_d_l1_diag_solver_mold - type(mld_d_ilu_solver_type) :: mld_d_ilu_solver_mold - type(mld_d_id_solver_type) :: mld_d_id_solver_mold - type(mld_d_gs_solver_type) :: mld_d_gs_solver_mold - type(mld_d_bwgs_solver_type) :: mld_d_bwgs_solver_mold -#if defined(HAVE_UMF_) - type(mld_d_umf_solver_type) :: mld_d_umf_solver_mold -#endif -#if defined(HAVE_SLUDIST_) - type(mld_d_sludist_solver_type) :: mld_d_sludist_solver_mold -#endif -#if defined(HAVE_SLU_) - type(mld_d_slu_solver_type) :: mld_d_slu_solver_mold -#endif -#if defined(HAVE_MUMPS_) - type(mld_d_mumps_solver_type) :: mld_d_mumps_solver_mold -#endif - - call psb_erractionsave(err_act) - info = psb_success_ - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - select case (psb_toupper(what)) - case ('SMOOTHER_TYPE') - select case (val) - case (mld_noprec_) - call lv%set(mld_d_base_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_d_id_solver_mold,info,pos=pos) - - case (mld_jac_) - call lv%set(mld_d_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_d_diag_solver_mold,info,pos=pos) - - case (mld_l1_jac_) - call lv%set(mld_d_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_d_l1_diag_solver_mold,info,pos=pos) - - case (mld_bjac_) - call lv%set(mld_d_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_d_ilu_solver_mold,info,pos=pos) - - case (mld_l1_bjac_) - call lv%set(mld_d_l1_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_d_ilu_solver_mold,info,pos=pos) - - case (mld_as_) - call lv%set(mld_d_as_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_d_ilu_solver_mold,info,pos=pos) - - case (mld_fbgs_) - call lv%set(mld_d_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_d_gs_solver_mold,info,pos='pre') - call lv%set(mld_d_jac_smoother_mold,info,pos='post') - if (info == 0) call lv%set(mld_d_bwgs_solver_mold,info,pos='post') - - case default - ! - ! Do nothing and hope for the best :) - ! - end select - if ((ipos_==mld_smooth_pre_).or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) call lv%sm%default() - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm2a)) call lv%sm2a%default() - end if - - - case('SUB_SOLVE') - select case (val) - case (mld_f_none_) - call lv%set(mld_d_id_solver_mold,info,pos=pos) - - case (mld_diag_scale_) - call lv%set(mld_d_diag_solver_mold,info,pos=pos) - - case (mld_l1_diag_scale_) - call lv%set(mld_d_l1_diag_solver_mold,info,pos=pos) - - case (mld_gs_) - call lv%set(mld_d_gs_solver_mold,info,pos=pos) - - case (mld_bwgs_) - call lv%set(mld_d_bwgs_solver_mold,info,pos=pos) - - case (psb_ilu_n_,psb_milu_n_,psb_ilu_t_) - call lv%set(mld_d_ilu_solver_mold,info,pos=pos) - if (info == 0) then - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - call lv%sm%sv%set('SUB_SOLVE',val,info) - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) call lv%sm2a%sv%set('SUB_SOLVE',val,info) - end if - end if -#ifdef HAVE_SLU_ - case (mld_slu_) - call lv%set(mld_d_slu_solver_mold,info,pos=pos) -#endif -#ifdef HAVE_MUMPS_ - case (mld_mumps_) - call lv%set(mld_d_mumps_solver_mold,info,pos=pos) -#endif -#ifdef HAVE_SLUDIST_ - case (mld_sludist_) - call lv%set(mld_d_sludist_solver_mold,info,pos=pos) -#endif -#ifdef HAVE_UMF_ - case (mld_umf_) - call lv%set(mld_d_umf_solver_mold,info,pos=pos) -#endif - case default - ! - ! Do nothing and hope for the best :) - ! - end select - - - case ('SMOOTHER_SWEEPS') - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) & - & lv%parms%sweeps_pre = val - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_)) & - & lv%parms%sweeps_post = val - - case ('ML_CYCLE') - lv%parms%ml_cycle = val - - case ('PAR_AGGR_ALG') - lv%parms%par_aggr_alg = val - if (allocated(lv%aggr)) then - call lv%aggr%free(info) - if (info == 0) deallocate(lv%aggr,stat=info) - if (info /= 0) then - info = psb_err_internal_error_ - return - end if - end if - - select case(val) - case(mld_dec_aggr_) - allocate(mld_d_dec_aggregator_type :: lv%aggr, stat=info) - case(mld_sym_dec_aggr_) - allocate(mld_d_symdec_aggregator_type :: lv%aggr, stat=info) - case default - info = psb_err_internal_error_ - end select - if (info == psb_success_) call lv%aggr%default() - - case ('AGGR_ORD') - lv%parms%aggr_ord = val - - case ('AGGR_TYPE') - lv%parms%aggr_type = val - if (allocated(lv%aggr)) call lv%aggr%set_aggr_type(lv%parms,info) - - case ('AGGR_PROL') - lv%parms%aggr_prol = val - - case ('COARSE_MAT') - lv%parms%coarse_mat = val - - case ('AGGR_OMEGA_ALG') - lv%parms%aggr_omega_alg= val - - case ('AGGR_EIG') - lv%parms%aggr_eig = val - - case ('AGGR_FILTER') - lv%parms%aggr_filter = val - - case ('COARSE_SOLVE') - lv%parms%coarse_solve = val - - case default - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) then - call lv%sm%set(what,val,info,idx=idx) - end if - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) then - call lv%sm2a%set(what,val,info,idx=idx) - end if - end if - if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) - - end select - if (info /= psb_success_) goto 9999 - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_d_base_onelev_cseti diff --git a/mlprec/impl/level/mld_d_base_onelev_csetr.f90 b/mlprec/impl/level/mld_d_base_onelev_csetr.f90 deleted file mode 100644 index 1fd2654c..00000000 --- a/mlprec/impl/level/mld_d_base_onelev_csetr.f90 +++ /dev/null @@ -1,105 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_onelev_csetr(lv,what,val,info,pos,idx) - - use psb_base_mod - use mld_d_onelev_mod, mld_protect_name => mld_d_base_onelev_csetr - - Implicit None - - ! Arguments - class(mld_d_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - ! Local - integer(psb_ipk_) :: ipos_, err_act - character(len=20) :: name='d_base_onelev_csetr' - - call psb_erractionsave(err_act) - - - info = psb_success_ - - select case (psb_toupper(what)) - - case ('AGGR_OMEGA_VAL') - lv%parms%aggr_omega_val= val - - case ('AGGR_THRESH') - lv%parms%aggr_thresh = val - - case default - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) then - call lv%sm%set(what,val,info,idx=idx) - end if - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) then - call lv%sm2a%set(what,val,info,idx=idx) - end if - end if - if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) - - end select - - if (info /= psb_success_) goto 9999 - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_d_base_onelev_csetr diff --git a/mlprec/impl/level/mld_d_base_onelev_descr.f90 b/mlprec/impl/level/mld_d_base_onelev_descr.f90 deleted file mode 100644 index 2ae49217..00000000 --- a/mlprec/impl/level/mld_d_base_onelev_descr.f90 +++ /dev/null @@ -1,112 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_onelev_descr(lv,il,nl,ilmin,info,iout) - - use psb_base_mod - use mld_d_onelev_mod, mld_protect_name => mld_d_base_onelev_descr - Implicit None - ! Arguments - class(mld_d_onelev_type), intent(in) :: lv - integer(psb_ipk_), intent(in) :: il,nl,ilmin - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_d_base_onelev_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse - - - call psb_erractionsave(err_act) - - - coarse = (il==nl) - - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - end if - - write(iout_,*) - if (il == ilmin) then - call lv%parms%mlcycledsc(iout_,info) - if (allocated(lv%aggr)) then - call lv%aggr%descr(lv%parms,iout_,info) - else - write(iout_,*) 'Internal error: unallocated aggregator object' - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - write(iout_,*) - end if - - if (il > 1) then - - if (coarse) then - write(iout_,*) ' Level ',il,' (coarse)' - else - write(iout_,*) ' Level ',il - end if - - call lv%parms%descr(iout_,info,coarse=coarse) - - if (nl > 1) then - if (allocated(lv%map%naggr)) then - write(iout_,*) ' Coarse Matrix: Global size: ', & - & sum((1_psb_lpk_*lv%map%naggr(:))),' Nonzeros: ',lv%ac_nz_tot - write(iout_,*) ' Local matrix sizes: ', & - & lv%map%naggr(:) - write(iout_,*) ' Aggregation ratio: ', & - & lv%szratio - end if - end if - - if (coarse.and.allocated(lv%sm)) & - & call lv%sm%descr(info,iout=iout_,coarse=coarse) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_d_base_onelev_descr diff --git a/mlprec/impl/level/mld_d_base_onelev_dump.f90 b/mlprec/impl/level/mld_d_base_onelev_dump.f90 deleted file mode 100644 index e974b8ee..00000000 --- a/mlprec/impl/level/mld_d_base_onelev_dump.f90 +++ /dev/null @@ -1,169 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_onelev_dump(lv,level,info,prefix,head,ac,rp,& - & smoother,solver,tprol,global_num) - - use psb_base_mod - use mld_d_onelev_mod, mld_protect_name => mld_d_base_onelev_dump - implicit none - class(mld_d_onelev_type), intent(in) :: lv - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: ac, rp, smoother, solver, tprol, global_num - ! Local variables - integer(psb_ipk_) :: i, j, il1, iln, lname, lev, ni - integer(psb_ipk_) :: icontxt,iam, np - character(len=80) :: prefix_, frmt - character(len=1024) :: fname - logical :: ac_, rp_, tprol_, global_num_ - integer(psb_lpk_), allocatable :: ivr(:), ivc(:) - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_lev_d" - end if - - if (associated(lv%base_desc)) then - icontxt = lv%base_desc%get_context() - call psb_info(icontxt,iam,np) - else - icontxt = -1 - iam = -1 - np = -1 - end if - if (present(ac)) then - ac_ = ac - else - ac_ = .false. - end if - if (present(rp)) then - rp_ = rp - else - rp_ = .false. - end if - if (present(tprol)) then - tprol_ = tprol - else - tprol_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - - if (np > 0) then - ni = floor(log10(1.0*np)) + 1 - write(frmt,'(a,i3.3,a,i3.3,a)') '(a,i',ni,'.',ni,')' - write(fname(lname+1:lname+ni+2),frmt) '_p',iam - lname = lname + ni + 2 - end if - - if (global_num_) then - if (level >= 2) then - if (ac_) then - ivr = lv%desc_ac%get_global_indices(owned=.false.) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx' - call lv%ac%print(fname,head=head,iv=ivr) - end if - if (rp_) then - ivr = lv%map%p_desc_U%get_global_indices(owned=.false.) - ivc = lv%map%p_desc_V%get_global_indices(owned=.false.) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx' - call lv%map%mat_U2V%print(fname,head=head,ivr=ivc,ivc=ivr) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx' - call lv%map%mat_V2U%print(fname,head=head,ivr=ivr,ivc=ivc) - end if - if (tprol_) then - ! Tentative prolongator is stored with column indices already - ! in global numbering, so only IVR is needed. - ivr = lv%map%p_desc_U%get_global_indices(owned=.false.) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_tprol.mtx' - ! - ! This is not implemented yet. - !call lv%tprol%print(fname,head=head,ivr=ivr) - end if - end if - else - if (level >= 2) then - if (ac_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx' - call lv%ac%print(fname,head=head) - end if - if (rp_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx' - call lv%map%mat_U2V%print(fname,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx' - call lv%map%mat_V2U%print(fname,head=head) - end if - if (tprol_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_tprol.mtx' - ! - ! This is not implemented yet. - !call lv%tprol%print(fname,head=head) - end if - end if - end if - - if (level >= 2) then - if (allocated(lv%sm)) then - call lv%sm%dump(lv%desc_ac,level,info,smoother=smoother, & - & solver=solver,prefix=trim(prefix_)//"_sm",global_num=global_num) - end if - if (allocated(lv%sm2a)) then - call lv%sm2a%dump(lv%desc_ac,level,info,smoother=smoother, & - & solver=solver,prefix=trim(prefix_)//"_sm2a",global_num=global_num) - end if - else - if (allocated(lv%sm)) then - call lv%sm%dump(lv%base_desc,level,info,smoother=smoother, & - & solver=solver,prefix=trim(prefix_)//"_sm",global_num=global_num) - end if - if (allocated(lv%sm2a)) then - call lv%sm2a%dump(lv%base_desc,level,info,smoother=smoother, & - & solver=solver,prefix=trim(prefix_)//"_sm2a",global_num=global_num) - end if - end if - -end subroutine mld_d_base_onelev_dump diff --git a/mlprec/impl/level/mld_d_base_onelev_free.f90 b/mlprec/impl/level/mld_d_base_onelev_free.f90 deleted file mode 100644 index beef8edd..00000000 --- a/mlprec/impl/level/mld_d_base_onelev_free.f90 +++ /dev/null @@ -1,75 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_onelev_free(lv,info) - - use psb_base_mod - use mld_d_onelev_mod, mld_protect_name => mld_d_base_onelev_free - implicit none - - class(mld_d_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: i - - info = psb_success_ - - ! We might just deallocate the top level array, except - ! that there may be inner objects containing C pointers, - ! e.g. UMFPACK, SLU or CUDA stuff. - ! We really need FINALs. - if (allocated(lv%sm)) & - & call lv%sm%free(info) - - if (allocated(lv%sm2a)) & - & call lv%sm2a%free(info) - - if (allocated(lv%wrk)) & - & call lv%wrk%free(info) - - call lv%ac%free() - if (lv%desc_ac%is_ok()) & - & call lv%desc_ac%free(info) - call lv%map%free(info) - - ! This is a pointer to something else, must not free it here. - nullify(lv%base_a) - ! This is a pointer to something else, must not free it here. - nullify(lv%base_desc) - - call lv%nullify() - -end subroutine mld_d_base_onelev_free diff --git a/mlprec/impl/level/mld_d_base_onelev_mat_asb.f90 b/mlprec/impl/level/mld_d_base_onelev_mat_asb.f90 deleted file mode 100644 index 6346f2fc..00000000 --- a/mlprec/impl/level/mld_d_base_onelev_mat_asb.f90 +++ /dev/null @@ -1,178 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_d_onelev_mat_asb.f90 -! -! Subroutine: mld_d_onelev_mat_asb -! Version: real -! -! This routine builds the matrix associated to the current level of the -! multilevel preconditioner from the matrix associated to the previous level, -! by using the user-specified aggregation technique (therefore, it also builds the -! prolongation and restriction operators mapping the current level to the -! previous one and vice versa). -! The current level is regarded as the coarse one, while the previous as -! the fine one. This is in agreement with the fact that the routine is called, -! by mld_mlprec_bld, only on levels >=2. -! The main structure is: -! 1. Perform sanity checks; -! 2. Call mld_Xaggrmat_asb to compute prolongator/restrictor/AC -! 3. According to the choice of DIST/REPL for AC, build a descriptor DESC_AC, -! and adjust the column numbering of AC/OP_PROL/OP_RESTR -! 4. Pack restrictor and prolongator into p%map -! 5. Fix base_a and base_desc pointers. -! -! -! Arguments: -! p - type(mld_d_onelev_type), input/output. -! The 'one-level' data structure containing the control -! parameters and (eventually) coarse matrix and prolongator/restrictors. -! -! a - type(psb_dspmat_type). -! The sparse matrix structure containing the local part of the -! fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_dspmat_type), input/output -! The tentative prolongator on input, released on output. -! -! info - integer, output. -! Error code. -! -subroutine mld_d_base_onelev_mat_asb(lv,a,desc_a,ilaggr,nlaggr,t_prol,info) - - use psb_base_mod - use mld_base_prec_type - use mld_d_onelev_mod, mld_protect_name => mld_d_base_onelev_mat_asb - - implicit none - - ! Arguments - class(mld_d_onelev_type), intent(inout), target :: lv - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - integer(psb_lpk_), intent(inout) :: ilaggr(:) - type(psb_ldspmat_type), intent(inout) :: t_prol - integer(psb_ipk_), intent(out) :: info - - - ! Local variables - character(len=24) :: name - integer(psb_ipk_) :: ictxt, np, me - integer(psb_ipk_) :: err_act - type(psb_dspmat_type) :: ac, op_restr, op_prol - integer(psb_ipk_) :: nzl, inl - integer(psb_ipk_) :: debug_level, debug_unit - - name='mld_d_onelev_mat_asb' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - call mld_check_def(lv%parms%aggr_prol,'Smoother',& - & mld_smooth_prol_,is_legal_ml_aggr_prol) - call mld_check_def(lv%parms%coarse_mat,'Coarse matrix',& - & mld_distr_mat_,is_legal_ml_coarse_mat) - call mld_check_def(lv%parms%aggr_filter,'Use filtered matrix',& - & mld_no_filter_mat_,is_legal_aggr_filter) - call mld_check_def(lv%parms%aggr_omega_alg,'Omega Alg.',& - & mld_eig_est_,is_legal_ml_aggr_omega_alg) - call mld_check_def(lv%parms%aggr_eig,'Eigenvalue estimate',& - & mld_max_norm_,is_legal_ml_aggr_eig) - call mld_check_def(lv%parms%aggr_omega_val,'Omega',dzero,is_legal_d_omega) - - - ! - ! Build the coarse-level matrix from the fine-level one, starting from - ! the mapping defined by mld_aggrmap_bld and applying the aggregation - ! algorithm specified by lv%iprcparm(mld_aggr_prol_) - ! - call lv%aggr%mat_bld(lv%parms,a,desc_a,ilaggr,nlaggr,& - & lv%ac,lv%desc_ac,op_prol,op_restr,t_prol,info) - - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_aggrmat_asb') - goto 9999 - end if - - ! - ! Now build its descriptor and convert global indices for - ! ac, op_restr and op_prol - ! - if (info == psb_success_) & - & call lv%aggr%mat_asb(lv%parms,a,desc_a,& - & lv%ac,lv%desc_ac,op_prol,op_restr,info) - - if (info == psb_success_) call lv%ac%cscnv(info,type='csr',dupl=psb_dupl_add_) - - if (info == psb_success_) call lv%aggr%bld_map(desc_a, lv%desc_ac,& - & ilaggr,nlaggr,op_restr,op_prol,lv%map,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mat_asb/map_bld') - goto 9999 - end if - ! - ! Fix the base_a and base_desc pointers for handling of residuals. - ! This is correct because this routine is only called at levels >=2. - ! - lv%base_a => lv%ac - lv%base_desc => lv%desc_ac - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_d_base_onelev_mat_asb diff --git a/mlprec/impl/level/mld_d_base_onelev_setag.f90 b/mlprec/impl/level/mld_d_base_onelev_setag.f90 deleted file mode 100644 index 83bd9f76..00000000 --- a/mlprec/impl/level/mld_d_base_onelev_setag.f90 +++ /dev/null @@ -1,82 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_onelev_setag(lv,val,info,pos) - - use psb_base_mod - use mld_d_onelev_mod, mld_protect_name => mld_d_base_onelev_setag - - implicit none - - ! Arguments - class(mld_d_onelev_type), target, intent(inout) :: lv - class(mld_d_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ipos_ - character(len=*), parameter :: name='mld_base_onelev_setag' - - info = psb_success_ - - ! Ignore pos for aggregator - - if (allocated(lv%aggr)) then - if (.not.same_type_as(lv%aggr,val)) then - call lv%aggr%free(info) - deallocate(lv%aggr,stat=info) - if (info /= 0) then - info = 3111 - return - end if - end if - end if - - if (.not.allocated(lv%aggr)) then - allocate(lv%aggr,mold=val,stat=info) - if (info /= 0) then - info = 3111 - return - end if - lv%parms%par_aggr_alg = mld_ext_aggr_ - lv%parms%aggr_type = mld_noalg_ - call lv%aggr%default() - end if - -end subroutine mld_d_base_onelev_setag - diff --git a/mlprec/impl/level/mld_d_base_onelev_setsm.F90 b/mlprec/impl/level/mld_d_base_onelev_setsm.F90 deleted file mode 100644 index cc9d526b..00000000 --- a/mlprec/impl/level/mld_d_base_onelev_setsm.F90 +++ /dev/null @@ -1,114 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_onelev_setsm(lev,val,info,pos) - - use psb_base_mod - use mld_d_prec_mod, mld_protect_name => mld_d_base_onelev_setsm - - implicit none - - ! Arguments - class(mld_d_onelev_type), target, intent(inout) :: lev - class(mld_d_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ipos_ - character(len=*), parameter :: name='mld_base_onelev_setsm' - - info = psb_success_ - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - if (ipos_ == mld_smooth_both_) then - if (allocated(lev%sm2a)) then - call lev%sm2a%free(info) - deallocate(lev%sm2a, stat=info) - lev%sm2 => null() - end if - end if - - select case(ipos_) - case(mld_smooth_pre_, mld_smooth_both_) - if (allocated(lev%sm)) then - if (.not.same_type_as(lev%sm,val)) then - call lev%sm%free(info) - deallocate(lev%sm, stat=info) - end if - endif - if (.not.allocated(lev%sm)) then -#ifdef HAVE_MOLD - allocate(lev%sm,mold=val) -#else - allocate(lev%sm,source=val) -#endif - end if - call lev%sm%default() - if (ipos_ == mld_smooth_both_) lev%sm2 => lev%sm - case(mld_smooth_post_) - if (allocated(lev%sm2a)) then - if (.not.same_type_as(lev%sm2a,val)) then - call lev%sm2a%free(info) - deallocate(lev%sm2a, stat=info) - endif - end if - if (.not.allocated(lev%sm2a)) then -#ifdef HAVE_MOLD - allocate(lev%sm2a,mold=val) -#else - allocate(lev%sm2a,source=val) -#endif - end if - call lev%sm2a%default() - lev%sm2 => lev%sm2a - end select - -end subroutine mld_d_base_onelev_setsm - diff --git a/mlprec/impl/level/mld_d_base_onelev_setsv.F90 b/mlprec/impl/level/mld_d_base_onelev_setsv.F90 deleted file mode 100644 index a00813c7..00000000 --- a/mlprec/impl/level/mld_d_base_onelev_setsv.F90 +++ /dev/null @@ -1,152 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_onelev_setsv(lev,val,info,pos) - - use psb_base_mod - use mld_d_prec_mod, mld_protect_name => mld_d_base_onelev_setsv - - implicit none - - ! Arguments - class(mld_d_onelev_type), target, intent(inout) :: lev - class(mld_d_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ipos_ - character(len=*), parameter :: name='mld_base_onelev_setsv' - - info = psb_success_ - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - if ((ipos_ == mld_smooth_pre_).or.(ipos_ == mld_smooth_both_)) then - if (allocated(lev%sm)) then - if (allocated(lev%sm%sv)) then - if (.not.same_type_as(lev%sm%sv,val)) then - call lev%sm%sv%free(info) - if (info == 0) deallocate(lev%sm%sv,stat=info) - if (info /= 0) then - info = 3111 - return - end if - end if - end if - - if (.not.allocated(lev%sm%sv)) then -#ifdef HAVE_MOLD - allocate(lev%sm%sv,mold=val,stat=info) -#else - allocate(lev%sm%sv,source=val,stat=info) -#endif - if (info /= 0) then - info = 3111 - return - end if - end if - call lev%sm%sv%default() - else - info = 3111 - write(psb_err_unit,*) name,& - &': Error: uninitialized preconditioner component,',& - &' should call MLD_PRECINIT/MLD_PRECSET' - return - - end if - end if - - ! - ! If POS was not specified and therefore we have mld_smooth_both_ - ! we need to update sm2a *only* if it was already allocated, - ! otherwise it is not needed (since we have just fixed %sm in the - ! pre section). - ! - - if ((ipos_ == mld_smooth_post_).or. & - ((ipos_ == mld_smooth_both_).and.(allocated(lev%sm2a)))) then - - - if (allocated(lev%sm2a)) then - if (allocated(lev%sm2a%sv)) then - if (.not.same_type_as(lev%sm2a%sv,val)) then - call lev%sm2a%sv%free(info) - if (info == 0) deallocate(lev%sm2a%sv,stat=info) - if (info /= 0) then - info = 3111 - return - end if - end if - end if - if (.not.allocated(lev%sm2a%sv)) then -#ifdef HAVE_MOLD - allocate(lev%sm2a%sv,mold=val,stat=info) -#else - allocate(lev%sm2a%sv,source=val,stat=info) -#endif - if (info /= 0) then - info = 3111 - return - end if - end if - call lev%sm2a%sv%default() - - else - info = 3111 - write(psb_err_unit,*) name,& - &': Error: uninitialized preconditioner component,',& - &' should call MLD_PRECINIT/MLD_PRECSET' - return - - end if - - end if - -end subroutine mld_d_base_onelev_setsv - diff --git a/mlprec/impl/level/mld_s_base_onelev_build.f90 b/mlprec/impl/level/mld_s_base_onelev_build.f90 deleted file mode 100644 index f0b523f1..00000000 --- a/mlprec/impl/level/mld_s_base_onelev_build.f90 +++ /dev/null @@ -1,153 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_onelev_build(lv,info,amold,vmold,imold,ilv) - use psb_base_mod - use mld_s_onelev_mod, mld_protect_name => mld_s_base_onelev_build - implicit none - class(mld_s_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - integer(psb_ipk_), intent(in), optional :: ilv - ! Local - integer(psb_ipk_) :: err,i,k, err_act - integer(psb_ipk_) :: ictxt, me, np - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - - name = 'mld_onelev_build' - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - if (.not.associated(lv%base_desc)) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Unassociated base DESC') - goto 9999 - end if - info = psb_success_ - ictxt = lv%base_desc%get_ctxt() - call psb_info(ictxt,me,np) - - if (.not.allocated(lv%sm)) then - !! Error: should have called mld_dprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - if (.not.allocated(lv%sm%sv)) then - !! Error: should have called mld_dprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - lv%ac_nz_loc = lv%ac%get_nzeros() - lv%ac_nz_tot = lv%ac_nz_loc - select case(lv%parms%coarse_mat) - case(mld_distr_mat_) - call psb_sum(ictxt,lv%ac_nz_tot) - case(mld_repl_mat_) - ! Do nothing - case default - ! Should never get here - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='Wrong lv%parms') - goto 9999 - end select - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Calling mlprcbld at level ',i - call mld_check_def(lv%parms%sweeps_pre,& - & 'Jacobi sweeps',izero,is_int_non_negative) - call mld_check_def(lv%parms%sweeps_post,& - & 'Jacobi sweeps',izero,is_int_non_negative) - - call lv%sm%build(lv%base_a,lv%base_desc,info) - if (info == 0) then - if (allocated(lv%sm2a)) then - call lv%sm2a%build(lv%base_a,lv%base_desc,info) - lv%sm2 => lv%sm2a - else - lv%sm2 => lv%sm - end if - end if - if (info /=0 ) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Smoother bld error') - goto 9999 - end if - - if (lv%sm%sv%is_global()) then - if ((lv%parms%sweeps_pre>1).or.(lv%parms%sweeps_post>1)) then - lv%parms%sweeps_pre = 1 - lv%parms%sweeps_post = 1 - if (me == 0) then - write(debug_unit,*) - if (present(ilv)) then - write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),& - & '" at level ',ilv - write(debug_unit,*) ' is configured as a global solver ' - else - write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),& - & '" is configured as a global solver ' - end if - write(debug_unit,*) ' Pre and post sweeps at this level reset to 1' - end if - end if - end if - - if (any((/present(amold),present(vmold),present(imold)/))) & - & call lv%cnv(info,amold=amold,vmold=vmold,imold=imold) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_base_onelev_build diff --git a/mlprec/impl/level/mld_s_base_onelev_check.f90 b/mlprec/impl/level/mld_s_base_onelev_check.f90 deleted file mode 100644 index ffa4c70d..00000000 --- a/mlprec/impl/level/mld_s_base_onelev_check.f90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_onelev_check(lv,info) - - use psb_base_mod - use mld_s_onelev_mod, mld_protect_name => mld_s_base_onelev_check - - Implicit None - - ! Arguments - class(mld_s_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_onelev_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - call mld_check_def(lv%parms%sweeps_pre,& - & 'Jacobi sweeps',ione,is_int_non_negative) - call mld_check_def(lv%parms%sweeps_post,& - & 'Jacobi sweeps',ione,is_int_non_negative) - - if (allocated(lv%sm)) then - call lv%sm%check(info) - else - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - if (allocated(lv%sm2a)) then - call lv%sm2a%check(info) - else if (.not.inner_check(lv%sm2,lv%sm)) then - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -contains - function inner_check(smp,sm) result(res) - implicit none - logical :: res - class(mld_s_base_smoother_type), intent(in), pointer :: smp - class(mld_s_base_smoother_type), intent(in), target :: sm - - res = associated(smp, sm) - end function inner_check - -end subroutine mld_s_base_onelev_check diff --git a/mlprec/impl/level/mld_s_base_onelev_cnv.f90 b/mlprec/impl/level/mld_s_base_onelev_cnv.f90 deleted file mode 100644 index 732681b7..00000000 --- a/mlprec/impl/level/mld_s_base_onelev_cnv.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_onelev_cnv(lv,info,amold,vmold,imold) - - use psb_base_mod - use mld_s_onelev_mod, mld_protect_name => mld_s_base_onelev_cnv - implicit none - - class(mld_s_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - integer(psb_ipk_) :: i - - info = psb_success_ - - if (any((/present(amold),present(vmold),present(imold)/))) then - if (allocated(lv%sm)) & - & call lv%sm%cnv(info,amold=amold,vmold=vmold,imold=imold) - if (info == psb_success_ .and. allocated(lv%sm2a)) & - & call lv%sm2a%cnv(info,amold=amold,vmold=vmold,imold=imold) - if (info == psb_success_ .and. allocated(lv%wrk)) & - & call lv%wrk%cnv(info,vmold=vmold) - if (info == psb_success_.and. lv%ac%is_asb()) & - & call lv%ac%cscnv(info,mold=amold) - if (info == psb_success_ .and. lv%desc_ac%is_ok() & - & .and. present(imold)) call lv%desc_ac%cnv(imold) - if (info == psb_success_) call lv%map%cnv(info,mold=amold,imold=imold) - end if -end subroutine mld_s_base_onelev_cnv diff --git a/mlprec/impl/level/mld_s_base_onelev_csetc.F90 b/mlprec/impl/level/mld_s_base_onelev_csetc.F90 deleted file mode 100644 index e28c64dc..00000000 --- a/mlprec/impl/level/mld_s_base_onelev_csetc.F90 +++ /dev/null @@ -1,292 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_onelev_csetc(lv,what,val,info,pos,idx) - - use psb_base_mod - use mld_s_onelev_mod, mld_protect_name => mld_s_base_onelev_csetc - use mld_s_base_aggregator_mod - use mld_s_dec_aggregator_mod - use mld_s_symdec_aggregator_mod - use mld_s_jac_smoother - use mld_s_as_smoother - use mld_s_diag_solver - use mld_s_l1_diag_solver - use mld_s_ilu_solver - use mld_s_id_solver - use mld_s_gs_solver -#if defined(HAVE_SLU_) - use mld_s_slu_solver -#endif -#if defined(HAVE_MUMPS_) - use mld_s_mumps_solver -#endif - - Implicit None - - ! Arguments - class(mld_s_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - ! Local - integer(psb_ipk_) :: ipos_, err_act - character(len=20) :: name='s_base_onelev_csetc' - integer(psb_ipk_) :: ival - type(mld_s_base_smoother_type) :: mld_s_base_smoother_mold - type(mld_s_jac_smoother_type) :: mld_s_jac_smoother_mold - type(mld_s_l1_jac_smoother_type) :: mld_s_l1_jac_smoother_mold - type(mld_s_as_smoother_type) :: mld_s_as_smoother_mold - type(mld_s_diag_solver_type) :: mld_s_diag_solver_mold - type(mld_s_l1_diag_solver_type) :: mld_s_l1_diag_solver_mold - type(mld_s_ilu_solver_type) :: mld_s_ilu_solver_mold - type(mld_s_id_solver_type) :: mld_s_id_solver_mold - type(mld_s_gs_solver_type) :: mld_s_gs_solver_mold - type(mld_s_bwgs_solver_type) :: mld_s_bwgs_solver_mold -#if defined(HAVE_SLU_) - type(mld_s_slu_solver_type) :: mld_s_slu_solver_mold -#endif -#if defined(HAVE_MUMPS_) - type(mld_s_mumps_solver_type) :: mld_s_mumps_solver_mold -#endif - - - call psb_erractionsave(err_act) - - info = psb_success_ - - ival = lv%stringval(val) - - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - select case (psb_toupper(trim(what))) - case ('SMOOTHER_TYPE') - select case (psb_toupper(trim(val))) - case ('NOPREC','NONE') - call lv%set(mld_s_base_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_s_id_solver_mold,info,pos=pos) - - case ('JAC','JACOBI') - call lv%set(mld_s_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_s_diag_solver_mold,info,pos=pos) - - case ('L1-JACOBI') - call lv%set(mld_s_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_s_l1_diag_solver_mold,info,pos=pos) - - case ('BJAC') - call lv%set(mld_s_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_s_ilu_solver_mold,info,pos=pos) - - case ('L1-BJAC') - call lv%set(mld_s_l1_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_s_ilu_solver_mold,info,pos=pos) - - case ('AS') - call lv%set(mld_s_as_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_s_ilu_solver_mold,info,pos=pos) - - case ('GS','FWGS') - call lv%set(mld_s_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_s_gs_solver_mold,info,pos='pre') - if (allocated(lv%sm2a)) deallocate(lv%sm2a) - case ('BWGS') - call lv%set(mld_s_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_s_bwgs_solver_mold,info,pos='pre') - if (allocated(lv%sm2a)) deallocate(lv%sm2a) - case ('FBGS') - call lv%set(mld_s_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_s_gs_solver_mold,info,pos='pre') - call lv%set(mld_s_jac_smoother_mold,info,pos='post') - if (info == 0) call lv%set(mld_s_bwgs_solver_mold,info,pos='post') - case ('L1-GS','L1-FWGS') - call lv%set(mld_s_l1_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_s_gs_solver_mold,info,pos='pre') - if (allocated(lv%sm2a)) deallocate(lv%sm2a) - case ('L1-BWGS') - call lv%set(mld_s_l1_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_s_bwgs_solver_mold,info,pos='pre') - if (allocated(lv%sm2a)) deallocate(lv%sm2a) - case ('L1-FBGS') - call lv%set(mld_s_l1_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_s_gs_solver_mold,info,pos='pre') - call lv%set(mld_s_l1_jac_smoother_mold,info,pos='post') - if (info == 0) call lv%set(mld_s_bwgs_solver_mold,info,pos='post') - - case default - ! - ! Do nothing and hope for the best :) - ! - end select - if ((ipos_==mld_smooth_pre_).or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) call lv%sm%default() - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm2a)) call lv%sm2a%default() - end if - - - case('SUB_SOLVE') - select case (psb_toupper(trim(val))) - case ('NONE','NOPREC','FACT_NONE') - call lv%set(mld_s_id_solver_mold,info,pos=pos) - - case ('DIAG') - call lv%set(mld_s_diag_solver_mold,info,pos=pos) - - case ('L1-DIAG') - call lv%set(mld_s_l1_diag_solver_mold,info,pos=pos) - - case ('GS','FGS','FWGS') - call lv%set(mld_s_gs_solver_mold,info,pos=pos) - - case ('BGS','BWGS') - call lv%set(mld_s_bwgs_solver_mold,info,pos=pos) - - case ('ILU','ILUT','MILU') - call lv%set(mld_s_ilu_solver_mold,info,pos=pos) - if (info == 0) then - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - call lv%sm%sv%set('SUB_SOLVE',val,info) - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) call lv%sm2a%sv%set('SUB_SOLVE',val,info) - end if - end if -#ifdef HAVE_SLU_ - case ('SLU') - call lv%set(mld_s_slu_solver_mold,info,pos=pos) -#endif -#ifdef HAVE_MUMPS_ - case ('MUMPS') - call lv%set(mld_s_mumps_solver_mold,info,pos=pos) -#endif - case default - ! - ! Do nothing and hope for the best :) - ! - end select - - case ('ML_CYCLE') - lv%parms%ml_cycle = mld_stringval(val) - - case ('PAR_AGGR_ALG') - ival = mld_stringval(val) - lv%parms%par_aggr_alg = ival - if (allocated(lv%aggr)) then - call lv%aggr%free(info) - if (info == 0) deallocate(lv%aggr,stat=info) - if (info /= 0) then - info = psb_err_internal_error_ - return - end if - end if - - select case(ival) - case(mld_dec_aggr_) - allocate(mld_s_dec_aggregator_type :: lv%aggr, stat=info) - case(mld_sym_dec_aggr_) - allocate(mld_s_symdec_aggregator_type :: lv%aggr, stat=info) - case default - info = psb_err_internal_error_ - end select - if (info == psb_success_) call lv%aggr%default() - - case ('AGGR_ORD') - lv%parms%aggr_ord = mld_stringval(val) - - case ('AGGR_TYPE') - lv%parms%aggr_type = mld_stringval(val) - if (allocated(lv%aggr)) call lv%aggr%set_aggr_type(lv%parms,info) - - case ('AGGR_PROL') - lv%parms%aggr_prol = mld_stringval(val) - - case ('COARSE_MAT') - lv%parms%coarse_mat = mld_stringval(val) - - case ('AGGR_OMEGA_ALG') - lv%parms%aggr_omega_alg= mld_stringval(val) - - case ('AGGR_EIG') - lv%parms%aggr_eig = mld_stringval(val) - - case ('AGGR_FILTER') - lv%parms%aggr_filter = mld_stringval(val) - - case ('COARSE_SOLVE') - lv%parms%coarse_solve = mld_stringval(val) - - case default - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) then - call lv%sm%set(what,val,info,idx=idx) - end if - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) then - call lv%sm2a%set(what,val,info,idx=idx) - end if - end if - if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) - - end select - - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_s_base_onelev_csetc diff --git a/mlprec/impl/level/mld_s_base_onelev_cseti.F90 b/mlprec/impl/level/mld_s_base_onelev_cseti.F90 deleted file mode 100644 index 8b244216..00000000 --- a/mlprec/impl/level/mld_s_base_onelev_cseti.F90 +++ /dev/null @@ -1,268 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_onelev_cseti(lv,what,val,info,pos,idx) - - use psb_base_mod - use mld_s_onelev_mod, mld_protect_name => mld_s_base_onelev_cseti - use mld_s_base_aggregator_mod - use mld_s_dec_aggregator_mod - use mld_s_symdec_aggregator_mod - use mld_s_jac_smoother - use mld_s_as_smoother - use mld_s_diag_solver - use mld_s_l1_diag_solver - use mld_s_ilu_solver - use mld_s_id_solver - use mld_s_gs_solver -#if defined(HAVE_SLU_) - use mld_s_slu_solver -#endif -#if defined(HAVE_MUMPS_) - use mld_s_mumps_solver -#endif - - Implicit None - - ! Arguments - class(mld_s_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - ! Local - integer(psb_ipk_) :: ipos_, err_act - character(len=20) :: name='s_base_onelev_cseti' - type(mld_s_base_smoother_type) :: mld_s_base_smoother_mold - type(mld_s_jac_smoother_type) :: mld_s_jac_smoother_mold - type(mld_s_l1_jac_smoother_type) :: mld_s_l1_jac_smoother_mold - type(mld_s_as_smoother_type) :: mld_s_as_smoother_mold - type(mld_s_diag_solver_type) :: mld_s_diag_solver_mold - type(mld_s_l1_diag_solver_type) :: mld_s_l1_diag_solver_mold - type(mld_s_ilu_solver_type) :: mld_s_ilu_solver_mold - type(mld_s_id_solver_type) :: mld_s_id_solver_mold - type(mld_s_gs_solver_type) :: mld_s_gs_solver_mold - type(mld_s_bwgs_solver_type) :: mld_s_bwgs_solver_mold -#if defined(HAVE_SLU_) - type(mld_s_slu_solver_type) :: mld_s_slu_solver_mold -#endif -#if defined(HAVE_MUMPS_) - type(mld_s_mumps_solver_type) :: mld_s_mumps_solver_mold -#endif - - call psb_erractionsave(err_act) - info = psb_success_ - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - select case (psb_toupper(what)) - case ('SMOOTHER_TYPE') - select case (val) - case (mld_noprec_) - call lv%set(mld_s_base_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_s_id_solver_mold,info,pos=pos) - - case (mld_jac_) - call lv%set(mld_s_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_s_diag_solver_mold,info,pos=pos) - - case (mld_l1_jac_) - call lv%set(mld_s_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_s_l1_diag_solver_mold,info,pos=pos) - - case (mld_bjac_) - call lv%set(mld_s_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_s_ilu_solver_mold,info,pos=pos) - - case (mld_l1_bjac_) - call lv%set(mld_s_l1_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_s_ilu_solver_mold,info,pos=pos) - - case (mld_as_) - call lv%set(mld_s_as_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_s_ilu_solver_mold,info,pos=pos) - - case (mld_fbgs_) - call lv%set(mld_s_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_s_gs_solver_mold,info,pos='pre') - call lv%set(mld_s_jac_smoother_mold,info,pos='post') - if (info == 0) call lv%set(mld_s_bwgs_solver_mold,info,pos='post') - - case default - ! - ! Do nothing and hope for the best :) - ! - end select - if ((ipos_==mld_smooth_pre_).or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) call lv%sm%default() - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm2a)) call lv%sm2a%default() - end if - - - case('SUB_SOLVE') - select case (val) - case (mld_f_none_) - call lv%set(mld_s_id_solver_mold,info,pos=pos) - - case (mld_diag_scale_) - call lv%set(mld_s_diag_solver_mold,info,pos=pos) - - case (mld_l1_diag_scale_) - call lv%set(mld_s_l1_diag_solver_mold,info,pos=pos) - - case (mld_gs_) - call lv%set(mld_s_gs_solver_mold,info,pos=pos) - - case (mld_bwgs_) - call lv%set(mld_s_bwgs_solver_mold,info,pos=pos) - - case (psb_ilu_n_,psb_milu_n_,psb_ilu_t_) - call lv%set(mld_s_ilu_solver_mold,info,pos=pos) - if (info == 0) then - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - call lv%sm%sv%set('SUB_SOLVE',val,info) - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) call lv%sm2a%sv%set('SUB_SOLVE',val,info) - end if - end if -#ifdef HAVE_SLU_ - case (mld_slu_) - call lv%set(mld_s_slu_solver_mold,info,pos=pos) -#endif -#ifdef HAVE_MUMPS_ - case (mld_mumps_) - call lv%set(mld_s_mumps_solver_mold,info,pos=pos) -#endif - case default - ! - ! Do nothing and hope for the best :) - ! - end select - - - case ('SMOOTHER_SWEEPS') - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) & - & lv%parms%sweeps_pre = val - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_)) & - & lv%parms%sweeps_post = val - - case ('ML_CYCLE') - lv%parms%ml_cycle = val - - case ('PAR_AGGR_ALG') - lv%parms%par_aggr_alg = val - if (allocated(lv%aggr)) then - call lv%aggr%free(info) - if (info == 0) deallocate(lv%aggr,stat=info) - if (info /= 0) then - info = psb_err_internal_error_ - return - end if - end if - - select case(val) - case(mld_dec_aggr_) - allocate(mld_s_dec_aggregator_type :: lv%aggr, stat=info) - case(mld_sym_dec_aggr_) - allocate(mld_s_symdec_aggregator_type :: lv%aggr, stat=info) - case default - info = psb_err_internal_error_ - end select - if (info == psb_success_) call lv%aggr%default() - - case ('AGGR_ORD') - lv%parms%aggr_ord = val - - case ('AGGR_TYPE') - lv%parms%aggr_type = val - if (allocated(lv%aggr)) call lv%aggr%set_aggr_type(lv%parms,info) - - case ('AGGR_PROL') - lv%parms%aggr_prol = val - - case ('COARSE_MAT') - lv%parms%coarse_mat = val - - case ('AGGR_OMEGA_ALG') - lv%parms%aggr_omega_alg= val - - case ('AGGR_EIG') - lv%parms%aggr_eig = val - - case ('AGGR_FILTER') - lv%parms%aggr_filter = val - - case ('COARSE_SOLVE') - lv%parms%coarse_solve = val - - case default - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) then - call lv%sm%set(what,val,info,idx=idx) - end if - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) then - call lv%sm2a%set(what,val,info,idx=idx) - end if - end if - if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) - - end select - if (info /= psb_success_) goto 9999 - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_s_base_onelev_cseti diff --git a/mlprec/impl/level/mld_s_base_onelev_csetr.f90 b/mlprec/impl/level/mld_s_base_onelev_csetr.f90 deleted file mode 100644 index f49ac7e3..00000000 --- a/mlprec/impl/level/mld_s_base_onelev_csetr.f90 +++ /dev/null @@ -1,105 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_onelev_csetr(lv,what,val,info,pos,idx) - - use psb_base_mod - use mld_s_onelev_mod, mld_protect_name => mld_s_base_onelev_csetr - - Implicit None - - ! Arguments - class(mld_s_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - ! Local - integer(psb_ipk_) :: ipos_, err_act - character(len=20) :: name='s_base_onelev_csetr' - - call psb_erractionsave(err_act) - - - info = psb_success_ - - select case (psb_toupper(what)) - - case ('AGGR_OMEGA_VAL') - lv%parms%aggr_omega_val= val - - case ('AGGR_THRESH') - lv%parms%aggr_thresh = val - - case default - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) then - call lv%sm%set(what,val,info,idx=idx) - end if - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) then - call lv%sm2a%set(what,val,info,idx=idx) - end if - end if - if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) - - end select - - if (info /= psb_success_) goto 9999 - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_s_base_onelev_csetr diff --git a/mlprec/impl/level/mld_s_base_onelev_descr.f90 b/mlprec/impl/level/mld_s_base_onelev_descr.f90 deleted file mode 100644 index 1862385f..00000000 --- a/mlprec/impl/level/mld_s_base_onelev_descr.f90 +++ /dev/null @@ -1,112 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_onelev_descr(lv,il,nl,ilmin,info,iout) - - use psb_base_mod - use mld_s_onelev_mod, mld_protect_name => mld_s_base_onelev_descr - Implicit None - ! Arguments - class(mld_s_onelev_type), intent(in) :: lv - integer(psb_ipk_), intent(in) :: il,nl,ilmin - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_s_base_onelev_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse - - - call psb_erractionsave(err_act) - - - coarse = (il==nl) - - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - end if - - write(iout_,*) - if (il == ilmin) then - call lv%parms%mlcycledsc(iout_,info) - if (allocated(lv%aggr)) then - call lv%aggr%descr(lv%parms,iout_,info) - else - write(iout_,*) 'Internal error: unallocated aggregator object' - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - write(iout_,*) - end if - - if (il > 1) then - - if (coarse) then - write(iout_,*) ' Level ',il,' (coarse)' - else - write(iout_,*) ' Level ',il - end if - - call lv%parms%descr(iout_,info,coarse=coarse) - - if (nl > 1) then - if (allocated(lv%map%naggr)) then - write(iout_,*) ' Coarse Matrix: Global size: ', & - & sum((1_psb_lpk_*lv%map%naggr(:))),' Nonzeros: ',lv%ac_nz_tot - write(iout_,*) ' Local matrix sizes: ', & - & lv%map%naggr(:) - write(iout_,*) ' Aggregation ratio: ', & - & lv%szratio - end if - end if - - if (coarse.and.allocated(lv%sm)) & - & call lv%sm%descr(info,iout=iout_,coarse=coarse) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_s_base_onelev_descr diff --git a/mlprec/impl/level/mld_s_base_onelev_dump.f90 b/mlprec/impl/level/mld_s_base_onelev_dump.f90 deleted file mode 100644 index 931d8599..00000000 --- a/mlprec/impl/level/mld_s_base_onelev_dump.f90 +++ /dev/null @@ -1,169 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_onelev_dump(lv,level,info,prefix,head,ac,rp,& - & smoother,solver,tprol,global_num) - - use psb_base_mod - use mld_s_onelev_mod, mld_protect_name => mld_s_base_onelev_dump - implicit none - class(mld_s_onelev_type), intent(in) :: lv - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: ac, rp, smoother, solver, tprol, global_num - ! Local variables - integer(psb_ipk_) :: i, j, il1, iln, lname, lev, ni - integer(psb_ipk_) :: icontxt,iam, np - character(len=80) :: prefix_, frmt - character(len=1024) :: fname - logical :: ac_, rp_, tprol_, global_num_ - integer(psb_lpk_), allocatable :: ivr(:), ivc(:) - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_lev_s" - end if - - if (associated(lv%base_desc)) then - icontxt = lv%base_desc%get_context() - call psb_info(icontxt,iam,np) - else - icontxt = -1 - iam = -1 - np = -1 - end if - if (present(ac)) then - ac_ = ac - else - ac_ = .false. - end if - if (present(rp)) then - rp_ = rp - else - rp_ = .false. - end if - if (present(tprol)) then - tprol_ = tprol - else - tprol_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - - if (np > 0) then - ni = floor(log10(1.0*np)) + 1 - write(frmt,'(a,i3.3,a,i3.3,a)') '(a,i',ni,'.',ni,')' - write(fname(lname+1:lname+ni+2),frmt) '_p',iam - lname = lname + ni + 2 - end if - - if (global_num_) then - if (level >= 2) then - if (ac_) then - ivr = lv%desc_ac%get_global_indices(owned=.false.) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx' - call lv%ac%print(fname,head=head,iv=ivr) - end if - if (rp_) then - ivr = lv%map%p_desc_U%get_global_indices(owned=.false.) - ivc = lv%map%p_desc_V%get_global_indices(owned=.false.) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx' - call lv%map%mat_U2V%print(fname,head=head,ivr=ivc,ivc=ivr) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx' - call lv%map%mat_V2U%print(fname,head=head,ivr=ivr,ivc=ivc) - end if - if (tprol_) then - ! Tentative prolongator is stored with column indices already - ! in global numbering, so only IVR is needed. - ivr = lv%map%p_desc_U%get_global_indices(owned=.false.) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_tprol.mtx' - ! - ! This is not implemented yet. - !call lv%tprol%print(fname,head=head,ivr=ivr) - end if - end if - else - if (level >= 2) then - if (ac_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx' - call lv%ac%print(fname,head=head) - end if - if (rp_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx' - call lv%map%mat_U2V%print(fname,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx' - call lv%map%mat_V2U%print(fname,head=head) - end if - if (tprol_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_tprol.mtx' - ! - ! This is not implemented yet. - !call lv%tprol%print(fname,head=head) - end if - end if - end if - - if (level >= 2) then - if (allocated(lv%sm)) then - call lv%sm%dump(lv%desc_ac,level,info,smoother=smoother, & - & solver=solver,prefix=trim(prefix_)//"_sm",global_num=global_num) - end if - if (allocated(lv%sm2a)) then - call lv%sm2a%dump(lv%desc_ac,level,info,smoother=smoother, & - & solver=solver,prefix=trim(prefix_)//"_sm2a",global_num=global_num) - end if - else - if (allocated(lv%sm)) then - call lv%sm%dump(lv%base_desc,level,info,smoother=smoother, & - & solver=solver,prefix=trim(prefix_)//"_sm",global_num=global_num) - end if - if (allocated(lv%sm2a)) then - call lv%sm2a%dump(lv%base_desc,level,info,smoother=smoother, & - & solver=solver,prefix=trim(prefix_)//"_sm2a",global_num=global_num) - end if - end if - -end subroutine mld_s_base_onelev_dump diff --git a/mlprec/impl/level/mld_s_base_onelev_free.f90 b/mlprec/impl/level/mld_s_base_onelev_free.f90 deleted file mode 100644 index de1a39ce..00000000 --- a/mlprec/impl/level/mld_s_base_onelev_free.f90 +++ /dev/null @@ -1,75 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_onelev_free(lv,info) - - use psb_base_mod - use mld_s_onelev_mod, mld_protect_name => mld_s_base_onelev_free - implicit none - - class(mld_s_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: i - - info = psb_success_ - - ! We might just deallocate the top level array, except - ! that there may be inner objects containing C pointers, - ! e.g. UMFPACK, SLU or CUDA stuff. - ! We really need FINALs. - if (allocated(lv%sm)) & - & call lv%sm%free(info) - - if (allocated(lv%sm2a)) & - & call lv%sm2a%free(info) - - if (allocated(lv%wrk)) & - & call lv%wrk%free(info) - - call lv%ac%free() - if (lv%desc_ac%is_ok()) & - & call lv%desc_ac%free(info) - call lv%map%free(info) - - ! This is a pointer to something else, must not free it here. - nullify(lv%base_a) - ! This is a pointer to something else, must not free it here. - nullify(lv%base_desc) - - call lv%nullify() - -end subroutine mld_s_base_onelev_free diff --git a/mlprec/impl/level/mld_s_base_onelev_mat_asb.f90 b/mlprec/impl/level/mld_s_base_onelev_mat_asb.f90 deleted file mode 100644 index 6221c9af..00000000 --- a/mlprec/impl/level/mld_s_base_onelev_mat_asb.f90 +++ /dev/null @@ -1,178 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_s_onelev_mat_asb.f90 -! -! Subroutine: mld_s_onelev_mat_asb -! Version: real -! -! This routine builds the matrix associated to the current level of the -! multilevel preconditioner from the matrix associated to the previous level, -! by using the user-specified aggregation technique (therefore, it also builds the -! prolongation and restriction operators mapping the current level to the -! previous one and vice versa). -! The current level is regarded as the coarse one, while the previous as -! the fine one. This is in agreement with the fact that the routine is called, -! by mld_mlprec_bld, only on levels >=2. -! The main structure is: -! 1. Perform sanity checks; -! 2. Call mld_Xaggrmat_asb to compute prolongator/restrictor/AC -! 3. According to the choice of DIST/REPL for AC, build a descriptor DESC_AC, -! and adjust the column numbering of AC/OP_PROL/OP_RESTR -! 4. Pack restrictor and prolongator into p%map -! 5. Fix base_a and base_desc pointers. -! -! -! Arguments: -! p - type(mld_s_onelev_type), input/output. -! The 'one-level' data structure containing the control -! parameters and (eventually) coarse matrix and prolongator/restrictors. -! -! a - type(psb_sspmat_type). -! The sparse matrix structure containing the local part of the -! fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_sspmat_type), input/output -! The tentative prolongator on input, released on output. -! -! info - integer, output. -! Error code. -! -subroutine mld_s_base_onelev_mat_asb(lv,a,desc_a,ilaggr,nlaggr,t_prol,info) - - use psb_base_mod - use mld_base_prec_type - use mld_s_onelev_mod, mld_protect_name => mld_s_base_onelev_mat_asb - - implicit none - - ! Arguments - class(mld_s_onelev_type), intent(inout), target :: lv - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - integer(psb_lpk_), intent(inout) :: ilaggr(:) - type(psb_lsspmat_type), intent(inout) :: t_prol - integer(psb_ipk_), intent(out) :: info - - - ! Local variables - character(len=24) :: name - integer(psb_ipk_) :: ictxt, np, me - integer(psb_ipk_) :: err_act - type(psb_sspmat_type) :: ac, op_restr, op_prol - integer(psb_ipk_) :: nzl, inl - integer(psb_ipk_) :: debug_level, debug_unit - - name='mld_s_onelev_mat_asb' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - call mld_check_def(lv%parms%aggr_prol,'Smoother',& - & mld_smooth_prol_,is_legal_ml_aggr_prol) - call mld_check_def(lv%parms%coarse_mat,'Coarse matrix',& - & mld_distr_mat_,is_legal_ml_coarse_mat) - call mld_check_def(lv%parms%aggr_filter,'Use filtered matrix',& - & mld_no_filter_mat_,is_legal_aggr_filter) - call mld_check_def(lv%parms%aggr_omega_alg,'Omega Alg.',& - & mld_eig_est_,is_legal_ml_aggr_omega_alg) - call mld_check_def(lv%parms%aggr_eig,'Eigenvalue estimate',& - & mld_max_norm_,is_legal_ml_aggr_eig) - call mld_check_def(lv%parms%aggr_omega_val,'Omega',szero,is_legal_s_omega) - - - ! - ! Build the coarse-level matrix from the fine-level one, starting from - ! the mapping defined by mld_aggrmap_bld and applying the aggregation - ! algorithm specified by lv%iprcparm(mld_aggr_prol_) - ! - call lv%aggr%mat_bld(lv%parms,a,desc_a,ilaggr,nlaggr,& - & lv%ac,lv%desc_ac,op_prol,op_restr,t_prol,info) - - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_aggrmat_asb') - goto 9999 - end if - - ! - ! Now build its descriptor and convert global indices for - ! ac, op_restr and op_prol - ! - if (info == psb_success_) & - & call lv%aggr%mat_asb(lv%parms,a,desc_a,& - & lv%ac,lv%desc_ac,op_prol,op_restr,info) - - if (info == psb_success_) call lv%ac%cscnv(info,type='csr',dupl=psb_dupl_add_) - - if (info == psb_success_) call lv%aggr%bld_map(desc_a, lv%desc_ac,& - & ilaggr,nlaggr,op_restr,op_prol,lv%map,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mat_asb/map_bld') - goto 9999 - end if - ! - ! Fix the base_a and base_desc pointers for handling of residuals. - ! This is correct because this routine is only called at levels >=2. - ! - lv%base_a => lv%ac - lv%base_desc => lv%desc_ac - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_s_base_onelev_mat_asb diff --git a/mlprec/impl/level/mld_s_base_onelev_setag.f90 b/mlprec/impl/level/mld_s_base_onelev_setag.f90 deleted file mode 100644 index e9de3cbc..00000000 --- a/mlprec/impl/level/mld_s_base_onelev_setag.f90 +++ /dev/null @@ -1,82 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_onelev_setag(lv,val,info,pos) - - use psb_base_mod - use mld_s_onelev_mod, mld_protect_name => mld_s_base_onelev_setag - - implicit none - - ! Arguments - class(mld_s_onelev_type), target, intent(inout) :: lv - class(mld_s_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ipos_ - character(len=*), parameter :: name='mld_base_onelev_setag' - - info = psb_success_ - - ! Ignore pos for aggregator - - if (allocated(lv%aggr)) then - if (.not.same_type_as(lv%aggr,val)) then - call lv%aggr%free(info) - deallocate(lv%aggr,stat=info) - if (info /= 0) then - info = 3111 - return - end if - end if - end if - - if (.not.allocated(lv%aggr)) then - allocate(lv%aggr,mold=val,stat=info) - if (info /= 0) then - info = 3111 - return - end if - lv%parms%par_aggr_alg = mld_ext_aggr_ - lv%parms%aggr_type = mld_noalg_ - call lv%aggr%default() - end if - -end subroutine mld_s_base_onelev_setag - diff --git a/mlprec/impl/level/mld_s_base_onelev_setsm.F90 b/mlprec/impl/level/mld_s_base_onelev_setsm.F90 deleted file mode 100644 index 30cba813..00000000 --- a/mlprec/impl/level/mld_s_base_onelev_setsm.F90 +++ /dev/null @@ -1,114 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_onelev_setsm(lev,val,info,pos) - - use psb_base_mod - use mld_s_prec_mod, mld_protect_name => mld_s_base_onelev_setsm - - implicit none - - ! Arguments - class(mld_s_onelev_type), target, intent(inout) :: lev - class(mld_s_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ipos_ - character(len=*), parameter :: name='mld_base_onelev_setsm' - - info = psb_success_ - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - if (ipos_ == mld_smooth_both_) then - if (allocated(lev%sm2a)) then - call lev%sm2a%free(info) - deallocate(lev%sm2a, stat=info) - lev%sm2 => null() - end if - end if - - select case(ipos_) - case(mld_smooth_pre_, mld_smooth_both_) - if (allocated(lev%sm)) then - if (.not.same_type_as(lev%sm,val)) then - call lev%sm%free(info) - deallocate(lev%sm, stat=info) - end if - endif - if (.not.allocated(lev%sm)) then -#ifdef HAVE_MOLD - allocate(lev%sm,mold=val) -#else - allocate(lev%sm,source=val) -#endif - end if - call lev%sm%default() - if (ipos_ == mld_smooth_both_) lev%sm2 => lev%sm - case(mld_smooth_post_) - if (allocated(lev%sm2a)) then - if (.not.same_type_as(lev%sm2a,val)) then - call lev%sm2a%free(info) - deallocate(lev%sm2a, stat=info) - endif - end if - if (.not.allocated(lev%sm2a)) then -#ifdef HAVE_MOLD - allocate(lev%sm2a,mold=val) -#else - allocate(lev%sm2a,source=val) -#endif - end if - call lev%sm2a%default() - lev%sm2 => lev%sm2a - end select - -end subroutine mld_s_base_onelev_setsm - diff --git a/mlprec/impl/level/mld_s_base_onelev_setsv.F90 b/mlprec/impl/level/mld_s_base_onelev_setsv.F90 deleted file mode 100644 index ac1c05d9..00000000 --- a/mlprec/impl/level/mld_s_base_onelev_setsv.F90 +++ /dev/null @@ -1,152 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_onelev_setsv(lev,val,info,pos) - - use psb_base_mod - use mld_s_prec_mod, mld_protect_name => mld_s_base_onelev_setsv - - implicit none - - ! Arguments - class(mld_s_onelev_type), target, intent(inout) :: lev - class(mld_s_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ipos_ - character(len=*), parameter :: name='mld_base_onelev_setsv' - - info = psb_success_ - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - if ((ipos_ == mld_smooth_pre_).or.(ipos_ == mld_smooth_both_)) then - if (allocated(lev%sm)) then - if (allocated(lev%sm%sv)) then - if (.not.same_type_as(lev%sm%sv,val)) then - call lev%sm%sv%free(info) - if (info == 0) deallocate(lev%sm%sv,stat=info) - if (info /= 0) then - info = 3111 - return - end if - end if - end if - - if (.not.allocated(lev%sm%sv)) then -#ifdef HAVE_MOLD - allocate(lev%sm%sv,mold=val,stat=info) -#else - allocate(lev%sm%sv,source=val,stat=info) -#endif - if (info /= 0) then - info = 3111 - return - end if - end if - call lev%sm%sv%default() - else - info = 3111 - write(psb_err_unit,*) name,& - &': Error: uninitialized preconditioner component,',& - &' should call MLD_PRECINIT/MLD_PRECSET' - return - - end if - end if - - ! - ! If POS was not specified and therefore we have mld_smooth_both_ - ! we need to update sm2a *only* if it was already allocated, - ! otherwise it is not needed (since we have just fixed %sm in the - ! pre section). - ! - - if ((ipos_ == mld_smooth_post_).or. & - ((ipos_ == mld_smooth_both_).and.(allocated(lev%sm2a)))) then - - - if (allocated(lev%sm2a)) then - if (allocated(lev%sm2a%sv)) then - if (.not.same_type_as(lev%sm2a%sv,val)) then - call lev%sm2a%sv%free(info) - if (info == 0) deallocate(lev%sm2a%sv,stat=info) - if (info /= 0) then - info = 3111 - return - end if - end if - end if - if (.not.allocated(lev%sm2a%sv)) then -#ifdef HAVE_MOLD - allocate(lev%sm2a%sv,mold=val,stat=info) -#else - allocate(lev%sm2a%sv,source=val,stat=info) -#endif - if (info /= 0) then - info = 3111 - return - end if - end if - call lev%sm2a%sv%default() - - else - info = 3111 - write(psb_err_unit,*) name,& - &': Error: uninitialized preconditioner component,',& - &' should call MLD_PRECINIT/MLD_PRECSET' - return - - end if - - end if - -end subroutine mld_s_base_onelev_setsv - diff --git a/mlprec/impl/level/mld_z_base_onelev_build.f90 b/mlprec/impl/level/mld_z_base_onelev_build.f90 deleted file mode 100644 index 9bc4ad17..00000000 --- a/mlprec/impl/level/mld_z_base_onelev_build.f90 +++ /dev/null @@ -1,153 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_onelev_build(lv,info,amold,vmold,imold,ilv) - use psb_base_mod - use mld_z_onelev_mod, mld_protect_name => mld_z_base_onelev_build - implicit none - class(mld_z_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - integer(psb_ipk_), intent(in), optional :: ilv - ! Local - integer(psb_ipk_) :: err,i,k, err_act - integer(psb_ipk_) :: ictxt, me, np - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - - name = 'mld_onelev_build' - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - if (.not.associated(lv%base_desc)) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Unassociated base DESC') - goto 9999 - end if - info = psb_success_ - ictxt = lv%base_desc%get_ctxt() - call psb_info(ictxt,me,np) - - if (.not.allocated(lv%sm)) then - !! Error: should have called mld_dprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - if (.not.allocated(lv%sm%sv)) then - !! Error: should have called mld_dprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - lv%ac_nz_loc = lv%ac%get_nzeros() - lv%ac_nz_tot = lv%ac_nz_loc - select case(lv%parms%coarse_mat) - case(mld_distr_mat_) - call psb_sum(ictxt,lv%ac_nz_tot) - case(mld_repl_mat_) - ! Do nothing - case default - ! Should never get here - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='Wrong lv%parms') - goto 9999 - end select - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Calling mlprcbld at level ',i - call mld_check_def(lv%parms%sweeps_pre,& - & 'Jacobi sweeps',izero,is_int_non_negative) - call mld_check_def(lv%parms%sweeps_post,& - & 'Jacobi sweeps',izero,is_int_non_negative) - - call lv%sm%build(lv%base_a,lv%base_desc,info) - if (info == 0) then - if (allocated(lv%sm2a)) then - call lv%sm2a%build(lv%base_a,lv%base_desc,info) - lv%sm2 => lv%sm2a - else - lv%sm2 => lv%sm - end if - end if - if (info /=0 ) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Smoother bld error') - goto 9999 - end if - - if (lv%sm%sv%is_global()) then - if ((lv%parms%sweeps_pre>1).or.(lv%parms%sweeps_post>1)) then - lv%parms%sweeps_pre = 1 - lv%parms%sweeps_post = 1 - if (me == 0) then - write(debug_unit,*) - if (present(ilv)) then - write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),& - & '" at level ',ilv - write(debug_unit,*) ' is configured as a global solver ' - else - write(debug_unit,*) 'Warning: the solver "',trim(lv%sm%sv%get_fmt()),& - & '" is configured as a global solver ' - end if - write(debug_unit,*) ' Pre and post sweeps at this level reset to 1' - end if - end if - end if - - if (any((/present(amold),present(vmold),present(imold)/))) & - & call lv%cnv(info,amold=amold,vmold=vmold,imold=imold) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_base_onelev_build diff --git a/mlprec/impl/level/mld_z_base_onelev_check.f90 b/mlprec/impl/level/mld_z_base_onelev_check.f90 deleted file mode 100644 index 74f48256..00000000 --- a/mlprec/impl/level/mld_z_base_onelev_check.f90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_onelev_check(lv,info) - - use psb_base_mod - use mld_z_onelev_mod, mld_protect_name => mld_z_base_onelev_check - - Implicit None - - ! Arguments - class(mld_z_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_onelev_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - call mld_check_def(lv%parms%sweeps_pre,& - & 'Jacobi sweeps',ione,is_int_non_negative) - call mld_check_def(lv%parms%sweeps_post,& - & 'Jacobi sweeps',ione,is_int_non_negative) - - if (allocated(lv%sm)) then - call lv%sm%check(info) - else - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - if (allocated(lv%sm2a)) then - call lv%sm2a%check(info) - else if (.not.inner_check(lv%sm2,lv%sm)) then - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -contains - function inner_check(smp,sm) result(res) - implicit none - logical :: res - class(mld_z_base_smoother_type), intent(in), pointer :: smp - class(mld_z_base_smoother_type), intent(in), target :: sm - - res = associated(smp, sm) - end function inner_check - -end subroutine mld_z_base_onelev_check diff --git a/mlprec/impl/level/mld_z_base_onelev_cnv.f90 b/mlprec/impl/level/mld_z_base_onelev_cnv.f90 deleted file mode 100644 index 11614681..00000000 --- a/mlprec/impl/level/mld_z_base_onelev_cnv.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_onelev_cnv(lv,info,amold,vmold,imold) - - use psb_base_mod - use mld_z_onelev_mod, mld_protect_name => mld_z_base_onelev_cnv - implicit none - - class(mld_z_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - integer(psb_ipk_) :: i - - info = psb_success_ - - if (any((/present(amold),present(vmold),present(imold)/))) then - if (allocated(lv%sm)) & - & call lv%sm%cnv(info,amold=amold,vmold=vmold,imold=imold) - if (info == psb_success_ .and. allocated(lv%sm2a)) & - & call lv%sm2a%cnv(info,amold=amold,vmold=vmold,imold=imold) - if (info == psb_success_ .and. allocated(lv%wrk)) & - & call lv%wrk%cnv(info,vmold=vmold) - if (info == psb_success_.and. lv%ac%is_asb()) & - & call lv%ac%cscnv(info,mold=amold) - if (info == psb_success_ .and. lv%desc_ac%is_ok() & - & .and. present(imold)) call lv%desc_ac%cnv(imold) - if (info == psb_success_) call lv%map%cnv(info,mold=amold,imold=imold) - end if -end subroutine mld_z_base_onelev_cnv diff --git a/mlprec/impl/level/mld_z_base_onelev_csetc.F90 b/mlprec/impl/level/mld_z_base_onelev_csetc.F90 deleted file mode 100644 index bfb4025b..00000000 --- a/mlprec/impl/level/mld_z_base_onelev_csetc.F90 +++ /dev/null @@ -1,312 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_onelev_csetc(lv,what,val,info,pos,idx) - - use psb_base_mod - use mld_z_onelev_mod, mld_protect_name => mld_z_base_onelev_csetc - use mld_z_base_aggregator_mod - use mld_z_dec_aggregator_mod - use mld_z_symdec_aggregator_mod - use mld_z_jac_smoother - use mld_z_as_smoother - use mld_z_diag_solver - use mld_z_l1_diag_solver - use mld_z_ilu_solver - use mld_z_id_solver - use mld_z_gs_solver -#if defined(HAVE_UMF_) - use mld_z_umf_solver -#endif -#if defined(HAVE_SLUDIST_) - use mld_z_sludist_solver -#endif -#if defined(HAVE_SLU_) - use mld_z_slu_solver -#endif -#if defined(HAVE_MUMPS_) - use mld_z_mumps_solver -#endif - - Implicit None - - ! Arguments - class(mld_z_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - ! Local - integer(psb_ipk_) :: ipos_, err_act - character(len=20) :: name='z_base_onelev_csetc' - integer(psb_ipk_) :: ival - type(mld_z_base_smoother_type) :: mld_z_base_smoother_mold - type(mld_z_jac_smoother_type) :: mld_z_jac_smoother_mold - type(mld_z_l1_jac_smoother_type) :: mld_z_l1_jac_smoother_mold - type(mld_z_as_smoother_type) :: mld_z_as_smoother_mold - type(mld_z_diag_solver_type) :: mld_z_diag_solver_mold - type(mld_z_l1_diag_solver_type) :: mld_z_l1_diag_solver_mold - type(mld_z_ilu_solver_type) :: mld_z_ilu_solver_mold - type(mld_z_id_solver_type) :: mld_z_id_solver_mold - type(mld_z_gs_solver_type) :: mld_z_gs_solver_mold - type(mld_z_bwgs_solver_type) :: mld_z_bwgs_solver_mold -#if defined(HAVE_UMF_) - type(mld_z_umf_solver_type) :: mld_z_umf_solver_mold -#endif -#if defined(HAVE_SLUDIST_) - type(mld_z_sludist_solver_type) :: mld_z_sludist_solver_mold -#endif -#if defined(HAVE_SLU_) - type(mld_z_slu_solver_type) :: mld_z_slu_solver_mold -#endif -#if defined(HAVE_MUMPS_) - type(mld_z_mumps_solver_type) :: mld_z_mumps_solver_mold -#endif - - - call psb_erractionsave(err_act) - - info = psb_success_ - - ival = lv%stringval(val) - - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - select case (psb_toupper(trim(what))) - case ('SMOOTHER_TYPE') - select case (psb_toupper(trim(val))) - case ('NOPREC','NONE') - call lv%set(mld_z_base_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_z_id_solver_mold,info,pos=pos) - - case ('JAC','JACOBI') - call lv%set(mld_z_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_z_diag_solver_mold,info,pos=pos) - - case ('L1-JACOBI') - call lv%set(mld_z_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_z_l1_diag_solver_mold,info,pos=pos) - - case ('BJAC') - call lv%set(mld_z_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_z_ilu_solver_mold,info,pos=pos) - - case ('L1-BJAC') - call lv%set(mld_z_l1_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_z_ilu_solver_mold,info,pos=pos) - - case ('AS') - call lv%set(mld_z_as_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_z_ilu_solver_mold,info,pos=pos) - - case ('GS','FWGS') - call lv%set(mld_z_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_z_gs_solver_mold,info,pos='pre') - if (allocated(lv%sm2a)) deallocate(lv%sm2a) - case ('BWGS') - call lv%set(mld_z_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_z_bwgs_solver_mold,info,pos='pre') - if (allocated(lv%sm2a)) deallocate(lv%sm2a) - case ('FBGS') - call lv%set(mld_z_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_z_gs_solver_mold,info,pos='pre') - call lv%set(mld_z_jac_smoother_mold,info,pos='post') - if (info == 0) call lv%set(mld_z_bwgs_solver_mold,info,pos='post') - case ('L1-GS','L1-FWGS') - call lv%set(mld_z_l1_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_z_gs_solver_mold,info,pos='pre') - if (allocated(lv%sm2a)) deallocate(lv%sm2a) - case ('L1-BWGS') - call lv%set(mld_z_l1_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_z_bwgs_solver_mold,info,pos='pre') - if (allocated(lv%sm2a)) deallocate(lv%sm2a) - case ('L1-FBGS') - call lv%set(mld_z_l1_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_z_gs_solver_mold,info,pos='pre') - call lv%set(mld_z_l1_jac_smoother_mold,info,pos='post') - if (info == 0) call lv%set(mld_z_bwgs_solver_mold,info,pos='post') - - case default - ! - ! Do nothing and hope for the best :) - ! - end select - if ((ipos_==mld_smooth_pre_).or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) call lv%sm%default() - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm2a)) call lv%sm2a%default() - end if - - - case('SUB_SOLVE') - select case (psb_toupper(trim(val))) - case ('NONE','NOPREC','FACT_NONE') - call lv%set(mld_z_id_solver_mold,info,pos=pos) - - case ('DIAG') - call lv%set(mld_z_diag_solver_mold,info,pos=pos) - - case ('L1-DIAG') - call lv%set(mld_z_l1_diag_solver_mold,info,pos=pos) - - case ('GS','FGS','FWGS') - call lv%set(mld_z_gs_solver_mold,info,pos=pos) - - case ('BGS','BWGS') - call lv%set(mld_z_bwgs_solver_mold,info,pos=pos) - - case ('ILU','ILUT','MILU') - call lv%set(mld_z_ilu_solver_mold,info,pos=pos) - if (info == 0) then - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - call lv%sm%sv%set('SUB_SOLVE',val,info) - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) call lv%sm2a%sv%set('SUB_SOLVE',val,info) - end if - end if -#ifdef HAVE_SLU_ - case ('SLU') - call lv%set(mld_z_slu_solver_mold,info,pos=pos) -#endif -#ifdef HAVE_MUMPS_ - case ('MUMPS') - call lv%set(mld_z_mumps_solver_mold,info,pos=pos) -#endif -#ifdef HAVE_SLUDIST_ - case ('SLUDIST') - call lv%set(mld_z_sludist_solver_mold,info,pos=pos) -#endif -#ifdef HAVE_UMF_ - case ('UMF') - call lv%set(mld_z_umf_solver_mold,info,pos=pos) -#endif - case default - ! - ! Do nothing and hope for the best :) - ! - end select - - case ('ML_CYCLE') - lv%parms%ml_cycle = mld_stringval(val) - - case ('PAR_AGGR_ALG') - ival = mld_stringval(val) - lv%parms%par_aggr_alg = ival - if (allocated(lv%aggr)) then - call lv%aggr%free(info) - if (info == 0) deallocate(lv%aggr,stat=info) - if (info /= 0) then - info = psb_err_internal_error_ - return - end if - end if - - select case(ival) - case(mld_dec_aggr_) - allocate(mld_z_dec_aggregator_type :: lv%aggr, stat=info) - case(mld_sym_dec_aggr_) - allocate(mld_z_symdec_aggregator_type :: lv%aggr, stat=info) - case default - info = psb_err_internal_error_ - end select - if (info == psb_success_) call lv%aggr%default() - - case ('AGGR_ORD') - lv%parms%aggr_ord = mld_stringval(val) - - case ('AGGR_TYPE') - lv%parms%aggr_type = mld_stringval(val) - if (allocated(lv%aggr)) call lv%aggr%set_aggr_type(lv%parms,info) - - case ('AGGR_PROL') - lv%parms%aggr_prol = mld_stringval(val) - - case ('COARSE_MAT') - lv%parms%coarse_mat = mld_stringval(val) - - case ('AGGR_OMEGA_ALG') - lv%parms%aggr_omega_alg= mld_stringval(val) - - case ('AGGR_EIG') - lv%parms%aggr_eig = mld_stringval(val) - - case ('AGGR_FILTER') - lv%parms%aggr_filter = mld_stringval(val) - - case ('COARSE_SOLVE') - lv%parms%coarse_solve = mld_stringval(val) - - case default - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) then - call lv%sm%set(what,val,info,idx=idx) - end if - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) then - call lv%sm2a%set(what,val,info,idx=idx) - end if - end if - if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) - - end select - - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_z_base_onelev_csetc diff --git a/mlprec/impl/level/mld_z_base_onelev_cseti.F90 b/mlprec/impl/level/mld_z_base_onelev_cseti.F90 deleted file mode 100644 index 3c678eb8..00000000 --- a/mlprec/impl/level/mld_z_base_onelev_cseti.F90 +++ /dev/null @@ -1,288 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_onelev_cseti(lv,what,val,info,pos,idx) - - use psb_base_mod - use mld_z_onelev_mod, mld_protect_name => mld_z_base_onelev_cseti - use mld_z_base_aggregator_mod - use mld_z_dec_aggregator_mod - use mld_z_symdec_aggregator_mod - use mld_z_jac_smoother - use mld_z_as_smoother - use mld_z_diag_solver - use mld_z_l1_diag_solver - use mld_z_ilu_solver - use mld_z_id_solver - use mld_z_gs_solver -#if defined(HAVE_UMF_) - use mld_z_umf_solver -#endif -#if defined(HAVE_SLUDIST_) - use mld_z_sludist_solver -#endif -#if defined(HAVE_SLU_) - use mld_z_slu_solver -#endif -#if defined(HAVE_MUMPS_) - use mld_z_mumps_solver -#endif - - Implicit None - - ! Arguments - class(mld_z_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - ! Local - integer(psb_ipk_) :: ipos_, err_act - character(len=20) :: name='z_base_onelev_cseti' - type(mld_z_base_smoother_type) :: mld_z_base_smoother_mold - type(mld_z_jac_smoother_type) :: mld_z_jac_smoother_mold - type(mld_z_l1_jac_smoother_type) :: mld_z_l1_jac_smoother_mold - type(mld_z_as_smoother_type) :: mld_z_as_smoother_mold - type(mld_z_diag_solver_type) :: mld_z_diag_solver_mold - type(mld_z_l1_diag_solver_type) :: mld_z_l1_diag_solver_mold - type(mld_z_ilu_solver_type) :: mld_z_ilu_solver_mold - type(mld_z_id_solver_type) :: mld_z_id_solver_mold - type(mld_z_gs_solver_type) :: mld_z_gs_solver_mold - type(mld_z_bwgs_solver_type) :: mld_z_bwgs_solver_mold -#if defined(HAVE_UMF_) - type(mld_z_umf_solver_type) :: mld_z_umf_solver_mold -#endif -#if defined(HAVE_SLUDIST_) - type(mld_z_sludist_solver_type) :: mld_z_sludist_solver_mold -#endif -#if defined(HAVE_SLU_) - type(mld_z_slu_solver_type) :: mld_z_slu_solver_mold -#endif -#if defined(HAVE_MUMPS_) - type(mld_z_mumps_solver_type) :: mld_z_mumps_solver_mold -#endif - - call psb_erractionsave(err_act) - info = psb_success_ - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - select case (psb_toupper(what)) - case ('SMOOTHER_TYPE') - select case (val) - case (mld_noprec_) - call lv%set(mld_z_base_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_z_id_solver_mold,info,pos=pos) - - case (mld_jac_) - call lv%set(mld_z_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_z_diag_solver_mold,info,pos=pos) - - case (mld_l1_jac_) - call lv%set(mld_z_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_z_l1_diag_solver_mold,info,pos=pos) - - case (mld_bjac_) - call lv%set(mld_z_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_z_ilu_solver_mold,info,pos=pos) - - case (mld_l1_bjac_) - call lv%set(mld_z_l1_jac_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_z_ilu_solver_mold,info,pos=pos) - - case (mld_as_) - call lv%set(mld_z_as_smoother_mold,info,pos=pos) - if (info == 0) call lv%set(mld_z_ilu_solver_mold,info,pos=pos) - - case (mld_fbgs_) - call lv%set(mld_z_jac_smoother_mold,info,pos='pre') - if (info == 0) call lv%set(mld_z_gs_solver_mold,info,pos='pre') - call lv%set(mld_z_jac_smoother_mold,info,pos='post') - if (info == 0) call lv%set(mld_z_bwgs_solver_mold,info,pos='post') - - case default - ! - ! Do nothing and hope for the best :) - ! - end select - if ((ipos_==mld_smooth_pre_).or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) call lv%sm%default() - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm2a)) call lv%sm2a%default() - end if - - - case('SUB_SOLVE') - select case (val) - case (mld_f_none_) - call lv%set(mld_z_id_solver_mold,info,pos=pos) - - case (mld_diag_scale_) - call lv%set(mld_z_diag_solver_mold,info,pos=pos) - - case (mld_l1_diag_scale_) - call lv%set(mld_z_l1_diag_solver_mold,info,pos=pos) - - case (mld_gs_) - call lv%set(mld_z_gs_solver_mold,info,pos=pos) - - case (mld_bwgs_) - call lv%set(mld_z_bwgs_solver_mold,info,pos=pos) - - case (psb_ilu_n_,psb_milu_n_,psb_ilu_t_) - call lv%set(mld_z_ilu_solver_mold,info,pos=pos) - if (info == 0) then - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - call lv%sm%sv%set('SUB_SOLVE',val,info) - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) call lv%sm2a%sv%set('SUB_SOLVE',val,info) - end if - end if -#ifdef HAVE_SLU_ - case (mld_slu_) - call lv%set(mld_z_slu_solver_mold,info,pos=pos) -#endif -#ifdef HAVE_MUMPS_ - case (mld_mumps_) - call lv%set(mld_z_mumps_solver_mold,info,pos=pos) -#endif -#ifdef HAVE_SLUDIST_ - case (mld_sludist_) - call lv%set(mld_z_sludist_solver_mold,info,pos=pos) -#endif -#ifdef HAVE_UMF_ - case (mld_umf_) - call lv%set(mld_z_umf_solver_mold,info,pos=pos) -#endif - case default - ! - ! Do nothing and hope for the best :) - ! - end select - - - case ('SMOOTHER_SWEEPS') - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) & - & lv%parms%sweeps_pre = val - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_)) & - & lv%parms%sweeps_post = val - - case ('ML_CYCLE') - lv%parms%ml_cycle = val - - case ('PAR_AGGR_ALG') - lv%parms%par_aggr_alg = val - if (allocated(lv%aggr)) then - call lv%aggr%free(info) - if (info == 0) deallocate(lv%aggr,stat=info) - if (info /= 0) then - info = psb_err_internal_error_ - return - end if - end if - - select case(val) - case(mld_dec_aggr_) - allocate(mld_z_dec_aggregator_type :: lv%aggr, stat=info) - case(mld_sym_dec_aggr_) - allocate(mld_z_symdec_aggregator_type :: lv%aggr, stat=info) - case default - info = psb_err_internal_error_ - end select - if (info == psb_success_) call lv%aggr%default() - - case ('AGGR_ORD') - lv%parms%aggr_ord = val - - case ('AGGR_TYPE') - lv%parms%aggr_type = val - if (allocated(lv%aggr)) call lv%aggr%set_aggr_type(lv%parms,info) - - case ('AGGR_PROL') - lv%parms%aggr_prol = val - - case ('COARSE_MAT') - lv%parms%coarse_mat = val - - case ('AGGR_OMEGA_ALG') - lv%parms%aggr_omega_alg= val - - case ('AGGR_EIG') - lv%parms%aggr_eig = val - - case ('AGGR_FILTER') - lv%parms%aggr_filter = val - - case ('COARSE_SOLVE') - lv%parms%coarse_solve = val - - case default - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) then - call lv%sm%set(what,val,info,idx=idx) - end if - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) then - call lv%sm2a%set(what,val,info,idx=idx) - end if - end if - if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) - - end select - if (info /= psb_success_) goto 9999 - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_z_base_onelev_cseti diff --git a/mlprec/impl/level/mld_z_base_onelev_csetr.f90 b/mlprec/impl/level/mld_z_base_onelev_csetr.f90 deleted file mode 100644 index 565524b9..00000000 --- a/mlprec/impl/level/mld_z_base_onelev_csetr.f90 +++ /dev/null @@ -1,105 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_onelev_csetr(lv,what,val,info,pos,idx) - - use psb_base_mod - use mld_z_onelev_mod, mld_protect_name => mld_z_base_onelev_csetr - - Implicit None - - ! Arguments - class(mld_z_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - ! Local - integer(psb_ipk_) :: ipos_, err_act - character(len=20) :: name='z_base_onelev_csetr' - - call psb_erractionsave(err_act) - - - info = psb_success_ - - select case (psb_toupper(what)) - - case ('AGGR_OMEGA_VAL') - lv%parms%aggr_omega_val= val - - case ('AGGR_THRESH') - lv%parms%aggr_thresh = val - - case default - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - if ((ipos_==mld_smooth_pre_) .or.(ipos_==mld_smooth_both_)) then - if (allocated(lv%sm)) then - call lv%sm%set(what,val,info,idx=idx) - end if - end if - if ((ipos_==mld_smooth_post_).or.(ipos_==mld_smooth_both_))then - if (allocated(lv%sm2a)) then - call lv%sm2a%set(what,val,info,idx=idx) - end if - end if - if (allocated(lv%aggr)) call lv%aggr%set(what,val,info,idx=idx) - - end select - - if (info /= psb_success_) goto 9999 - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_z_base_onelev_csetr diff --git a/mlprec/impl/level/mld_z_base_onelev_descr.f90 b/mlprec/impl/level/mld_z_base_onelev_descr.f90 deleted file mode 100644 index cadd83ca..00000000 --- a/mlprec/impl/level/mld_z_base_onelev_descr.f90 +++ /dev/null @@ -1,112 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_onelev_descr(lv,il,nl,ilmin,info,iout) - - use psb_base_mod - use mld_z_onelev_mod, mld_protect_name => mld_z_base_onelev_descr - Implicit None - ! Arguments - class(mld_z_onelev_type), intent(in) :: lv - integer(psb_ipk_), intent(in) :: il,nl,ilmin - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_z_base_onelev_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse - - - call psb_erractionsave(err_act) - - - coarse = (il==nl) - - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - end if - - write(iout_,*) - if (il == ilmin) then - call lv%parms%mlcycledsc(iout_,info) - if (allocated(lv%aggr)) then - call lv%aggr%descr(lv%parms,iout_,info) - else - write(iout_,*) 'Internal error: unallocated aggregator object' - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - write(iout_,*) - end if - - if (il > 1) then - - if (coarse) then - write(iout_,*) ' Level ',il,' (coarse)' - else - write(iout_,*) ' Level ',il - end if - - call lv%parms%descr(iout_,info,coarse=coarse) - - if (nl > 1) then - if (allocated(lv%map%naggr)) then - write(iout_,*) ' Coarse Matrix: Global size: ', & - & sum((1_psb_lpk_*lv%map%naggr(:))),' Nonzeros: ',lv%ac_nz_tot - write(iout_,*) ' Local matrix sizes: ', & - & lv%map%naggr(:) - write(iout_,*) ' Aggregation ratio: ', & - & lv%szratio - end if - end if - - if (coarse.and.allocated(lv%sm)) & - & call lv%sm%descr(info,iout=iout_,coarse=coarse) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_z_base_onelev_descr diff --git a/mlprec/impl/level/mld_z_base_onelev_dump.f90 b/mlprec/impl/level/mld_z_base_onelev_dump.f90 deleted file mode 100644 index a7676b1c..00000000 --- a/mlprec/impl/level/mld_z_base_onelev_dump.f90 +++ /dev/null @@ -1,169 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_onelev_dump(lv,level,info,prefix,head,ac,rp,& - & smoother,solver,tprol,global_num) - - use psb_base_mod - use mld_z_onelev_mod, mld_protect_name => mld_z_base_onelev_dump - implicit none - class(mld_z_onelev_type), intent(in) :: lv - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: ac, rp, smoother, solver, tprol, global_num - ! Local variables - integer(psb_ipk_) :: i, j, il1, iln, lname, lev, ni - integer(psb_ipk_) :: icontxt,iam, np - character(len=80) :: prefix_, frmt - character(len=1024) :: fname - logical :: ac_, rp_, tprol_, global_num_ - integer(psb_lpk_), allocatable :: ivr(:), ivc(:) - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_lev_z" - end if - - if (associated(lv%base_desc)) then - icontxt = lv%base_desc%get_context() - call psb_info(icontxt,iam,np) - else - icontxt = -1 - iam = -1 - np = -1 - end if - if (present(ac)) then - ac_ = ac - else - ac_ = .false. - end if - if (present(rp)) then - rp_ = rp - else - rp_ = .false. - end if - if (present(tprol)) then - tprol_ = tprol - else - tprol_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - - if (np > 0) then - ni = floor(log10(1.0*np)) + 1 - write(frmt,'(a,i3.3,a,i3.3,a)') '(a,i',ni,'.',ni,')' - write(fname(lname+1:lname+ni+2),frmt) '_p',iam - lname = lname + ni + 2 - end if - - if (global_num_) then - if (level >= 2) then - if (ac_) then - ivr = lv%desc_ac%get_global_indices(owned=.false.) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx' - call lv%ac%print(fname,head=head,iv=ivr) - end if - if (rp_) then - ivr = lv%map%p_desc_U%get_global_indices(owned=.false.) - ivc = lv%map%p_desc_V%get_global_indices(owned=.false.) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx' - call lv%map%mat_U2V%print(fname,head=head,ivr=ivc,ivc=ivr) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx' - call lv%map%mat_V2U%print(fname,head=head,ivr=ivr,ivc=ivc) - end if - if (tprol_) then - ! Tentative prolongator is stored with column indices already - ! in global numbering, so only IVR is needed. - ivr = lv%map%p_desc_U%get_global_indices(owned=.false.) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_tprol.mtx' - ! - ! This is not implemented yet. - !call lv%tprol%print(fname,head=head,ivr=ivr) - end if - end if - else - if (level >= 2) then - if (ac_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_ac.mtx' - call lv%ac%print(fname,head=head) - end if - if (rp_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_r.mtx' - call lv%map%mat_U2V%print(fname,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_p.mtx' - call lv%map%mat_V2U%print(fname,head=head) - end if - if (tprol_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_tprol.mtx' - ! - ! This is not implemented yet. - !call lv%tprol%print(fname,head=head) - end if - end if - end if - - if (level >= 2) then - if (allocated(lv%sm)) then - call lv%sm%dump(lv%desc_ac,level,info,smoother=smoother, & - & solver=solver,prefix=trim(prefix_)//"_sm",global_num=global_num) - end if - if (allocated(lv%sm2a)) then - call lv%sm2a%dump(lv%desc_ac,level,info,smoother=smoother, & - & solver=solver,prefix=trim(prefix_)//"_sm2a",global_num=global_num) - end if - else - if (allocated(lv%sm)) then - call lv%sm%dump(lv%base_desc,level,info,smoother=smoother, & - & solver=solver,prefix=trim(prefix_)//"_sm",global_num=global_num) - end if - if (allocated(lv%sm2a)) then - call lv%sm2a%dump(lv%base_desc,level,info,smoother=smoother, & - & solver=solver,prefix=trim(prefix_)//"_sm2a",global_num=global_num) - end if - end if - -end subroutine mld_z_base_onelev_dump diff --git a/mlprec/impl/level/mld_z_base_onelev_free.f90 b/mlprec/impl/level/mld_z_base_onelev_free.f90 deleted file mode 100644 index 2e2af950..00000000 --- a/mlprec/impl/level/mld_z_base_onelev_free.f90 +++ /dev/null @@ -1,75 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_onelev_free(lv,info) - - use psb_base_mod - use mld_z_onelev_mod, mld_protect_name => mld_z_base_onelev_free - implicit none - - class(mld_z_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: i - - info = psb_success_ - - ! We might just deallocate the top level array, except - ! that there may be inner objects containing C pointers, - ! e.g. UMFPACK, SLU or CUDA stuff. - ! We really need FINALs. - if (allocated(lv%sm)) & - & call lv%sm%free(info) - - if (allocated(lv%sm2a)) & - & call lv%sm2a%free(info) - - if (allocated(lv%wrk)) & - & call lv%wrk%free(info) - - call lv%ac%free() - if (lv%desc_ac%is_ok()) & - & call lv%desc_ac%free(info) - call lv%map%free(info) - - ! This is a pointer to something else, must not free it here. - nullify(lv%base_a) - ! This is a pointer to something else, must not free it here. - nullify(lv%base_desc) - - call lv%nullify() - -end subroutine mld_z_base_onelev_free diff --git a/mlprec/impl/level/mld_z_base_onelev_mat_asb.f90 b/mlprec/impl/level/mld_z_base_onelev_mat_asb.f90 deleted file mode 100644 index 8b3cfdb6..00000000 --- a/mlprec/impl/level/mld_z_base_onelev_mat_asb.f90 +++ /dev/null @@ -1,178 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_z_onelev_mat_asb.f90 -! -! Subroutine: mld_z_onelev_mat_asb -! Version: complex -! -! This routine builds the matrix associated to the current level of the -! multilevel preconditioner from the matrix associated to the previous level, -! by using the user-specified aggregation technique (therefore, it also builds the -! prolongation and restriction operators mapping the current level to the -! previous one and vice versa). -! The current level is regarded as the coarse one, while the previous as -! the fine one. This is in agreement with the fact that the routine is called, -! by mld_mlprec_bld, only on levels >=2. -! The main structure is: -! 1. Perform sanity checks; -! 2. Call mld_Xaggrmat_asb to compute prolongator/restrictor/AC -! 3. According to the choice of DIST/REPL for AC, build a descriptor DESC_AC, -! and adjust the column numbering of AC/OP_PROL/OP_RESTR -! 4. Pack restrictor and prolongator into p%map -! 5. Fix base_a and base_desc pointers. -! -! -! Arguments: -! p - type(mld_z_onelev_type), input/output. -! The 'one-level' data structure containing the control -! parameters and (eventually) coarse matrix and prolongator/restrictors. -! -! a - type(psb_zspmat_type). -! The sparse matrix structure containing the local part of the -! fine-level matrix. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! ilaggr - integer, dimension(:), input -! The mapping between the row indices of the coarse-level -! matrix and the row indices of the fine-level matrix. -! ilaggr(i)=j means that node i in the adjacency graph -! of the fine-level matrix is mapped onto node j in the -! adjacency graph of the coarse-level matrix. Note that the indices -! are assumed to be shifted so as to make sure the ranges on -! the various processes do not overlap. -! nlaggr - integer, dimension(:) input -! nlaggr(i) contains the aggregates held by process i. -! op_prol - type(psb_zspmat_type), input/output -! The tentative prolongator on input, released on output. -! -! info - integer, output. -! Error code. -! -subroutine mld_z_base_onelev_mat_asb(lv,a,desc_a,ilaggr,nlaggr,t_prol,info) - - use psb_base_mod - use mld_base_prec_type - use mld_z_onelev_mod, mld_protect_name => mld_z_base_onelev_mat_asb - - implicit none - - ! Arguments - class(mld_z_onelev_type), intent(inout), target :: lv - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - integer(psb_lpk_), intent(inout) :: ilaggr(:) - type(psb_lzspmat_type), intent(inout) :: t_prol - integer(psb_ipk_), intent(out) :: info - - - ! Local variables - character(len=24) :: name - integer(psb_ipk_) :: ictxt, np, me - integer(psb_ipk_) :: err_act - type(psb_zspmat_type) :: ac, op_restr, op_prol - integer(psb_ipk_) :: nzl, inl - integer(psb_ipk_) :: debug_level, debug_unit - - name='mld_z_onelev_mat_asb' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) - - call mld_check_def(lv%parms%aggr_prol,'Smoother',& - & mld_smooth_prol_,is_legal_ml_aggr_prol) - call mld_check_def(lv%parms%coarse_mat,'Coarse matrix',& - & mld_distr_mat_,is_legal_ml_coarse_mat) - call mld_check_def(lv%parms%aggr_filter,'Use filtered matrix',& - & mld_no_filter_mat_,is_legal_aggr_filter) - call mld_check_def(lv%parms%aggr_omega_alg,'Omega Alg.',& - & mld_eig_est_,is_legal_ml_aggr_omega_alg) - call mld_check_def(lv%parms%aggr_eig,'Eigenvalue estimate',& - & mld_max_norm_,is_legal_ml_aggr_eig) - call mld_check_def(lv%parms%aggr_omega_val,'Omega',dzero,is_legal_d_omega) - - - ! - ! Build the coarse-level matrix from the fine-level one, starting from - ! the mapping defined by mld_aggrmap_bld and applying the aggregation - ! algorithm specified by lv%iprcparm(mld_aggr_prol_) - ! - call lv%aggr%mat_bld(lv%parms,a,desc_a,ilaggr,nlaggr,& - & lv%ac,lv%desc_ac,op_prol,op_restr,t_prol,info) - - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_aggrmat_asb') - goto 9999 - end if - - ! - ! Now build its descriptor and convert global indices for - ! ac, op_restr and op_prol - ! - if (info == psb_success_) & - & call lv%aggr%mat_asb(lv%parms,a,desc_a,& - & lv%ac,lv%desc_ac,op_prol,op_restr,info) - - if (info == psb_success_) call lv%ac%cscnv(info,type='csr',dupl=psb_dupl_add_) - - if (info == psb_success_) call lv%aggr%bld_map(desc_a, lv%desc_ac,& - & ilaggr,nlaggr,op_restr,op_prol,lv%map,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mat_asb/map_bld') - goto 9999 - end if - ! - ! Fix the base_a and base_desc pointers for handling of residuals. - ! This is correct because this routine is only called at levels >=2. - ! - lv%base_a => lv%ac - lv%base_desc => lv%desc_ac - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_z_base_onelev_mat_asb diff --git a/mlprec/impl/level/mld_z_base_onelev_setag.f90 b/mlprec/impl/level/mld_z_base_onelev_setag.f90 deleted file mode 100644 index 84bf26be..00000000 --- a/mlprec/impl/level/mld_z_base_onelev_setag.f90 +++ /dev/null @@ -1,82 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_onelev_setag(lv,val,info,pos) - - use psb_base_mod - use mld_z_onelev_mod, mld_protect_name => mld_z_base_onelev_setag - - implicit none - - ! Arguments - class(mld_z_onelev_type), target, intent(inout) :: lv - class(mld_z_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ipos_ - character(len=*), parameter :: name='mld_base_onelev_setag' - - info = psb_success_ - - ! Ignore pos for aggregator - - if (allocated(lv%aggr)) then - if (.not.same_type_as(lv%aggr,val)) then - call lv%aggr%free(info) - deallocate(lv%aggr,stat=info) - if (info /= 0) then - info = 3111 - return - end if - end if - end if - - if (.not.allocated(lv%aggr)) then - allocate(lv%aggr,mold=val,stat=info) - if (info /= 0) then - info = 3111 - return - end if - lv%parms%par_aggr_alg = mld_ext_aggr_ - lv%parms%aggr_type = mld_noalg_ - call lv%aggr%default() - end if - -end subroutine mld_z_base_onelev_setag - diff --git a/mlprec/impl/level/mld_z_base_onelev_setsm.F90 b/mlprec/impl/level/mld_z_base_onelev_setsm.F90 deleted file mode 100644 index 4f2081ef..00000000 --- a/mlprec/impl/level/mld_z_base_onelev_setsm.F90 +++ /dev/null @@ -1,114 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_onelev_setsm(lev,val,info,pos) - - use psb_base_mod - use mld_z_prec_mod, mld_protect_name => mld_z_base_onelev_setsm - - implicit none - - ! Arguments - class(mld_z_onelev_type), target, intent(inout) :: lev - class(mld_z_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ipos_ - character(len=*), parameter :: name='mld_base_onelev_setsm' - - info = psb_success_ - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - if (ipos_ == mld_smooth_both_) then - if (allocated(lev%sm2a)) then - call lev%sm2a%free(info) - deallocate(lev%sm2a, stat=info) - lev%sm2 => null() - end if - end if - - select case(ipos_) - case(mld_smooth_pre_, mld_smooth_both_) - if (allocated(lev%sm)) then - if (.not.same_type_as(lev%sm,val)) then - call lev%sm%free(info) - deallocate(lev%sm, stat=info) - end if - endif - if (.not.allocated(lev%sm)) then -#ifdef HAVE_MOLD - allocate(lev%sm,mold=val) -#else - allocate(lev%sm,source=val) -#endif - end if - call lev%sm%default() - if (ipos_ == mld_smooth_both_) lev%sm2 => lev%sm - case(mld_smooth_post_) - if (allocated(lev%sm2a)) then - if (.not.same_type_as(lev%sm2a,val)) then - call lev%sm2a%free(info) - deallocate(lev%sm2a, stat=info) - endif - end if - if (.not.allocated(lev%sm2a)) then -#ifdef HAVE_MOLD - allocate(lev%sm2a,mold=val) -#else - allocate(lev%sm2a,source=val) -#endif - end if - call lev%sm2a%default() - lev%sm2 => lev%sm2a - end select - -end subroutine mld_z_base_onelev_setsm - diff --git a/mlprec/impl/level/mld_z_base_onelev_setsv.F90 b/mlprec/impl/level/mld_z_base_onelev_setsv.F90 deleted file mode 100644 index 9481b8f2..00000000 --- a/mlprec/impl/level/mld_z_base_onelev_setsv.F90 +++ /dev/null @@ -1,152 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_onelev_setsv(lev,val,info,pos) - - use psb_base_mod - use mld_z_prec_mod, mld_protect_name => mld_z_base_onelev_setsv - - implicit none - - ! Arguments - class(mld_z_onelev_type), target, intent(inout) :: lev - class(mld_z_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ipos_ - character(len=*), parameter :: name='mld_base_onelev_setsv' - - info = psb_success_ - - if (present(pos)) then - select case(psb_toupper(trim(pos))) - case('PRE') - ipos_ = mld_smooth_pre_ - case('POST') - ipos_ = mld_smooth_post_ - case default - ipos_ = mld_smooth_both_ - end select - else - ipos_ = mld_smooth_both_ - end if - - if ((ipos_ == mld_smooth_pre_).or.(ipos_ == mld_smooth_both_)) then - if (allocated(lev%sm)) then - if (allocated(lev%sm%sv)) then - if (.not.same_type_as(lev%sm%sv,val)) then - call lev%sm%sv%free(info) - if (info == 0) deallocate(lev%sm%sv,stat=info) - if (info /= 0) then - info = 3111 - return - end if - end if - end if - - if (.not.allocated(lev%sm%sv)) then -#ifdef HAVE_MOLD - allocate(lev%sm%sv,mold=val,stat=info) -#else - allocate(lev%sm%sv,source=val,stat=info) -#endif - if (info /= 0) then - info = 3111 - return - end if - end if - call lev%sm%sv%default() - else - info = 3111 - write(psb_err_unit,*) name,& - &': Error: uninitialized preconditioner component,',& - &' should call MLD_PRECINIT/MLD_PRECSET' - return - - end if - end if - - ! - ! If POS was not specified and therefore we have mld_smooth_both_ - ! we need to update sm2a *only* if it was already allocated, - ! otherwise it is not needed (since we have just fixed %sm in the - ! pre section). - ! - - if ((ipos_ == mld_smooth_post_).or. & - ((ipos_ == mld_smooth_both_).and.(allocated(lev%sm2a)))) then - - - if (allocated(lev%sm2a)) then - if (allocated(lev%sm2a%sv)) then - if (.not.same_type_as(lev%sm2a%sv,val)) then - call lev%sm2a%sv%free(info) - if (info == 0) deallocate(lev%sm2a%sv,stat=info) - if (info /= 0) then - info = 3111 - return - end if - end if - end if - if (.not.allocated(lev%sm2a%sv)) then -#ifdef HAVE_MOLD - allocate(lev%sm2a%sv,mold=val,stat=info) -#else - allocate(lev%sm2a%sv,source=val,stat=info) -#endif - if (info /= 0) then - info = 3111 - return - end if - end if - call lev%sm2a%sv%default() - - else - info = 3111 - write(psb_err_unit,*) name,& - &': Error: uninitialized preconditioner component,',& - &' should call MLD_PRECINIT/MLD_PRECSET' - return - - end if - - end if - -end subroutine mld_z_base_onelev_setsv - diff --git a/mlprec/impl/mld_c_extprol_bld.F90 b/mlprec/impl/mld_c_extprol_bld.F90 deleted file mode 100644 index d52ce68a..00000000 --- a/mlprec/impl/mld_c_extprol_bld.F90 +++ /dev/null @@ -1,534 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_c_extprol_bld.f90 -! -! Subroutine: mld_c_extprol_bld -! Version: real -! -! This routine builds the preconditioner according to the requirements made by -! the user trough the subroutines mld_precinit and mld_precset. -! -! A multilevel preconditioner is regarded as an array of 'one-level' data structures, -! each containing the part of the preconditioner associated to a certain level, -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level. No transfer operators are associated to level 1. -! -! -! Arguments: -! a - type(psb_cspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_cprec_type), input/output. -! The preconditioner data structure containing the local part -! of the preconditioner to be built. -! info - integer, output. -! Error code. -! -! amold - class(psb_c_base_sparse_mat), input, optional -! Mold for the inner format of matrices contained in the -! preconditioner -! -! -! vmold - class(psb_c_base_vect_type), input, optional -! Mold for the inner format of vectors contained in the -! preconditioner -! -! -! -subroutine mld_c_extprol_bld(a,desc_a,p,prolv,restrv,info,amold,vmold,imold) - - use psb_base_mod - use mld_c_inner_mod - use mld_c_prec_mod, mld_protect_name => mld_c_extprol_bld - - Implicit None - - ! Arguments - type(psb_cspmat_type),intent(in), target :: a - type(psb_cspmat_type),intent(inout), target :: prolv(:) - type(psb_cspmat_type),intent(inout), target :: restrv(:) - type(psb_desc_type), intent(inout), target :: desc_a - type(mld_cprec_type),intent(inout),target :: p - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! !$ character, intent(in), optional :: upd - - ! Local Variables - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, casize, nplevs, mxplevs - integer(psb_ipk_) :: nprolv, nrestrv - real(psb_spk_) :: mnaggratio - integer(psb_ipk_) :: ipv(mld_ifpsz_), val - class(mld_c_base_smoother_type), allocatable :: coarse_sm, base_sm, med_sm - type(mld_sml_parms) :: baseparms, medparms, coarseparms - type(mld_c_onelev_type), allocatable :: tprecv(:) - integer(psb_ipk_) :: int_err(5) - character :: upd_ - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - logical, parameter :: debug=.false. - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_c_extprol_bld' - info = psb_success_ - int_err(1) = 0 - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - p%ictxt = ictxt - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' -#if defined(LPK8) - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Need fix for LPK8') - goto 9999 -#else - - ! - ! For the time being we are commenting out the UPDATE argument - ! we plan to resurrect it later. - ! !$ if (present(upd)) then - ! !$ if (debug_level >= psb_debug_outer_) & - ! !$ & write(debug_unit,*) me,' ',trim(name),'UPD ', upd - ! !$ - ! !$ if ((psb_toupper(upd).eq.'F').or.(psb_toupper(upd).eq.'T')) then - ! !$ upd_=psb_toupper(upd) - ! !$ else - ! !$ upd_='F' - ! !$ endif - ! !$ else - ! !$ upd_='F' - ! !$ endif - upd_ = 'F' - - if (.not.allocated(p%precv)) then - !! Error: should have called mld_cprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - ! - ! Check to ensure all procs have the same - ! - newsz = -1 - mxplevs = p%ag_data%max_levs - mnaggratio = p%ag_data%min_cr_ratio - casize = p%ag_data%min_coarse_size - iszv = size(p%precv) - nprolv = size(prolv) - nrestrv = size(restrv) - call psb_bcast(ictxt,iszv) - call psb_bcast(ictxt,casize) - call psb_bcast(ictxt,mxplevs) - call psb_bcast(ictxt,mnaggratio) - call psb_bcast(ictxt,nprolv) - call psb_bcast(ictxt,nrestrv) - if (casize /= p%ag_data%min_coarse_size) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent min_coarse_size') - goto 9999 - end if - if (mxplevs /= p%ag_data%max_levs) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent max_levs') - goto 9999 - end if - if (mnaggratio /= p%ag_data%min_cr_ratio) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent min_cr_ratio') - goto 9999 - end if - if (iszv /= size(p%precv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of precv') - goto 9999 - end if - if (nprolv /= size(prolv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of prolv') - goto 9999 - end if - if (nrestrv /= size(restrv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of restrv') - goto 9999 - end if - if (nrestrv /= nprolv) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size prolv vs restrv') - goto 9999 - end if - - if (iszv <= 1) then - ! We should only ever get here for multilevel. - info=psb_err_from_subroutine_ - ch_err='size bpv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - endif - - if (nrestrv < 1) then - ! We should only ever get here for multilevel. - info=psb_err_from_subroutine_ - ch_err='size restrv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - endif - - ! - nplevs = nrestrv + 1 - p%ag_data%max_levs = nplevs - - ! - ! Fixed number of levels. - ! - nplevs = max(itwo,mxplevs) - - coarseparms = p%precv(iszv)%parms - baseparms = p%precv(1)%parms - medparms = p%precv(2)%parms - - allocate(coarse_sm, source=p%precv(iszv)%sm,stat=info) - if (info == psb_success_) & - & allocate(med_sm, source=p%precv(2)%sm,stat=info) - if (info == psb_success_) & - & allocate(base_sm, source=p%precv(1)%sm,stat=info) - if (info /= psb_success_) then - write(0,*) 'Error in saving smoothers',info - call psb_errpush(psb_err_internal_error_,name,a_err='Base level precbuild.') - goto 9999 - end if - - if (iszv /= nplevs) then - allocate(tprecv(nplevs),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - tprecv(1)%parms = baseparms - allocate(tprecv(1)%sm,source=base_sm,stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - do i=2,nplevs-1 - tprecv(i)%parms = medparms - allocate(tprecv(i)%sm,source=med_sm,stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - end do - tprecv(nplevs)%parms = coarseparms - allocate(tprecv(nplevs)%sm,source=coarse_sm,stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - do i=1,iszv - call p%precv(i)%free(info) - end do - call move_alloc(tprecv,p%precv) - iszv = size(p%precv) - end if - ! - ! Finest level first; remember to fix base_a and base_desc - ! - p%precv(1)%base_a => a - p%precv(1)%base_desc => desc_a - newsz = 0 - array_build_loop: do i=2, iszv - - ! - ! Sanity checks on the parameters - ! - if (i p%precv(i)%ac - p%precv(i)%base_desc => p%precv(i)%desc_ac - - - if (i>2) then - if (all(p%precv(i)%map%naggr == p%precv(i-1)%map%naggr)) then - newsz=i-1 - end if - call psb_bcast(ictxt,newsz) - if (newsz > 0) exit array_build_loop - end if - end do array_build_loop - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Internal extprol build' ) - goto 9999 - endif - - iszv = size(p%precv) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Exiting with',iszv,' levels' -#endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - - subroutine mld_c_extaggr_bld(a,desc_a,p,op_restr,op_prol,info) - use psb_base_mod - use mld_c_inner_mod - - implicit none - - ! Arguments - type(psb_cspmat_type), intent(in), target :: a - type(psb_cspmat_type), intent(inout) :: op_restr,op_prol - type(psb_desc_type), intent(in), target :: desc_a - type(mld_c_onelev_type), intent(inout),target :: p - integer(psb_ipk_), intent(out) :: info - - ! Local variables - character(len=20) :: name - integer(psb_mpk_) :: ictxt, np, me, ncol - integer(psb_ipk_) :: err_act,ntaggr,nzl - integer(psb_ipk_), allocatable :: ilaggr(:), nlaggr(:) - type(psb_cspmat_type) :: ac, am2, am3, am4 - type(psb_c_coo_sparse_mat) :: acoo, bcoo - type(psb_c_csr_sparse_mat) :: acsr1 - logical, parameter :: debug=.false. - - name='mld_c_extaggr_bld' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) -#if defined(LPK8) - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Need fix for LPK8') - goto 9999 -#else - allocate(nlaggr(np),ilaggr(1)) - nlaggr = 0 - ilaggr = 0 - p%parms%par_aggr_alg = mld_ext_aggr_ - call mld_check_def(p%parms%ml_cycle,'Multilevel cycle',& - & mld_mult_ml_,is_legal_ml_cycle) - call mld_check_def(p%parms%coarse_mat,'Coarse matrix',& - & mld_distr_mat_,is_legal_ml_coarse_mat) - - nlaggr(me+1) = op_restr%get_nrows() - if (op_restr%get_nrows() /= op_prol%get_ncols()) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent restr/prol sizes') - goto 9999 - end if - call psb_sum(ictxt,nlaggr) - ntaggr = sum(nlaggr) - ncol = desc_a%get_local_cols() - if (debug) write(0,*)me,' Sizes:',op_restr%get_nrows(),op_restr%get_ncols(),& - & op_prol%get_nrows(),op_prol%get_ncols(), a%get_nrows(),a%get_ncols() - ! - ! Compute local part of AC - ! - call op_prol%clone(am2,info) - if (info == psb_success_) call psb_sphalo(am2,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.) - if (info == psb_success_) call psb_rwextd(ncol,am2,info,b=am4) - if (info == psb_success_) call am4%free() - call psb_spspmm(a,am2,am3,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 2') - goto 9999 - end if - call psb_sphalo(am3,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.) - if (info == psb_success_) call psb_rwextd(ncol,am3,info,b=am4) - if (info == psb_success_) call am4%free() - if(info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Extend am3') - goto 9999 - end if - call psb_spspmm(op_restr,am3,ac,info) - if (info == psb_success_) call am3%free() - if (info == psb_success_) call ac%cscnv(info,type='csr',dupl=psb_dupl_add_) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Build ac = op_restr x am3') - goto 9999 - end if - - select case(p%parms%coarse_mat) - - case(mld_distr_mat_) - - call ac%mv_to(bcoo) - nzl = bcoo%get_nzeros() - - if (info == psb_success_) call psb_cdall(ictxt,p%desc_ac,info,nl=nlaggr(me+1)) - if (info == psb_success_) call psb_cdins(nzl,bcoo%ia,bcoo%ja,p%desc_ac,info) - if (info == psb_success_) call psb_cdasb(p%desc_ac,info) - if (info == psb_success_) call psb_glob_to_loc(bcoo%ia(1:nzl),p%desc_ac,info,iact='I') - if (info == psb_success_) call psb_glob_to_loc(bcoo%ja(1:nzl),p%desc_ac,info,iact='I') - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Creating p%desc_ac and converting ac') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Assembld aux descr. distr.' - call p%ac%mv_from(bcoo) - - call p%ac%set_nrows(p%desc_ac%get_local_rows()) - call p%ac%set_ncols(p%desc_ac%get_local_cols()) - call p%ac%set_asb() - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_sp_free') - goto 9999 - end if - - if (np>1) then - call op_prol%mv_to(acsr1) - nzl = acsr1%get_nzeros() - call psb_glob_to_loc(acsr1%ja(1:nzl),p%desc_ac,info,'I') - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_glob_to_loc') - goto 9999 - end if - call op_prol%mv_from(acsr1) - endif - call op_prol%set_ncols(p%desc_ac%get_local_cols()) - - if (np>1) then - call op_restr%cscnv(info,type='coo',dupl=psb_dupl_add_) - call op_restr%mv_to(acoo) - nzl = acoo%get_nzeros() - if (info == psb_success_) call psb_glob_to_loc(acoo%ia(1:nzl),p%desc_ac,info,'I') - call acoo%set_dupl(psb_dupl_add_) - if (info == psb_success_) call op_restr%mv_from(acoo) - if (info == psb_success_) call op_restr%cscnv(info,type='csr') - if(info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Converting op_restr to local') - goto 9999 - end if - end if - call op_restr%set_nrows(p%desc_ac%get_local_cols()) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ac ' - - case(mld_repl_mat_) - ! - ! - call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) - if (info == psb_success_) call psb_cdasb(p%desc_ac,info) - if (info == psb_success_) & - & call psb_gather(p%ac,ac,p%desc_ac,info,dupl=psb_dupl_add_,keeploc=.false.) - - if (info /= psb_success_) goto 9999 - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_coarse_mat_') - goto 9999 - end select - - call p%ac%cscnv(info,type='csr',dupl=psb_dupl_add_) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv') - goto 9999 - end if - - ! - ! Copy the prolongation/restriction matrices into the descriptor map. - ! op_restr => PR^T i.e. restriction operator - ! op_prol => PR i.e. prolongation operator - ! - - p%map = psb_linmap(psb_map_aggr_,desc_a,& - & p%desc_ac,op_restr,op_prol,ilaggr,nlaggr) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_Free') - goto 9999 - end if -#endif - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - end subroutine mld_c_extaggr_bld - -end subroutine mld_c_extprol_bld diff --git a/mlprec/impl/mld_c_hierarchy_bld.f90 b/mlprec/impl/mld_c_hierarchy_bld.f90 deleted file mode 100644 index 26d09aeb..00000000 --- a/mlprec/impl/mld_c_hierarchy_bld.f90 +++ /dev/null @@ -1,539 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_c_hierarchy_bld.f90 -! -! Subroutine: mld_c_hierarchy_bld -! Version: complex -! -! This routine builds the preconditioner according to the requirements made by -! the user trough the subroutines mld_precinit and mld_precset. -! -! A multilevel preconditioner is regarded as an array of 'one-level' data structures, -! each containing the part of the preconditioner associated to a certain level, -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level. No transfer operators are associated to level 1. -! -! -! Arguments: -! a - type(psb_cspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_cprec_type), input/output. -! The preconditioner data structure; upon exit it contains -! the multilevel hierarchy of prolongators, restrictors -! and coarse matrices. -! info - integer, output. -! Error code. -! -subroutine mld_c_hierarchy_bld(a,desc_a,prec,info) - - use psb_base_mod - use mld_c_inner_mod - use mld_c_prec_mod, mld_protect_name => mld_c_hierarchy_bld - - Implicit None - - ! Arguments - type(psb_cspmat_type),intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_cprec_type),intent(inout),target :: prec - integer(psb_ipk_), intent(out) :: info - - ! Local Variables - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz,& - & nplevs, mxplevs - integer(psb_lpk_) :: iaggsize, casize - real(psb_spk_) :: mnaggratio, sizeratio, athresh, aomega - class(mld_c_base_smoother_type), allocatable :: coarse_sm, med_sm, & - & med_sm2, coarse_sm2 - class(mld_c_base_aggregator_type), allocatable :: tmp_aggr - type(mld_sml_parms) :: medparms, coarseparms - integer(psb_lpk_), allocatable :: ilaggr(:), nlaggr(:) - type(psb_lcspmat_type) :: op_prol - type(mld_c_onelev_type), allocatable :: tprecv(:) - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - integer(psb_ipk_), save :: idx_bldtp=-1, idx_matasb=-1 - logical, parameter :: do_timings=.false. - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_c_hierarchy_bld' - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - prec%ictxt = ictxt - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' - if ((do_timings).and.(idx_bldtp==-1)) & - & idx_bldtp = psb_get_timer_idx("BLD_HIER: bld_tprol") - if ((do_timings).and.(idx_matasb==-1)) & - & idx_matasb = psb_get_timer_idx("BLD_HIER: mmat_asb") - ! - - if (.not.allocated(prec%precv)) then - !! Error: should have called mld_cprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - ! - ! Check to ensure all procs have the same - ! - newsz = -1 - mxplevs = prec%ag_data%max_levs - mnaggratio = prec%ag_data%min_cr_ratio - casize = prec%ag_data%min_coarse_size - iszv = size(prec%precv) - call psb_bcast(ictxt,iszv) - call psb_bcast(ictxt,casize) - call psb_bcast(ictxt,mxplevs) - call psb_bcast(ictxt,mnaggratio) - if (casize /= prec%ag_data%min_coarse_size) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent min_coarse_size') - goto 9999 - end if - if (mxplevs /= prec%ag_data%max_levs) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent max_levs') - goto 9999 - end if - if (mnaggratio /= prec%ag_data%min_cr_ratio) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent min_cr_ratio') - goto 9999 - end if - if (iszv /= size(prec%precv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of precv') - goto 9999 - end if - - if (iszv < 1) then - ! - ! This is wrong, cannot be size <1 - ! - info=psb_err_from_subroutine_ - ch_err='size bpv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - endif - if (iszv == 1) then - ! - ! This is OK, since it may be called by the user even if there - ! is only one level - ! - prec%precv(1)%base_a => a - prec%precv(1)%base_desc => desc_a - - call psb_erractionrestore(err_act) - return - endif - - ! - ! The strategy: - ! 1. The maximum number of levels should be already encoded in the - ! size of the array; - ! 2. If the user did not specify anything, then a default coarse size - ! is generated, and the number of levels is set to the maximum; - ! 3. If the size of the array is different from target number of levels, - ! reallocate; - ! 4. Build the matrix hierarchy, stopping early if either the target - ! coarse size is hit, or the gain falls below the min_cr_ratio - ! threshold. - ! - - if (casize < 0) then - ! - ! Default to the cubic root of the size at base level. - ! - casize = desc_a%get_global_rows() - casize = int((sone*casize)**(sone/(sone*3)),psb_lpk_) - casize = max(casize,lone) - casize = casize*40_psb_lpk_ - call psb_bcast(ictxt,casize) - if (casize > huge(prec%ag_data%min_coarse_size)) then - ! - ! computed coarse size does not fit in IPK_. - ! This is very unlikely, but make sure to put a positive number - ! - prec%ag_data%min_coarse_size = huge(prec%ag_data%min_coarse_size) - else - prec%ag_data%min_coarse_size = casize - end if - end if - nplevs = max(itwo,mxplevs) - - ! - ! The coarse parameters will be needed later - ! - coarseparms = prec%precv(iszv)%parms - call save_smoothers(prec%precv(iszv),coarse_sm,coarse_sm2,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Base level precbuild.') - goto 9999 - end if - ! - ! First set desired number of levels - ! - if (iszv /= nplevs) then - allocate(tprecv(nplevs),stat=info) - ! First all existing levels - do i=1, min(iszv,nplevs) - 1 - if (info == 0) tprecv(i)%parms = prec%precv(i)%parms - if (info == 0) call restore_smoothers(tprecv(i),& - & prec%precv(i)%sm,prec%precv(i)%sm2a,info) - if (info == 0) call move_alloc(prec%precv(i)%aggr,tprecv(i)%aggr) - end do - if (iszv < nplevs) then - ! Further intermediates, if needed - allocate(tmp_aggr,source=tprecv(iszv-1)%aggr,stat=info) - medparms = prec%precv(iszv-1)%parms - call save_smoothers(prec%precv(iszv-1),med_sm,med_sm2,info) - do i=iszv, nplevs - 1 - if (info == 0) tprecv(i)%parms = medparms - if (info == 0) call restore_smoothers(tprecv(i),med_sm,med_sm2,info) - if ((info == 0).and..not.allocated(tprecv(i)%aggr))& - & allocate(tprecv(i)%aggr,source=tmp_aggr,stat=info) - end do - deallocate(tmp_aggr,stat=info) - end if - - ! Then coarse - if (info == 0) tprecv(nplevs)%parms = coarseparms - if (info == 0) call restore_smoothers(tprecv(nplevs),coarse_sm,coarse_sm2,info) - if (info == 0) then - if (nplevs <= iszv) then - allocate(tprecv(nplevs)%aggr,source=prec%precv(nplevs)%aggr,stat=info) - else - allocate(tmp_aggr,source=tprecv(nplevs-1)%aggr,stat=info) - call move_alloc(tmp_aggr,tprecv(nplevs)%aggr) - end if - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - - do i=1,iszv - call prec%precv(i)%free(info) - end do - call move_alloc(tprecv,prec%precv) - iszv = size(prec%precv) - end if - - ! - ! Finest level first; create a GEN_BLOCK - ! copy of the descriptor. - ! - prec%precv(1)%base_a => a - call psb_cd_renum_block(desc_a,prec%precv(1)%desc_ac,info) - prec%precv(1)%base_desc => prec%precv(1)%desc_ac - newsz = 0 - array_build_loop: do i=2, iszv - ! - ! Check on the iprcparm contents: they should be the same - ! on all processes. - ! - call psb_bcast(ictxt,prec%precv(i)%parms) - - ! - ! Sanity checks on the parameters - ! - if (i= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Calling mlprcbld at level ',i - ! - ! Build the mapping between levels i-1 and i and the matrix - ! at level i - ! - if (do_timings) call psb_tic(idx_bldtp) - if (info == psb_success_)& - & call prec%precv(i)%bld_tprol(prec%precv(i-1)%base_a,& - & prec%precv(i-1)%base_desc,& - & ilaggr,nlaggr,op_prol,prec%ag_data,info) - if (do_timings) call psb_toc(idx_bldtp) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Map build') - goto 9999 - endif - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Return from ',i,' call to bld_tprol', info - ! - ! Save op_prol just in case - ! - call op_prol%clone(prec%precv(i)%tprol,info) - ! - ! Check for early termination of aggregation loop. - ! - iaggsize = sum(nlaggr) - - sizeratio = iaggsize - if (i==2) then - sizeratio = desc_a%get_global_rows()/sizeratio - else - sizeratio = sum(prec%precv(i-1)%map%naggr)/sizeratio - end if - prec%precv(i)%szratio = sizeratio - - if (iaggsize <= casize) newsz = i - if (i == iszv) newsz = i - - if (i>2) then - if (sizeratio < mnaggratio) then - if (sizeratio > 1) then - newsz = i - else - ! - ! We are not gaining - ! - newsz = i-1 - end if - end if - - if (all(nlaggr == prec%precv(i-1)%map%naggr)) then - newsz=i-1 - if (me == 0) then - write(debug_unit,*) trim(name),& - &': Warning: aggregates from level ',& - & newsz - write(debug_unit,*) trim(name),& - &': to level ',& - & iszv,' coincide.' - write(debug_unit,*) trim(name),& - &': Number of levels actually used :',newsz - write(debug_unit,*) - end if - end if - end if - call psb_bcast(ictxt,newsz) - - if (newsz > 0) then - ! - ! This is awkward, we are saving the aggregation parms, for the sake - ! of distr/repl matrix at coarse level. Should be rethought. - ! - athresh = prec%precv(newsz)%parms%aggr_thresh - aomega = prec%precv(newsz)%parms%aggr_omega_val - if (info == 0) prec%precv(newsz)%parms = coarseparms - prec%precv(newsz)%parms%aggr_thresh = athresh - prec%precv(newsz)%parms%aggr_omega_val = aomega - - if (info == 0) call restore_smoothers(prec%precv(newsz),& - & coarse_sm,coarse_sm2,info) - if (newsz < i) then - ! - ! We are going back and revisit a previous leve; - ! recover the aggregation. - ! - ilaggr = prec%precv(newsz)%map%iaggr - nlaggr = prec%precv(newsz)%map%naggr - call prec%precv(newsz)%tprol%clone(op_prol,info) - end if - if (do_timings) call psb_tic(idx_matasb) - if (info == psb_success_) call prec%precv(newsz)%mat_asb( & - & prec%precv(newsz-1)%base_a,prec%precv(newsz-1)%base_desc,& - & ilaggr,nlaggr,op_prol,info) - if (do_timings) call psb_toc(idx_matasb) - if (info /= 0) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Mat asb') - goto 9999 - endif - exit array_build_loop - else - if (do_timings) call psb_tic(idx_matasb) - if (info == psb_success_) call prec%precv(i)%mat_asb(& - & prec%precv(i-1)%base_a,prec%precv(i-1)%base_desc,& - & ilaggr,nlaggr,op_prol,info) - if (do_timings) call psb_toc(idx_matasb) - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Map build') - goto 9999 - endif - if (i 0) then - ! - ! We exited early from the build loop, need to fix - ! the size. - ! - allocate(tprecv(newsz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - do i=1,newsz - call prec%precv(i)%move_alloc(tprecv(i),info) - end do - do i=newsz+1, iszv - call prec%precv(i)%free(info) - end do - call move_alloc(tprecv,prec%precv) - ! Ignore errors from transfer - info = psb_success_ - ! - ! Restart - iszv = newsz - ! Fix the pointers, but the level 1 should - ! be treated differently - if (.not.associated(prec%precv(1)%base_desc,desc_a)) then - prec%precv(1)%base_desc => prec%precv(1)%desc_ac - end if - do i=2, iszv - prec%precv(i)%base_a => prec%precv(i)%ac - prec%precv(i)%base_desc => prec%precv(i)%desc_ac - prec%precv(i)%map%p_desc_U => prec%precv(i-1)%base_desc - prec%precv(i)%map%p_desc_V => prec%precv(i)%base_desc - end do - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Internal hierarchy build' ) - goto 9999 - endif - - iszv = size(prec%precv) - - call prec%cmp_complexity() - call prec%cmp_avg_cr() - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Exiting with',iszv,' levels' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - subroutine save_smoothers(level,save1, save2,info) - type(mld_c_onelev_type), intent(inout) :: level - class(mld_c_base_smoother_type), allocatable , intent(inout) :: save1, save2 - integer(psb_ipk_), intent(out) :: info - - info = 0 - if (allocated(save1)) then - call save1%free(info) - if (info == 0) deallocate(save1,stat=info) - if (info /= 0) return - end if - if (allocated(save2)) then - call save2%free(info) - if (info == 0) deallocate(save2,stat=info) - if (info /= 0) return - end if - allocate(save1, mold=level%sm,stat=info) - if (info == 0) call level%sm%clone_settings(save1,info) - if ((info == 0).and.allocated(level%sm2a)) then - allocate(save2, mold=level%sm2a,stat=info) - if (info == 0) call level%sm2a%clone_settings(save2,info) - end if - - return - end subroutine save_smoothers - - subroutine restore_smoothers(level,save1, save2,info) - type(mld_c_onelev_type), intent(inout), target :: level - class(mld_c_base_smoother_type), allocatable, intent(inout) :: save1, save2 - integer(psb_ipk_), intent(out) :: info - - info = 0 - - if (allocated(level%sm)) then - if (info == 0) call level%sm%free(info) - if (info == 0) deallocate(level%sm,stat=info) - end if - if (allocated(save1)) then - if (info == 0) allocate(level%sm,mold=save1,stat=info) - if (info == 0) call save1%clone_settings(level%sm,info) - end if - - if (info /= 0) return - - if (allocated(level%sm2a)) then - if (info == 0) call level%sm2a%free(info) - if (info == 0) deallocate(level%sm2a,stat=info) - end if - if (allocated(save2)) then - if (info == 0) allocate(level%sm2a,mold=save2,stat=info) - if (info == 0) call save2%clone_settings(level%sm2a,info) - if (info == 0) level%sm2 => level%sm2a - else - if (allocated(level%sm)) level%sm2 => level%sm - end if - - return - end subroutine restore_smoothers - -end subroutine mld_c_hierarchy_bld diff --git a/mlprec/impl/mld_c_smoothers_bld.f90 b/mlprec/impl/mld_c_smoothers_bld.f90 deleted file mode 100644 index b2b3079b..00000000 --- a/mlprec/impl/mld_c_smoothers_bld.f90 +++ /dev/null @@ -1,313 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_c_smoothers_bld.f90 -! -! Subroutine: mld_c_smoothers_bld -! Version: complex -! -! This routine performs the final phase of the multilevel preconditioner -! build process: builds the "smoother" objects at each level, -! based on the matrix hierarchy prepared by mld_c_hierarchy_bld. -! -! A multilevel preconditioner is regarded as an array of 'one-level' -! data structures, each containing the part of the -! preconditioner associated to a certain level, -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level. No transfer operators are associated to level 1. -! Each level provides a "build" method; for the base type, the "one-level" -! build procedure simply invokes the build method of the first smoother object, -! and also on the second object if allocated. -! -! -! Arguments: -! a - type(psb_cspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_cprec_type), input/output. -! The preconditioner data structure containing the local part -! of the preconditioner to be built. -! info - integer, output. -! Error code. -! -! amold - class(psb_c_base_sparse_mat), input, optional -! Mold for the inner format of matrices contained in the -! preconditioner -! -! -! vmold - class(psb_c_base_vect_type), input, optional -! Mold for the inner format of vectors contained in the -! preconditioner -! -! -! -subroutine mld_c_smoothers_bld(a,desc_a,prec,info,amold,vmold,imold) - - use psb_base_mod - !use mld_c_inner_mod - use mld_c_prec_mod, mld_protect_name => mld_c_smoothers_bld - - Implicit None - - ! Arguments - type(psb_cspmat_type),intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_cprec_type),intent(inout),target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local Variables - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, nplevs, mxplevs - real(psb_spk_) :: mnaggratio - integer(psb_ipk_) :: coarse_solve_id - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_c_smoothers_bld' - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' - ! - if (.not.allocated(prec%precv)) then - !! Error: should have called mld_cprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - ! - ! Check to ensure all procs have the same - ! - iszv = size(prec%precv) - call psb_bcast(ictxt,iszv) - if (iszv /= size(prec%precv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of precv') - goto 9999 - end if - - if (iszv < 1) then - ! We should never get here. - info=psb_err_from_subroutine_ - ch_err='size bpv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - endif - - ! - ! Issue a warning for inconsistent changes to COARSE_SOLVE - ! but only if it really is a multilevel - ! - if ((me == psb_root_).and.(iszv>1)) then - coarse_solve_id = prec%precv(iszv)%parms%coarse_solve - select case (coarse_solve_id) - case(mld_umf_,mld_slu_) - if (prec%precv(iszv)%sm%sv%get_id() /= coarse_solve_id) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id) - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) then - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else if (prec%precv(iszv)%parms%coarse_mat == mld_distr_mat_) then - write(psb_err_unit,*) ' but I am building BJAC with ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - end if - write(psb_err_unit,*) 'This may happen if: ' - write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' - write(psb_err_unit,*) ' 2. the solver ', mld_fact_names(coarse_solve_id),& - & ' was not configured at MLD2P4 build time, or' - write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' - end if - if (prec%precv(iszv)%parms%coarse_mat /= mld_repl_mat_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse matrix was requested as replicated', & - & ' but it has been changed to distributed.' - end if - - case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) - if (prec%precv(iszv)%sm%sv%get_id() /= psb_ilu_n_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id) - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) then - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else if (prec%precv(iszv)%parms%coarse_mat == mld_distr_mat_) then - write(psb_err_unit,*) ' but I am building BJAC with ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - end if - write(psb_err_unit,*) & - &'This may happen if coarse_subsolve has been reset' - end if - if (prec%precv(iszv)%parms%coarse_mat /= mld_repl_mat_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id),& - & ' but the coarse matrix has been changed to distributed' - end if - - case(mld_mumps_) - if (prec%precv(iszv)%sm%sv%get_id() /= mld_mumps_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id) - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) then - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else if (prec%precv(iszv)%parms%coarse_mat == mld_distr_mat_) then - write(psb_err_unit,*) ' but I am building BJAC with ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - end if - write(psb_err_unit,*) 'This may happen if: ' - write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' - write(psb_err_unit,*) ' 2. the solver ', mld_fact_names(coarse_solve_id),& - & ' was not configured at MLD2P4 build time, or' - write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' - end if - - case(mld_sludist_) - if (prec%precv(iszv)%sm%sv%get_id() /= coarse_solve_id) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id) - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) then - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else if (prec%precv(iszv)%parms%coarse_mat == mld_distr_mat_) then - write(psb_err_unit,*) ' but I am building BJAC with ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - end if - write(psb_err_unit,*) 'This may happen if: ' - write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' - write(psb_err_unit,*) ' 2. the solver ', mld_fact_names(coarse_solve_id), & - & ' was not configured at MLD2P4 build time, or' - write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' - end if - if (prec%precv(iszv)%parms%coarse_mat /= mld_distr_mat_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id),& - & ' but the coarse matrix has been changed to replicated' - end if - - case(mld_bjac_,mld_l1_bjac_,mld_jac_, mld_l1_jac_, mld_gs_, mld_fbgs_, mld_l1_gs_,mld_l1_fbgs_) - if (prec%precv(iszv)%parms%coarse_mat /= mld_distr_mat_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id),& - & ' but the coarse matrix has been changed to replicated' - end if - - case default - ! We should never get here. - info=psb_err_from_subroutine_ - ch_err='unkn coarse_solve' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - - end select - end if - - ! Sanity check: need to ensure that the MUMPS local/global NZ - ! are handled correctly; this is controlled by local vs global solver. - ! From this point of view, REPL is LOCAL because it owns everyting. - ! Should really find a better way of handling this. - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) & - & call prec%precv(iszv)%sm%sv%set('MUMPS_LOC_GLOB', mld_local_solver_,info) - ! - ! Now do the real build. - ! - - do i=1, iszv - ! - ! build the base preconditioner at level i - ! - call prec%precv(i)%bld(info,amold=amold,vmold=vmold,imold=imold,ilv=i) - - if (info /= psb_success_) then - write(ch_err,'(a,i7)') 'Error @ level',i - call psb_errpush(psb_err_internal_error_,name,& - & a_err=ch_err) - goto 9999 - endif - - end do - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Exiting with',iszv,' levels' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_smoothers_bld diff --git a/mlprec/impl/mld_ccprecset.F90 b/mlprec/impl/mld_ccprecset.F90 deleted file mode 100644 index 11b28915..00000000 --- a/mlprec/impl/mld_ccprecset.F90 +++ /dev/null @@ -1,971 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_cprecset.f90 -! -! Subroutine: mld_cprecseti -! Version: complex -! -! This routine sets the integer parameters defining the preconditioner. More -! precisely, the integer parameter identified by 'what' is assigned the value -! contained in 'val'. -! For the multilevel preconditioners, the levels are numbered in increasing -! order starting from the finest one, i.e. level 1 is the finest level. -! -! To set character and complex parameters, see mld_cprecsetc and mld_cprecsetr, -! respectively. -! -! -! Arguments: -! p - type(mld_cprec_type), input/output. -! The preconditioner data structure. -! what - integer, input. -! The number identifying the parameter to be set. -! A mnemonic constant has been associated to each of these -! numbers, as reported in the MLD2P4 User's and Reference Guide. -! val - integer, input. -! The value of the parameter to be set. The list of allowed -! values is reported in the MLD2P4 User's and Reference Guide. -! info - integer, output. -! Error code. -! ilev - integer, optional, input. -! For the multilevel preconditioner, the level at which the -! preconditioner parameter has to be set. -! If nlev is not present, the parameter identified by 'what' -! is set at all the appropriate levels. -! -! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to -! MLD2P4 developers. Indeed, by using ilev it is possible to set different values -! of the same parameter at different levels 1,...,nlev-1, even in cases where -! the parameter must have the same value at all the levels but the coarsest one. -! For this reason, the interface mld_precset to this routine has been built in -! such a way that ilev is not visible to the user (see mld_prec_mod.f90). -! -subroutine mld_ccprecseti(p,what,val,info,ilev,ilmax,pos,idx) - - use psb_base_mod - use mld_c_prec_mod, mld_protect_name => mld_ccprecseti - use mld_c_jac_smoother - use mld_c_as_smoother - use mld_c_diag_solver - use mld_c_l1_diag_solver - use mld_c_ilu_solver - use mld_c_id_solver - use mld_c_gs_solver -#if defined(HAVE_SLU_) - use mld_c_slu_solver -#endif -#if defined(HAVE_MUMPS_) - use mld_c_mumps_solver -#endif - - - implicit none - - ! Arguments - class(mld_cprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_, ilmax_, il - character(len=*), parameter :: name='mld_precseti' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmax_ = nlev_ - end if - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - select case(psb_toupper(what)) - case ('MIN_COARSE_SIZE') - p%ag_data%min_coarse_size = max(val,-1) - return - case('MAX_LEVS') - p%ag_data%max_levs = max(val,1) - return - case ('OUTER_SWEEPS') - p%outer_sweeps = max(val,1) - return - end select - - ! - ! Set preconditioner parameters at level ilev. - ! - if (present(ilev)) then - - select case(psb_toupper(what)) - case('SMOOTHER_TYPE','SUB_SOLVE','SMOOTHER_SWEEPS',& - & 'ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD',& - & 'AGGR_TYPE','AGGR_PROL','AGGR_OMEGA_ALG',& - & 'AGGR_EIG','SUB_RESTR','SUB_PROL', & - & 'SUB_OVR','SUB_FILLIN',& - & 'COARSE_MAT') - do il=ilev_, ilmax_ - call p%precv(il)%set(what,val,info,pos=pos) - end do - - case('COARSE_SUBSOLVE') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - call p%precv(ilev_)%set('SUB_SOLVE',val,info,pos=pos) - case('COARSE_SOLVE') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_SOLVE',val,info,pos=pos) - select case (val) - case(mld_bjac_,mld_l1_bjac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',val,info,pos=pos) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) -#else - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) -#endif - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info) - case(mld_slu_) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) - case(mld_mumps_) -#if defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(mld_umf_) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - - case(mld_sludist_) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(mld_jac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_diag_scale_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - - case(mld_l1_jac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_l1_diag_scale_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_gs_,mld_fbgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_gs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_bwgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_bwgs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_l1_gs_,mld_l1_fbgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_l1_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_gs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - end select - - endif - case('COARSE_SWEEPS') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - call p%precv(nlev_)%set('SMOOTHER_SWEEPS',val,info,pos=pos) - - case('COARSE_FILLIN') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - call p%precv(nlev_)%set('SUB_FILLIN',val,info,pos=pos) - - case default - do il=ilev_, ilmax_ - call p%precv(il)%set(what,val,info,pos=pos,idx=idx) - end do - end select - - - else if (.not.present(ilev)) then - ! - ! ilev not specified: set preconditioner parameters at all the appropriate - ! levels - ! - select case(psb_toupper(trim(what))) - case('SUB_SOLVE','SUB_RESTR','SUB_PROL',& - & 'SUB_OVR','SUB_FILLIN',& - & 'SMOOTHER_SWEEPS','SMOOTHER_TYPE') - do ilev_=1,max(1,nlev_-1) - call p%precv(ilev_)%set(what,val,info,pos=pos) - if (info /= 0) return - end do - - case('ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD','AGGR_PROL','AGGR_TYPE',& - & 'AGGR_OMEGA_ALG','AGGR_EIG','AGGR_FILTER') - do ilev_=1,nlev_ - call p%precv(ilev_)%set(what,val,info,pos=pos) - if (info /= 0) return - end do - - case('COARSE_MAT') - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_MAT',val,info,pos=pos) - end if - - case('COARSE_SOLVE') - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_SOLVE',val,info,pos=pos) - select case (val) - case(mld_bjac_,mld_l1_bjac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',val,info,pos=pos) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) -#else - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) -#endif - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info) - case(mld_slu_) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) - case(mld_mumps_) -#if defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(mld_umf_) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - - case(mld_sludist_) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(mld_jac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_diag_scale_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - - case(mld_l1_jac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_l1_diag_scale_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_gs_,mld_fbgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_gs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_bwgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_bwgs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_l1_gs_,mld_l1_fbgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_l1_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_gs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - end select - endif - - case('COARSE_SUBSOLVE') - if (nlev_ > 1) then - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - endif - - case('COARSE_SWEEPS') - - if (nlev_ > 1) then - call p%precv(nlev_)%set('SMOOTHER_SWEEPS',val,info,pos=pos) - end if - - case('COARSE_FILLIN') - if (nlev_ > 1) then - call p%precv(nlev_)%set('SUB_FILLIN',val,info,pos=pos) - end if - - case default - do ilev_=1,nlev_ - call p%precv(ilev_)%set(what,val,info,pos=pos,idx=idx) - end do - end select - - endif - -end subroutine mld_ccprecseti - -! -! Subroutine: mld_cprecsetc -! Version: complex -! -! This routine sets the character parameters defining the preconditioner. More -! precisely, the character parameter identified by 'what' is assigned the value -! contained in 'val'. -! For the multilevel preconditioners, the levels are numbered in increasing -! order starting from the finest one, i.e. level 1 is the finest level. -! -! To set integer and complex parameters, see mld_cprecseti and mld_cprecsetr, -! respectively. -! -! -! Arguments: -! p - type(mld_cprec_type), input/output. -! The preconditioner data structure. -! what - integer, input. -! The number identifying the parameter to be set. -! A mnemonic constant has been associated to each of these -! numbers, as reported in the MLD2P4 User's and Reference Guide. -! string - character(len=*), input. -! The value of the parameter to be set. The list of allowed -! values is reported in the MLD2P4 User's and Reference Guide. -! info - integer, output. -! Error code. -! ilev - integer, optional, input. -! For the multilevel preconditioner, the level at which the -! preconditioner parameter has to be set. -! If nlev is not present, the parameter identified by 'what' -! is set at all the appropriate levels. -! -! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to -! MLD2P4 developers. Indeed, by using ilev it is possible to set different values -! of the same parameter at different levels 1,...,nlev-1, even in cases where -! the parameter must have the same value at all the levels but the coarsest one. -! For this reason, the interface mld_precset to this routine has been built in -! such a way that ilev is not visible to the user (see mld_prec_mod.f90). -! -subroutine mld_ccprecsetc(p,what,string,info,ilev,ilmax,pos,idx) - - use psb_base_mod - use mld_c_prec_mod, mld_protect_name => mld_ccprecsetc - use mld_c_jac_smoother - use mld_c_as_smoother - use mld_c_diag_solver - use mld_c_l1_diag_solver - use mld_c_ilu_solver - use mld_c_id_solver - use mld_c_gs_solver -#if defined(HAVE_SLU_) - use mld_c_slu_solver -#endif -#if defined(HAVE_MUMPS_) - use mld_c_mumps_solver -#endif - - - implicit none - - ! Arguments - class(mld_cprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - character(len=*), intent(in) :: string - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_,val,ilmax_, il - character(len=*), parameter :: name='mld_precsetc' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmax_ = nlev_ - end if - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - ! - ! Set preconditioner parameters at level ilev. - ! - if (present(ilev)) then - - select case(psb_toupper(what)) - case('SMOOTHER_TYPE','SUB_SOLVE',& - & 'ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD',& - & 'AGGR_TYPE','AGGR_PROL','AGGR_OMEGA_ALG',& - & 'AGGR_EIG','SUB_RESTR','SUB_PROL', & - & 'COARSE_MAT') - do il=ilev_, ilmax_ - call p%precv(il)%set(what,string,info,pos=pos) - end do - - case('COARSE_SUBSOLVE') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - call p%precv(ilev_)%set('SUB_SOLVE',string,info,pos=pos) - case('COARSE_SOLVE') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_SOLVE',string,info,pos=pos) - select case (psb_toupper(trim(string))) - case('BJAC', 'L1-BJAC') - call p%precv(nlev_)%set('SMOOTHER_TYPE',psb_toupper(trim(string)),info,pos=pos) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) -#else - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) -#endif - call p%precv(nlev_)%set('COARSE_MAT','dist',info) - case('SLU') -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('ILU','MILU','ILUT') - call p%precv(nlev_)%set('SMOOTHER_TYPE','bjac',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) - case('MUMPS') -#if defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('UMF') -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - - case('SLUDIST') -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('JAC','JACOBI') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','DIAG',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - - case('L1-JACOBI') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','L1-DIAG',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('GS','FWGS','FBGS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('BWGS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','BWGS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('L1-GS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','L1-BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - end select - - endif - - case default - do il=ilev_, ilmax_ - call p%precv(il)%set(what,string,info,pos=pos,idx=idx) - end do - end select - - - else if (.not.present(ilev)) then - ! - ! ilev not specified: set preconditioner parameters at all the appropriate - ! levels - ! - select case(psb_toupper(trim(what))) - case('SUB_SOLVE','SUB_RESTR','SUB_PROL',& - & 'SMOOTHER_TYPE') - do ilev_=1,max(1,nlev_-1) - call p%precv(ilev_)%set(what,string,info,pos=pos) - if (info /= 0) return - end do - - case('ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD','AGGR_PROL','AGGR_TYPE',& - & 'AGGR_OMEGA_ALG','AGGR_EIG','AGGR_FILTER') - do ilev_=1,nlev_ - call p%precv(ilev_)%set(what,string,info,pos=pos) - if (info /= 0) return - end do - - case('COARSE_MAT') - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_MAT',string,info,pos=pos) - end if - - case('COARSE_SOLVE') - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_SOLVE',string,info,pos=pos) - select case (psb_toupper(trim(string))) - case('BJAC', 'L1-BJAC') - call p%precv(nlev_)%set('SMOOTHER_TYPE',psb_toupper(trim(string)),info,pos=pos) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) -#else - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) -#endif - call p%precv(nlev_)%set('COARSE_MAT','DIST',info) - case('SLU') -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('ILU', 'ILUT','MILU') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) - case('MUMPS') -#if defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('UMF') -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - - case('SLUDIST') -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('JAC','JACOBI') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','DIAG',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('L1-JACOBI') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','L1-DIAG',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('GS','FWGS','FBGS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('BWGS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','BWGS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('L1-GS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','L1-BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - end select - endif - - case('COARSE_SUBSOLVE') - if (nlev_ > 1) then - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - endif - - case default - do ilev_=1,nlev_ - call p%precv(ilev_)%set(what,string,info,pos=pos,idx=idx) - end do - end select - - endif - - -end subroutine mld_ccprecsetc - - -! -! Subroutine: mld_cprecsetr -! Version: complex -! -! This routine sets the complex parameters defining the preconditioner. More -! precisely, the complex parameter identified by 'what' is assigned the value -! contained in 'val'. -! For the multilevel preconditioners, the levels are numbered in increasing -! order starting from the finest one, i.e. level 1 is the finest level. -! -! To set integer and character parameters, see mld_cprecseti and mld_cprecsetc, -! respectively. -! -! Arguments: -! p - type(mld_cprec_type), input/output. -! The preconditioner data structure. -! what - integer, input. -! The number identifying the parameter to be set. -! A mnemonic constant has been associated to each of these -! numbers, as reported in the MLD2P4 User's and Reference Guide. -! val - real(psb_spk_), input. -! The value of the parameter to be set. The list of allowed -! values is reported in the MLD2P4 User's and Reference Guide. -! info - integer, output. -! Error code. -! ilev - integer, optional, input. -! For the multilevel preconditioner, the level at which the -! preconditioner parameter has to be set. -! If nlev is not present, the parameter identified by 'what' -! is set at all the appropriate levels. -! -! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to -! MLD2P4 developers. Indeed, by using ilev it is possible to set different values -! of the same parameter at different levels 1,...,nlev-1, even in cases where -! the parameter must have the same value at all the levels but the coarsest one. -! For this reason, the interface mld_precset to this routine has been built in -! such a way that ilev is not visible to the user (see mld_prec_mod.f90). -! -subroutine mld_ccprecsetr(p,what,val,info,ilev,ilmax,pos,idx) - - use psb_base_mod - use mld_c_prec_mod, mld_protect_name => mld_ccprecsetr - - implicit none - - ! Arguments - class(mld_cprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - - ! Local variables - integer(psb_ipk_) :: ilev_,nlev_, ilmax_, il - real(psb_spk_) :: thr - character(len=*), parameter :: name='mld_precsetr' - - info = psb_success_ - - if (present(ilev)) then - ilev_ = ilev - else - ilev_ = 1 - end if - - select case(psb_toupper(what)) - case ('MIN_CR_RATIO') - p%ag_data%min_cr_ratio = max(sone,val) - return - end select - - if (.not.allocated(p%precv)) then - write(psb_err_unit,*) name,& - &': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - info = 3111 - return - endif - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmax_ = nlev_ - end if - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - - ! - ! Set preconditioner parameters at level ilev. - ! - if (present(ilev)) then - - do il=ilev_, ilmax_ - call p%precv(il)%set(what,val,info,pos=pos,idx=idx) - end do - - else if (.not.present(ilev)) then - ! - ! ilev not specified: set preconditioner parameters at all the appropriate levels - ! - - select case(psb_toupper(what)) - case('COARSE_ILUTHRS') - ilev_=nlev_ - call p%precv(ilev_)%set('SUB_ILUTHRS',val,info,pos=pos) - - case default - - do il=1,nlev_ - call p%precv(il)%set(what,val,info,pos=pos,idx=idx) - end do - end select - - endif - -end subroutine mld_ccprecsetr - - diff --git a/mlprec/impl/mld_cfile_prec_descr.f90 b/mlprec/impl/mld_cfile_prec_descr.f90 deleted file mode 100644 index 499421d0..00000000 --- a/mlprec/impl/mld_cfile_prec_descr.f90 +++ /dev/null @@ -1,199 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_dfile_prec_descr.f90 -! -! -! Subroutine: mld_file_prec_descr -! Version: complex -! -! This routine prints a description of the preconditioner to the standard -! output or to a file. It must be called after the preconditioner has been -! built by mld_precbld. -! -! Arguments: -! p - type(mld_Tprec_type), input. -! The preconditioner data structure to be printed out. -! info - integer, output. -! error code. -! iout - integer, input, optional. -! The id of the file where the preconditioner description -! will be printed. If iout is not present, then the standard -! output is condidered. -! root - integer, input, optional. -! The id of the process printing the message; -1 acts as a wildcard. -! Default is psb_root_ -! -subroutine mld_cfile_prec_descr(prec,iout,root) - use psb_base_mod - use mld_c_prec_mod, mld_protect_name => mld_cfile_prec_descr - use mld_c_inner_mod - use mld_c_gs_solver - - implicit none - ! Arguments - class(mld_cprec_type), intent(in) :: prec - integer(psb_ipk_), intent(in), optional :: iout - integer(psb_ipk_), intent(in), optional :: root - - ! Local variables - integer(psb_ipk_) :: ilev, nlev, ilmin, info, nswps - integer(psb_ipk_) :: ictxt, me, np - logical :: is_symgs - character(len=20), parameter :: name='mld_file_prec_descr' - integer(psb_ipk_) :: iout_ - integer(psb_ipk_) :: root_ - - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - end if - if (iout_ < 0) iout_ = psb_out_unit - - ictxt = prec%ictxt - - if (allocated(prec%precv)) then - - call psb_info(ictxt,me,np) - if (present(root)) then - root_ = root - else - root_ = psb_root_ - end if - if (root_ == -1) root_ = me - - ! - ! The preconditioner description is printed by processor psb_root_. - ! This agrees with the fact that all the parameters defining the - ! preconditioner have the same values on all the procs (this is - ! ensured by mld_precbld). - ! - if (me == root_) then - nlev = size(prec%precv) - do ilev = 1, nlev - if (.not.allocated(prec%precv(ilev)%sm)) then - info = 3111 - write(iout_,*) ' ',name,& - & ': error: inconsistent MLPREC part, should call MLD_PRECINIT' - return - endif - end do - - write(iout_,*) - write(iout_,'(a)') 'Preconditioner description' - - if (nlev == 1) then - ! - ! Here we have a gigantic kludge just to handle Symmetrized Gauss-Seidel. - ! Will need rethinking... - ! - if (allocated(prec%precv(1)%sm2a)) then - is_symgs = .false. - select type(sv2 => prec%precv(1)%sm2a%sv) - class is (mld_c_bwgs_solver_type) - select type(sv1 => prec%precv(1)%sm%sv) - class is (mld_c_gs_solver_type) - is_symgs = .true. - end select - end select - if (is_symgs) then - write(iout_,*) ' Forward-Backward (symmetrized) Hybrid Gauss-Seidel' - else - write(iout_,*) 'Pre Smoother: ' - call prec%precv(1)%sm%descr(info,iout=iout_) - write(iout_,*) 'Post smoother:' - call prec%precv(1)%sm2a%descr(info,iout=iout_) - end if - nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) - - else - call prec%precv(1)%sm%descr(info,iout=iout_) - nswps = prec%precv(1)%parms%sweeps_pre - end if - if (nswps > 1) write(iout_,*) ' Number of sweeps : ',nswps - write(iout_,*) - - else if (nlev > 1) then - ! - ! Print description of base preconditioner - ! - write(iout_,*) 'Multilevel Preconditioner' - write(iout_,*) 'Outer sweeps:',prec%outer_sweeps - write(iout_,*) - if (allocated(prec%precv(1)%sm2a)) then - write(iout_,*) 'Pre Smoother: ' - call prec%precv(1)%sm%descr(info,iout=iout_) - write(iout_,*) 'Post smoother:' - call prec%precv(1)%sm2a%descr(info,iout=iout_) - else - write(iout_,*) 'Smoother: ' - call prec%precv(1)%sm%descr(info,iout=iout_) - end if - ! - ! Print multilevel details - ! - write(iout_,*) - write(iout_,*) 'Multilevel hierarchy: ' - write(iout_,*) ' Number of levels : ',nlev - write(iout_,*) ' Operator complexity: ',prec%get_complexity() - write(iout_,*) ' Average coarsening : ',prec%get_avg_cr() - ilmin = 2 - if (nlev == 2) ilmin=1 - do ilev=ilmin,nlev - call prec%precv(ilev)%descr(ilev,nlev,ilmin,info,iout=iout_) - end do - write(iout_,*) - - else - write(iout_,*) trim(name), & - & ': invalid preconditioner array size ?',nlev - info = -2 - return - - end if - end if - - else - write(iout_,*) trim(name), & - & ': Error: no base preconditioner available, something is wrong!' - info = -2 - return - endif - -end subroutine mld_cfile_prec_descr diff --git a/mlprec/impl/mld_cmlprec_aply.f90 b/mlprec/impl/mld_cmlprec_aply.f90 deleted file mode 100644 index 652b5437..00000000 --- a/mlprec/impl/mld_cmlprec_aply.f90 +++ /dev/null @@ -1,1669 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_cmlprec_aply.f90 -! -! Subroutine: mld_cmlprec_aply -! Version: real -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -! This routine computes -! -! Y = beta*Y + alpha*op(ML^(-1))*X, -! where -! - ML is a multilevel preconditioner associated with -! a certain matrix A and stored in p, -! - op(ML^(-1)) is ML^(-1) or its transpose, according to the value of trans, -! - X and Y are vectors, -! - alpha and beta are scalars. -! -! The following multilevel strategies can be applied: -! -! - Additive multilevel Schwarz, -! - classical V-cycle, -! - classical W-cycle, -! - K-cycle both for symmetric and nonsymmetric matrices, where 2 iterations -! of FCG(1) or GCR, respectively, are applied at each level -! except the coarsest. -! -! For each level we have as many submatrices as processes (except for the coarsest -! level where we might have a replicated index space) and each process takes care -! of one submatrix. -! -! A multilevel preconditioner is regarded as an array of 'one-level' data structures, -! each containing the part of the preconditioner associated to a certain level -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! For each level lev, there is a smoother stored in -! p%precv(lev)%sm -! which in turn contains a solver -! p$precv(lev)%sm%sv -! Typically the solver acts only locally, and the smoother applies any required -! parallel communication/action. -! Each level has a matrix A(lev), obtained by 'tranferring' the original -! matrix A (i.e. the matrix to be preconditioned) to the level lev, through smoothed -! aggregation. -! -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level and A(1) is the matrix A. -! -! This routine is formulated in a recursive way, so it is quite compact. -! -! The V-cycle can be described as follows, where -! P(lev) denotes the smoothed prolongator from level lev to level -! lev-1, while R(lev) denotes the corresponding restriction operator -! (normally its transpose) from level lev-1 to level lev. -! M(lev) is the smoother at the current level. -! -! -! 1. Transfer the outer vector Xest to u(1) (inner X at level 1) -! -! 2. Invoke V-cycle(1,M,P,R,A,b,u) -! -! procedure V-cycle(lev,M,P,R,A,b,u) -! -! if (lev < nlev) then -! -! u(lev) = u(lev) + M(lev)*(b(lev)-A(lev)*u(lev)) -! -! b(lev+1) = R(lev+1)*(b(lev)-A(lev)*u(lev)) -! -! u(lev+1) = V-cycle(lev+1,M,P,R,A,b,u) -! -! u(lev) = u(lev) + P(lev+1) * u(lev+1) -! -! u(lev) = u(lev) + M(lev)*(b(lev)-A(lev)*u(lev)) -! -! else -! -! solve A(lev)*u(lev) = b(lev) -! -! end if -! -! return u(lev) -! end -! -! 3. Transfer u(1) to the external: -! Yext = beta*Yext + alpha*u(1) -! -! -! In the implementation, the recursive procedure is inner_ml_aply, which -! in turn uses mld_inner_add (for additive multilevel), -! mld_inner_mult (for V-cycle and W-cycle), and -! mld_inner_k_cycle (for symmetric and non-symmetric K-cycle). -! -! For a detailed description of the algorithms, see: -! -! - B.F. Smith, P.E. Bjorstad, W.D. Gropp, -! Domain decomposition: parallel multilevel methods for elliptic partial -! differential equations, Cambridge University Press, 1996. -! -! - W. L. Briggs, V. E. Henson, S. F. McCormick, -! A Multigrid Tutorial, Second Edition -! SIAM, 2000. -! -! - K. Stuben, -! An Introduction to Algebraic Multigrid, -! in A. Schuller, U. Trottenberg, C. Oosterlee, Multigrid, Academic Press, 2001. -! -! - Y. Notay, P. S. Vassilevski, -! Recursive Krylov-based multigrid cycles -! Numerical Linear Algebra with Applications, 15 (5), 2008, 473--487. -! -! -! Arguments: -! alpha - complex(psb_spk_), input. -! The scalar alpha. -! p - type(mld_cprec_type), input. -! The multilevel preconditioner data structure containing the -! local part of the preconditioner to be applied. -! Note that nlev = size(p%precv) = number of levels. -! p%precv(lev)%sm - type(psb_cbaseprec_type) -! The pre-'smoother' for the current level -! p%precv(lev)%sm2 - type(psb_cbaseprec_type) -! The post-'smoother' for the current level -! may be the same or different from %sm -! p%precv(lev)%ac - type(psb_cspmat_type) -! The local part of the matrix A(lev). -! p%precv(lev)%parms - type(psb_sml_parms) -! Parameters controllin the multilevel prec. -! p%precv(lev)%desc_ac - type(psb_desc_type). -! The communication descriptor associated to the sparse -! matrix A(lev) -! p%precv(lev)%map - type(psb_inter_desc_type) -! Stores the linear operators mapping level (lev-1) -! to (lev) and vice versa. These are the restriction -! and prolongation operators described in the sequel. -! p%precv(lev)%base_a - type(psb_cspmat_type), pointer. -! Pointer (really a pointer!) to the base matrix of -! the current level, i.e. the local part of A(lev); -! so we have a unified treatment of residuals. We -! need this to avoid passing explicitly the matrix -! A(lev) to the routine which applies the -! preconditioner. -! p%precv(lev)%base_desc - type(psb_desc_type), pointer. -! Pointer to the communication descriptor associated -! to the sparse matrix pointed by base_a. -! -! x - complex(psb_spk_), dimension(:), input. -! The local part of the vector X. -! beta - complex(psb_spk_), input. -! The scalar beta. -! y - complex(psb_spk_), dimension(:), input/output. -! The local part of the vector Y. -! desc_data - type(psb_desc_type), input. -! The communication descriptor associated to the matrix to be -! preconditioned. -! trans - character, optional. -! If trans='N','n' then op(M^(-1)) = M^(-1); -! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). -! work - complex(psb_spk_), dimension (:), optional, target. -! Workspace. Its size must be at least 4*desc_data%get_local_cols(). -! info - integer, output. -! Error code. -! -! Note that when the LU factorization of the matrix A(lev) is computed instead of -! the ILU one, by using UMFPACK or SuperLU or MUMPS, the corresponding -! L and U factors are stored in data structures handled -! by the third party software. -! -subroutine mld_cmlprec_aply_vect(alpha,p,x,beta,y,desc_data,trans,work,info) - - use psb_base_mod - use mld_base_prec_type - use mld_c_inner_mod, mld_protect_name => mld_cmlprec_aply_vect - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_cprec_type), intent(inout) :: p - complex(psb_spk_),intent(in) :: alpha,beta - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - character, intent(in) :: trans - complex(psb_spk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: ictxt, np, me - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, nc2l, level, isweep, err_act - character(len=20) :: name - character :: trans_ - complex(psb_spk_) :: beta_ - logical :: do_alloc_wrk - type(mld_cmlprec_wrk_type), allocatable, target :: mlprec_wrk(:) - - name='mld_cmlprec_aply' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (debug_level >= psb_debug_inner_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(p%precv) - - trans_ = psb_toupper(trans) - nlev = size(p%precv) - - do_alloc_wrk = .not.allocated(p%precv(1)%wrk) - - if (do_alloc_wrk) call p%allocate_wrk(info,vmold=x%v) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') - goto 9999 - end if - level = 1 - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & wv => p%precv(level)%wrk%wv(:)) - ! - ! At first iteration we must use the input BETA - ! - beta_ = beta - - - call psb_geaxpby(cone,x,czero,vx2l,base_desc,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='geaxbpy') - goto 9999 - end if - - do isweep = 1, p%outer_sweeps - 1 - ! - ! With the current implementation, y2l is zeroed internally at first smoother. - ! call p%wrk(level)%vy2l%zero() - ! - call inner_ml_aply(level,p,trans_,work,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Inner prec aply') - goto 9999 - end if - call psb_geaxpby(alpha,vy2l,beta_,y,base_desc,info) - ! all iterations after the first must use BETA = 1 - beta_ = cone - ! - ! Next iteration should use the current residual to compute a correction - ! - call psb_geaxpby(cone,x,czero,vx2l,base_desc,info) - call psb_spmm(-cone,base_a,y,cone,vx2l,base_desc,info) - end do - - ! - ! If outer_sweeps == 1 we have just skipped the loop, and it's - ! equivalent to a single application. - ! - - ! - ! With the current implementation, y2l is zeroed internally at first smoother. - ! call p%wrk(level)%vy2l%zero() - ! - call inner_ml_aply(level,p,trans_,work,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Inner prec aply') - goto 9999 - end if - call psb_geaxpby(alpha,vy2l,beta_,y,base_desc,info) - - end associate - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error final update') - goto 9999 - end if - if (do_alloc_wrk) call p%free_wrk(info) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - ! - ! - ! inner_ml_aply: apply AMG at a given level. - ! This routine dispatches the computation according to the type - ! specified at the current level. - ! Each of the corrections will inturn call recursively this routine. - ! - ! Assumptions: - ! On input: - ! mlprec_wkr(level)%vx2l contains the input vector (RHS) - ! mlprec_wkr(level)%vy2l contains the initial guess - ! - ! On output: - ! mlprec_wkr(level)%vy2l contains the solution - ! - ! Constraints: each of the called routines must properly handle - ! the input/output conditions for level+1 (i.e. apply - ! prolongation/restriction). - ! Note: for historical/convenience reasons the prolongator/restrictor - ! between level and level+1 are stored at level+1. - ! - ! - recursive subroutine inner_ml_aply(level,p,trans,work,info) - - implicit none - - ! Arguments - integer(psb_ipk_) :: level - type(mld_cprec_type), target, intent(inout) :: p - character, intent(in) :: trans - complex(psb_spk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - - type(psb_c_vect_type) :: res - type(psb_c_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_ml_aply' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_ml') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' Start inner_ml_aply at level ',level, info - end if - - select case(p%precv(level)%parms%ml_cycle) - - case(mld_no_ml_) - ! - ! No preconditioning, should not really get here - ! - call psb_errpush(psb_err_internal_error_,name,& - & a_err='mld_no_ml_ in mlprc_aply?') - goto 9999 - - case(mld_add_ml_) - - call mld_c_inner_add(p, level, trans, work) - - case(mld_mult_ml_,mld_vcycle_ml_, mld_wcycle_ml_) - - call mld_c_inner_mult(p, level, trans, work) - - case(mld_kcycle_ml_, mld_kcyclesym_ml_) - - call mld_c_inner_k_cycle(p, level, trans, work) - - case default - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='invalid ml_cycle',& - & i_Err=(/p%precv(level)%parms%ml_cycle,izero,izero,izero,izero/)) - goto 9999 - - end select - if(debug_level > 1) then - write(debug_unit,*) me,' End inner_ml_aply at level ',level - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine inner_ml_aply - - - recursive subroutine mld_c_inner_add(p, level, trans, work) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_cprec_type), intent(inout) :: p - - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - complex(psb_spk_),target :: work(:) - type(psb_c_vect_type) :: res - type(psb_c_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act, k - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_inner_add' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_add') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_add at level ',level - end if - - if ((level<1).or.(level>nlev)) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL>NLEV') - goto 9999 - end if - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & wv => p%precv(level)%wrk%wv) - - if (allocated(p%precv(level)%sm2a)) then - call psb_geaxpby(cone,vx2l,czero,vy2l,base_desc,info) - - sweeps = max(p%precv(level)%parms%sweeps_pre,p%precv(level)%parms%sweeps_post) - do k=1, sweeps - call p%precv(level)%sm%apply(cone,& - & vy2l,czero,vty,& - & base_desc, trans,& - & ione,work,wv,info,init='Z') - - call p%precv(level)%sm2a%apply(cone,& - & vty,czero,vy2l,& - & base_desc, trans,& - & ione,work,wv,info,init='Z') - end do - - else - sweeps = p%precv(level)%parms%sweeps_pre - call p%precv(level)%sm%apply(cone,& - & vx2l,czero,vy2l,& - & base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during ADD smoother_apply') - goto 9999 - end if - - if (level < nlev) then - ! Apply the restriction - call p%precv(level+1)%map%map_U2V(cone,vx2l,& - & czero,p%precv(level+1)%wrk%vx2l,& - & info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - - call inner_ml_aply(level+1,p,trans,work,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in recursive call') - goto 9999 - end if - - ! - ! Apply the prolongator - ! - call p%precv(level+1)%map%map_V2U(cone,& - & p%precv(level+1)%wrk%vy2l, cone,vy2l,& - & info,work=work,& - & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - - end if - end associate - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_c_inner_add - - recursive subroutine mld_c_inner_mult(p, level, trans, work) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_cprec_type), intent(inout) :: p - - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - complex(psb_spk_),target :: work(:) - type(psb_c_vect_type) :: res - type(psb_c_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - name = 'inner_inner_mult' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_mult') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_mult at level ',level - end if - - sweeps_post = p%precv(level)%parms%sweeps_post - sweeps_pre = p%precv(level)%parms%sweeps_pre - pre = ((sweeps_pre>0).and.(trans=='N')).or.((sweeps_post>0).and.(trans/='N')) - post = ((sweeps_post>0).and.(trans=='N')).or.((sweeps_pre>0).and.(trans/='N')) - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & wv => p%precv(level)%wrk%wv) - if (level < nlev) then - ! - ! Apply the first smoother - ! The residual has been prepared before the recursive call. - ! - - if (pre) then - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(cone,& - & vx2l,czero,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(cone,& - & vx2l,czero,vy2l, base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during PRE smoother_apply') - goto 9999 - end if - endif - ! - ! Compute the residual for next level and call recursively - ! - if (pre) then - call psb_geaxpby(cone,vx2l,& - & czero,vty,& - & base_desc,info) - - if (info == psb_success_) call psb_spmm(-cone,base_a,& - & vy2l,cone,vty,& - & base_desc,info,work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - call p%precv(level+1)%map%map_U2V(cone,vty,& - & czero,p%precv(level+1)%wrk%vx2l,& - & info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - else - ! Shortcut: just transfer x2l. - call p%precv(level+1)%map%map_U2V(cone,vx2l,& - & czero,p%precv(level+1)%wrk%vx2l,& - & info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - endif - - call inner_ml_aply(level+1,p,trans,work,info) - - ! - ! Apply the prolongator - ! - call p%precv(level+1)%map%map_V2U(cone,& - & p%precv(level+1)%wrk%vy2l,cone,vy2l,& - & info,work=work,& - & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - if (p%precv(level)%parms%ml_cycle == mld_wcycle_ml_) then - - call psb_geaxpby(cone,vx2l, czero,vty,& - & base_desc,info) - if (info == psb_success_) call psb_spmm(-cone,base_a,& - & vy2l,cone,vty,& - & base_desc,info,work=work,trans=trans) - if (info == psb_success_) & - & call p%precv(level+1)%map%map_U2V(cone,vty,& - & czero,p%precv(level+1)%wrk%vx2l,info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during W-cycle restriction') - goto 9999 - end if - - call inner_ml_aply(level+1,p,trans,work,info) - - if (info == psb_success_) call p%precv(level+1)%map%map_V2U(cone, & - & p%precv(level+1)%wrk%vy2l,cone,vy2l,& - & info,work=work,& - & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during W recusion/prolongation') - goto 9999 - end if - - endif - - - if (post) then - call psb_geaxpby(cone,vx2l,& - & czero,vty,& - & base_desc,info) - if (info == psb_success_) call psb_spmm(-cone,base_a,& - & vy2l, cone,vty,base_desc,info,& - & work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - - ! - ! Apply the second smoother - ! - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(cone,& - & vty,cone,vy2l, base_desc, trans,& - & sweeps,work,wv,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(cone,& - & vty,cone,vy2l, base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during POST smoother_apply') - goto 9999 - end if - - endif - - else if (level == nlev) then - - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(cone,& - & vx2l,czero,vy2l,base_desc, trans,& - & sweeps,work,wv,info) - - else - - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL vs NLEV') - goto 9999 - end if - end associate - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_c_inner_mult - - recursive subroutine mld_c_inner_k_cycle(p, level, trans, work,u) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_cprec_type), intent(inout) :: p - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - complex(psb_spk_),target :: work(:) - type(psb_c_vect_type),intent(inout), optional :: u - - - - type(psb_c_vect_type) :: res - type(psb_c_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_kcycle' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_add') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,name,' start at level ',level - end if - - if ((level<1).or.(level>nlev)) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL>NLEV') - goto 9999 - end if - - !K cycle - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & wv => p%precv(level)%wrk%wv(8:)) - if (level == nlev) then - ! - ! Apply smoother - ! - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(cone,& - & vx2l,czero,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - - else if (level < nlev) then - - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(cone,& - & vx2l,czero,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(cone,& - & vx2l,czero,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during 2-PRE smoother_apply') - goto 9999 - end if - - - ! - ! Compute the residual and call recursively - ! - - call psb_geaxpby(cone,vx2l,& - & czero,vty,& - & base_desc,info) - - if (info == psb_success_) call psb_spmm(-cone,base_a,& - & vy2l,cone,vty,base_desc,info,work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - - ! Apply the restriction - call p%precv(level + 1)%map%map_U2V(cone,vty,& - & czero,p%precv(level + 1)%wrk%vx2l,& - &info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - - !Set the preconditioner - - if (level <= nlev - 2 ) then - if (p%precv(level)%parms%ml_cycle == mld_kcyclesym_ml_) then - call mld_cinneritkcycle(p, level + 1, trans, work, 'FCG') - elseif (p%precv(level)%parms%ml_cycle == mld_kcycle_ml_) then - call mld_cinneritkcycle(p, level + 1, trans, work, 'GCR') - else - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Bad value for ml_cycle') - goto 9999 - endif - else - call inner_ml_aply(level + 1 ,p,trans,work,info) - endif - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in recursive call') - goto 9999 - end if - - ! - ! Apply the prolongator - ! - call p%precv(level+1)%map%map_V2U(cone,& - & p%precv(level+1)%wrk%vy2l,cone,vy2l,& - & info,work=work,& - & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - ! - ! Compute the residual - ! - call psb_geaxpby(cone,vx2l,& - & czero,vty,base_desc,info) - call psb_spmm(-cone,base_a,vy2l,& - & cone,vty,base_desc,info,& - & work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - ! - ! Apply the smoother - ! - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(cone,& - & vty,cone,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(cone,& - & vty,cone,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during POST smoother_apply') - goto 9999 - end if - else - - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL vs NLEV') - goto 9999 - - endif - end associate - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_c_inner_k_cycle - - - recursive subroutine mld_cinneritkcycle(p, level, trans, work, innersolv) - use psb_base_mod - use mld_prec_mod - use mld_c_inner_mod, mld_protect_name => mld_cmlprec_aply - - implicit none - - !Input/Oputput variables - type(mld_cprec_type), intent(inout) :: p - - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - character(len=*), intent(in) :: innersolv - complex(psb_spk_),target :: work(:) - - !Other variables - type(psb_c_vect_type) :: v, w, rhs, v1, x - type(psb_c_vect_type) :: d0, d1 - complex(psb_spk_) :: delta_old, rhs_norm, alpha, tau, tau1, tau2, tau3, tau4, beta - - real(psb_spk_) :: l2_norm, delta, rtol=0.25, delta0, tnrm - complex(psb_spk_), allocatable :: temp_v(:) - integer(psb_ipk_) :: info, nlev, i, iter, max_iter=2, idx - character(len=20) :: name = 'innerit_k_cycle' - - - if (size(p%precv(level)%wrk%wv)<7) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size') - goto 9999 - end if - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & v => p%precv(level)%wrk%wv(1), & - & w => p%precv(level)%wrk%wv(2),& - & rhs => p%precv(level)%wrk%wv(3), & - & v1 => p%precv(level)%wrk%wv(4), & - & x => p%precv(level)%wrk%wv(5), & - & d0 => p%precv(level)%wrk%wv(6), & - & d1 => p%precv(level)%wrk%wv(7)) - - call x%zero() - - ! rhs=vx2l and w=rhs - call psb_geaxpby(cone,vx2l,czero,rhs, base_desc,info) - call psb_geaxpby(cone,vx2l,czero,w, base_desc,info) - - if (psb_errstatus_fatal()) then - nc2l = base_desc%get_local_cols() - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - - delta0 = psb_genrm2(w, base_desc, info) - - !Apply the preconditioner - call vy2l%zero() - - idx=0 - call inner_ml_aply(level,p,trans,work,info) - - call psb_geaxpby(cone,vy2l,czero,d0,base_desc,info) - - call psb_spmm(cone,base_a,d0,czero,v,base_desc,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - - !FCG - if (psb_toupper(trim(innersolv)) == 'FCG') then - delta_old = psb_gedot(d0, w, base_desc, info) - tau = psb_gedot(d0, v, base_desc, info) - !GCR - else if (psb_toupper(trim(innersolv)) == 'GCR') then - delta_old = psb_gedot(v, w, base_desc, info) - tau = psb_gedot(v, v, base_desc, info) - else - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid inner solver') - goto 9999 - endif - - alpha = delta_old/tau - !Update residual w - call psb_geaxpby(-alpha, v, cone, w, base_desc, info) - - l2_norm = psb_genrm2(w, base_desc, info) - iter = 0 - - if (l2_norm <= rtol*delta0) then - !Update solution x - call psb_geaxpby(alpha, d0, cone, x, base_desc, info) - else - iter = iter + 1 - idx=mod(iter,2) - - !Apply preconditioner - call psb_geaxpby(cone,w,czero,vx2l,base_desc,info) - call inner_ml_aply(level,p,trans,work,info) - call psb_geaxpby(cone,vy2l,czero,d1,base_desc,info) - - !Sparse matrix vector product - - call psb_spmm(cone,base_a,d1,czero,v1,base_desc,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - - !tau1, tau2, tau3, tau4 - if (psb_toupper(trim(innersolv)) == 'FCG') then - tau1= psb_gedot(d1, v, base_desc, info) - tau2= psb_gedot(d1, v1, base_desc, info) - tau3= psb_gedot(d1, w, base_desc, info) - tau4= tau2 - (tau1*tau1)/tau - else if (psb_toupper(trim(innersolv)) == 'GCR') then - tau1= psb_gedot(v1, v, base_desc, info) - tau2= psb_gedot(v1, v1, base_desc, info) - tau3= psb_gedot(v1, w, base_desc, info) - tau4= tau2 - (tau1*tau1)/tau - else - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid inner solver') - goto 9999 - endif - - !Update solution - alpha=alpha-(tau1*tau3)/(tau*tau4) - call psb_geaxpby(alpha,d0,cone,x,base_desc,info) - alpha=tau3/tau4 - call psb_geaxpby(alpha,d1,cone,x,base_desc,info) - endif - - call psb_geaxpby(cone,x,czero,vy2l,base_desc,info) - end associate - -9999 continue - call psb_erractionrestore(err_act) - if (err_act.eq.psb_act_abort_) then - call psb_error() - return - end if - return - end subroutine mld_cinneritkcycle - -end subroutine mld_cmlprec_aply_vect - - -! -! Old routine for arrays instead of psb_X_vector. To be deleted eventually. -! -! -subroutine mld_cmlprec_aply(alpha,p,x,beta,y,desc_data,trans,work,info) - - use psb_base_mod - use mld_base_prec_type - use mld_c_inner_mod, mld_protect_name => mld_cmlprec_aply - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_cprec_type), intent(inout) :: p - complex(psb_spk_),intent(in) :: alpha,beta - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - character, intent(in) :: trans - complex(psb_spk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: ictxt, np, me - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: debug_level, debug_unit, nlev,nc2l,nr2l,level - character(len=20) :: name - character :: trans_ - type mld_mlwrk_type - complex(psb_spk_), allocatable :: tx(:), ty(:), x2l(:), y2l(:) - end type mld_mlwrk_type - type(mld_mlwrk_type), allocatable, target :: mlwrk(:) - - name='mld_cmlprec_aply' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (debug_level >= psb_debug_inner_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(p%precv) - - trans_ = psb_toupper(trans) - - nlev = size(p%precv) - allocate(mlwrk(nlev),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') - goto 9999 - end if - level = 1 - - do level = 1, nlev - call psb_geasb(mlwrk(level)%x2l,& - & p%precv(level)%base_desc,info) - call psb_geasb(mlwrk(level)%y2l,& - & p%precv(level)%base_desc,info) - call psb_geasb(mlwrk(level)%tx,& - & p%precv(level)%base_desc,info) - call psb_geasb(mlwrk(level)%ty,& - & p%precv(level)%base_desc,info) - if (psb_errstatus_fatal()) then - nc2l = p%precv(level)%base_desc%get_local_cols() - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - end do - - mlwrk(level)%x2l(:) = x(:) - mlwrk(level)%y2l(:) = czero - - call inner_ml_aply(level,p,mlwrk,trans_,work,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Inner prec aply') - goto 9999 - end if - - call psb_geaxpby(alpha,mlwrk(level)%y2l,beta,y,& - & p%precv(level)%base_desc,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error final update') - goto 9999 - end if - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - - ! - ! - ! inner_ml_aply: apply AMG at a given level. - ! This routine dispatches the computation according to the type - ! specified at the current level. - ! Each of the corrections will inturn call recursively this routine. - ! - ! Assumptions: - ! On input: - ! mlprec_wkr(level)%vx2l contains the input vector (RHS) - ! mlprec_wkr(level)%vy2l contains the initial guess - ! - ! On output: - ! mlprec_wkr(level)%vy2l contains the solution - ! - ! Constraints: each of the called routines must properly handle - ! the input/output conditions for level+1 (i.e. apply - ! prolongation/restriction). - ! Note: for historical/convenience reasons the prolongator/restrictor - ! between level and level+1 are stored at level+1. - ! - ! - recursive subroutine inner_ml_aply(level,p,mlwrk,trans,work,info) - - implicit none - - ! Arguments - integer(psb_ipk_) :: level - type(mld_cprec_type), target, intent(inout) :: p - type(mld_mlwrk_type), intent(inout), target :: mlwrk(:) - character, intent(in) :: trans - complex(psb_spk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - - type(psb_c_vect_type) :: res - type(psb_c_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_ml_aply' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_ml') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_ml_aply at level ',level - end if - - select case(p%precv(level)%parms%ml_cycle) - - case(mld_no_ml_) - ! - ! No preconditioning, should not really get here - ! - call psb_errpush(psb_err_internal_error_,name,& - & a_err='mld_no_ml_ in mlprc_aply?') - goto 9999 - - case(mld_add_ml_) - - call mld_c_inner_add(p, mlwrk, level, trans, work) - - case(mld_mult_ml_, mld_vcycle_ml_, mld_wcycle_ml_) - - call mld_c_inner_mult(p, mlwrk, level, trans, work) - -! !$ case(mld_kcycle_ml_, mld_kcyclesym_ml_) -! !$ -! !$ call mld_c_inner_k_cycle(p, mlwrk, level, trans, work) - - case default - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='invalid ml_cycle',& - & i_Err=(/p%precv(level)%parms%ml_cycle,izero,izero,izero,izero/)) - goto 9999 - - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine inner_ml_aply - - - recursive subroutine mld_c_inner_add(p, mlwrk, level, trans, work) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_cprec_type), intent(inout) :: p - - type(mld_mlwrk_type), target, intent(inout) :: mlwrk(:) - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - complex(psb_spk_),target :: work(:) - type(psb_c_vect_type) :: res - type(psb_c_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_inner_add' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_add') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_add at level ',level - end if - - if ((level<1).or.(level>nlev)) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL>NLEV') - goto 9999 - end if - - sweeps = p%precv(level)%parms%sweeps_pre - call p%precv(level)%sm%apply(cone,& - & mlwrk(level)%x2l,czero,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during ADD smoother_apply') - goto 9999 - end if - - if (level < nlev) then - ! Apply the restriction - call p%precv(level+1)%map%map_U2V(cone,mlwrk(level)%x2l,& - & czero,mlwrk(level+1)%x2l,& - & info,work=work) - mlwrk(level+1)%y2l(:) = czero - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - - call inner_ml_aply(level+1,p,mlwrk,trans,work,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in recursive call') - goto 9999 - end if - - ! - ! Apply the prolongator and add correction. - ! - call p%precv(level+1)%map%map_V2U(cone,& - & mlwrk(level+1)%y2l,cone,mlwrk(level)%y2l,& - & info,work=work) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_c_inner_add - - recursive subroutine mld_c_inner_mult(p, mlwrk, level, trans, work) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_cprec_type), intent(inout) :: p - - type(mld_mlwrk_type), target, intent(inout) :: mlwrk(:) - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - complex(psb_spk_),target :: work(:) - type(psb_c_vect_type) :: res - type(psb_c_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_inner_mult' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_mult') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_mult at level ',level - end if - - if ((level < nlev).or.(nlev == 1)) then - sweeps_post = p%precv(level)%parms%sweeps_post - sweeps_pre = p%precv(level)%parms%sweeps_pre - else - sweeps_post = p%precv(level-1)%parms%sweeps_post - sweeps_pre = p%precv(level-1)%parms%sweeps_pre - endif - - pre = ((sweeps_pre>0).and.(trans=='N')).or.((sweeps_post>0).and.(trans/='N')) - post = ((sweeps_post>0).and.(trans=='N')).or.((sweeps_pre>0).and.(trans/='N')) - - - if (level < nlev) then - - ! - ! Apply the first smoother - ! - - if (pre) then - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(cone,& - & mlwrk(level)%x2l,czero,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info,init='Y') - else - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(cone,& - & mlwrk(level)%x2l,czero,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info,init='Y') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during PRE smoother_apply') - goto 9999 - end if - endif - - ! - ! Compute the residual and call recursively - ! - if (pre) then - call psb_geaxpby(cone,mlwrk(level)%x2l,& - & czero,mlwrk(level)%ty,& - & p%precv(level)%base_desc,info) - - if (info == psb_success_) call psb_spmm(-cone,p%precv(level)%base_a,& - & mlwrk(level)%y2l,cone,mlwrk(level)%ty,& - & p%precv(level)%base_desc,info,work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - call p%precv(level+1)%map%map_U2V(cone,mlwrk(level)%ty,& - & czero,mlwrk(level+1)%x2l,info,work=work) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - else - ! Shortcut: just transfer x2l. - call p%precv(level+1)%map%map_U2V(cone,mlwrk(level)%x2l,& - & czero,mlwrk(level+1)%x2l,info,work=work) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - endif - ! First guess is zero - mlwrk(level+1)%y2l(:) = czero - - - call inner_ml_aply(level+1,p,mlwrk,trans,work,info) - - if (p%precv(level)%parms%ml_cycle == mld_wcycle_ml_) then - ! On second call will use output y2l as initial guess - if (info == psb_success_) call inner_ml_aply(level+1,p,mlwrk,trans,work,info) - endif - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in recursive call') - goto 9999 - end if - - - ! - ! Apply the prolongator - ! - call p%precv(level+1)%map%map_V2U(cone,mlwrk(level+1)%y2l,& - & cone,mlwrk(level)%y2l,info,work=work) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - ! - ! Compute the residual - ! - if (post) then - call psb_geaxpby(cone,mlwrk(level)%x2l,& - & czero,mlwrk(level)%tx,& - & p%precv(level)%base_desc,info) - call psb_spmm(-cone,p%precv(level)%base_a,mlwrk(level)%y2l,& - & cone,mlwrk(level)%tx,p%precv(level)%base_desc,info,& - & work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - ! - ! Apply the second smoother - ! - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(cone,& - & mlwrk(level)%tx,cone,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(cone,& - & mlwrk(level)%tx,cone,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during POST smoother_apply') - goto 9999 - end if - - endif - - else if (level == nlev) then - - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(cone,& - & mlwrk(level)%x2l,czero,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info) - - else - - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL vs NLEV') - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_c_inner_mult - - -end subroutine mld_cmlprec_aply diff --git a/mlprec/impl/mld_cmlprec_bld.f90 b/mlprec/impl/mld_cmlprec_bld.f90 deleted file mode 100644 index 6db6a541..00000000 --- a/mlprec/impl/mld_cmlprec_bld.f90 +++ /dev/null @@ -1,152 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_cmlprec_bld.f90 -! -! Subroutine: mld_cmlprec_bld -! Version: complex -! -! This routine builds the preconditioner according to the requirements made by -! the user trough the subroutines mld_precinit and mld_precset. -! -! A multilevel preconditioner is regarded as an array of 'one-level' data structures, -! each containing the part of the preconditioner associated to a certain level, -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level. No transfer operators are associated to level 1. -! -! This routine simply calls mld_c_hierarchy_bld and mld_c_smoothers_bld; they -! can also be called explicitly from the user. -! -! -! Arguments: -! a - type(psb_cspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_cprec_type), input/output. -! The preconditioner data structure containing the local part -! of the preconditioner to be built. -! info - integer, output. -! Error code. -! -! amold - class(psb_c_base_sparse_mat), input, optional -! Mold for the inner format of matrices contained in the -! preconditioner -! -! -! vmold - class(psb_c_base_vect_type), input, optional -! Mold for the inner format of vectors contained in the -! preconditioner -! -! -! -subroutine mld_cmlprec_bld(a,desc_a,p,info,amold,vmold,imold) - - use psb_base_mod - use mld_c_inner_mod, mld_protect_name => mld_cmlprec_bld - use mld_c_prec_mod - - Implicit None - - ! Arguments - type(psb_cspmat_type),intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - type(mld_cprec_type),intent(inout),target :: p - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local Variables - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, casize, nplevs, mxplevs - real(psb_spk_) :: mnaggratio - integer(psb_ipk_) :: ipv(mld_ifpsz_), val - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_cmlprec_bld' - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' - - call p%hierarchy_build(a,desc_a,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Error from hierarchy build') - goto 9999 - end if - - iszv = p%get_nlevs() - - call p%smoothers_build(a,desc_a,info,amold,vmold,imold) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Error from smoothers build') - goto 9999 - end if - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Exiting with',iszv,' levels' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_cmlprec_bld diff --git a/mlprec/impl/mld_cprecaply.f90 b/mlprec/impl/mld_cprecaply.f90 deleted file mode 100644 index 854d62c9..00000000 --- a/mlprec/impl/mld_cprecaply.f90 +++ /dev/null @@ -1,600 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_cprecaply.f90 -! -! Subroutine: mld_cprecaply -! Version: complex -! -! This routine applies the preconditioner built by mld_cprecbld, i.e. it computes -! -! Y = op(M^(-1)) * X, -! where -! - M is the preconditioner, -! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, -! - X and Y are vectors. -! This operation is performed at each iteration of a preconditioned Krylov solver. -! -! -! Arguments: -! prec - type(mld_cprec_type), input. -! The preconditioner data structure containing the local part -! of the preconditioner to be applied. -! x - complex(psb_spk_), dimension(:), input. -! The local part of the vector X in Y=op(M^(-1))*X. -! y - complex(psb_spk_), dimension(:), output. -! The local part of the vector Y in Y=op(M^(-1))*X. -! desc_data - type(psb_desc_type), input. -! The communication descriptor associated to the matrix to be -! preconditioned. -! info - integer, output. -! Error code. -! trans - character(len=1), optional. -! If trans='N','n' then op(M^(-1)) = M^(-1); -! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). -! work - complex(psb_spk_), dimension (:), optional, target. -! Workspace. Its size must be at -! least 4*desc_data%get_local_cols(). -! -subroutine mld_cprecaply(prec,x,y,desc_data,info,trans,work) - - use psb_base_mod - use mld_c_inner_mod!, mld_protect_name => mld_cprecaply - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_cprec_type), intent(inout) :: prec - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_spk_),intent(inout), optional, target :: work(:) - - ! Local variables - character :: trans_ - complex(psb_spk_), pointer :: work_(:) - complex(psb_spk_), allocatable :: w1(:), w2(:) - - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: err_act,iwsz, k, nswps - character(len=20) :: name - - name='mld_cprecaply' - info = psb_success_ - call psb_erractionsave(err_act) - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (present(trans)) then - trans_=psb_toupper(trans) - else - trans_='N' - end if - - if (present(work)) then - work_ => work - else - iwsz = max(1,4*desc_data%get_local_cols()) - allocate(work_(iwsz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name, & - & i_err=(/iwsz,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - - end if - - if (.not.(allocated(prec%precv))) then - !! Error 1: should call mld_cprecbld - info=3112 - call psb_errpush(info,name) - goto 9999 - end if - - if (size(prec%precv) >1) then - ! - ! Number of levels > 1: apply the multilevel preconditioner - ! - call mld_mlprec_aply(cone,prec,x,czero,y,desc_data,trans_,work_,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_cmlprec_aply') - goto 9999 - end if - - else if (size(prec%precv) == 1) then - ! - ! Number of levels = 1: apply the base preconditioner - ! - if (allocated(prec%precv(1)%sm2a)) then - nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) - ! - ! This is a kludge for handling the symmetrized GS case. - ! Will need some rethinking. - ! - call psb_geasb(w1,desc_data,info,scratch=.true.) - call psb_geasb(w2,desc_data,info,scratch=.true.) - - call psb_geaxpby(cone,x,czero,w1,desc_data,info) - select case(trans_) - case ('N') - do k=1, nswps - call prec%precv(1)%sm%apply(cone,w1,czero,w2,desc_data,trans_,& - & ione, work_,info) - call prec%precv(1)%sm2a%apply(cone,w2,czero,w1,desc_data,trans_,& - & ione, work_,info) - end do - - case('T','C') - do k=1, nswps - call prec%precv(1)%sm2a%apply(cone,w1,czero,w2,desc_data,trans_,& - & ione, work_,info) - call prec%precv(1)%sm%apply(cone,w2,czero,w1,desc_data,trans_,& - & ione, work_,info) - end do - case default - info = psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='Invalid trans') - goto 9999 - end select - call psb_geaxpby(cone,w1,czero,y,desc_data,info) - call psb_gefree(w1,desc_data,info) - call psb_gefree(w2,desc_data,info) - - else - nswps = prec%precv(1)%parms%sweeps_pre - call prec%precv(1)%sm%apply(cone,x,czero,y,desc_data,trans_,& - & nswps, work_,info) - end if - else - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='Invalid size of precv',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - endif - - ! If the original distribution has an overlap we should fix that. - call psb_halo(y,desc_data,info,data=psb_comm_mov_) - - - if (present(work)) then - else - deallocate(work_) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_cprecaply - - -! -! Subroutine: mld_cprecaply1 -! Version: complex -! -! Applies the preconditioner built by mld_cprecbld, i.e. computes -! -! X = op(M^(-1)) * X, -! where -! - M is the preconditioner, -! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, -! - X is a vectors. -! This operation is performed at each iteration of a preconditioned Krylov solver. -! -! This routine differs from mld_cprecaply because the preconditioned vector X -! overwrites the original one. -! -! -! Arguments: -! prec - type(mld_cprec_type), input. -! The preconditioner data structure containing the local part -! of the preconditioner to be applied. -! x - complex(psb_spk_), dimension(:), input/output. -! The local part of vector X in X := op(M^(-1)) * X. -! desc_data - type(psb_desc_type), input. -! The communication descriptor associated to the matrix to be -! preconditioned. -! info - integer, output. -! Error code. -! trans - character(len=1), optional. -! If trans='N','n' then op(M^(-1)) = M^(-1); -! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). -! -subroutine mld_cprecaply1(prec,x,desc_data,info,trans) - - use psb_base_mod - use mld_c_inner_mod!, mld_protect_name => mld_cprecaply1 - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_cprec_type), intent(inout) :: prec - complex(psb_spk_),intent(inout) :: x(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: err_act - complex(psb_spk_), pointer :: ww(:), w1(:) - character(len=20) :: name - - name='mld_cprecaply1' - info = psb_success_ - call psb_erractionsave(err_act) - - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - allocate(ww(size(x)),w1(size(x)),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name, & - & i_err=(/itwo*size(x),izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - - call prec%apply(x,ww,desc_data,info,trans=trans,work=w1) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_precaply') - goto 9999 - end if - - x(:) = ww(:) - deallocate(ww,w1,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_cprecaply1 - - - -subroutine mld_cprecaply2_vect(prec,x,y,desc_data,info,trans,work) - - use psb_base_mod - use mld_c_inner_mod!, mld_protect_name => mld_cprecaply2_vect - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_cprec_type), intent(inout) :: prec - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_spk_),intent(inout), optional, target :: work(:) - - ! Local variables - character :: trans_ - complex(psb_spk_), pointer :: work_(:) - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: err_act,iwsz, k, nswps - logical :: do_alloc_wrk - character(len=20) :: name - - name='mld_cprecaply' - info = psb_success_ - call psb_erractionsave(err_act) - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (present(trans)) then - trans_=psb_toupper(trans) - else - trans_='N' - end if - - if (present(work)) then - work_ => work - else - iwsz = max(1,4*desc_data%get_local_cols()) - allocate(work_(iwsz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name, & - & i_err=(/iwsz,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - - end if - - if (.not.(allocated(prec%precv))) then - !! Error 1: should call mld_cprecbld - info=3112 - call psb_errpush(info,name) - goto 9999 - end if - - do_alloc_wrk = .not.allocated(prec%precv(1)%wrk) - if (do_alloc_wrk) call prec%allocate_wrk(info,vmold=x%v) - - if (size(prec%precv) >1) then - ! - ! Number of levels > 1: apply the multilevel preconditioner - ! - ! FIXME: generic name causes an ICE with Intel - call mld_cmlprec_aply_vect(cone,prec,x,czero,y,desc_data,trans_,work_,info) - - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_cmlprec_aply') - goto 9999 - end if - - else if (size(prec%precv) == 1) then - ! - ! Number of levels = 1: apply the base preconditioner - ! - nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) - - associate(w1 => prec%precv(1)%wrk%vx2l, w2 => prec%precv(1)%wrk%vy2l,& - & wv => prec%precv(1)%wrk%wv) - if (allocated(prec%precv(1)%sm2a)) then - ! - ! This is a kludge for handling the symmetrized GS case. - ! Will need some rethinking. - ! - call psb_geaxpby(cone,x,czero,w1,desc_data,info) - select case(trans_) - case ('N') - do k=1, nswps - if (info == 0) call prec%precv(1)%sm%apply(cone,w1,czero,w2,desc_data,trans_,& - & ione, work_,wv,info) - if (info == 0) call prec%precv(1)%sm2a%apply(cone,w2,czero,w1,desc_data,trans_,& - & ione, work_,wv,info) - end do - - case('T','C') - do k=1, nswps - if (info == 0) call prec%precv(1)%sm2a%apply(cone,w1,czero,w2,desc_data,trans_,& - & ione, work_,wv,info) - if (info == 0) call prec%precv(1)%sm%apply(cone,w2,czero,w1,desc_data,trans_,& - & ione, work_,wv,info) - end do - case default - info = psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='Invalid trans') - goto 9999 - end select - if (info == 0) call psb_geaxpby(cone,w1,czero,y,desc_data,info) - else - if (info == 0) call prec%precv(1)%sm%apply(cone,x,czero,y,desc_data,trans_,& - & nswps,work_,wv,info) - end if - end associate - if (psb_errstatus_fatal()) info = psb_err_internal_error_ - if (info /= 0) then - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='Smoother application',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - end if - - else - - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='Invalid size of precv',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - endif - - ! If the original distribution has an overlap we should fix that. - call psb_halo(y,desc_data,info,data=psb_comm_mov_) - - if (do_alloc_wrk) call prec%free_wrk(info) - - if (present(work)) then - else - deallocate(work_) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_cprecaply2_vect - - -subroutine mld_cprecaply1_vect(prec,x,desc_data,info,trans,work) - - use psb_base_mod - use mld_c_inner_mod!, mld_protect_name => mld_cprecaply1_vect - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_cprec_type), intent(inout) :: prec - type(psb_c_vect_type),intent(inout) :: x - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_spk_),intent(inout), optional, target :: work(:) - - ! Local variables - character :: trans_ - complex(psb_spk_), pointer :: work_(:) - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: err_act,iwsz, k, nswps - logical :: do_alloc_wrk - character(len=20) :: name - - name='mld_cprecaply' - info = psb_success_ - call psb_erractionsave(err_act) - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (present(trans)) then - trans_=psb_toupper(trans) - else - trans_='N' - end if - - if (present(work)) then - work_ => work - else - iwsz = max(1,4*desc_data%get_local_cols()) - allocate(work_(iwsz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name, & - & i_err=(/iwsz,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - - end if - - if (.not.(allocated(prec%precv))) then - !! Error 1: should call mld_cprecbld - info=3112 - call psb_errpush(info,name) - goto 9999 - end if - - do_alloc_wrk = .not.allocated(prec%precv(1)%wrk) - if (do_alloc_wrk) call prec%allocate_wrk(info,vmold=x%v) - - associate(ww => prec%precv(1)%wrk%vtx, wv => prec%precv(1)%wrk%wv) - - if (size(prec%precv) >1) then - ! - ! Number of levels > 1: apply the multilevel preconditioner - ! - ! FIXME: generic name causes an ICE with Intel - call mld_cmlprec_aply_vect(cone,prec,x,czero,ww,desc_data,trans_,work_,info) - if (info == 0) call psb_geaxpby(cone,ww,czero,x,desc_data,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_cmlprec_aply') - goto 9999 - end if - - else if (size(prec%precv) == 1) then - ! - ! Number of levels = 1: apply the base preconditioner - ! - nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) - if (allocated(prec%precv(1)%sm2a)) then - ! - ! This is a kludge for handling the symmetrized GS case. - ! Will need some rethinking. - ! - select case(trans_) - case ('N') - do k=1, nswps - if (info == 0) call prec%precv(1)%sm%apply(cone,x,czero,ww,desc_data,trans_,& - & ione, work_,wv,info) - if (info == 0) call prec%precv(1)%sm2a%apply(cone,ww,czero,x,desc_data,trans_,& - & ione, work_,wv,info) - end do - case('T','C') - do k=1, nswps - if (info == 0) call prec%precv(1)%sm2a%apply(cone,x,czero,ww,desc_data,trans_,& - & ione, work_,wv,info) - if (info == 0) call prec%precv(1)%sm%apply(cone,ww,czero,x,desc_data,trans_,& - & ione, work_,wv,info) - end do - case default - info = psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='Invalid trans') - goto 9999 - end select - - else - if (info == 0) call prec%precv(1)%sm%apply(cone,x,czero,ww,desc_data,trans_,& - & nswps, work_,wv,info) - if (info == 0) call psb_geaxpby(cone,ww,czero,x,desc_data,info) - end if - - if (psb_errstatus_fatal()) info = psb_err_internal_error_ - if (info /=0) then - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='Smoother application',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - end if - - else - - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='Invalid size of precv',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - endif - end associate - - ! If the original distribution has an overlap we should fix that. - call psb_halo(x,desc_data,info,data=psb_comm_mov_) - - if (do_alloc_wrk) call prec%free_wrk(info) - - if (present(work)) then - else - deallocate(work_) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_cprecaply1_vect diff --git a/mlprec/impl/mld_cprecbld.f90 b/mlprec/impl/mld_cprecbld.f90 deleted file mode 100644 index 74015a14..00000000 --- a/mlprec/impl/mld_cprecbld.f90 +++ /dev/null @@ -1,161 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_cprecbld.f90 -! -! Subroutine: mld_cprecbld -! Version: complex -! Contains: subroutine init_baseprec_av -! -! This routine builds the preconditioner according to the requirements made by -! the user through the subroutines mld_precinit and mld_precset. -! -! -! Arguments: -! a - type(psb_cspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_cprec_type), input/output. -! The preconditioner data structure containing the local part -! of the preconditioner to be built. -! info - integer, output. -! Error code. -! -subroutine mld_cprecbld(a,desc_a,prec,info,amold,vmold,imold) - - use psb_base_mod - use mld_c_prec_mod, mld_protect_name => mld_cprecbld - - Implicit None - - ! Arguments - type(psb_cspmat_type),intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_cprec_type),intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local Variables - type(mld_cprec_type) :: t_prec - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k,err_act, iszv, newsz - integer(psb_ipk_) :: ipv(mld_ifpsz_), val - integer(psb_ipk_) :: int_err(5) - type(mld_dml_parms) :: prm - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_cprecbld' - info = psb_success_ - int_err(1) = 0 - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - prec%ictxt = ictxt - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' - ! - - if (.not.allocated(prec%precv)) then - !! Error: should have called mld_cprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - ! - ! Check to ensure all procs have the same - ! - newsz = -1 - iszv = size(prec%precv) - call psb_bcast(ictxt,iszv) - if (iszv /= size(prec%precv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of precv') - goto 9999 - end if - - if (iszv <= 0) then - ! Is this really possible? probably not. - info=psb_err_from_subroutine_ - ch_err='size bpv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - ! - ! Build the preconditioner - ! - call prec%hierarchy_build(a,desc_a,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Error from hierarchy build') - goto 9999 - end if - - call prec%smoothers_build(a,desc_a,info,amold,vmold,imold) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Error from smoothers build') - goto 9999 - end if - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_cprecbld diff --git a/mlprec/impl/mld_cprecinit.F90 b/mlprec/impl/mld_cprecinit.F90 deleted file mode 100644 index 901dc382..00000000 --- a/mlprec/impl/mld_cprecinit.F90 +++ /dev/null @@ -1,237 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_cprecinit.f90 -! -! Subroutine: mld_cprecinit -! Version: complex -! -! This routine allocates and initializes the preconditioner data structure, -! according to the preconditioner type chosen by the user. -! -! A default preconditioner is set for each preconditioner type -! specified by the user: -! -! 'NOPREC' - no preconditioner -! -! 'DIAG', 'JACOBI' - diagonal/Jacobi -! -! 'L1-DIAG', 'L1-JACOBI' - diagonal/Jacobi with L1 norm correction -! -! 'GS', 'FBGS' - Hybrid Gauss-Seidel, also symmetrized -! -! 'BJAC' - block Jacobi preconditioner, with ILU(0) -! on the local blocks -! -! 'L1-BJAC' - block Jacobi preconditioner, with ILU(0) -! on the local blocks and L1 correction for off-diag blocks -! -! 'AS' - Additive Schwarz (AS), with -! overlap 1 and ILU(0) on the local submatrices -! -! 'ML' - Multilevel hybrid preconditioner (additive on the -! same level and multiplicative through the levels), -! with 2 levels, pre and post-smoothing, RAS with -! overlap 1 and ILU(0) on the local blocks is -! applied as post-smoother at each level, but the -! coarsest one; four sweeps of the block-Jacobi solver, -! with LU from UMFPACK on the blocks, are applied at -! the coarsest level, on the distributed coarse matrix. -! The smoothed aggregation algorithm with threshold 0 -! is used to build the coarse matrix. -! -! For the multilevel preconditioners, the levels are numbered in increasing -! order starting from the finest one, i.e. level 1 is the finest level. -! -! -! Arguments: -! p - type(mld_cprec_type), input/output. -! The preconditioner data structure. -! ptype - character(len=*), input. -! The type of preconditioner. Its values are 'NOPREC', -! 'DIAG', 'BJAC', 'AS', 'ML' (and the corresponding -! lowercase strings). -! info - integer, output. -! Error code. -! -subroutine mld_cprecinit(ictxt,prec,ptype,info) - - use psb_base_mod - use mld_c_prec_mod, mld_protect_name => mld_cprecinit - use mld_c_jac_smoother - use mld_c_as_smoother - use mld_c_id_solver - use mld_c_diag_solver - use mld_c_ilu_solver - use mld_c_gs_solver -#if defined(HAVE_SLU_) - use mld_c_slu_solver -#endif - - - implicit none - - ! Arguments - integer(psb_ipk_), intent(in) :: ictxt - class(mld_cprec_type), intent(inout) :: prec - character(len=*), intent(in) :: ptype - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: nlev_, ilev_ - real(psb_spk_) :: thr - character(len=*), parameter :: name='mld_precinit' - info = psb_success_ - - if (allocated(prec%precv)) then - call prec%free(info) - if (info /= psb_success_) then - ! Do we want to do something? - endif - endif - prec%ictxt = ictxt - prec%ag_data%min_coarse_size = -1 - - select case(psb_toupper(trim(ptype))) - case ('NOPREC','NONE') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_c_base_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_c_id_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('JAC','DIAG','JACOBI') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_c_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_c_diag_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('L1-DIAG','L1-JACOBI','L1_DIAG','L1_JACOBI') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_c_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_c_l1_diag_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('GS','FWGS') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_c_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_c_gs_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('BWGS') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_c_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_c_bwgs_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('FBGS') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - call prec%set('SMOOTHER_TYPE','FBGS',info) - call prec%precv(ilev_)%default() - - case ('BJAC') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_c_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_c_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('L1-BJAC','L1_BJAC') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_c_l1_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_c_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('AS') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_c_as_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_c_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - - case ('ML') - - nlev_ = prec%ag_data%max_levs - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - - do ilev_ = 1, nlev_ - call prec%precv(ilev_)%default() - end do - call prec%set('ML_CYCLE','VCYCLE',info) - call prec%set('SMOOTHER_TYPE','FBGS',info) -#if defined(HAVE_MUMPS_) - call prec%set('COARSE_SOLVE','MUMPS',info) -#elif defined(HAVE_SLU_) - call prec%set('COARSE_SOLVE','SLU',info) -#else - call prec%set('COARSE_SOLVE','ILU',info) -#endif - - case default - write(psb_err_unit,*) name,& - &': Warning: Unknown preconditioner type request "',ptype,'"' - info = psb_err_pivot_too_small_ - - end select - - -end subroutine mld_cprecinit diff --git a/mlprec/impl/mld_cprecset.F90 b/mlprec/impl/mld_cprecset.F90 deleted file mode 100644 index 5bfc0b66..00000000 --- a/mlprec/impl/mld_cprecset.F90 +++ /dev/null @@ -1,229 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_cprecset.f90 -! -subroutine mld_cprecsetsm(p,val,info,ilev,ilmax,pos) - - use psb_base_mod - use mld_c_prec_mod, mld_protect_name => mld_cprecsetsm - - implicit none - - ! Arguments - class(mld_cprec_type), intent(inout) :: p - class(mld_c_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ - character(len=*), parameter :: name='mld_precsetsm' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - ilmin_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmin_ = 1 - ilmax_ = nlev_ - end if - - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - do ilev_ = ilmin_, ilmax_ - call p%precv(ilev_)%set(val,info,pos=pos) - if (info /= 0) return - end do - -end subroutine mld_cprecsetsm - -subroutine mld_cprecsetsv(p,val,info,ilev,ilmax,pos) - - use psb_base_mod - use mld_c_prec_mod, mld_protect_name => mld_cprecsetsv - - implicit none - - ! Arguments - class(mld_cprec_type), intent(inout) :: p - class(mld_c_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ - character(len=*), parameter :: name='mld_precsetsv' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - ilmin_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmin_ = 1 - ilmax_ = nlev_ - end if - - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - do ilev_ = ilmin_, ilmax_ - call p%precv(ilev_)%set(val,info,pos=pos) - if (info /= 0) return - end do - -end subroutine mld_cprecsetsv - -subroutine mld_cprecsetag(p,val,info,ilev,ilmax,pos) - - use psb_base_mod - use mld_c_prec_mod, mld_protect_name => mld_cprecsetag - - implicit none - - ! Arguments - class(mld_cprec_type), intent(inout) :: p - class(mld_c_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev, ilmax - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ - character(len=*), parameter :: name='mld_precsetag' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - ilmin_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmin_ = 1 - ilmax_ = nlev_ - end if - - - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - do ilev_ = ilmin_, ilmax_ - call p%precv(ilev_)%set(val,info,pos=pos) - if (info /= 0) return - end do - -end subroutine mld_cprecsetag - diff --git a/mlprec/impl/mld_cslu_interface.c b/mlprec/impl/mld_cslu_interface.c deleted file mode 100644 index cb298ebb..00000000 --- a/mlprec/impl/mld_cslu_interface.c +++ /dev/null @@ -1,328 +0,0 @@ -/* - * - * MLD2P4 version 2.1 - * MultiLevel Domain Decomposition Parallel Preconditioners Package - * based on PSBLAS (Parallel Sparse BLAS version 3.5) - * - * (C) Copyright 2008-2018 - * - * Salvatore Filippone - * Pasqua D'Ambra - * Daniela di Serafino - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions, and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the MLD2P4 group or the names of its contributors may - * not be used to endorse or promote products derived from this - * software without specific written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * - * File: mld_cslu_interface.c - * - * Functions: mld_cslu_fact, mld_cslu_solve, mld_cslu_free. - * - * This file is an interface to the SuperLU routines for sparse factorization and - * solve. It was obtained by modifying the c_fortran_cgssv.c file from the SuperLU - * source distribution; original copyright terms are reproduced below. - * - */ - - -/* ===================== - -Copyright (c) 2003, The Regents of the University of California, through -Lawrence Berkeley National Laboratory (subject to receipt of any required -approvals from U.S. Dept. of Energy) - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -(1) Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. -(2) Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. -(3) Neither the name of Lawrence Berkeley National Laboratory, U.S. Dept. of -Energy nor the names of its contributors may be used to endorse or promote -products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -/* - * -- SuperLU routine (version 3.0) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * October 15, 2003 - * - */ - -#ifdef Have_SLU_ -#include "slu_cdefs.h" -#define HANDLE_SIZE 8 - - -typedef struct { - SuperMatrix *L; - SuperMatrix *U; - int *perm_c; - int *perm_r; -} factors_t; - - -#else - -#include - -#endif - - - -int mld_cslu_fact(int n, int nnz, -#ifdef HAVE_SLU_ - complex *values, -#else - void *values, -#endif - int *colptr, int *rowind, void **f_factors) -{ -/* - * This routine can be called from Fortran. - * performs LU decomposition. - * - * f_factors (input/output) - * On output contains the pointer pointing to - * the structure of the factored matrices. - * - */ - -#ifdef Have_SLU_ - SuperMatrix A, AC; - SuperMatrix *L, *U; - int *perm_r; /* row permutations from partial pivoting */ - int *perm_c; /* column permutation vector */ - int *etree; /* column elimination tree */ - SCformat *Lstore; - NCformat *Ustore; - int i, panel_size, permc_spec, relax; - trans_t trans; - mem_usage_t mem_usage; - superlu_options_t options; - SuperLUStat_t stat; - factors_t *LUfactors; - GlobalLU_t Glu; /* Not needed on return. */ - int info; - - trans = NOTRANS; - - - /* Set the default input options. */ - set_default_options(&options); - - /* Initialize the statistics variables. */ - StatInit(&stat); - - cCreate_CompCol_Matrix(&A, n, n, nnz, values, rowind, colptr, - SLU_NC, SLU_C, SLU_GE); - L = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) ); - U = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) ); - if ( !(perm_r = intMalloc(n)) ) ABORT("Malloc fails for perm_r[]."); - if ( !(perm_c = intMalloc(n)) ) ABORT("Malloc fails for perm_c[]."); - if ( !(etree = intMalloc(n)) ) ABORT("Malloc fails for etree[]."); - - /* - * Get column permutation vector perm_c[], according to permc_spec: - * permc_spec = 0: natural ordering - * permc_spec = 1: minimum degree on structure of A'*A - * permc_spec = 2: minimum degree on structure of A'+A - * permc_spec = 3: approximate minimum degree for unsymmetric matrices - */ - options.ColPerm=2; - permc_spec = options.ColPerm; - get_perm_c(permc_spec, &A, perm_c); - - sp_preorder(&options, &A, perm_c, etree, &AC); - - panel_size = sp_ienv(1); - relax = sp_ienv(2); -#if defined(SLU_VERSION_5) - cgstrf(&options, &AC, relax, panel_size, etree, - NULL, 0, perm_c, perm_r, L, U, &Glu, &stat, &info); -#elif defined(SLU_VERSION_4) - cgstrf(&options, &AC, relax, panel_size, etree, - NULL, 0, perm_c, perm_r, L, U, &stat, &info); -#else - choke_on_me; -#endif - - if ( info == 0 ) { - Lstore = (SCformat *) L->Store; - Ustore = (NCformat *) U->Store; - cQuerySpace(L, U, &mem_usage); -#if 0 - printf("No of nonzeros in factor L = %d\n", Lstore->nnz); - printf("No of nonzeros in factor U = %d\n", Ustore->nnz); - printf("No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz); - printf("L\\U MB %.3f\ttotal MB needed %.3f\n", - mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); -#endif - } else { - printf("cgstrf() error returns INFO= %d\n", info); - if ( info <= n ) { /* factorization completes */ - cQuerySpace(L, U, &mem_usage); - printf("L\\U MB %.3f\ttotal MB needed %.3f\n", - mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); - } - } - - /* Save the LU factors in the factors handle */ - LUfactors = (factors_t*) SUPERLU_MALLOC(sizeof(factors_t)); - LUfactors->L = L; - LUfactors->U = U; - LUfactors->perm_c = perm_c; - LUfactors->perm_r = perm_r; - *f_factors = (void *) LUfactors; - - /* Free un-wanted storage */ - SUPERLU_FREE(etree); - Destroy_SuperMatrix_Store(&A); - Destroy_CompCol_Permuted(&AC); - StatFree(&stat); - return(info); -#else - fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); - return(-1); -#endif -} - - -int mld_cslu_solve(int itrans, int n, int nrhs, -#ifdef HAVE_SLU_ - complex *b, -#else - void *b, -#endif - int ldb,void *f_factors) -{ - /* - * This routine can be called from Fortran. - * performs triangular solve - * - */ - int info; -#ifdef Have_SLU_ - SuperMatrix B; - SuperMatrix *L, *U; - int *perm_r; /* row permutations from partial pivoting */ - int *perm_c; /* column permutation vector */ - int *etree; /* column elimination tree */ - SCformat *Lstore; - NCformat *Ustore; - int i, panel_size, permc_spec, relax; - trans_t trans; - float drop_tol = 0.0; - mem_usage_t mem_usage; - superlu_options_t options; - SuperLUStat_t stat; - factors_t *LUfactors; - - if (itrans == 0) { - trans = NOTRANS; - } else if (itrans ==1) { - trans = TRANS; - } else if (itrans ==2) { - trans = CONJ; - } else { - trans = NOTRANS; - } - /* Initialize the statistics variables. */ - StatInit(&stat); - - /* Extract the LU factors in the factors handle */ - LUfactors = (factors_t*) f_factors; - L = LUfactors->L; - U = LUfactors->U; - perm_c = LUfactors->perm_c; - perm_r = LUfactors->perm_r; - - cCreate_Dense_Matrix(&B, n, nrhs, b, ldb, SLU_DN, SLU_C, SLU_GE); - /* Solve the system A*X=B, overwriting B with X. */ - cgstrs (trans, L, U, perm_c, perm_r, &B, &stat, &info); - if (info != 0) { - if (B.Stype != SLU_DN) fprintf(stderr,"cgstrs error kind 1: SLU_DN\n"); - if (B.Dtype != SLU_C) fprintf(stderr,"cgstrs error kind 2: SLU_C\n"); - if (B.Mtype != SLU_GE) fprintf(stderr,"cgstrs error kind 3: SLU_GE\n"); - } - - Destroy_SuperMatrix_Store(&B); - StatFree(&stat); -#else - fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); - info=-1; -#endif - return(info); -} - - -int mld_cslu_free(void *f_factors) -{ -/* - * This routine can be called from Fortran. - * - * free all storage in the end - * - */ -#ifdef Have_SLU_ - factors_t *LUfactors; - - /* Free the LU factors in the factors handle */ - LUfactors = (factors_t*) f_factors; - if (LUfactors != NULL) { - SUPERLU_FREE (LUfactors->perm_r); - SUPERLU_FREE (LUfactors->perm_c); - Destroy_SuperNode_Matrix(LUfactors->L); - Destroy_CompCol_Matrix(LUfactors->U); - SUPERLU_FREE (LUfactors->L); - SUPERLU_FREE (LUfactors->U); - SUPERLU_FREE (LUfactors); - } - return(0); -#else - fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); - return(-1); -#endif -} - - diff --git a/mlprec/impl/mld_d_extprol_bld.F90 b/mlprec/impl/mld_d_extprol_bld.F90 deleted file mode 100644 index aff2d843..00000000 --- a/mlprec/impl/mld_d_extprol_bld.F90 +++ /dev/null @@ -1,534 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_d_extprol_bld.f90 -! -! Subroutine: mld_d_extprol_bld -! Version: real -! -! This routine builds the preconditioner according to the requirements made by -! the user trough the subroutines mld_precinit and mld_precset. -! -! A multilevel preconditioner is regarded as an array of 'one-level' data structures, -! each containing the part of the preconditioner associated to a certain level, -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level. No transfer operators are associated to level 1. -! -! -! Arguments: -! a - type(psb_dspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_dprec_type), input/output. -! The preconditioner data structure containing the local part -! of the preconditioner to be built. -! info - integer, output. -! Error code. -! -! amold - class(psb_d_base_sparse_mat), input, optional -! Mold for the inner format of matrices contained in the -! preconditioner -! -! -! vmold - class(psb_d_base_vect_type), input, optional -! Mold for the inner format of vectors contained in the -! preconditioner -! -! -! -subroutine mld_d_extprol_bld(a,desc_a,p,prolv,restrv,info,amold,vmold,imold) - - use psb_base_mod - use mld_d_inner_mod - use mld_d_prec_mod, mld_protect_name => mld_d_extprol_bld - - Implicit None - - ! Arguments - type(psb_dspmat_type),intent(in), target :: a - type(psb_dspmat_type),intent(inout), target :: prolv(:) - type(psb_dspmat_type),intent(inout), target :: restrv(:) - type(psb_desc_type), intent(inout), target :: desc_a - type(mld_dprec_type),intent(inout),target :: p - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! !$ character, intent(in), optional :: upd - - ! Local Variables - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, casize, nplevs, mxplevs - integer(psb_ipk_) :: nprolv, nrestrv - real(psb_dpk_) :: mnaggratio - integer(psb_ipk_) :: ipv(mld_ifpsz_), val - class(mld_d_base_smoother_type), allocatable :: coarse_sm, base_sm, med_sm - type(mld_dml_parms) :: baseparms, medparms, coarseparms - type(mld_d_onelev_type), allocatable :: tprecv(:) - integer(psb_ipk_) :: int_err(5) - character :: upd_ - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - logical, parameter :: debug=.false. - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_d_extprol_bld' - info = psb_success_ - int_err(1) = 0 - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - p%ictxt = ictxt - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' -#if defined(LPK8) - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Need fix for LPK8') - goto 9999 -#else - - ! - ! For the time being we are commenting out the UPDATE argument - ! we plan to resurrect it later. - ! !$ if (present(upd)) then - ! !$ if (debug_level >= psb_debug_outer_) & - ! !$ & write(debug_unit,*) me,' ',trim(name),'UPD ', upd - ! !$ - ! !$ if ((psb_toupper(upd).eq.'F').or.(psb_toupper(upd).eq.'T')) then - ! !$ upd_=psb_toupper(upd) - ! !$ else - ! !$ upd_='F' - ! !$ endif - ! !$ else - ! !$ upd_='F' - ! !$ endif - upd_ = 'F' - - if (.not.allocated(p%precv)) then - !! Error: should have called mld_dprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - ! - ! Check to ensure all procs have the same - ! - newsz = -1 - mxplevs = p%ag_data%max_levs - mnaggratio = p%ag_data%min_cr_ratio - casize = p%ag_data%min_coarse_size - iszv = size(p%precv) - nprolv = size(prolv) - nrestrv = size(restrv) - call psb_bcast(ictxt,iszv) - call psb_bcast(ictxt,casize) - call psb_bcast(ictxt,mxplevs) - call psb_bcast(ictxt,mnaggratio) - call psb_bcast(ictxt,nprolv) - call psb_bcast(ictxt,nrestrv) - if (casize /= p%ag_data%min_coarse_size) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent min_coarse_size') - goto 9999 - end if - if (mxplevs /= p%ag_data%max_levs) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent max_levs') - goto 9999 - end if - if (mnaggratio /= p%ag_data%min_cr_ratio) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent min_cr_ratio') - goto 9999 - end if - if (iszv /= size(p%precv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of precv') - goto 9999 - end if - if (nprolv /= size(prolv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of prolv') - goto 9999 - end if - if (nrestrv /= size(restrv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of restrv') - goto 9999 - end if - if (nrestrv /= nprolv) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size prolv vs restrv') - goto 9999 - end if - - if (iszv <= 1) then - ! We should only ever get here for multilevel. - info=psb_err_from_subroutine_ - ch_err='size bpv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - endif - - if (nrestrv < 1) then - ! We should only ever get here for multilevel. - info=psb_err_from_subroutine_ - ch_err='size restrv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - endif - - ! - nplevs = nrestrv + 1 - p%ag_data%max_levs = nplevs - - ! - ! Fixed number of levels. - ! - nplevs = max(itwo,mxplevs) - - coarseparms = p%precv(iszv)%parms - baseparms = p%precv(1)%parms - medparms = p%precv(2)%parms - - allocate(coarse_sm, source=p%precv(iszv)%sm,stat=info) - if (info == psb_success_) & - & allocate(med_sm, source=p%precv(2)%sm,stat=info) - if (info == psb_success_) & - & allocate(base_sm, source=p%precv(1)%sm,stat=info) - if (info /= psb_success_) then - write(0,*) 'Error in saving smoothers',info - call psb_errpush(psb_err_internal_error_,name,a_err='Base level precbuild.') - goto 9999 - end if - - if (iszv /= nplevs) then - allocate(tprecv(nplevs),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - tprecv(1)%parms = baseparms - allocate(tprecv(1)%sm,source=base_sm,stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - do i=2,nplevs-1 - tprecv(i)%parms = medparms - allocate(tprecv(i)%sm,source=med_sm,stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - end do - tprecv(nplevs)%parms = coarseparms - allocate(tprecv(nplevs)%sm,source=coarse_sm,stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - do i=1,iszv - call p%precv(i)%free(info) - end do - call move_alloc(tprecv,p%precv) - iszv = size(p%precv) - end if - ! - ! Finest level first; remember to fix base_a and base_desc - ! - p%precv(1)%base_a => a - p%precv(1)%base_desc => desc_a - newsz = 0 - array_build_loop: do i=2, iszv - - ! - ! Sanity checks on the parameters - ! - if (i p%precv(i)%ac - p%precv(i)%base_desc => p%precv(i)%desc_ac - - - if (i>2) then - if (all(p%precv(i)%map%naggr == p%precv(i-1)%map%naggr)) then - newsz=i-1 - end if - call psb_bcast(ictxt,newsz) - if (newsz > 0) exit array_build_loop - end if - end do array_build_loop - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Internal extprol build' ) - goto 9999 - endif - - iszv = size(p%precv) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Exiting with',iszv,' levels' -#endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - - subroutine mld_d_extaggr_bld(a,desc_a,p,op_restr,op_prol,info) - use psb_base_mod - use mld_d_inner_mod - - implicit none - - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - type(psb_dspmat_type), intent(inout) :: op_restr,op_prol - type(psb_desc_type), intent(in), target :: desc_a - type(mld_d_onelev_type), intent(inout),target :: p - integer(psb_ipk_), intent(out) :: info - - ! Local variables - character(len=20) :: name - integer(psb_mpk_) :: ictxt, np, me, ncol - integer(psb_ipk_) :: err_act,ntaggr,nzl - integer(psb_ipk_), allocatable :: ilaggr(:), nlaggr(:) - type(psb_dspmat_type) :: ac, am2, am3, am4 - type(psb_d_coo_sparse_mat) :: acoo, bcoo - type(psb_d_csr_sparse_mat) :: acsr1 - logical, parameter :: debug=.false. - - name='mld_d_extaggr_bld' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) -#if defined(LPK8) - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Need fix for LPK8') - goto 9999 -#else - allocate(nlaggr(np),ilaggr(1)) - nlaggr = 0 - ilaggr = 0 - p%parms%par_aggr_alg = mld_ext_aggr_ - call mld_check_def(p%parms%ml_cycle,'Multilevel cycle',& - & mld_mult_ml_,is_legal_ml_cycle) - call mld_check_def(p%parms%coarse_mat,'Coarse matrix',& - & mld_distr_mat_,is_legal_ml_coarse_mat) - - nlaggr(me+1) = op_restr%get_nrows() - if (op_restr%get_nrows() /= op_prol%get_ncols()) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent restr/prol sizes') - goto 9999 - end if - call psb_sum(ictxt,nlaggr) - ntaggr = sum(nlaggr) - ncol = desc_a%get_local_cols() - if (debug) write(0,*)me,' Sizes:',op_restr%get_nrows(),op_restr%get_ncols(),& - & op_prol%get_nrows(),op_prol%get_ncols(), a%get_nrows(),a%get_ncols() - ! - ! Compute local part of AC - ! - call op_prol%clone(am2,info) - if (info == psb_success_) call psb_sphalo(am2,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.) - if (info == psb_success_) call psb_rwextd(ncol,am2,info,b=am4) - if (info == psb_success_) call am4%free() - call psb_spspmm(a,am2,am3,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 2') - goto 9999 - end if - call psb_sphalo(am3,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.) - if (info == psb_success_) call psb_rwextd(ncol,am3,info,b=am4) - if (info == psb_success_) call am4%free() - if(info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Extend am3') - goto 9999 - end if - call psb_spspmm(op_restr,am3,ac,info) - if (info == psb_success_) call am3%free() - if (info == psb_success_) call ac%cscnv(info,type='csr',dupl=psb_dupl_add_) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Build ac = op_restr x am3') - goto 9999 - end if - - select case(p%parms%coarse_mat) - - case(mld_distr_mat_) - - call ac%mv_to(bcoo) - nzl = bcoo%get_nzeros() - - if (info == psb_success_) call psb_cdall(ictxt,p%desc_ac,info,nl=nlaggr(me+1)) - if (info == psb_success_) call psb_cdins(nzl,bcoo%ia,bcoo%ja,p%desc_ac,info) - if (info == psb_success_) call psb_cdasb(p%desc_ac,info) - if (info == psb_success_) call psb_glob_to_loc(bcoo%ia(1:nzl),p%desc_ac,info,iact='I') - if (info == psb_success_) call psb_glob_to_loc(bcoo%ja(1:nzl),p%desc_ac,info,iact='I') - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Creating p%desc_ac and converting ac') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Assembld aux descr. distr.' - call p%ac%mv_from(bcoo) - - call p%ac%set_nrows(p%desc_ac%get_local_rows()) - call p%ac%set_ncols(p%desc_ac%get_local_cols()) - call p%ac%set_asb() - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_sp_free') - goto 9999 - end if - - if (np>1) then - call op_prol%mv_to(acsr1) - nzl = acsr1%get_nzeros() - call psb_glob_to_loc(acsr1%ja(1:nzl),p%desc_ac,info,'I') - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_glob_to_loc') - goto 9999 - end if - call op_prol%mv_from(acsr1) - endif - call op_prol%set_ncols(p%desc_ac%get_local_cols()) - - if (np>1) then - call op_restr%cscnv(info,type='coo',dupl=psb_dupl_add_) - call op_restr%mv_to(acoo) - nzl = acoo%get_nzeros() - if (info == psb_success_) call psb_glob_to_loc(acoo%ia(1:nzl),p%desc_ac,info,'I') - call acoo%set_dupl(psb_dupl_add_) - if (info == psb_success_) call op_restr%mv_from(acoo) - if (info == psb_success_) call op_restr%cscnv(info,type='csr') - if(info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Converting op_restr to local') - goto 9999 - end if - end if - call op_restr%set_nrows(p%desc_ac%get_local_cols()) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ac ' - - case(mld_repl_mat_) - ! - ! - call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) - if (info == psb_success_) call psb_cdasb(p%desc_ac,info) - if (info == psb_success_) & - & call psb_gather(p%ac,ac,p%desc_ac,info,dupl=psb_dupl_add_,keeploc=.false.) - - if (info /= psb_success_) goto 9999 - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_coarse_mat_') - goto 9999 - end select - - call p%ac%cscnv(info,type='csr',dupl=psb_dupl_add_) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv') - goto 9999 - end if - - ! - ! Copy the prolongation/restriction matrices into the descriptor map. - ! op_restr => PR^T i.e. restriction operator - ! op_prol => PR i.e. prolongation operator - ! - - p%map = psb_linmap(psb_map_aggr_,desc_a,& - & p%desc_ac,op_restr,op_prol,ilaggr,nlaggr) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_Free') - goto 9999 - end if -#endif - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - end subroutine mld_d_extaggr_bld - -end subroutine mld_d_extprol_bld diff --git a/mlprec/impl/mld_d_hierarchy_bld.f90 b/mlprec/impl/mld_d_hierarchy_bld.f90 deleted file mode 100644 index 0f0c3756..00000000 --- a/mlprec/impl/mld_d_hierarchy_bld.f90 +++ /dev/null @@ -1,539 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_d_hierarchy_bld.f90 -! -! Subroutine: mld_d_hierarchy_bld -! Version: real -! -! This routine builds the preconditioner according to the requirements made by -! the user trough the subroutines mld_precinit and mld_precset. -! -! A multilevel preconditioner is regarded as an array of 'one-level' data structures, -! each containing the part of the preconditioner associated to a certain level, -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level. No transfer operators are associated to level 1. -! -! -! Arguments: -! a - type(psb_dspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_dprec_type), input/output. -! The preconditioner data structure; upon exit it contains -! the multilevel hierarchy of prolongators, restrictors -! and coarse matrices. -! info - integer, output. -! Error code. -! -subroutine mld_d_hierarchy_bld(a,desc_a,prec,info) - - use psb_base_mod - use mld_d_inner_mod - use mld_d_prec_mod, mld_protect_name => mld_d_hierarchy_bld - - Implicit None - - ! Arguments - type(psb_dspmat_type),intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_dprec_type),intent(inout),target :: prec - integer(psb_ipk_), intent(out) :: info - - ! Local Variables - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz,& - & nplevs, mxplevs - integer(psb_lpk_) :: iaggsize, casize - real(psb_dpk_) :: mnaggratio, sizeratio, athresh, aomega - class(mld_d_base_smoother_type), allocatable :: coarse_sm, med_sm, & - & med_sm2, coarse_sm2 - class(mld_d_base_aggregator_type), allocatable :: tmp_aggr - type(mld_dml_parms) :: medparms, coarseparms - integer(psb_lpk_), allocatable :: ilaggr(:), nlaggr(:) - type(psb_ldspmat_type) :: op_prol - type(mld_d_onelev_type), allocatable :: tprecv(:) - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - integer(psb_ipk_), save :: idx_bldtp=-1, idx_matasb=-1 - logical, parameter :: do_timings=.false. - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_d_hierarchy_bld' - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - prec%ictxt = ictxt - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' - if ((do_timings).and.(idx_bldtp==-1)) & - & idx_bldtp = psb_get_timer_idx("BLD_HIER: bld_tprol") - if ((do_timings).and.(idx_matasb==-1)) & - & idx_matasb = psb_get_timer_idx("BLD_HIER: mmat_asb") - ! - - if (.not.allocated(prec%precv)) then - !! Error: should have called mld_dprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - ! - ! Check to ensure all procs have the same - ! - newsz = -1 - mxplevs = prec%ag_data%max_levs - mnaggratio = prec%ag_data%min_cr_ratio - casize = prec%ag_data%min_coarse_size - iszv = size(prec%precv) - call psb_bcast(ictxt,iszv) - call psb_bcast(ictxt,casize) - call psb_bcast(ictxt,mxplevs) - call psb_bcast(ictxt,mnaggratio) - if (casize /= prec%ag_data%min_coarse_size) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent min_coarse_size') - goto 9999 - end if - if (mxplevs /= prec%ag_data%max_levs) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent max_levs') - goto 9999 - end if - if (mnaggratio /= prec%ag_data%min_cr_ratio) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent min_cr_ratio') - goto 9999 - end if - if (iszv /= size(prec%precv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of precv') - goto 9999 - end if - - if (iszv < 1) then - ! - ! This is wrong, cannot be size <1 - ! - info=psb_err_from_subroutine_ - ch_err='size bpv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - endif - if (iszv == 1) then - ! - ! This is OK, since it may be called by the user even if there - ! is only one level - ! - prec%precv(1)%base_a => a - prec%precv(1)%base_desc => desc_a - - call psb_erractionrestore(err_act) - return - endif - - ! - ! The strategy: - ! 1. The maximum number of levels should be already encoded in the - ! size of the array; - ! 2. If the user did not specify anything, then a default coarse size - ! is generated, and the number of levels is set to the maximum; - ! 3. If the size of the array is different from target number of levels, - ! reallocate; - ! 4. Build the matrix hierarchy, stopping early if either the target - ! coarse size is hit, or the gain falls below the min_cr_ratio - ! threshold. - ! - - if (casize < 0) then - ! - ! Default to the cubic root of the size at base level. - ! - casize = desc_a%get_global_rows() - casize = int((done*casize)**(done/(done*3)),psb_lpk_) - casize = max(casize,lone) - casize = casize*40_psb_lpk_ - call psb_bcast(ictxt,casize) - if (casize > huge(prec%ag_data%min_coarse_size)) then - ! - ! computed coarse size does not fit in IPK_. - ! This is very unlikely, but make sure to put a positive number - ! - prec%ag_data%min_coarse_size = huge(prec%ag_data%min_coarse_size) - else - prec%ag_data%min_coarse_size = casize - end if - end if - nplevs = max(itwo,mxplevs) - - ! - ! The coarse parameters will be needed later - ! - coarseparms = prec%precv(iszv)%parms - call save_smoothers(prec%precv(iszv),coarse_sm,coarse_sm2,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Base level precbuild.') - goto 9999 - end if - ! - ! First set desired number of levels - ! - if (iszv /= nplevs) then - allocate(tprecv(nplevs),stat=info) - ! First all existing levels - do i=1, min(iszv,nplevs) - 1 - if (info == 0) tprecv(i)%parms = prec%precv(i)%parms - if (info == 0) call restore_smoothers(tprecv(i),& - & prec%precv(i)%sm,prec%precv(i)%sm2a,info) - if (info == 0) call move_alloc(prec%precv(i)%aggr,tprecv(i)%aggr) - end do - if (iszv < nplevs) then - ! Further intermediates, if needed - allocate(tmp_aggr,source=tprecv(iszv-1)%aggr,stat=info) - medparms = prec%precv(iszv-1)%parms - call save_smoothers(prec%precv(iszv-1),med_sm,med_sm2,info) - do i=iszv, nplevs - 1 - if (info == 0) tprecv(i)%parms = medparms - if (info == 0) call restore_smoothers(tprecv(i),med_sm,med_sm2,info) - if ((info == 0).and..not.allocated(tprecv(i)%aggr))& - & allocate(tprecv(i)%aggr,source=tmp_aggr,stat=info) - end do - deallocate(tmp_aggr,stat=info) - end if - - ! Then coarse - if (info == 0) tprecv(nplevs)%parms = coarseparms - if (info == 0) call restore_smoothers(tprecv(nplevs),coarse_sm,coarse_sm2,info) - if (info == 0) then - if (nplevs <= iszv) then - allocate(tprecv(nplevs)%aggr,source=prec%precv(nplevs)%aggr,stat=info) - else - allocate(tmp_aggr,source=tprecv(nplevs-1)%aggr,stat=info) - call move_alloc(tmp_aggr,tprecv(nplevs)%aggr) - end if - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - - do i=1,iszv - call prec%precv(i)%free(info) - end do - call move_alloc(tprecv,prec%precv) - iszv = size(prec%precv) - end if - - ! - ! Finest level first; create a GEN_BLOCK - ! copy of the descriptor. - ! - prec%precv(1)%base_a => a - call psb_cd_renum_block(desc_a,prec%precv(1)%desc_ac,info) - prec%precv(1)%base_desc => prec%precv(1)%desc_ac - newsz = 0 - array_build_loop: do i=2, iszv - ! - ! Check on the iprcparm contents: they should be the same - ! on all processes. - ! - call psb_bcast(ictxt,prec%precv(i)%parms) - - ! - ! Sanity checks on the parameters - ! - if (i= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Calling mlprcbld at level ',i - ! - ! Build the mapping between levels i-1 and i and the matrix - ! at level i - ! - if (do_timings) call psb_tic(idx_bldtp) - if (info == psb_success_)& - & call prec%precv(i)%bld_tprol(prec%precv(i-1)%base_a,& - & prec%precv(i-1)%base_desc,& - & ilaggr,nlaggr,op_prol,prec%ag_data,info) - if (do_timings) call psb_toc(idx_bldtp) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Map build') - goto 9999 - endif - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Return from ',i,' call to bld_tprol', info - ! - ! Save op_prol just in case - ! - call op_prol%clone(prec%precv(i)%tprol,info) - ! - ! Check for early termination of aggregation loop. - ! - iaggsize = sum(nlaggr) - - sizeratio = iaggsize - if (i==2) then - sizeratio = desc_a%get_global_rows()/sizeratio - else - sizeratio = sum(prec%precv(i-1)%map%naggr)/sizeratio - end if - prec%precv(i)%szratio = sizeratio - - if (iaggsize <= casize) newsz = i - if (i == iszv) newsz = i - - if (i>2) then - if (sizeratio < mnaggratio) then - if (sizeratio > 1) then - newsz = i - else - ! - ! We are not gaining - ! - newsz = i-1 - end if - end if - - if (all(nlaggr == prec%precv(i-1)%map%naggr)) then - newsz=i-1 - if (me == 0) then - write(debug_unit,*) trim(name),& - &': Warning: aggregates from level ',& - & newsz - write(debug_unit,*) trim(name),& - &': to level ',& - & iszv,' coincide.' - write(debug_unit,*) trim(name),& - &': Number of levels actually used :',newsz - write(debug_unit,*) - end if - end if - end if - call psb_bcast(ictxt,newsz) - - if (newsz > 0) then - ! - ! This is awkward, we are saving the aggregation parms, for the sake - ! of distr/repl matrix at coarse level. Should be rethought. - ! - athresh = prec%precv(newsz)%parms%aggr_thresh - aomega = prec%precv(newsz)%parms%aggr_omega_val - if (info == 0) prec%precv(newsz)%parms = coarseparms - prec%precv(newsz)%parms%aggr_thresh = athresh - prec%precv(newsz)%parms%aggr_omega_val = aomega - - if (info == 0) call restore_smoothers(prec%precv(newsz),& - & coarse_sm,coarse_sm2,info) - if (newsz < i) then - ! - ! We are going back and revisit a previous leve; - ! recover the aggregation. - ! - ilaggr = prec%precv(newsz)%map%iaggr - nlaggr = prec%precv(newsz)%map%naggr - call prec%precv(newsz)%tprol%clone(op_prol,info) - end if - if (do_timings) call psb_tic(idx_matasb) - if (info == psb_success_) call prec%precv(newsz)%mat_asb( & - & prec%precv(newsz-1)%base_a,prec%precv(newsz-1)%base_desc,& - & ilaggr,nlaggr,op_prol,info) - if (do_timings) call psb_toc(idx_matasb) - if (info /= 0) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Mat asb') - goto 9999 - endif - exit array_build_loop - else - if (do_timings) call psb_tic(idx_matasb) - if (info == psb_success_) call prec%precv(i)%mat_asb(& - & prec%precv(i-1)%base_a,prec%precv(i-1)%base_desc,& - & ilaggr,nlaggr,op_prol,info) - if (do_timings) call psb_toc(idx_matasb) - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Map build') - goto 9999 - endif - if (i 0) then - ! - ! We exited early from the build loop, need to fix - ! the size. - ! - allocate(tprecv(newsz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - do i=1,newsz - call prec%precv(i)%move_alloc(tprecv(i),info) - end do - do i=newsz+1, iszv - call prec%precv(i)%free(info) - end do - call move_alloc(tprecv,prec%precv) - ! Ignore errors from transfer - info = psb_success_ - ! - ! Restart - iszv = newsz - ! Fix the pointers, but the level 1 should - ! be treated differently - if (.not.associated(prec%precv(1)%base_desc,desc_a)) then - prec%precv(1)%base_desc => prec%precv(1)%desc_ac - end if - do i=2, iszv - prec%precv(i)%base_a => prec%precv(i)%ac - prec%precv(i)%base_desc => prec%precv(i)%desc_ac - prec%precv(i)%map%p_desc_U => prec%precv(i-1)%base_desc - prec%precv(i)%map%p_desc_V => prec%precv(i)%base_desc - end do - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Internal hierarchy build' ) - goto 9999 - endif - - iszv = size(prec%precv) - - call prec%cmp_complexity() - call prec%cmp_avg_cr() - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Exiting with',iszv,' levels' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - subroutine save_smoothers(level,save1, save2,info) - type(mld_d_onelev_type), intent(inout) :: level - class(mld_d_base_smoother_type), allocatable , intent(inout) :: save1, save2 - integer(psb_ipk_), intent(out) :: info - - info = 0 - if (allocated(save1)) then - call save1%free(info) - if (info == 0) deallocate(save1,stat=info) - if (info /= 0) return - end if - if (allocated(save2)) then - call save2%free(info) - if (info == 0) deallocate(save2,stat=info) - if (info /= 0) return - end if - allocate(save1, mold=level%sm,stat=info) - if (info == 0) call level%sm%clone_settings(save1,info) - if ((info == 0).and.allocated(level%sm2a)) then - allocate(save2, mold=level%sm2a,stat=info) - if (info == 0) call level%sm2a%clone_settings(save2,info) - end if - - return - end subroutine save_smoothers - - subroutine restore_smoothers(level,save1, save2,info) - type(mld_d_onelev_type), intent(inout), target :: level - class(mld_d_base_smoother_type), allocatable, intent(inout) :: save1, save2 - integer(psb_ipk_), intent(out) :: info - - info = 0 - - if (allocated(level%sm)) then - if (info == 0) call level%sm%free(info) - if (info == 0) deallocate(level%sm,stat=info) - end if - if (allocated(save1)) then - if (info == 0) allocate(level%sm,mold=save1,stat=info) - if (info == 0) call save1%clone_settings(level%sm,info) - end if - - if (info /= 0) return - - if (allocated(level%sm2a)) then - if (info == 0) call level%sm2a%free(info) - if (info == 0) deallocate(level%sm2a,stat=info) - end if - if (allocated(save2)) then - if (info == 0) allocate(level%sm2a,mold=save2,stat=info) - if (info == 0) call save2%clone_settings(level%sm2a,info) - if (info == 0) level%sm2 => level%sm2a - else - if (allocated(level%sm)) level%sm2 => level%sm - end if - - return - end subroutine restore_smoothers - -end subroutine mld_d_hierarchy_bld diff --git a/mlprec/impl/mld_d_smoothers_bld.f90 b/mlprec/impl/mld_d_smoothers_bld.f90 deleted file mode 100644 index b2ac13e1..00000000 --- a/mlprec/impl/mld_d_smoothers_bld.f90 +++ /dev/null @@ -1,313 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_d_smoothers_bld.f90 -! -! Subroutine: mld_d_smoothers_bld -! Version: real -! -! This routine performs the final phase of the multilevel preconditioner -! build process: builds the "smoother" objects at each level, -! based on the matrix hierarchy prepared by mld_d_hierarchy_bld. -! -! A multilevel preconditioner is regarded as an array of 'one-level' -! data structures, each containing the part of the -! preconditioner associated to a certain level, -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level. No transfer operators are associated to level 1. -! Each level provides a "build" method; for the base type, the "one-level" -! build procedure simply invokes the build method of the first smoother object, -! and also on the second object if allocated. -! -! -! Arguments: -! a - type(psb_dspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_dprec_type), input/output. -! The preconditioner data structure containing the local part -! of the preconditioner to be built. -! info - integer, output. -! Error code. -! -! amold - class(psb_d_base_sparse_mat), input, optional -! Mold for the inner format of matrices contained in the -! preconditioner -! -! -! vmold - class(psb_d_base_vect_type), input, optional -! Mold for the inner format of vectors contained in the -! preconditioner -! -! -! -subroutine mld_d_smoothers_bld(a,desc_a,prec,info,amold,vmold,imold) - - use psb_base_mod - !use mld_d_inner_mod - use mld_d_prec_mod, mld_protect_name => mld_d_smoothers_bld - - Implicit None - - ! Arguments - type(psb_dspmat_type),intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_dprec_type),intent(inout),target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local Variables - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, nplevs, mxplevs - real(psb_dpk_) :: mnaggratio - integer(psb_ipk_) :: coarse_solve_id - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_d_smoothers_bld' - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' - ! - if (.not.allocated(prec%precv)) then - !! Error: should have called mld_dprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - ! - ! Check to ensure all procs have the same - ! - iszv = size(prec%precv) - call psb_bcast(ictxt,iszv) - if (iszv /= size(prec%precv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of precv') - goto 9999 - end if - - if (iszv < 1) then - ! We should never get here. - info=psb_err_from_subroutine_ - ch_err='size bpv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - endif - - ! - ! Issue a warning for inconsistent changes to COARSE_SOLVE - ! but only if it really is a multilevel - ! - if ((me == psb_root_).and.(iszv>1)) then - coarse_solve_id = prec%precv(iszv)%parms%coarse_solve - select case (coarse_solve_id) - case(mld_umf_,mld_slu_) - if (prec%precv(iszv)%sm%sv%get_id() /= coarse_solve_id) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id) - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) then - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else if (prec%precv(iszv)%parms%coarse_mat == mld_distr_mat_) then - write(psb_err_unit,*) ' but I am building BJAC with ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - end if - write(psb_err_unit,*) 'This may happen if: ' - write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' - write(psb_err_unit,*) ' 2. the solver ', mld_fact_names(coarse_solve_id),& - & ' was not configured at MLD2P4 build time, or' - write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' - end if - if (prec%precv(iszv)%parms%coarse_mat /= mld_repl_mat_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse matrix was requested as replicated', & - & ' but it has been changed to distributed.' - end if - - case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) - if (prec%precv(iszv)%sm%sv%get_id() /= psb_ilu_n_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id) - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) then - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else if (prec%precv(iszv)%parms%coarse_mat == mld_distr_mat_) then - write(psb_err_unit,*) ' but I am building BJAC with ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - end if - write(psb_err_unit,*) & - &'This may happen if coarse_subsolve has been reset' - end if - if (prec%precv(iszv)%parms%coarse_mat /= mld_repl_mat_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id),& - & ' but the coarse matrix has been changed to distributed' - end if - - case(mld_mumps_) - if (prec%precv(iszv)%sm%sv%get_id() /= mld_mumps_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id) - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) then - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else if (prec%precv(iszv)%parms%coarse_mat == mld_distr_mat_) then - write(psb_err_unit,*) ' but I am building BJAC with ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - end if - write(psb_err_unit,*) 'This may happen if: ' - write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' - write(psb_err_unit,*) ' 2. the solver ', mld_fact_names(coarse_solve_id),& - & ' was not configured at MLD2P4 build time, or' - write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' - end if - - case(mld_sludist_) - if (prec%precv(iszv)%sm%sv%get_id() /= coarse_solve_id) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id) - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) then - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else if (prec%precv(iszv)%parms%coarse_mat == mld_distr_mat_) then - write(psb_err_unit,*) ' but I am building BJAC with ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - end if - write(psb_err_unit,*) 'This may happen if: ' - write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' - write(psb_err_unit,*) ' 2. the solver ', mld_fact_names(coarse_solve_id), & - & ' was not configured at MLD2P4 build time, or' - write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' - end if - if (prec%precv(iszv)%parms%coarse_mat /= mld_distr_mat_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id),& - & ' but the coarse matrix has been changed to replicated' - end if - - case(mld_bjac_,mld_l1_bjac_,mld_jac_, mld_l1_jac_, mld_gs_, mld_fbgs_, mld_l1_gs_,mld_l1_fbgs_) - if (prec%precv(iszv)%parms%coarse_mat /= mld_distr_mat_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id),& - & ' but the coarse matrix has been changed to replicated' - end if - - case default - ! We should never get here. - info=psb_err_from_subroutine_ - ch_err='unkn coarse_solve' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - - end select - end if - - ! Sanity check: need to ensure that the MUMPS local/global NZ - ! are handled correctly; this is controlled by local vs global solver. - ! From this point of view, REPL is LOCAL because it owns everyting. - ! Should really find a better way of handling this. - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) & - & call prec%precv(iszv)%sm%sv%set('MUMPS_LOC_GLOB', mld_local_solver_,info) - ! - ! Now do the real build. - ! - - do i=1, iszv - ! - ! build the base preconditioner at level i - ! - call prec%precv(i)%bld(info,amold=amold,vmold=vmold,imold=imold,ilv=i) - - if (info /= psb_success_) then - write(ch_err,'(a,i7)') 'Error @ level',i - call psb_errpush(psb_err_internal_error_,name,& - & a_err=ch_err) - goto 9999 - endif - - end do - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Exiting with',iszv,' levels' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_smoothers_bld diff --git a/mlprec/impl/mld_dcprecset.F90 b/mlprec/impl/mld_dcprecset.F90 deleted file mode 100644 index d92d68d7..00000000 --- a/mlprec/impl/mld_dcprecset.F90 +++ /dev/null @@ -1,1038 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_dprecset.f90 -! -! Subroutine: mld_dprecseti -! Version: real -! -! This routine sets the integer parameters defining the preconditioner. More -! precisely, the integer parameter identified by 'what' is assigned the value -! contained in 'val'. -! For the multilevel preconditioners, the levels are numbered in increasing -! order starting from the finest one, i.e. level 1 is the finest level. -! -! To set character and real parameters, see mld_dprecsetc and mld_dprecsetr, -! respectively. -! -! -! Arguments: -! p - type(mld_dprec_type), input/output. -! The preconditioner data structure. -! what - integer, input. -! The number identifying the parameter to be set. -! A mnemonic constant has been associated to each of these -! numbers, as reported in the MLD2P4 User's and Reference Guide. -! val - integer, input. -! The value of the parameter to be set. The list of allowed -! values is reported in the MLD2P4 User's and Reference Guide. -! info - integer, output. -! Error code. -! ilev - integer, optional, input. -! For the multilevel preconditioner, the level at which the -! preconditioner parameter has to be set. -! If nlev is not present, the parameter identified by 'what' -! is set at all the appropriate levels. -! -! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to -! MLD2P4 developers. Indeed, by using ilev it is possible to set different values -! of the same parameter at different levels 1,...,nlev-1, even in cases where -! the parameter must have the same value at all the levels but the coarsest one. -! For this reason, the interface mld_precset to this routine has been built in -! such a way that ilev is not visible to the user (see mld_prec_mod.f90). -! -subroutine mld_dcprecseti(p,what,val,info,ilev,ilmax,pos,idx) - - use psb_base_mod - use mld_d_prec_mod, mld_protect_name => mld_dcprecseti - use mld_d_jac_smoother - use mld_d_as_smoother - use mld_d_diag_solver - use mld_d_l1_diag_solver - use mld_d_ilu_solver - use mld_d_id_solver - use mld_d_gs_solver -#if defined(HAVE_UMF_) - use mld_d_umf_solver -#endif -#if defined(HAVE_SLUDIST_) - use mld_d_sludist_solver -#endif -#if defined(HAVE_SLU_) - use mld_d_slu_solver -#endif -#if defined(HAVE_MUMPS_) - use mld_d_mumps_solver -#endif - - - implicit none - - ! Arguments - class(mld_dprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_, ilmax_, il - character(len=*), parameter :: name='mld_precseti' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmax_ = nlev_ - end if - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - select case(psb_toupper(what)) - case ('MIN_COARSE_SIZE') - p%ag_data%min_coarse_size = max(val,-1) - return - case('MAX_LEVS') - p%ag_data%max_levs = max(val,1) - return - case ('OUTER_SWEEPS') - p%outer_sweeps = max(val,1) - return - end select - - ! - ! Set preconditioner parameters at level ilev. - ! - if (present(ilev)) then - - select case(psb_toupper(what)) - case('SMOOTHER_TYPE','SUB_SOLVE','SMOOTHER_SWEEPS',& - & 'ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD',& - & 'AGGR_TYPE','AGGR_PROL','AGGR_OMEGA_ALG',& - & 'AGGR_EIG','SUB_RESTR','SUB_PROL', & - & 'SUB_OVR','SUB_FILLIN',& - & 'COARSE_MAT') - do il=ilev_, ilmax_ - call p%precv(il)%set(what,val,info,pos=pos) - end do - - case('COARSE_SUBSOLVE') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - call p%precv(ilev_)%set('SUB_SOLVE',val,info,pos=pos) - case('COARSE_SOLVE') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_SOLVE',val,info,pos=pos) - select case (val) - case(mld_bjac_,mld_l1_bjac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',val,info,pos=pos) -#if defined(HAVE_UMF_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_umf_,info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) -#else - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) -#endif - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info) - case(mld_slu_) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) - case(mld_mumps_) -#if defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(mld_umf_) -#if defined(HAVE_UMF_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - - case(mld_sludist_) -#if defined(HAVE_SLUDIST_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#elif defined(HAVE_UMF_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_umf_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(mld_jac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_diag_scale_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - - case(mld_l1_jac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_l1_diag_scale_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_gs_,mld_fbgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_gs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_bwgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_bwgs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_l1_gs_,mld_l1_fbgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_l1_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_gs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - end select - - endif - case('COARSE_SWEEPS') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - call p%precv(nlev_)%set('SMOOTHER_SWEEPS',val,info,pos=pos) - - case('COARSE_FILLIN') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - call p%precv(nlev_)%set('SUB_FILLIN',val,info,pos=pos) - - case default - do il=ilev_, ilmax_ - call p%precv(il)%set(what,val,info,pos=pos,idx=idx) - end do - end select - - - else if (.not.present(ilev)) then - ! - ! ilev not specified: set preconditioner parameters at all the appropriate - ! levels - ! - select case(psb_toupper(trim(what))) - case('SUB_SOLVE','SUB_RESTR','SUB_PROL',& - & 'SUB_OVR','SUB_FILLIN',& - & 'SMOOTHER_SWEEPS','SMOOTHER_TYPE') - do ilev_=1,max(1,nlev_-1) - call p%precv(ilev_)%set(what,val,info,pos=pos) - if (info /= 0) return - end do - - case('ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD','AGGR_PROL','AGGR_TYPE',& - & 'AGGR_OMEGA_ALG','AGGR_EIG','AGGR_FILTER') - do ilev_=1,nlev_ - call p%precv(ilev_)%set(what,val,info,pos=pos) - if (info /= 0) return - end do - - case('COARSE_MAT') - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_MAT',val,info,pos=pos) - end if - - case('COARSE_SOLVE') - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_SOLVE',val,info,pos=pos) - select case (val) - case(mld_bjac_,mld_l1_bjac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',val,info,pos=pos) -#if defined(HAVE_UMF_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_umf_,info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) -#else - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) -#endif - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info) - case(mld_slu_) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) - case(mld_mumps_) -#if defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(mld_umf_) -#if defined(HAVE_UMF_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - - case(mld_sludist_) -#if defined(HAVE_SLUDIST_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#elif defined(HAVE_UMF_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_umf_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(mld_jac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_diag_scale_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - - case(mld_l1_jac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_l1_diag_scale_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_gs_,mld_fbgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_gs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_bwgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_bwgs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_l1_gs_,mld_l1_fbgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_l1_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_gs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - end select - endif - - case('COARSE_SUBSOLVE') - if (nlev_ > 1) then - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - endif - - case('COARSE_SWEEPS') - - if (nlev_ > 1) then - call p%precv(nlev_)%set('SMOOTHER_SWEEPS',val,info,pos=pos) - end if - - case('COARSE_FILLIN') - if (nlev_ > 1) then - call p%precv(nlev_)%set('SUB_FILLIN',val,info,pos=pos) - end if - - case default - do ilev_=1,nlev_ - call p%precv(ilev_)%set(what,val,info,pos=pos,idx=idx) - end do - end select - - endif - -end subroutine mld_dcprecseti - -! -! Subroutine: mld_dprecsetc -! Version: real -! -! This routine sets the character parameters defining the preconditioner. More -! precisely, the character parameter identified by 'what' is assigned the value -! contained in 'val'. -! For the multilevel preconditioners, the levels are numbered in increasing -! order starting from the finest one, i.e. level 1 is the finest level. -! -! To set integer and real parameters, see mld_dprecseti and mld_dprecsetr, -! respectively. -! -! -! Arguments: -! p - type(mld_dprec_type), input/output. -! The preconditioner data structure. -! what - integer, input. -! The number identifying the parameter to be set. -! A mnemonic constant has been associated to each of these -! numbers, as reported in the MLD2P4 User's and Reference Guide. -! string - character(len=*), input. -! The value of the parameter to be set. The list of allowed -! values is reported in the MLD2P4 User's and Reference Guide. -! info - integer, output. -! Error code. -! ilev - integer, optional, input. -! For the multilevel preconditioner, the level at which the -! preconditioner parameter has to be set. -! If nlev is not present, the parameter identified by 'what' -! is set at all the appropriate levels. -! -! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to -! MLD2P4 developers. Indeed, by using ilev it is possible to set different values -! of the same parameter at different levels 1,...,nlev-1, even in cases where -! the parameter must have the same value at all the levels but the coarsest one. -! For this reason, the interface mld_precset to this routine has been built in -! such a way that ilev is not visible to the user (see mld_prec_mod.f90). -! -subroutine mld_dcprecsetc(p,what,string,info,ilev,ilmax,pos,idx) - - use psb_base_mod - use mld_d_prec_mod, mld_protect_name => mld_dcprecsetc - use mld_d_jac_smoother - use mld_d_as_smoother - use mld_d_diag_solver - use mld_d_l1_diag_solver - use mld_d_ilu_solver - use mld_d_id_solver - use mld_d_gs_solver -#if defined(HAVE_UMF_) - use mld_d_umf_solver -#endif -#if defined(HAVE_SLUDIST_) - use mld_d_sludist_solver -#endif -#if defined(HAVE_SLU_) - use mld_d_slu_solver -#endif -#if defined(HAVE_MUMPS_) - use mld_d_mumps_solver -#endif - - - implicit none - - ! Arguments - class(mld_dprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - character(len=*), intent(in) :: string - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_,val,ilmax_, il - character(len=*), parameter :: name='mld_precsetc' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmax_ = nlev_ - end if - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - ! - ! Set preconditioner parameters at level ilev. - ! - if (present(ilev)) then - - select case(psb_toupper(what)) - case('SMOOTHER_TYPE','SUB_SOLVE',& - & 'ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD',& - & 'AGGR_TYPE','AGGR_PROL','AGGR_OMEGA_ALG',& - & 'AGGR_EIG','SUB_RESTR','SUB_PROL', & - & 'COARSE_MAT') - do il=ilev_, ilmax_ - call p%precv(il)%set(what,string,info,pos=pos) - end do - - case('COARSE_SUBSOLVE') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - call p%precv(ilev_)%set('SUB_SOLVE',string,info,pos=pos) - case('COARSE_SOLVE') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_SOLVE',string,info,pos=pos) - select case (psb_toupper(trim(string))) - case('BJAC', 'L1-BJAC') - call p%precv(nlev_)%set('SMOOTHER_TYPE',psb_toupper(trim(string)),info,pos=pos) -#if defined(HAVE_UMF_) - call p%precv(nlev_)%set('SUB_SOLVE','UMF',info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) -#else - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) -#endif - call p%precv(nlev_)%set('COARSE_MAT','dist',info) - case('SLU') -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('ILU','MILU','ILUT') - call p%precv(nlev_)%set('SMOOTHER_TYPE','bjac',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) - case('MUMPS') -#if defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('UMF') -#if defined(HAVE_UMF_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('SLUDIST') -#if defined(HAVE_SLUDIST_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#elif defined(HAVE_UMF_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','UMF',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('JAC','JACOBI') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','DIAG',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - - case('L1-JACOBI') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','L1-DIAG',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('GS','FWGS','FBGS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('BWGS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','BWGS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('L1-GS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','L1-BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - end select - - endif - - case default - do il=ilev_, ilmax_ - call p%precv(il)%set(what,string,info,pos=pos,idx=idx) - end do - end select - - - else if (.not.present(ilev)) then - ! - ! ilev not specified: set preconditioner parameters at all the appropriate - ! levels - ! - select case(psb_toupper(trim(what))) - case('SUB_SOLVE','SUB_RESTR','SUB_PROL',& - & 'SMOOTHER_TYPE') - do ilev_=1,max(1,nlev_-1) - call p%precv(ilev_)%set(what,string,info,pos=pos) - if (info /= 0) return - end do - - case('ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD','AGGR_PROL','AGGR_TYPE',& - & 'AGGR_OMEGA_ALG','AGGR_EIG','AGGR_FILTER') - do ilev_=1,nlev_ - call p%precv(ilev_)%set(what,string,info,pos=pos) - if (info /= 0) return - end do - - case('COARSE_MAT') - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_MAT',string,info,pos=pos) - end if - - case('COARSE_SOLVE') - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_SOLVE',string,info,pos=pos) - select case (psb_toupper(trim(string))) - case('BJAC', 'L1-BJAC') - call p%precv(nlev_)%set('SMOOTHER_TYPE',psb_toupper(trim(string)),info,pos=pos) -#if defined(HAVE_UMF_) - call p%precv(nlev_)%set('SUB_SOLVE','UMF',info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) -#else - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) -#endif - call p%precv(nlev_)%set('COARSE_MAT','DIST',info) - case('SLU') -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('ILU', 'ILUT','MILU') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) - case('MUMPS') -#if defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('UMF') -#if defined(HAVE_UMF_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - - case('SLUDIST') -#if defined(HAVE_SLUDIST_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#elif defined(HAVE_UMF_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','UMF',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('JAC','JACOBI') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','DIAG',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('L1-JACOBI') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','L1-DIAG',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('GS','FWGS','FBGS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('BWGS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','BWGS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('L1-GS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','L1-BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - end select - endif - - case('COARSE_SUBSOLVE') - if (nlev_ > 1) then - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - endif - - case default - do ilev_=1,nlev_ - call p%precv(ilev_)%set(what,string,info,pos=pos,idx=idx) - end do - end select - - endif - - -end subroutine mld_dcprecsetc - - -! -! Subroutine: mld_dprecsetr -! Version: real -! -! This routine sets the real parameters defining the preconditioner. More -! precisely, the real parameter identified by 'what' is assigned the value -! contained in 'val'. -! For the multilevel preconditioners, the levels are numbered in increasing -! order starting from the finest one, i.e. level 1 is the finest level. -! -! To set integer and character parameters, see mld_dprecseti and mld_dprecsetc, -! respectively. -! -! Arguments: -! p - type(mld_dprec_type), input/output. -! The preconditioner data structure. -! what - integer, input. -! The number identifying the parameter to be set. -! A mnemonic constant has been associated to each of these -! numbers, as reported in the MLD2P4 User's and Reference Guide. -! val - real(psb_dpk_), input. -! The value of the parameter to be set. The list of allowed -! values is reported in the MLD2P4 User's and Reference Guide. -! info - integer, output. -! Error code. -! ilev - integer, optional, input. -! For the multilevel preconditioner, the level at which the -! preconditioner parameter has to be set. -! If nlev is not present, the parameter identified by 'what' -! is set at all the appropriate levels. -! -! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to -! MLD2P4 developers. Indeed, by using ilev it is possible to set different values -! of the same parameter at different levels 1,...,nlev-1, even in cases where -! the parameter must have the same value at all the levels but the coarsest one. -! For this reason, the interface mld_precset to this routine has been built in -! such a way that ilev is not visible to the user (see mld_prec_mod.f90). -! -subroutine mld_dcprecsetr(p,what,val,info,ilev,ilmax,pos,idx) - - use psb_base_mod - use mld_d_prec_mod, mld_protect_name => mld_dcprecsetr - - implicit none - - ! Arguments - class(mld_dprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - - ! Local variables - integer(psb_ipk_) :: ilev_,nlev_, ilmax_, il - real(psb_dpk_) :: thr - character(len=*), parameter :: name='mld_precsetr' - - info = psb_success_ - - if (present(ilev)) then - ilev_ = ilev - else - ilev_ = 1 - end if - - select case(psb_toupper(what)) - case ('MIN_CR_RATIO') - p%ag_data%min_cr_ratio = max(done,val) - return - end select - - if (.not.allocated(p%precv)) then - write(psb_err_unit,*) name,& - &': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - info = 3111 - return - endif - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmax_ = nlev_ - end if - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - - ! - ! Set preconditioner parameters at level ilev. - ! - if (present(ilev)) then - - do il=ilev_, ilmax_ - call p%precv(il)%set(what,val,info,pos=pos,idx=idx) - end do - - else if (.not.present(ilev)) then - ! - ! ilev not specified: set preconditioner parameters at all the appropriate levels - ! - - select case(psb_toupper(what)) - case('COARSE_ILUTHRS') - ilev_=nlev_ - call p%precv(ilev_)%set('SUB_ILUTHRS',val,info,pos=pos) - - case default - - do il=1,nlev_ - call p%precv(il)%set(what,val,info,pos=pos,idx=idx) - end do - end select - - endif - -end subroutine mld_dcprecsetr - - diff --git a/mlprec/impl/mld_dfile_prec_descr.f90 b/mlprec/impl/mld_dfile_prec_descr.f90 deleted file mode 100644 index d2c3735b..00000000 --- a/mlprec/impl/mld_dfile_prec_descr.f90 +++ /dev/null @@ -1,199 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_dfile_prec_descr.f90 -! -! -! Subroutine: mld_file_prec_descr -! Version: real -! -! This routine prints a description of the preconditioner to the standard -! output or to a file. It must be called after the preconditioner has been -! built by mld_precbld. -! -! Arguments: -! p - type(mld_Tprec_type), input. -! The preconditioner data structure to be printed out. -! info - integer, output. -! error code. -! iout - integer, input, optional. -! The id of the file where the preconditioner description -! will be printed. If iout is not present, then the standard -! output is condidered. -! root - integer, input, optional. -! The id of the process printing the message; -1 acts as a wildcard. -! Default is psb_root_ -! -subroutine mld_dfile_prec_descr(prec,iout,root) - use psb_base_mod - use mld_d_prec_mod, mld_protect_name => mld_dfile_prec_descr - use mld_d_inner_mod - use mld_d_gs_solver - - implicit none - ! Arguments - class(mld_dprec_type), intent(in) :: prec - integer(psb_ipk_), intent(in), optional :: iout - integer(psb_ipk_), intent(in), optional :: root - - ! Local variables - integer(psb_ipk_) :: ilev, nlev, ilmin, info, nswps - integer(psb_ipk_) :: ictxt, me, np - logical :: is_symgs - character(len=20), parameter :: name='mld_file_prec_descr' - integer(psb_ipk_) :: iout_ - integer(psb_ipk_) :: root_ - - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - end if - if (iout_ < 0) iout_ = psb_out_unit - - ictxt = prec%ictxt - - if (allocated(prec%precv)) then - - call psb_info(ictxt,me,np) - if (present(root)) then - root_ = root - else - root_ = psb_root_ - end if - if (root_ == -1) root_ = me - - ! - ! The preconditioner description is printed by processor psb_root_. - ! This agrees with the fact that all the parameters defining the - ! preconditioner have the same values on all the procs (this is - ! ensured by mld_precbld). - ! - if (me == root_) then - nlev = size(prec%precv) - do ilev = 1, nlev - if (.not.allocated(prec%precv(ilev)%sm)) then - info = 3111 - write(iout_,*) ' ',name,& - & ': error: inconsistent MLPREC part, should call MLD_PRECINIT' - return - endif - end do - - write(iout_,*) - write(iout_,'(a)') 'Preconditioner description' - - if (nlev == 1) then - ! - ! Here we have a gigantic kludge just to handle Symmetrized Gauss-Seidel. - ! Will need rethinking... - ! - if (allocated(prec%precv(1)%sm2a)) then - is_symgs = .false. - select type(sv2 => prec%precv(1)%sm2a%sv) - class is (mld_d_bwgs_solver_type) - select type(sv1 => prec%precv(1)%sm%sv) - class is (mld_d_gs_solver_type) - is_symgs = .true. - end select - end select - if (is_symgs) then - write(iout_,*) ' Forward-Backward (symmetrized) Hybrid Gauss-Seidel' - else - write(iout_,*) 'Pre Smoother: ' - call prec%precv(1)%sm%descr(info,iout=iout_) - write(iout_,*) 'Post smoother:' - call prec%precv(1)%sm2a%descr(info,iout=iout_) - end if - nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) - - else - call prec%precv(1)%sm%descr(info,iout=iout_) - nswps = prec%precv(1)%parms%sweeps_pre - end if - if (nswps > 1) write(iout_,*) ' Number of sweeps : ',nswps - write(iout_,*) - - else if (nlev > 1) then - ! - ! Print description of base preconditioner - ! - write(iout_,*) 'Multilevel Preconditioner' - write(iout_,*) 'Outer sweeps:',prec%outer_sweeps - write(iout_,*) - if (allocated(prec%precv(1)%sm2a)) then - write(iout_,*) 'Pre Smoother: ' - call prec%precv(1)%sm%descr(info,iout=iout_) - write(iout_,*) 'Post smoother:' - call prec%precv(1)%sm2a%descr(info,iout=iout_) - else - write(iout_,*) 'Smoother: ' - call prec%precv(1)%sm%descr(info,iout=iout_) - end if - ! - ! Print multilevel details - ! - write(iout_,*) - write(iout_,*) 'Multilevel hierarchy: ' - write(iout_,*) ' Number of levels : ',nlev - write(iout_,*) ' Operator complexity: ',prec%get_complexity() - write(iout_,*) ' Average coarsening : ',prec%get_avg_cr() - ilmin = 2 - if (nlev == 2) ilmin=1 - do ilev=ilmin,nlev - call prec%precv(ilev)%descr(ilev,nlev,ilmin,info,iout=iout_) - end do - write(iout_,*) - - else - write(iout_,*) trim(name), & - & ': invalid preconditioner array size ?',nlev - info = -2 - return - - end if - end if - - else - write(iout_,*) trim(name), & - & ': Error: no base preconditioner available, something is wrong!' - info = -2 - return - endif - -end subroutine mld_dfile_prec_descr diff --git a/mlprec/impl/mld_dmlprec_aply.f90 b/mlprec/impl/mld_dmlprec_aply.f90 deleted file mode 100644 index 987807e0..00000000 --- a/mlprec/impl/mld_dmlprec_aply.f90 +++ /dev/null @@ -1,1669 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_dmlprec_aply.f90 -! -! Subroutine: mld_dmlprec_aply -! Version: real -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -! This routine computes -! -! Y = beta*Y + alpha*op(ML^(-1))*X, -! where -! - ML is a multilevel preconditioner associated with -! a certain matrix A and stored in p, -! - op(ML^(-1)) is ML^(-1) or its transpose, according to the value of trans, -! - X and Y are vectors, -! - alpha and beta are scalars. -! -! The following multilevel strategies can be applied: -! -! - Additive multilevel Schwarz, -! - classical V-cycle, -! - classical W-cycle, -! - K-cycle both for symmetric and nonsymmetric matrices, where 2 iterations -! of FCG(1) or GCR, respectively, are applied at each level -! except the coarsest. -! -! For each level we have as many submatrices as processes (except for the coarsest -! level where we might have a replicated index space) and each process takes care -! of one submatrix. -! -! A multilevel preconditioner is regarded as an array of 'one-level' data structures, -! each containing the part of the preconditioner associated to a certain level -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! For each level lev, there is a smoother stored in -! p%precv(lev)%sm -! which in turn contains a solver -! p$precv(lev)%sm%sv -! Typically the solver acts only locally, and the smoother applies any required -! parallel communication/action. -! Each level has a matrix A(lev), obtained by 'tranferring' the original -! matrix A (i.e. the matrix to be preconditioned) to the level lev, through smoothed -! aggregation. -! -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level and A(1) is the matrix A. -! -! This routine is formulated in a recursive way, so it is quite compact. -! -! The V-cycle can be described as follows, where -! P(lev) denotes the smoothed prolongator from level lev to level -! lev-1, while R(lev) denotes the corresponding restriction operator -! (normally its transpose) from level lev-1 to level lev. -! M(lev) is the smoother at the current level. -! -! -! 1. Transfer the outer vector Xest to u(1) (inner X at level 1) -! -! 2. Invoke V-cycle(1,M,P,R,A,b,u) -! -! procedure V-cycle(lev,M,P,R,A,b,u) -! -! if (lev < nlev) then -! -! u(lev) = u(lev) + M(lev)*(b(lev)-A(lev)*u(lev)) -! -! b(lev+1) = R(lev+1)*(b(lev)-A(lev)*u(lev)) -! -! u(lev+1) = V-cycle(lev+1,M,P,R,A,b,u) -! -! u(lev) = u(lev) + P(lev+1) * u(lev+1) -! -! u(lev) = u(lev) + M(lev)*(b(lev)-A(lev)*u(lev)) -! -! else -! -! solve A(lev)*u(lev) = b(lev) -! -! end if -! -! return u(lev) -! end -! -! 3. Transfer u(1) to the external: -! Yext = beta*Yext + alpha*u(1) -! -! -! In the implementation, the recursive procedure is inner_ml_aply, which -! in turn uses mld_inner_add (for additive multilevel), -! mld_inner_mult (for V-cycle and W-cycle), and -! mld_inner_k_cycle (for symmetric and non-symmetric K-cycle). -! -! For a detailed description of the algorithms, see: -! -! - B.F. Smith, P.E. Bjorstad, W.D. Gropp, -! Domain decomposition: parallel multilevel methods for elliptic partial -! differential equations, Cambridge University Press, 1996. -! -! - W. L. Briggs, V. E. Henson, S. F. McCormick, -! A Multigrid Tutorial, Second Edition -! SIAM, 2000. -! -! - K. Stuben, -! An Introduction to Algebraic Multigrid, -! in A. Schuller, U. Trottenberg, C. Oosterlee, Multigrid, Academic Press, 2001. -! -! - Y. Notay, P. S. Vassilevski, -! Recursive Krylov-based multigrid cycles -! Numerical Linear Algebra with Applications, 15 (5), 2008, 473--487. -! -! -! Arguments: -! alpha - real(psb_dpk_), input. -! The scalar alpha. -! p - type(mld_dprec_type), input. -! The multilevel preconditioner data structure containing the -! local part of the preconditioner to be applied. -! Note that nlev = size(p%precv) = number of levels. -! p%precv(lev)%sm - type(psb_dbaseprec_type) -! The pre-'smoother' for the current level -! p%precv(lev)%sm2 - type(psb_dbaseprec_type) -! The post-'smoother' for the current level -! may be the same or different from %sm -! p%precv(lev)%ac - type(psb_dspmat_type) -! The local part of the matrix A(lev). -! p%precv(lev)%parms - type(psb_dml_parms) -! Parameters controllin the multilevel prec. -! p%precv(lev)%desc_ac - type(psb_desc_type). -! The communication descriptor associated to the sparse -! matrix A(lev) -! p%precv(lev)%map - type(psb_inter_desc_type) -! Stores the linear operators mapping level (lev-1) -! to (lev) and vice versa. These are the restriction -! and prolongation operators described in the sequel. -! p%precv(lev)%base_a - type(psb_dspmat_type), pointer. -! Pointer (really a pointer!) to the base matrix of -! the current level, i.e. the local part of A(lev); -! so we have a unified treatment of residuals. We -! need this to avoid passing explicitly the matrix -! A(lev) to the routine which applies the -! preconditioner. -! p%precv(lev)%base_desc - type(psb_desc_type), pointer. -! Pointer to the communication descriptor associated -! to the sparse matrix pointed by base_a. -! -! x - real(psb_dpk_), dimension(:), input. -! The local part of the vector X. -! beta - real(psb_dpk_), input. -! The scalar beta. -! y - real(psb_dpk_), dimension(:), input/output. -! The local part of the vector Y. -! desc_data - type(psb_desc_type), input. -! The communication descriptor associated to the matrix to be -! preconditioned. -! trans - character, optional. -! If trans='N','n' then op(M^(-1)) = M^(-1); -! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). -! work - real(psb_dpk_), dimension (:), optional, target. -! Workspace. Its size must be at least 4*desc_data%get_local_cols(). -! info - integer, output. -! Error code. -! -! Note that when the LU factorization of the matrix A(lev) is computed instead of -! the ILU one, by using UMFPACK or SuperLU or MUMPS, the corresponding -! L and U factors are stored in data structures handled -! by the third party software. -! -subroutine mld_dmlprec_aply_vect(alpha,p,x,beta,y,desc_data,trans,work,info) - - use psb_base_mod - use mld_base_prec_type - use mld_d_inner_mod, mld_protect_name => mld_dmlprec_aply_vect - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_dprec_type), intent(inout) :: p - real(psb_dpk_),intent(in) :: alpha,beta - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - character, intent(in) :: trans - real(psb_dpk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: ictxt, np, me - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, nc2l, level, isweep, err_act - character(len=20) :: name - character :: trans_ - real(psb_dpk_) :: beta_ - logical :: do_alloc_wrk - type(mld_dmlprec_wrk_type), allocatable, target :: mlprec_wrk(:) - - name='mld_dmlprec_aply' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (debug_level >= psb_debug_inner_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(p%precv) - - trans_ = psb_toupper(trans) - nlev = size(p%precv) - - do_alloc_wrk = .not.allocated(p%precv(1)%wrk) - - if (do_alloc_wrk) call p%allocate_wrk(info,vmold=x%v) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') - goto 9999 - end if - level = 1 - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & wv => p%precv(level)%wrk%wv(:)) - ! - ! At first iteration we must use the input BETA - ! - beta_ = beta - - - call psb_geaxpby(done,x,dzero,vx2l,base_desc,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='geaxbpy') - goto 9999 - end if - - do isweep = 1, p%outer_sweeps - 1 - ! - ! With the current implementation, y2l is zeroed internally at first smoother. - ! call p%wrk(level)%vy2l%zero() - ! - call inner_ml_aply(level,p,trans_,work,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Inner prec aply') - goto 9999 - end if - call psb_geaxpby(alpha,vy2l,beta_,y,base_desc,info) - ! all iterations after the first must use BETA = 1 - beta_ = done - ! - ! Next iteration should use the current residual to compute a correction - ! - call psb_geaxpby(done,x,dzero,vx2l,base_desc,info) - call psb_spmm(-done,base_a,y,done,vx2l,base_desc,info) - end do - - ! - ! If outer_sweeps == 1 we have just skipped the loop, and it's - ! equivalent to a single application. - ! - - ! - ! With the current implementation, y2l is zeroed internally at first smoother. - ! call p%wrk(level)%vy2l%zero() - ! - call inner_ml_aply(level,p,trans_,work,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Inner prec aply') - goto 9999 - end if - call psb_geaxpby(alpha,vy2l,beta_,y,base_desc,info) - - end associate - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error final update') - goto 9999 - end if - if (do_alloc_wrk) call p%free_wrk(info) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - ! - ! - ! inner_ml_aply: apply AMG at a given level. - ! This routine dispatches the computation according to the type - ! specified at the current level. - ! Each of the corrections will inturn call recursively this routine. - ! - ! Assumptions: - ! On input: - ! mlprec_wkr(level)%vx2l contains the input vector (RHS) - ! mlprec_wkr(level)%vy2l contains the initial guess - ! - ! On output: - ! mlprec_wkr(level)%vy2l contains the solution - ! - ! Constraints: each of the called routines must properly handle - ! the input/output conditions for level+1 (i.e. apply - ! prolongation/restriction). - ! Note: for historical/convenience reasons the prolongator/restrictor - ! between level and level+1 are stored at level+1. - ! - ! - recursive subroutine inner_ml_aply(level,p,trans,work,info) - - implicit none - - ! Arguments - integer(psb_ipk_) :: level - type(mld_dprec_type), target, intent(inout) :: p - character, intent(in) :: trans - real(psb_dpk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - - type(psb_d_vect_type) :: res - type(psb_d_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_ml_aply' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_ml') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' Start inner_ml_aply at level ',level, info - end if - - select case(p%precv(level)%parms%ml_cycle) - - case(mld_no_ml_) - ! - ! No preconditioning, should not really get here - ! - call psb_errpush(psb_err_internal_error_,name,& - & a_err='mld_no_ml_ in mlprc_aply?') - goto 9999 - - case(mld_add_ml_) - - call mld_d_inner_add(p, level, trans, work) - - case(mld_mult_ml_,mld_vcycle_ml_, mld_wcycle_ml_) - - call mld_d_inner_mult(p, level, trans, work) - - case(mld_kcycle_ml_, mld_kcyclesym_ml_) - - call mld_d_inner_k_cycle(p, level, trans, work) - - case default - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='invalid ml_cycle',& - & i_Err=(/p%precv(level)%parms%ml_cycle,izero,izero,izero,izero/)) - goto 9999 - - end select - if(debug_level > 1) then - write(debug_unit,*) me,' End inner_ml_aply at level ',level - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine inner_ml_aply - - - recursive subroutine mld_d_inner_add(p, level, trans, work) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_dprec_type), intent(inout) :: p - - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - real(psb_dpk_),target :: work(:) - type(psb_d_vect_type) :: res - type(psb_d_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act, k - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_inner_add' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_add') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_add at level ',level - end if - - if ((level<1).or.(level>nlev)) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL>NLEV') - goto 9999 - end if - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & wv => p%precv(level)%wrk%wv) - - if (allocated(p%precv(level)%sm2a)) then - call psb_geaxpby(done,vx2l,dzero,vy2l,base_desc,info) - - sweeps = max(p%precv(level)%parms%sweeps_pre,p%precv(level)%parms%sweeps_post) - do k=1, sweeps - call p%precv(level)%sm%apply(done,& - & vy2l,dzero,vty,& - & base_desc, trans,& - & ione,work,wv,info,init='Z') - - call p%precv(level)%sm2a%apply(done,& - & vty,dzero,vy2l,& - & base_desc, trans,& - & ione,work,wv,info,init='Z') - end do - - else - sweeps = p%precv(level)%parms%sweeps_pre - call p%precv(level)%sm%apply(done,& - & vx2l,dzero,vy2l,& - & base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during ADD smoother_apply') - goto 9999 - end if - - if (level < nlev) then - ! Apply the restriction - call p%precv(level+1)%map%map_U2V(done,vx2l,& - & dzero,p%precv(level+1)%wrk%vx2l,& - & info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - - call inner_ml_aply(level+1,p,trans,work,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in recursive call') - goto 9999 - end if - - ! - ! Apply the prolongator - ! - call p%precv(level+1)%map%map_V2U(done,& - & p%precv(level+1)%wrk%vy2l, done,vy2l,& - & info,work=work,& - & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - - end if - end associate - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_d_inner_add - - recursive subroutine mld_d_inner_mult(p, level, trans, work) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_dprec_type), intent(inout) :: p - - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - real(psb_dpk_),target :: work(:) - type(psb_d_vect_type) :: res - type(psb_d_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - name = 'inner_inner_mult' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_mult') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_mult at level ',level - end if - - sweeps_post = p%precv(level)%parms%sweeps_post - sweeps_pre = p%precv(level)%parms%sweeps_pre - pre = ((sweeps_pre>0).and.(trans=='N')).or.((sweeps_post>0).and.(trans/='N')) - post = ((sweeps_post>0).and.(trans=='N')).or.((sweeps_pre>0).and.(trans/='N')) - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & wv => p%precv(level)%wrk%wv) - if (level < nlev) then - ! - ! Apply the first smoother - ! The residual has been prepared before the recursive call. - ! - - if (pre) then - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(done,& - & vx2l,dzero,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(done,& - & vx2l,dzero,vy2l, base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during PRE smoother_apply') - goto 9999 - end if - endif - ! - ! Compute the residual for next level and call recursively - ! - if (pre) then - call psb_geaxpby(done,vx2l,& - & dzero,vty,& - & base_desc,info) - - if (info == psb_success_) call psb_spmm(-done,base_a,& - & vy2l,done,vty,& - & base_desc,info,work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - call p%precv(level+1)%map%map_U2V(done,vty,& - & dzero,p%precv(level+1)%wrk%vx2l,& - & info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - else - ! Shortcut: just transfer x2l. - call p%precv(level+1)%map%map_U2V(done,vx2l,& - & dzero,p%precv(level+1)%wrk%vx2l,& - & info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - endif - - call inner_ml_aply(level+1,p,trans,work,info) - - ! - ! Apply the prolongator - ! - call p%precv(level+1)%map%map_V2U(done,& - & p%precv(level+1)%wrk%vy2l,done,vy2l,& - & info,work=work,& - & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - if (p%precv(level)%parms%ml_cycle == mld_wcycle_ml_) then - - call psb_geaxpby(done,vx2l, dzero,vty,& - & base_desc,info) - if (info == psb_success_) call psb_spmm(-done,base_a,& - & vy2l,done,vty,& - & base_desc,info,work=work,trans=trans) - if (info == psb_success_) & - & call p%precv(level+1)%map%map_U2V(done,vty,& - & dzero,p%precv(level+1)%wrk%vx2l,info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during W-cycle restriction') - goto 9999 - end if - - call inner_ml_aply(level+1,p,trans,work,info) - - if (info == psb_success_) call p%precv(level+1)%map%map_V2U(done, & - & p%precv(level+1)%wrk%vy2l,done,vy2l,& - & info,work=work,& - & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during W recusion/prolongation') - goto 9999 - end if - - endif - - - if (post) then - call psb_geaxpby(done,vx2l,& - & dzero,vty,& - & base_desc,info) - if (info == psb_success_) call psb_spmm(-done,base_a,& - & vy2l, done,vty,base_desc,info,& - & work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - - ! - ! Apply the second smoother - ! - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(done,& - & vty,done,vy2l, base_desc, trans,& - & sweeps,work,wv,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(done,& - & vty,done,vy2l, base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during POST smoother_apply') - goto 9999 - end if - - endif - - else if (level == nlev) then - - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(done,& - & vx2l,dzero,vy2l,base_desc, trans,& - & sweeps,work,wv,info) - - else - - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL vs NLEV') - goto 9999 - end if - end associate - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_d_inner_mult - - recursive subroutine mld_d_inner_k_cycle(p, level, trans, work,u) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_dprec_type), intent(inout) :: p - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - real(psb_dpk_),target :: work(:) - type(psb_d_vect_type),intent(inout), optional :: u - - - - type(psb_d_vect_type) :: res - type(psb_d_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_kcycle' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_add') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,name,' start at level ',level - end if - - if ((level<1).or.(level>nlev)) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL>NLEV') - goto 9999 - end if - - !K cycle - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & wv => p%precv(level)%wrk%wv(8:)) - if (level == nlev) then - ! - ! Apply smoother - ! - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(done,& - & vx2l,dzero,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - - else if (level < nlev) then - - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(done,& - & vx2l,dzero,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(done,& - & vx2l,dzero,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during 2-PRE smoother_apply') - goto 9999 - end if - - - ! - ! Compute the residual and call recursively - ! - - call psb_geaxpby(done,vx2l,& - & dzero,vty,& - & base_desc,info) - - if (info == psb_success_) call psb_spmm(-done,base_a,& - & vy2l,done,vty,base_desc,info,work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - - ! Apply the restriction - call p%precv(level + 1)%map%map_U2V(done,vty,& - & dzero,p%precv(level + 1)%wrk%vx2l,& - &info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - - !Set the preconditioner - - if (level <= nlev - 2 ) then - if (p%precv(level)%parms%ml_cycle == mld_kcyclesym_ml_) then - call mld_dinneritkcycle(p, level + 1, trans, work, 'FCG') - elseif (p%precv(level)%parms%ml_cycle == mld_kcycle_ml_) then - call mld_dinneritkcycle(p, level + 1, trans, work, 'GCR') - else - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Bad value for ml_cycle') - goto 9999 - endif - else - call inner_ml_aply(level + 1 ,p,trans,work,info) - endif - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in recursive call') - goto 9999 - end if - - ! - ! Apply the prolongator - ! - call p%precv(level+1)%map%map_V2U(done,& - & p%precv(level+1)%wrk%vy2l,done,vy2l,& - & info,work=work,& - & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - ! - ! Compute the residual - ! - call psb_geaxpby(done,vx2l,& - & dzero,vty,base_desc,info) - call psb_spmm(-done,base_a,vy2l,& - & done,vty,base_desc,info,& - & work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - ! - ! Apply the smoother - ! - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(done,& - & vty,done,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(done,& - & vty,done,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during POST smoother_apply') - goto 9999 - end if - else - - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL vs NLEV') - goto 9999 - - endif - end associate - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_d_inner_k_cycle - - - recursive subroutine mld_dinneritkcycle(p, level, trans, work, innersolv) - use psb_base_mod - use mld_prec_mod - use mld_d_inner_mod, mld_protect_name => mld_dmlprec_aply - - implicit none - - !Input/Oputput variables - type(mld_dprec_type), intent(inout) :: p - - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - character(len=*), intent(in) :: innersolv - real(psb_dpk_),target :: work(:) - - !Other variables - type(psb_d_vect_type) :: v, w, rhs, v1, x - type(psb_d_vect_type) :: d0, d1 - real(psb_dpk_) :: delta_old, rhs_norm, alpha, tau, tau1, tau2, tau3, tau4, beta - - real(psb_dpk_) :: l2_norm, delta, rtol=0.25, delta0, tnrm - real(psb_dpk_), allocatable :: temp_v(:) - integer(psb_ipk_) :: info, nlev, i, iter, max_iter=2, idx - character(len=20) :: name = 'innerit_k_cycle' - - - if (size(p%precv(level)%wrk%wv)<7) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size') - goto 9999 - end if - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & v => p%precv(level)%wrk%wv(1), & - & w => p%precv(level)%wrk%wv(2),& - & rhs => p%precv(level)%wrk%wv(3), & - & v1 => p%precv(level)%wrk%wv(4), & - & x => p%precv(level)%wrk%wv(5), & - & d0 => p%precv(level)%wrk%wv(6), & - & d1 => p%precv(level)%wrk%wv(7)) - - call x%zero() - - ! rhs=vx2l and w=rhs - call psb_geaxpby(done,vx2l,dzero,rhs, base_desc,info) - call psb_geaxpby(done,vx2l,dzero,w, base_desc,info) - - if (psb_errstatus_fatal()) then - nc2l = base_desc%get_local_cols() - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - - delta0 = psb_genrm2(w, base_desc, info) - - !Apply the preconditioner - call vy2l%zero() - - idx=0 - call inner_ml_aply(level,p,trans,work,info) - - call psb_geaxpby(done,vy2l,dzero,d0,base_desc,info) - - call psb_spmm(done,base_a,d0,dzero,v,base_desc,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - - !FCG - if (psb_toupper(trim(innersolv)) == 'FCG') then - delta_old = psb_gedot(d0, w, base_desc, info) - tau = psb_gedot(d0, v, base_desc, info) - !GCR - else if (psb_toupper(trim(innersolv)) == 'GCR') then - delta_old = psb_gedot(v, w, base_desc, info) - tau = psb_gedot(v, v, base_desc, info) - else - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid inner solver') - goto 9999 - endif - - alpha = delta_old/tau - !Update residual w - call psb_geaxpby(-alpha, v, done, w, base_desc, info) - - l2_norm = psb_genrm2(w, base_desc, info) - iter = 0 - - if (l2_norm <= rtol*delta0) then - !Update solution x - call psb_geaxpby(alpha, d0, done, x, base_desc, info) - else - iter = iter + 1 - idx=mod(iter,2) - - !Apply preconditioner - call psb_geaxpby(done,w,dzero,vx2l,base_desc,info) - call inner_ml_aply(level,p,trans,work,info) - call psb_geaxpby(done,vy2l,dzero,d1,base_desc,info) - - !Sparse matrix vector product - - call psb_spmm(done,base_a,d1,dzero,v1,base_desc,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - - !tau1, tau2, tau3, tau4 - if (psb_toupper(trim(innersolv)) == 'FCG') then - tau1= psb_gedot(d1, v, base_desc, info) - tau2= psb_gedot(d1, v1, base_desc, info) - tau3= psb_gedot(d1, w, base_desc, info) - tau4= tau2 - (tau1*tau1)/tau - else if (psb_toupper(trim(innersolv)) == 'GCR') then - tau1= psb_gedot(v1, v, base_desc, info) - tau2= psb_gedot(v1, v1, base_desc, info) - tau3= psb_gedot(v1, w, base_desc, info) - tau4= tau2 - (tau1*tau1)/tau - else - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid inner solver') - goto 9999 - endif - - !Update solution - alpha=alpha-(tau1*tau3)/(tau*tau4) - call psb_geaxpby(alpha,d0,done,x,base_desc,info) - alpha=tau3/tau4 - call psb_geaxpby(alpha,d1,done,x,base_desc,info) - endif - - call psb_geaxpby(done,x,dzero,vy2l,base_desc,info) - end associate - -9999 continue - call psb_erractionrestore(err_act) - if (err_act.eq.psb_act_abort_) then - call psb_error() - return - end if - return - end subroutine mld_dinneritkcycle - -end subroutine mld_dmlprec_aply_vect - - -! -! Old routine for arrays instead of psb_X_vector. To be deleted eventually. -! -! -subroutine mld_dmlprec_aply(alpha,p,x,beta,y,desc_data,trans,work,info) - - use psb_base_mod - use mld_base_prec_type - use mld_d_inner_mod, mld_protect_name => mld_dmlprec_aply - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_dprec_type), intent(inout) :: p - real(psb_dpk_),intent(in) :: alpha,beta - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - character, intent(in) :: trans - real(psb_dpk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: ictxt, np, me - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: debug_level, debug_unit, nlev,nc2l,nr2l,level - character(len=20) :: name - character :: trans_ - type mld_mlwrk_type - real(psb_dpk_), allocatable :: tx(:), ty(:), x2l(:), y2l(:) - end type mld_mlwrk_type - type(mld_mlwrk_type), allocatable, target :: mlwrk(:) - - name='mld_dmlprec_aply' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (debug_level >= psb_debug_inner_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(p%precv) - - trans_ = psb_toupper(trans) - - nlev = size(p%precv) - allocate(mlwrk(nlev),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') - goto 9999 - end if - level = 1 - - do level = 1, nlev - call psb_geasb(mlwrk(level)%x2l,& - & p%precv(level)%base_desc,info) - call psb_geasb(mlwrk(level)%y2l,& - & p%precv(level)%base_desc,info) - call psb_geasb(mlwrk(level)%tx,& - & p%precv(level)%base_desc,info) - call psb_geasb(mlwrk(level)%ty,& - & p%precv(level)%base_desc,info) - if (psb_errstatus_fatal()) then - nc2l = p%precv(level)%base_desc%get_local_cols() - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - end do - - mlwrk(level)%x2l(:) = x(:) - mlwrk(level)%y2l(:) = dzero - - call inner_ml_aply(level,p,mlwrk,trans_,work,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Inner prec aply') - goto 9999 - end if - - call psb_geaxpby(alpha,mlwrk(level)%y2l,beta,y,& - & p%precv(level)%base_desc,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error final update') - goto 9999 - end if - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - - ! - ! - ! inner_ml_aply: apply AMG at a given level. - ! This routine dispatches the computation according to the type - ! specified at the current level. - ! Each of the corrections will inturn call recursively this routine. - ! - ! Assumptions: - ! On input: - ! mlprec_wkr(level)%vx2l contains the input vector (RHS) - ! mlprec_wkr(level)%vy2l contains the initial guess - ! - ! On output: - ! mlprec_wkr(level)%vy2l contains the solution - ! - ! Constraints: each of the called routines must properly handle - ! the input/output conditions for level+1 (i.e. apply - ! prolongation/restriction). - ! Note: for historical/convenience reasons the prolongator/restrictor - ! between level and level+1 are stored at level+1. - ! - ! - recursive subroutine inner_ml_aply(level,p,mlwrk,trans,work,info) - - implicit none - - ! Arguments - integer(psb_ipk_) :: level - type(mld_dprec_type), target, intent(inout) :: p - type(mld_mlwrk_type), intent(inout), target :: mlwrk(:) - character, intent(in) :: trans - real(psb_dpk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - - type(psb_d_vect_type) :: res - type(psb_d_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_ml_aply' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_ml') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_ml_aply at level ',level - end if - - select case(p%precv(level)%parms%ml_cycle) - - case(mld_no_ml_) - ! - ! No preconditioning, should not really get here - ! - call psb_errpush(psb_err_internal_error_,name,& - & a_err='mld_no_ml_ in mlprc_aply?') - goto 9999 - - case(mld_add_ml_) - - call mld_d_inner_add(p, mlwrk, level, trans, work) - - case(mld_mult_ml_, mld_vcycle_ml_, mld_wcycle_ml_) - - call mld_d_inner_mult(p, mlwrk, level, trans, work) - -! !$ case(mld_kcycle_ml_, mld_kcyclesym_ml_) -! !$ -! !$ call mld_d_inner_k_cycle(p, mlwrk, level, trans, work) - - case default - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='invalid ml_cycle',& - & i_Err=(/p%precv(level)%parms%ml_cycle,izero,izero,izero,izero/)) - goto 9999 - - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine inner_ml_aply - - - recursive subroutine mld_d_inner_add(p, mlwrk, level, trans, work) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_dprec_type), intent(inout) :: p - - type(mld_mlwrk_type), target, intent(inout) :: mlwrk(:) - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - real(psb_dpk_),target :: work(:) - type(psb_d_vect_type) :: res - type(psb_d_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_inner_add' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_add') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_add at level ',level - end if - - if ((level<1).or.(level>nlev)) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL>NLEV') - goto 9999 - end if - - sweeps = p%precv(level)%parms%sweeps_pre - call p%precv(level)%sm%apply(done,& - & mlwrk(level)%x2l,dzero,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during ADD smoother_apply') - goto 9999 - end if - - if (level < nlev) then - ! Apply the restriction - call p%precv(level+1)%map%map_U2V(done,mlwrk(level)%x2l,& - & dzero,mlwrk(level+1)%x2l,& - & info,work=work) - mlwrk(level+1)%y2l(:) = dzero - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - - call inner_ml_aply(level+1,p,mlwrk,trans,work,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in recursive call') - goto 9999 - end if - - ! - ! Apply the prolongator and add correction. - ! - call p%precv(level+1)%map%map_V2U(done,& - & mlwrk(level+1)%y2l,done,mlwrk(level)%y2l,& - & info,work=work) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_d_inner_add - - recursive subroutine mld_d_inner_mult(p, mlwrk, level, trans, work) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_dprec_type), intent(inout) :: p - - type(mld_mlwrk_type), target, intent(inout) :: mlwrk(:) - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - real(psb_dpk_),target :: work(:) - type(psb_d_vect_type) :: res - type(psb_d_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_inner_mult' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_mult') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_mult at level ',level - end if - - if ((level < nlev).or.(nlev == 1)) then - sweeps_post = p%precv(level)%parms%sweeps_post - sweeps_pre = p%precv(level)%parms%sweeps_pre - else - sweeps_post = p%precv(level-1)%parms%sweeps_post - sweeps_pre = p%precv(level-1)%parms%sweeps_pre - endif - - pre = ((sweeps_pre>0).and.(trans=='N')).or.((sweeps_post>0).and.(trans/='N')) - post = ((sweeps_post>0).and.(trans=='N')).or.((sweeps_pre>0).and.(trans/='N')) - - - if (level < nlev) then - - ! - ! Apply the first smoother - ! - - if (pre) then - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(done,& - & mlwrk(level)%x2l,dzero,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info,init='Y') - else - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(done,& - & mlwrk(level)%x2l,dzero,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info,init='Y') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during PRE smoother_apply') - goto 9999 - end if - endif - - ! - ! Compute the residual and call recursively - ! - if (pre) then - call psb_geaxpby(done,mlwrk(level)%x2l,& - & dzero,mlwrk(level)%ty,& - & p%precv(level)%base_desc,info) - - if (info == psb_success_) call psb_spmm(-done,p%precv(level)%base_a,& - & mlwrk(level)%y2l,done,mlwrk(level)%ty,& - & p%precv(level)%base_desc,info,work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - call p%precv(level+1)%map%map_U2V(done,mlwrk(level)%ty,& - & dzero,mlwrk(level+1)%x2l,info,work=work) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - else - ! Shortcut: just transfer x2l. - call p%precv(level+1)%map%map_U2V(done,mlwrk(level)%x2l,& - & dzero,mlwrk(level+1)%x2l,info,work=work) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - endif - ! First guess is zero - mlwrk(level+1)%y2l(:) = dzero - - - call inner_ml_aply(level+1,p,mlwrk,trans,work,info) - - if (p%precv(level)%parms%ml_cycle == mld_wcycle_ml_) then - ! On second call will use output y2l as initial guess - if (info == psb_success_) call inner_ml_aply(level+1,p,mlwrk,trans,work,info) - endif - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in recursive call') - goto 9999 - end if - - - ! - ! Apply the prolongator - ! - call p%precv(level+1)%map%map_V2U(done,mlwrk(level+1)%y2l,& - & done,mlwrk(level)%y2l,info,work=work) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - ! - ! Compute the residual - ! - if (post) then - call psb_geaxpby(done,mlwrk(level)%x2l,& - & dzero,mlwrk(level)%tx,& - & p%precv(level)%base_desc,info) - call psb_spmm(-done,p%precv(level)%base_a,mlwrk(level)%y2l,& - & done,mlwrk(level)%tx,p%precv(level)%base_desc,info,& - & work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - ! - ! Apply the second smoother - ! - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(done,& - & mlwrk(level)%tx,done,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(done,& - & mlwrk(level)%tx,done,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during POST smoother_apply') - goto 9999 - end if - - endif - - else if (level == nlev) then - - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(done,& - & mlwrk(level)%x2l,dzero,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info) - - else - - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL vs NLEV') - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_d_inner_mult - - -end subroutine mld_dmlprec_aply diff --git a/mlprec/impl/mld_dmlprec_bld.f90 b/mlprec/impl/mld_dmlprec_bld.f90 deleted file mode 100644 index 381fac45..00000000 --- a/mlprec/impl/mld_dmlprec_bld.f90 +++ /dev/null @@ -1,152 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_dmlprec_bld.f90 -! -! Subroutine: mld_dmlprec_bld -! Version: real -! -! This routine builds the preconditioner according to the requirements made by -! the user trough the subroutines mld_precinit and mld_precset. -! -! A multilevel preconditioner is regarded as an array of 'one-level' data structures, -! each containing the part of the preconditioner associated to a certain level, -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level. No transfer operators are associated to level 1. -! -! This routine simply calls mld_d_hierarchy_bld and mld_d_smoothers_bld; they -! can also be called explicitly from the user. -! -! -! Arguments: -! a - type(psb_dspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_dprec_type), input/output. -! The preconditioner data structure containing the local part -! of the preconditioner to be built. -! info - integer, output. -! Error code. -! -! amold - class(psb_d_base_sparse_mat), input, optional -! Mold for the inner format of matrices contained in the -! preconditioner -! -! -! vmold - class(psb_d_base_vect_type), input, optional -! Mold for the inner format of vectors contained in the -! preconditioner -! -! -! -subroutine mld_dmlprec_bld(a,desc_a,p,info,amold,vmold,imold) - - use psb_base_mod - use mld_d_inner_mod, mld_protect_name => mld_dmlprec_bld - use mld_d_prec_mod - - Implicit None - - ! Arguments - type(psb_dspmat_type),intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - type(mld_dprec_type),intent(inout),target :: p - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local Variables - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, casize, nplevs, mxplevs - real(psb_dpk_) :: mnaggratio - integer(psb_ipk_) :: ipv(mld_ifpsz_), val - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_dmlprec_bld' - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' - - call p%hierarchy_build(a,desc_a,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Error from hierarchy build') - goto 9999 - end if - - iszv = p%get_nlevs() - - call p%smoothers_build(a,desc_a,info,amold,vmold,imold) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Error from smoothers build') - goto 9999 - end if - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Exiting with',iszv,' levels' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_dmlprec_bld diff --git a/mlprec/impl/mld_dprecaply.f90 b/mlprec/impl/mld_dprecaply.f90 deleted file mode 100644 index 99471302..00000000 --- a/mlprec/impl/mld_dprecaply.f90 +++ /dev/null @@ -1,600 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_dprecaply.f90 -! -! Subroutine: mld_dprecaply -! Version: real -! -! This routine applies the preconditioner built by mld_dprecbld, i.e. it computes -! -! Y = op(M^(-1)) * X, -! where -! - M is the preconditioner, -! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, -! - X and Y are vectors. -! This operation is performed at each iteration of a preconditioned Krylov solver. -! -! -! Arguments: -! prec - type(mld_dprec_type), input. -! The preconditioner data structure containing the local part -! of the preconditioner to be applied. -! x - real(psb_dpk_), dimension(:), input. -! The local part of the vector X in Y=op(M^(-1))*X. -! y - real(psb_dpk_), dimension(:), output. -! The local part of the vector Y in Y=op(M^(-1))*X. -! desc_data - type(psb_desc_type), input. -! The communication descriptor associated to the matrix to be -! preconditioned. -! info - integer, output. -! Error code. -! trans - character(len=1), optional. -! If trans='N','n' then op(M^(-1)) = M^(-1); -! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). -! work - real(psb_dpk_), dimension (:), optional, target. -! Workspace. Its size must be at -! least 4*desc_data%get_local_cols(). -! -subroutine mld_dprecaply(prec,x,y,desc_data,info,trans,work) - - use psb_base_mod - use mld_d_inner_mod!, mld_protect_name => mld_dprecaply - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_dprec_type), intent(inout) :: prec - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_dpk_),intent(inout), optional, target :: work(:) - - ! Local variables - character :: trans_ - real(psb_dpk_), pointer :: work_(:) - real(psb_dpk_), allocatable :: w1(:), w2(:) - - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: err_act,iwsz, k, nswps - character(len=20) :: name - - name='mld_dprecaply' - info = psb_success_ - call psb_erractionsave(err_act) - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (present(trans)) then - trans_=psb_toupper(trans) - else - trans_='N' - end if - - if (present(work)) then - work_ => work - else - iwsz = max(1,4*desc_data%get_local_cols()) - allocate(work_(iwsz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name, & - & i_err=(/iwsz,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - - end if - - if (.not.(allocated(prec%precv))) then - !! Error 1: should call mld_dprecbld - info=3112 - call psb_errpush(info,name) - goto 9999 - end if - - if (size(prec%precv) >1) then - ! - ! Number of levels > 1: apply the multilevel preconditioner - ! - call mld_mlprec_aply(done,prec,x,dzero,y,desc_data,trans_,work_,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_dmlprec_aply') - goto 9999 - end if - - else if (size(prec%precv) == 1) then - ! - ! Number of levels = 1: apply the base preconditioner - ! - if (allocated(prec%precv(1)%sm2a)) then - nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) - ! - ! This is a kludge for handling the symmetrized GS case. - ! Will need some rethinking. - ! - call psb_geasb(w1,desc_data,info,scratch=.true.) - call psb_geasb(w2,desc_data,info,scratch=.true.) - - call psb_geaxpby(done,x,dzero,w1,desc_data,info) - select case(trans_) - case ('N') - do k=1, nswps - call prec%precv(1)%sm%apply(done,w1,dzero,w2,desc_data,trans_,& - & ione, work_,info) - call prec%precv(1)%sm2a%apply(done,w2,dzero,w1,desc_data,trans_,& - & ione, work_,info) - end do - - case('T','C') - do k=1, nswps - call prec%precv(1)%sm2a%apply(done,w1,dzero,w2,desc_data,trans_,& - & ione, work_,info) - call prec%precv(1)%sm%apply(done,w2,dzero,w1,desc_data,trans_,& - & ione, work_,info) - end do - case default - info = psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='Invalid trans') - goto 9999 - end select - call psb_geaxpby(done,w1,dzero,y,desc_data,info) - call psb_gefree(w1,desc_data,info) - call psb_gefree(w2,desc_data,info) - - else - nswps = prec%precv(1)%parms%sweeps_pre - call prec%precv(1)%sm%apply(done,x,dzero,y,desc_data,trans_,& - & nswps, work_,info) - end if - else - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='Invalid size of precv',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - endif - - ! If the original distribution has an overlap we should fix that. - call psb_halo(y,desc_data,info,data=psb_comm_mov_) - - - if (present(work)) then - else - deallocate(work_) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_dprecaply - - -! -! Subroutine: mld_dprecaply1 -! Version: real -! -! Applies the preconditioner built by mld_dprecbld, i.e. computes -! -! X = op(M^(-1)) * X, -! where -! - M is the preconditioner, -! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, -! - X is a vectors. -! This operation is performed at each iteration of a preconditioned Krylov solver. -! -! This routine differs from mld_dprecaply because the preconditioned vector X -! overwrites the original one. -! -! -! Arguments: -! prec - type(mld_dprec_type), input. -! The preconditioner data structure containing the local part -! of the preconditioner to be applied. -! x - real(psb_dpk_), dimension(:), input/output. -! The local part of vector X in X := op(M^(-1)) * X. -! desc_data - type(psb_desc_type), input. -! The communication descriptor associated to the matrix to be -! preconditioned. -! info - integer, output. -! Error code. -! trans - character(len=1), optional. -! If trans='N','n' then op(M^(-1)) = M^(-1); -! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). -! -subroutine mld_dprecaply1(prec,x,desc_data,info,trans) - - use psb_base_mod - use mld_d_inner_mod!, mld_protect_name => mld_dprecaply1 - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_dprec_type), intent(inout) :: prec - real(psb_dpk_),intent(inout) :: x(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: err_act - real(psb_dpk_), pointer :: ww(:), w1(:) - character(len=20) :: name - - name='mld_dprecaply1' - info = psb_success_ - call psb_erractionsave(err_act) - - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - allocate(ww(size(x)),w1(size(x)),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name, & - & i_err=(/itwo*size(x),izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - - call prec%apply(x,ww,desc_data,info,trans=trans,work=w1) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_precaply') - goto 9999 - end if - - x(:) = ww(:) - deallocate(ww,w1,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_dprecaply1 - - - -subroutine mld_dprecaply2_vect(prec,x,y,desc_data,info,trans,work) - - use psb_base_mod - use mld_d_inner_mod!, mld_protect_name => mld_dprecaply2_vect - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_dprec_type), intent(inout) :: prec - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_dpk_),intent(inout), optional, target :: work(:) - - ! Local variables - character :: trans_ - real(psb_dpk_), pointer :: work_(:) - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: err_act,iwsz, k, nswps - logical :: do_alloc_wrk - character(len=20) :: name - - name='mld_dprecaply' - info = psb_success_ - call psb_erractionsave(err_act) - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (present(trans)) then - trans_=psb_toupper(trans) - else - trans_='N' - end if - - if (present(work)) then - work_ => work - else - iwsz = max(1,4*desc_data%get_local_cols()) - allocate(work_(iwsz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name, & - & i_err=(/iwsz,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - - end if - - if (.not.(allocated(prec%precv))) then - !! Error 1: should call mld_dprecbld - info=3112 - call psb_errpush(info,name) - goto 9999 - end if - - do_alloc_wrk = .not.allocated(prec%precv(1)%wrk) - if (do_alloc_wrk) call prec%allocate_wrk(info,vmold=x%v) - - if (size(prec%precv) >1) then - ! - ! Number of levels > 1: apply the multilevel preconditioner - ! - ! FIXME: generic name causes an ICE with Intel - call mld_dmlprec_aply_vect(done,prec,x,dzero,y,desc_data,trans_,work_,info) - - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_dmlprec_aply') - goto 9999 - end if - - else if (size(prec%precv) == 1) then - ! - ! Number of levels = 1: apply the base preconditioner - ! - nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) - - associate(w1 => prec%precv(1)%wrk%vx2l, w2 => prec%precv(1)%wrk%vy2l,& - & wv => prec%precv(1)%wrk%wv) - if (allocated(prec%precv(1)%sm2a)) then - ! - ! This is a kludge for handling the symmetrized GS case. - ! Will need some rethinking. - ! - call psb_geaxpby(done,x,dzero,w1,desc_data,info) - select case(trans_) - case ('N') - do k=1, nswps - if (info == 0) call prec%precv(1)%sm%apply(done,w1,dzero,w2,desc_data,trans_,& - & ione, work_,wv,info) - if (info == 0) call prec%precv(1)%sm2a%apply(done,w2,dzero,w1,desc_data,trans_,& - & ione, work_,wv,info) - end do - - case('T','C') - do k=1, nswps - if (info == 0) call prec%precv(1)%sm2a%apply(done,w1,dzero,w2,desc_data,trans_,& - & ione, work_,wv,info) - if (info == 0) call prec%precv(1)%sm%apply(done,w2,dzero,w1,desc_data,trans_,& - & ione, work_,wv,info) - end do - case default - info = psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='Invalid trans') - goto 9999 - end select - if (info == 0) call psb_geaxpby(done,w1,dzero,y,desc_data,info) - else - if (info == 0) call prec%precv(1)%sm%apply(done,x,dzero,y,desc_data,trans_,& - & nswps,work_,wv,info) - end if - end associate - if (psb_errstatus_fatal()) info = psb_err_internal_error_ - if (info /= 0) then - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='Smoother application',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - end if - - else - - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='Invalid size of precv',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - endif - - ! If the original distribution has an overlap we should fix that. - call psb_halo(y,desc_data,info,data=psb_comm_mov_) - - if (do_alloc_wrk) call prec%free_wrk(info) - - if (present(work)) then - else - deallocate(work_) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_dprecaply2_vect - - -subroutine mld_dprecaply1_vect(prec,x,desc_data,info,trans,work) - - use psb_base_mod - use mld_d_inner_mod!, mld_protect_name => mld_dprecaply1_vect - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_dprec_type), intent(inout) :: prec - type(psb_d_vect_type),intent(inout) :: x - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_dpk_),intent(inout), optional, target :: work(:) - - ! Local variables - character :: trans_ - real(psb_dpk_), pointer :: work_(:) - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: err_act,iwsz, k, nswps - logical :: do_alloc_wrk - character(len=20) :: name - - name='mld_dprecaply' - info = psb_success_ - call psb_erractionsave(err_act) - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (present(trans)) then - trans_=psb_toupper(trans) - else - trans_='N' - end if - - if (present(work)) then - work_ => work - else - iwsz = max(1,4*desc_data%get_local_cols()) - allocate(work_(iwsz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name, & - & i_err=(/iwsz,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - - end if - - if (.not.(allocated(prec%precv))) then - !! Error 1: should call mld_dprecbld - info=3112 - call psb_errpush(info,name) - goto 9999 - end if - - do_alloc_wrk = .not.allocated(prec%precv(1)%wrk) - if (do_alloc_wrk) call prec%allocate_wrk(info,vmold=x%v) - - associate(ww => prec%precv(1)%wrk%vtx, wv => prec%precv(1)%wrk%wv) - - if (size(prec%precv) >1) then - ! - ! Number of levels > 1: apply the multilevel preconditioner - ! - ! FIXME: generic name causes an ICE with Intel - call mld_dmlprec_aply_vect(done,prec,x,dzero,ww,desc_data,trans_,work_,info) - if (info == 0) call psb_geaxpby(done,ww,dzero,x,desc_data,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_dmlprec_aply') - goto 9999 - end if - - else if (size(prec%precv) == 1) then - ! - ! Number of levels = 1: apply the base preconditioner - ! - nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) - if (allocated(prec%precv(1)%sm2a)) then - ! - ! This is a kludge for handling the symmetrized GS case. - ! Will need some rethinking. - ! - select case(trans_) - case ('N') - do k=1, nswps - if (info == 0) call prec%precv(1)%sm%apply(done,x,dzero,ww,desc_data,trans_,& - & ione, work_,wv,info) - if (info == 0) call prec%precv(1)%sm2a%apply(done,ww,dzero,x,desc_data,trans_,& - & ione, work_,wv,info) - end do - case('T','C') - do k=1, nswps - if (info == 0) call prec%precv(1)%sm2a%apply(done,x,dzero,ww,desc_data,trans_,& - & ione, work_,wv,info) - if (info == 0) call prec%precv(1)%sm%apply(done,ww,dzero,x,desc_data,trans_,& - & ione, work_,wv,info) - end do - case default - info = psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='Invalid trans') - goto 9999 - end select - - else - if (info == 0) call prec%precv(1)%sm%apply(done,x,dzero,ww,desc_data,trans_,& - & nswps, work_,wv,info) - if (info == 0) call psb_geaxpby(done,ww,dzero,x,desc_data,info) - end if - - if (psb_errstatus_fatal()) info = psb_err_internal_error_ - if (info /=0) then - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='Smoother application',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - end if - - else - - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='Invalid size of precv',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - endif - end associate - - ! If the original distribution has an overlap we should fix that. - call psb_halo(x,desc_data,info,data=psb_comm_mov_) - - if (do_alloc_wrk) call prec%free_wrk(info) - - if (present(work)) then - else - deallocate(work_) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_dprecaply1_vect diff --git a/mlprec/impl/mld_dprecbld.f90 b/mlprec/impl/mld_dprecbld.f90 deleted file mode 100644 index a2662786..00000000 --- a/mlprec/impl/mld_dprecbld.f90 +++ /dev/null @@ -1,161 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_dprecbld.f90 -! -! Subroutine: mld_dprecbld -! Version: real -! Contains: subroutine init_baseprec_av -! -! This routine builds the preconditioner according to the requirements made by -! the user through the subroutines mld_precinit and mld_precset. -! -! -! Arguments: -! a - type(psb_dspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_dprec_type), input/output. -! The preconditioner data structure containing the local part -! of the preconditioner to be built. -! info - integer, output. -! Error code. -! -subroutine mld_dprecbld(a,desc_a,prec,info,amold,vmold,imold) - - use psb_base_mod - use mld_d_prec_mod, mld_protect_name => mld_dprecbld - - Implicit None - - ! Arguments - type(psb_dspmat_type),intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_dprec_type),intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local Variables - type(mld_dprec_type) :: t_prec - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k,err_act, iszv, newsz - integer(psb_ipk_) :: ipv(mld_ifpsz_), val - integer(psb_ipk_) :: int_err(5) - type(mld_dml_parms) :: prm - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_dprecbld' - info = psb_success_ - int_err(1) = 0 - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - prec%ictxt = ictxt - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' - ! - - if (.not.allocated(prec%precv)) then - !! Error: should have called mld_dprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - ! - ! Check to ensure all procs have the same - ! - newsz = -1 - iszv = size(prec%precv) - call psb_bcast(ictxt,iszv) - if (iszv /= size(prec%precv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of precv') - goto 9999 - end if - - if (iszv <= 0) then - ! Is this really possible? probably not. - info=psb_err_from_subroutine_ - ch_err='size bpv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - ! - ! Build the preconditioner - ! - call prec%hierarchy_build(a,desc_a,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Error from hierarchy build') - goto 9999 - end if - - call prec%smoothers_build(a,desc_a,info,amold,vmold,imold) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Error from smoothers build') - goto 9999 - end if - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_dprecbld diff --git a/mlprec/impl/mld_dprecinit.F90 b/mlprec/impl/mld_dprecinit.F90 deleted file mode 100644 index 9156d5ad..00000000 --- a/mlprec/impl/mld_dprecinit.F90 +++ /dev/null @@ -1,242 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_dprecinit.f90 -! -! Subroutine: mld_dprecinit -! Version: real -! -! This routine allocates and initializes the preconditioner data structure, -! according to the preconditioner type chosen by the user. -! -! A default preconditioner is set for each preconditioner type -! specified by the user: -! -! 'NOPREC' - no preconditioner -! -! 'DIAG', 'JACOBI' - diagonal/Jacobi -! -! 'L1-DIAG', 'L1-JACOBI' - diagonal/Jacobi with L1 norm correction -! -! 'GS', 'FBGS' - Hybrid Gauss-Seidel, also symmetrized -! -! 'BJAC' - block Jacobi preconditioner, with ILU(0) -! on the local blocks -! -! 'L1-BJAC' - block Jacobi preconditioner, with ILU(0) -! on the local blocks and L1 correction for off-diag blocks -! -! 'AS' - Additive Schwarz (AS), with -! overlap 1 and ILU(0) on the local submatrices -! -! 'ML' - Multilevel hybrid preconditioner (additive on the -! same level and multiplicative through the levels), -! with 2 levels, pre and post-smoothing, RAS with -! overlap 1 and ILU(0) on the local blocks is -! applied as post-smoother at each level, but the -! coarsest one; four sweeps of the block-Jacobi solver, -! with LU from UMFPACK on the blocks, are applied at -! the coarsest level, on the distributed coarse matrix. -! The smoothed aggregation algorithm with threshold 0 -! is used to build the coarse matrix. -! -! For the multilevel preconditioners, the levels are numbered in increasing -! order starting from the finest one, i.e. level 1 is the finest level. -! -! -! Arguments: -! p - type(mld_dprec_type), input/output. -! The preconditioner data structure. -! ptype - character(len=*), input. -! The type of preconditioner. Its values are 'NOPREC', -! 'DIAG', 'BJAC', 'AS', 'ML' (and the corresponding -! lowercase strings). -! info - integer, output. -! Error code. -! -subroutine mld_dprecinit(ictxt,prec,ptype,info) - - use psb_base_mod - use mld_d_prec_mod, mld_protect_name => mld_dprecinit - use mld_d_jac_smoother - use mld_d_as_smoother - use mld_d_id_solver - use mld_d_diag_solver - use mld_d_ilu_solver - use mld_d_gs_solver -#if defined(HAVE_UMF_) - use mld_d_umf_solver -#endif -#if defined(HAVE_SLU_) - use mld_d_slu_solver -#endif - - - implicit none - - ! Arguments - integer(psb_ipk_), intent(in) :: ictxt - class(mld_dprec_type), intent(inout) :: prec - character(len=*), intent(in) :: ptype - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: nlev_, ilev_ - real(psb_dpk_) :: thr - character(len=*), parameter :: name='mld_precinit' - info = psb_success_ - - if (allocated(prec%precv)) then - call prec%free(info) - if (info /= psb_success_) then - ! Do we want to do something? - endif - endif - prec%ictxt = ictxt - prec%ag_data%min_coarse_size = -1 - - select case(psb_toupper(trim(ptype))) - case ('NOPREC','NONE') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_d_base_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_d_id_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('JAC','DIAG','JACOBI') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_d_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_d_diag_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('L1-DIAG','L1-JACOBI','L1_DIAG','L1_JACOBI') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_d_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_d_l1_diag_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('GS','FWGS') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_d_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_d_gs_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('BWGS') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_d_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_d_bwgs_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('FBGS') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - call prec%set('SMOOTHER_TYPE','FBGS',info) - call prec%precv(ilev_)%default() - - case ('BJAC') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_d_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_d_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('L1-BJAC','L1_BJAC') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_d_l1_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_d_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('AS') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_d_as_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_d_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - - case ('ML') - - nlev_ = prec%ag_data%max_levs - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - - do ilev_ = 1, nlev_ - call prec%precv(ilev_)%default() - end do - call prec%set('ML_CYCLE','VCYCLE',info) - call prec%set('SMOOTHER_TYPE','FBGS',info) -#if defined(HAVE_UMF_) - call prec%set('COARSE_SOLVE','UMF',info) -#elif defined(HAVE_MUMPS_) - call prec%set('COARSE_SOLVE','MUMPS',info) -#elif defined(HAVE_SLU_) - call prec%set('COARSE_SOLVE','SLU',info) -#else - call prec%set('COARSE_SOLVE','ILU',info) -#endif - - case default - write(psb_err_unit,*) name,& - &': Warning: Unknown preconditioner type request "',ptype,'"' - info = psb_err_pivot_too_small_ - - end select - - -end subroutine mld_dprecinit diff --git a/mlprec/impl/mld_dprecset.F90 b/mlprec/impl/mld_dprecset.F90 deleted file mode 100644 index 44daac05..00000000 --- a/mlprec/impl/mld_dprecset.F90 +++ /dev/null @@ -1,229 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_dprecset.f90 -! -subroutine mld_dprecsetsm(p,val,info,ilev,ilmax,pos) - - use psb_base_mod - use mld_d_prec_mod, mld_protect_name => mld_dprecsetsm - - implicit none - - ! Arguments - class(mld_dprec_type), intent(inout) :: p - class(mld_d_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ - character(len=*), parameter :: name='mld_precsetsm' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - ilmin_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmin_ = 1 - ilmax_ = nlev_ - end if - - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - do ilev_ = ilmin_, ilmax_ - call p%precv(ilev_)%set(val,info,pos=pos) - if (info /= 0) return - end do - -end subroutine mld_dprecsetsm - -subroutine mld_dprecsetsv(p,val,info,ilev,ilmax,pos) - - use psb_base_mod - use mld_d_prec_mod, mld_protect_name => mld_dprecsetsv - - implicit none - - ! Arguments - class(mld_dprec_type), intent(inout) :: p - class(mld_d_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ - character(len=*), parameter :: name='mld_precsetsv' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - ilmin_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmin_ = 1 - ilmax_ = nlev_ - end if - - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - do ilev_ = ilmin_, ilmax_ - call p%precv(ilev_)%set(val,info,pos=pos) - if (info /= 0) return - end do - -end subroutine mld_dprecsetsv - -subroutine mld_dprecsetag(p,val,info,ilev,ilmax,pos) - - use psb_base_mod - use mld_d_prec_mod, mld_protect_name => mld_dprecsetag - - implicit none - - ! Arguments - class(mld_dprec_type), intent(inout) :: p - class(mld_d_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev, ilmax - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ - character(len=*), parameter :: name='mld_precsetag' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - ilmin_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmin_ = 1 - ilmax_ = nlev_ - end if - - - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - do ilev_ = ilmin_, ilmax_ - call p%precv(ilev_)%set(val,info,pos=pos) - if (info /= 0) return - end do - -end subroutine mld_dprecsetag - diff --git a/mlprec/impl/mld_dslu_interface.c b/mlprec/impl/mld_dslu_interface.c deleted file mode 100644 index bc4c12c4..00000000 --- a/mlprec/impl/mld_dslu_interface.c +++ /dev/null @@ -1,309 +0,0 @@ -/* - * - * MLD2P4 version 2.1 - * MultiLevel Domain Decomposition Parallel Preconditioners Package - * based on PSBLAS (Parallel Sparse BLAS version 3.5) - * - * (C) Copyright 2008-2018 - * - * Salvatore Filippone - * Pasqua D'Ambra - * Daniela di Serafino - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions, and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the MLD2P4 group or the names of its contributors may - * not be used to endorse or promote products derived from this - * software without specific written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * - * File: mld_slu_interface.c - * - * Functions: mld_dslu_fact, mld_dslu_solve, mld_dslu_free. - * - * This file is an interface to the SuperLU routines for sparse factorization and - * solve. It was obtained by modifying the c_fortran_dgssv.c file from the SuperLU - * source distribution; original copyright terms are reproduced below. - * - */ - - -/* ===================== - -Copyright (c) 2003, The Regents of the University of California, through -Lawrence Berkeley National Laboratory (subject to receipt of any required -approvals from U.S. Dept. of Energy) - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -(1) Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. -(2) Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. -(3) Neither the name of Lawrence Berkeley National Laboratory, U.S. Dept. of -Energy nor the names of its contributors may be used to endorse or promote -products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -/* - * -- SuperLU routine (version 3.0) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * October 15, 2003 - * - */ - -#ifdef Have_SLU_ -#include "slu_ddefs.h" - -#define HANDLE_SIZE 8 - -typedef struct { - SuperMatrix *L; - SuperMatrix *U; - int *perm_c; - int *perm_r; -} factors_t; - - -#else - -#include - -#endif - - - -int mld_dslu_fact(int n, int nnz, double *values, - int *colptr, int *rowind, void **f_factors) -{ -/* - * This routine can be called from Fortran. - * performs LU decomposition. - * - * f_factors (input/output) - * On output contains the pointer pointing to - * the structure of the factored matrices. - * - */ - -#ifdef Have_SLU_ - SuperMatrix A, AC; - SuperMatrix *L, *U; - int *perm_r; /* row permutations from partial pivoting */ - int *perm_c; /* column permutation vector */ - int *etree; /* column elimination tree */ - SCformat *Lstore; - NCformat *Ustore; - int i, panel_size, permc_spec, relax; - trans_t trans; - mem_usage_t mem_usage; - superlu_options_t options; - SuperLUStat_t stat; - factors_t *LUfactors; - GlobalLU_t Glu; /* Not needed on return. */ - int info; - - trans = NOTRANS; - - - /* Set the default input options. */ - set_default_options(&options); - - /* Initialize the statistics variables. */ - StatInit(&stat); - - dCreate_CompCol_Matrix(&A, n, n, nnz, values, rowind, colptr, - SLU_NC, SLU_D, SLU_GE); - L = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) ); - U = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) ); - if ( !(perm_r = intMalloc(n)) ) ABORT("Malloc fails for perm_r[]."); - if ( !(perm_c = intMalloc(n)) ) ABORT("Malloc fails for perm_c[]."); - if ( !(etree = intMalloc(n)) ) ABORT("Malloc fails for etree[]."); - - /* - * Get column permutation vector perm_c[], according to permc_spec: - * permc_spec = 0: natural ordering - * permc_spec = 1: minimum degree on structure of A'*A - * permc_spec = 2: minimum degree on structure of A'+A - * permc_spec = 3: approximate minimum degree for unsymmetric matrices - */ - options.ColPerm=2; - permc_spec = options.ColPerm; - get_perm_c(permc_spec, &A, perm_c); - - sp_preorder(&options, &A, perm_c, etree, &AC); - - panel_size = sp_ienv(1); - relax = sp_ienv(2); -#if defined(SLU_VERSION_5) - dgstrf(&options, &AC, relax, panel_size, etree, - NULL, 0, perm_c, perm_r, L, U, &Glu, &stat, &info); -#elif defined(SLU_VERSION_4) - dgstrf(&options, &AC, relax, panel_size, etree, - NULL, 0, perm_c, perm_r, L, U, &stat, &info); -#else - choke_on_me; -#endif - - if ( info == 0 ) { - Lstore = (SCformat *) L->Store; - Ustore = (NCformat *) U->Store; - dQuerySpace(L, U, &mem_usage); -#if 0 - printf("No of nonzeros in factor L = %d\n", Lstore->nnz); - printf("No of nonzeros in factor U = %d\n", Ustore->nnz); - printf("No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz); - printf("L\\U MB %.3f\ttotal MB needed %.3f\n", - mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); -#endif - } else { - printf("dgstrf() error returns INFO= %d\n", info); - if ( info <= n ) { /* factorization completes */ - dQuerySpace(L, U, &mem_usage); - printf("L\\U MB %.3f\ttotal MB needed %.3f\n", - mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); - } - } - - /* Save the LU factors in the factors handle */ - LUfactors = (factors_t*) SUPERLU_MALLOC(sizeof(factors_t)); - LUfactors->L = L; - LUfactors->U = U; - LUfactors->perm_c = perm_c; - LUfactors->perm_r = perm_r; - *f_factors = (void *) LUfactors; - - /* Free un-wanted storage */ - SUPERLU_FREE(etree); - Destroy_SuperMatrix_Store(&A); - Destroy_CompCol_Permuted(&AC); - StatFree(&stat); - return(info); -#else - fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); - return(-1); -#endif -} - - -int mld_dslu_solve(int itrans, int n, int nrhs, double *b, int ldb, - void *f_factors) -{ - /* - * This routine can be called from Fortran. - * performs triangular solve - * - */ - int info; -#ifdef Have_SLU_ - SuperMatrix B; - SuperMatrix *L, *U; - int *perm_r; /* row permutations from partial pivoting */ - int *perm_c; /* column permutation vector */ - int *etree; /* column elimination tree */ - SCformat *Lstore; - NCformat *Ustore; - int i, panel_size, permc_spec, relax; - trans_t trans; - SuperLUStat_t stat; - factors_t *LUfactors; - - if (itrans == 0) { - trans = NOTRANS; - } else if (itrans ==1) { - trans = TRANS; - } else if (itrans ==2) { - trans = CONJ; - } else { - trans = NOTRANS; - } - /* Initialize the statistics variables. */ - StatInit(&stat); - - /* Extract the LU factors in the factors handle */ - LUfactors = (factors_t*) f_factors; - L = LUfactors->L; - U = LUfactors->U; - perm_c = LUfactors->perm_c; - perm_r = LUfactors->perm_r; - - dCreate_Dense_Matrix(&B, n, nrhs, b, ldb, SLU_DN, SLU_D, SLU_GE); - /* Solve the system A*X=B, overwriting B with X. */ - dgstrs(trans, L, U, perm_c, perm_r, &B, &stat, &info); - - Destroy_SuperMatrix_Store(&B); - StatFree(&stat); -#else - fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); - info=-1; -#endif - return(info); -} - - -int mld_dslu_free(void *f_factors) -{ - /* - * This routine can be called from Fortran. - * - * free all storage in the end - * - */ -#ifdef Have_SLU_ - factors_t *LUfactors; - - /* Free the LU factors in the factors handle */ - LUfactors = (factors_t*) f_factors; - if (LUfactors != NULL) { - SUPERLU_FREE (LUfactors->perm_r); - SUPERLU_FREE (LUfactors->perm_c); - Destroy_SuperNode_Matrix(LUfactors->L); - Destroy_CompCol_Matrix(LUfactors->U); - SUPERLU_FREE (LUfactors->L); - SUPERLU_FREE (LUfactors->U); - SUPERLU_FREE (LUfactors); - } - return(0); -#else - fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); - return(-1); -#endif -} - - diff --git a/mlprec/impl/mld_dslud_interface.c b/mlprec/impl/mld_dslud_interface.c deleted file mode 100644 index 754cd521..00000000 --- a/mlprec/impl/mld_dslud_interface.c +++ /dev/null @@ -1,391 +0,0 @@ -/* - * - * MLD2P4 version 2.1 - * MultiLevel Domain Decomposition Parallel Preconditioners Package - * based on PSBLAS (Parallel Sparse BLAS version 3.5) - * - * (C) Copyright 2008-2018 - * - * Salvatore Filippone - * Ambra Abdullahi Hassan - * Alfredo Buttari CNRS-IRIT, Toulouse, FR - * Pasqua D'Ambra - * Daniela di Serafino - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions, and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the MLD2P4 group or the names of its contributors may - * not be used to endorse or promote products derived from this - * software without specific written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * - * File: mld_dslud_interface.c - * - * Functions: mld_dsludist_fact, mld_dsludist_solve, mld_dsludist_free. - * - * This file is an interface to the SuperLU_dist routines for sparse factorization and - * solve. It was obtained by modifying the c_fortran_dgssv.c file from the SuperLU_dist - * source distribution; original copyright terms are reproduced below. - * - */ - -/* ===================== - -Copyright (c) 2003, The Regents of the University of California, through -Lawrence Berkeley National Laboratory (subject to receipt of any required -approvals from U.S. Dept. of Energy) - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -(1) Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. -(2) Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. -(3) Neither the name of Lawrence Berkeley National Laboratory, U.S. Dept. of -Energy nor the names of its contributors may be used to endorse or promote -products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -/* - * -- Distributed SuperLU routine (version 2.0) -- - * Lawrence Berkeley National Lab, Univ. of California Berkeley. - * March 15, 2003 - * - */ - -#ifdef Have_SLUDist_ -#include -#include "superlu_ddefs.h" - -#define HANDLE_SIZE 8 - -#if defined(SLUD_VERSION_63) -typedef struct { - SuperMatrix *A; - dLUstruct_t *LUstruct; - gridinfo_t *grid; - dScalePermstruct_t *ScalePermstruct; -} factors_t; -#else -typedef struct { - SuperMatrix *A; - LUstruct_t *LUstruct; - gridinfo_t *grid; - ScalePermstruct_t *ScalePermstruct; -} factors_t; -#endif - -#else - -#include - -#endif - - -int mld_dsludist_fact(int n, int nl, int nnzl, int ffstr, - double *values, int *rowptr, int *colind, - void **f_factors, int nprow, int npcol) -{ -/* - * This routine can be called from Fortran. - * performs LU decomposition. - * - * f_factors (input/output) void** - * On output contains the pointer pointing to - * the structure of the factored matrices. - * - */ - -#ifdef Have_SLUDist_ - SuperMatrix *A; - NRformat_loc *Astore; - -#if defined(SLUD_VERSION_63) - dScalePermstruct_t *ScalePermstruct; - dLUstruct_t *LUstruct; - dSOLVEstruct_t SOLVEstruct; -#else - ScalePermstruct_t *ScalePermstruct; - LUstruct_t *LUstruct; - SOLVEstruct_t SOLVEstruct; -#endif - gridinfo_t *grid; - int i, panel_size, permc_spec, relax, info; - trans_t trans; - double drop_tol = 0.0, b[1], berr[1]; -#if defined(SLUD_VERSION_63) || defined(SLUD_VERSION_6)||defined(SLUD_VERSION_5) - superlu_dist_options_t options; -#elif defined(SLUD_VERSION_4)||defined(SLUD_VERSION_3) - superlu_options_t options; -#else - choke_on_me; -#endif - SuperLUStat_t stat; - factors_t *LUfactors; - int fst_row; - int *icol,*irpt; - double *ival; - - trans = NOTRANS; - grid = (gridinfo_t *) SUPERLU_MALLOC(sizeof(gridinfo_t)); - superlu_gridinit(MPI_COMM_WORLD, nprow, npcol, grid); - /* Initialize the statistics variables. */ - PStatInit(&stat); - fst_row = (ffstr); - - A = (SuperMatrix *) malloc(sizeof(SuperMatrix)); - dCreate_CompRowLoc_Matrix_dist(A, n, n, nnzl, nl, fst_row, - values, colind, rowptr, - SLU_NR_loc, SLU_D, SLU_GE); - - /* Initialize ScalePermstruct and LUstruct. */ -#if defined(SLUD_VERSION_63) - ScalePermstruct = (dScalePermstruct_t *) SUPERLU_MALLOC(sizeof(dScalePermstruct_t)); - LUstruct = (dLUstruct_t *) SUPERLU_MALLOC(sizeof(dLUstruct_t)); - dScalePermstructInit(n,n, ScalePermstruct); -#else - ScalePermstruct = (ScalePermstruct_t *) SUPERLU_MALLOC(sizeof(ScalePermstruct_t)); - LUstruct = (LUstruct_t *) SUPERLU_MALLOC(sizeof(LUstruct_t)); - ScalePermstructInit(n,n, ScalePermstruct); -#endif -#if defined(SLUD_VERSION_63) - dLUstructInit(n, LUstruct); -#elif defined(SLUD_VERSION_4) || defined(SLUD_VERSION_5) || defined(SLUD_VERSION_6) - LUstructInit(n, LUstruct); -#elif defined(SLUD_VERSION_3) - LUstructInit(n,n, LUstruct); -#else - choke_on_me; -#endif - - /* Set the default input options. */ - set_default_options_dist(&options); - options.IterRefine=NO; - options.PrintStat=NO; - - pdgssvx(&options, A, ScalePermstruct, b, nl, 0, - grid, LUstruct, &SOLVEstruct, berr, &stat, &info); - - if ( info == 0 ) { - ; - } else { - printf("pdgssvx() error returns INFO= %d\n", info); - if ( info <= n ) { /* factorization completes */ - ; - } - } - if (options.SolveInitialized) { - dSolveFinalize(&options,&SOLVEstruct); - } - - - /* Save the LU factors in the factors handle */ - LUfactors = (factors_t *) SUPERLU_MALLOC(sizeof(factors_t)); - LUfactors->LUstruct = LUstruct; - LUfactors->grid = grid; - LUfactors->A = A; - LUfactors->ScalePermstruct = ScalePermstruct; -/* fprintf(stderr,"slud factor: LUFactors %p \n",LUfactors); */ -/* fprintf(stderr,"slud factor: A %p %p\n",A,LUfactors->A); */ -/* fprintf(stderr,"slud factor: grid %p %p\n",grid,LUfactors->grid); */ -/* fprintf(stderr,"slud factor: LUstruct %p %p\n",LUstruct,LUfactors->LUstruct); */ - *f_factors = (void *) LUfactors; - PStatFree(&stat); - return(info); -#else - fprintf(stderr," SLUDist Not Configured, fix make.inc and recompile\n"); - return(-1); -#endif -} - - -int mld_dsludist_solve(int itrans, int n, int nrhs, - double *b, int ldb, void *f_factors) - -{ -/* - * This routine can be called from Fortran. - * performs triangular solve - * - */ -#ifdef Have_SLUDist_ - SuperMatrix *A; -#if defined(SLUD_VERSION_63) - dScalePermstruct_t *ScalePermstruct; - dLUstruct_t *LUstruct; - dSOLVEstruct_t SOLVEstruct; -#else - ScalePermstruct_t *ScalePermstruct; - LUstruct_t *LUstruct; - SOLVEstruct_t SOLVEstruct; -#endif - gridinfo_t *grid; - int i, panel_size, permc_spec, relax, info; - trans_t trans; - double drop_tol = 0.0; - double *berr; -#if defined(SLUD_VERSION_63) || defined(SLUD_VERSION_6) ||defined(SLUD_VERSION_5) - superlu_dist_options_t options; -#elif defined(SLUD_VERSION_4)|| defined(SLUD_VERSION_3) - superlu_options_t options; -#else - choke_on_me; -#endif - SuperLUStat_t stat; - factors_t *LUfactors; - - LUfactors = (factors_t *) f_factors ; - A = LUfactors->A ; - LUstruct = LUfactors->LUstruct ; - grid = LUfactors->grid ; - - ScalePermstruct = LUfactors->ScalePermstruct; -/* fprintf(stderr,"slud solve: LUFactors %p \n",LUfactors); */ -/* fprintf(stderr,"slud solve: A %p %p\n",A,LUfactors->A); */ -/* fprintf(stderr,"slud solve: grid %p %p\n",grid,LUfactors->grid); */ -/* fprintf(stderr,"slud solve: LUstruct %p %p\n",LUstruct,LUfactors->LUstruct); */ - - - if (itrans == 0) { - trans = NOTRANS; - } else if (itrans ==1) { - trans = TRANS; - } else if (itrans ==2) { - trans = CONJ; - } else { - trans = NOTRANS; - } - -/* fprintf(stderr,"Entry to sludist_solve\n"); */ - berr = (double *) malloc((nrhs) *sizeof(double)); - - /* Initialize the statistics variables. */ - PStatInit(&stat); - - /* Set the default input options. */ - set_default_options_dist(&options); - options.IterRefine = NO; - options.Fact = FACTORED; - options.PrintStat = NO; - - pdgssvx(&options, A, ScalePermstruct, b, ldb, nrhs, - grid, LUstruct, &SOLVEstruct, berr, &stat, &info); - -/* fprintf(stderr,"Double check: after solve %d %lf\n",*info,berr[0]); */ - if (options.SolveInitialized) { - dSolveFinalize(&options,&SOLVEstruct); - } - PStatFree(&stat); - free(berr); - return(info); -#else - fprintf(stderr," SLUDist Not Configured, fix make.inc and recompile\n"); - return(-1); -#endif - -} - - -int mld_dsludist_free(void *f_factors) -{ -/* - * This routine can be called from Fortran. - * - * free all storage in the end -* - */ -#ifdef Have_SLUDist_ - SuperMatrix *A; -#if defined(SLUD_VERSION_63) - dScalePermstruct_t *ScalePermstruct; - dLUstruct_t *LUstruct; - dSOLVEstruct_t SOLVEstruct; -#else - ScalePermstruct_t *ScalePermstruct; - LUstruct_t *LUstruct; - SOLVEstruct_t SOLVEstruct; -#endif - gridinfo_t *grid; - int i, panel_size, permc_spec, relax; - trans_t trans; - double drop_tol = 0.0; - double *berr; -#if defined(SLUD_VERSION_63)||defined(SLUD_VERSION_6)||defined(SLUD_VERSION_5) - superlu_dist_options_t options; -#elif defined(SLUD_VERSION_4)||defined(SLUD_VERSION_3) - superlu_options_t options; -#else - choke_on_me; -#endif - SuperLUStat_t stat; - factors_t *LUfactors; - - - if (f_factors == NULL) - return(0); - LUfactors = (factors_t *) f_factors ; - A = LUfactors->A ; - LUstruct = LUfactors->LUstruct ; - grid = LUfactors->grid ; - ScalePermstruct = LUfactors->ScalePermstruct; - - // Memory leak: with SuperLU_Dist 3.3 - // we either have a leak or a segfault here. - // To be investigated further. - //Destroy_CompRowLoc_Matrix_dist(A); -#if defined(SLUD_VERSION_63) - dScalePermstructFree(ScalePermstruct); - dLUstructFree(LUstruct); -#else - ScalePermstructFree(ScalePermstruct); - LUstructFree(LUstruct); -#endif - superlu_gridexit(grid); - - free(grid); - free(LUstruct); - free(LUfactors); - return(0); - -#else - fprintf(stderr," SLUDist Not Configured, fix make.inc and recompile\n"); - return(-1); -#endif -} - - diff --git a/mlprec/impl/mld_dumf_interface.c b/mlprec/impl/mld_dumf_interface.c deleted file mode 100644 index 5aa0587a..00000000 --- a/mlprec/impl/mld_dumf_interface.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - * - * MLD2P4 version 2.1 - * MultiLevel Domain Decomposition Parallel Preconditioners Package - * based on PSBLAS (Parallel Sparse BLAS version 3.5) - * - * (C) Copyright 2008-2018 - * - * Salvatore Filippone - * Pasqua D'Ambra - * Daniela di Serafino - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions, and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the MLD2P4 group or the names of its contributors may - * not be used to endorse or promote products derived from this - * software without specific written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * - * File: mld_umf_interface.c - * - * Functions: mld_dumf_fact_, mld_dumf_solve_, mld_umf_free_. - * - * This file is an interface to the UMFPACK routines for sparse factorization and - * solve. It was obtained by adapting umfpack_di_demo under the original UMFPACK - * copyright terms reproduced below. - * - */ - -/* ===================== -UMFPACK Version 4.4 (Jan. 28, 2005), Copyright (c) 2005 by Timothy A. -Davis. All Rights Reserved. - -UMFPACK License: - - Your use or distribution of UMFPACK or any modified version of - UMFPACK implies that you agree to this License. - - THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY - EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - - Permission is hereby granted to use or copy this program, provided - that the Copyright, this License, and the Availability of the original - version is retained on all copies. User documentation of any code that - uses UMFPACK or any modified version of UMFPACK code must cite the - Copyright, this License, the Availability note, and "Used by permission." - Permission to modify the code and to distribute modified code is granted, - provided the Copyright, this License, and the Availability note are - retained, and a notice that the code was modified is included. This - software was developed with support from the National Science Foundation, - and is provided to you free of charge. - -Availability: - - http://www.cise.ufl.edu/research/sparse/umfpack - -*/ - - -#include -#ifdef Have_UMF_ -#include "umfpack.h" -#endif - -int mld_dumf_fact(int n, int nnz, - double *values, int *rowind, int *colptr, - void **symptr, void **numptr, - long long int *ssize, - long long int *nsize) - -{ - -#ifdef Have_UMF_ - double Info [UMFPACK_INFO], Control [UMFPACK_CONTROL]; - void *Symbolic, *Numeric ; - int i, info; - - - umfpack_di_defaults(Control); - - info = umfpack_di_symbolic (n, n, colptr, rowind, values, &Symbolic, - Control, Info); - - - if ( info == UMFPACK_OK ) { - info = 0; - } else { - printf("umfpack_di_symbolic() error returns INFO= %d\n", info); - umfpack_di_report_status(Control,info); - *symptr = (void *) NULL; - *numptr = (void *) NULL; - return -11; - } - - *symptr = Symbolic; - *ssize = Info[UMFPACK_SYMBOLIC_SIZE]; - *ssize *= Info[UMFPACK_SIZE_OF_UNIT]; - - info = umfpack_di_numeric (colptr, rowind, values, Symbolic, &Numeric, - Control, Info) ; - - - if ( info == UMFPACK_OK ) { - info = 0; - *numptr = Numeric; - *nsize = Info[UMFPACK_NUMERIC_SIZE]; - *nsize *= Info[UMFPACK_SIZE_OF_UNIT]; - - } else { - printf("umfpack_di_numeric() error returns INFO= %d\n", info); - umfpack_di_report_status(Control,info); - info = -12; - *numptr = NULL; - } - - - return info; - -#else - fprintf(stderr," UMF Not Configured, fix make.inc and recompile\n"); - return -1; -#endif -} - - -int mld_dumf_solve(int itrans, int n, - double *x, double *b, int ldb, - void *numptr) - -{ -#ifdef Have_UMF_ - double Info [UMFPACK_INFO], Control [UMFPACK_CONTROL]; - void *Symbolic, *Numeric ; - int i,trans, info; - - - umfpack_di_defaults(Control); - Control[UMFPACK_IRSTEP]=0; - - - if (itrans == 0) { - trans = UMFPACK_A; - } else if (itrans ==1) { - trans = UMFPACK_At; - } else { - trans = UMFPACK_A; - } - - info = umfpack_di_solve(trans,NULL,NULL,NULL, - x,b,numptr,Control,Info); - return info; -#else - fprintf(stderr," UMF Not Configured, fix make.inc and recompile\n"); - return -1; -#endif - -} - - -int mld_dumf_free(void *symptr, void *numptr) - -{ -#ifdef Have_UMF_ - void *Symbolic, *Numeric ; - Symbolic = symptr; - Numeric = numptr; - - if (numptr != NULL) umfpack_di_free_numeric(&Numeric); - if (symptr != NULL) umfpack_di_free_symbolic(&Symbolic); - return 0; -#else - fprintf(stderr," UMF Not Configured, fix make.inc and recompile\n"); - return -1; -#endif -} - - diff --git a/mlprec/impl/mld_s_extprol_bld.F90 b/mlprec/impl/mld_s_extprol_bld.F90 deleted file mode 100644 index 9ee6755c..00000000 --- a/mlprec/impl/mld_s_extprol_bld.F90 +++ /dev/null @@ -1,534 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_s_extprol_bld.f90 -! -! Subroutine: mld_s_extprol_bld -! Version: real -! -! This routine builds the preconditioner according to the requirements made by -! the user trough the subroutines mld_precinit and mld_precset. -! -! A multilevel preconditioner is regarded as an array of 'one-level' data structures, -! each containing the part of the preconditioner associated to a certain level, -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level. No transfer operators are associated to level 1. -! -! -! Arguments: -! a - type(psb_sspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_sprec_type), input/output. -! The preconditioner data structure containing the local part -! of the preconditioner to be built. -! info - integer, output. -! Error code. -! -! amold - class(psb_s_base_sparse_mat), input, optional -! Mold for the inner format of matrices contained in the -! preconditioner -! -! -! vmold - class(psb_s_base_vect_type), input, optional -! Mold for the inner format of vectors contained in the -! preconditioner -! -! -! -subroutine mld_s_extprol_bld(a,desc_a,p,prolv,restrv,info,amold,vmold,imold) - - use psb_base_mod - use mld_s_inner_mod - use mld_s_prec_mod, mld_protect_name => mld_s_extprol_bld - - Implicit None - - ! Arguments - type(psb_sspmat_type),intent(in), target :: a - type(psb_sspmat_type),intent(inout), target :: prolv(:) - type(psb_sspmat_type),intent(inout), target :: restrv(:) - type(psb_desc_type), intent(inout), target :: desc_a - type(mld_sprec_type),intent(inout),target :: p - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! !$ character, intent(in), optional :: upd - - ! Local Variables - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, casize, nplevs, mxplevs - integer(psb_ipk_) :: nprolv, nrestrv - real(psb_spk_) :: mnaggratio - integer(psb_ipk_) :: ipv(mld_ifpsz_), val - class(mld_s_base_smoother_type), allocatable :: coarse_sm, base_sm, med_sm - type(mld_sml_parms) :: baseparms, medparms, coarseparms - type(mld_s_onelev_type), allocatable :: tprecv(:) - integer(psb_ipk_) :: int_err(5) - character :: upd_ - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - logical, parameter :: debug=.false. - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_s_extprol_bld' - info = psb_success_ - int_err(1) = 0 - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - p%ictxt = ictxt - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' -#if defined(LPK8) - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Need fix for LPK8') - goto 9999 -#else - - ! - ! For the time being we are commenting out the UPDATE argument - ! we plan to resurrect it later. - ! !$ if (present(upd)) then - ! !$ if (debug_level >= psb_debug_outer_) & - ! !$ & write(debug_unit,*) me,' ',trim(name),'UPD ', upd - ! !$ - ! !$ if ((psb_toupper(upd).eq.'F').or.(psb_toupper(upd).eq.'T')) then - ! !$ upd_=psb_toupper(upd) - ! !$ else - ! !$ upd_='F' - ! !$ endif - ! !$ else - ! !$ upd_='F' - ! !$ endif - upd_ = 'F' - - if (.not.allocated(p%precv)) then - !! Error: should have called mld_sprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - ! - ! Check to ensure all procs have the same - ! - newsz = -1 - mxplevs = p%ag_data%max_levs - mnaggratio = p%ag_data%min_cr_ratio - casize = p%ag_data%min_coarse_size - iszv = size(p%precv) - nprolv = size(prolv) - nrestrv = size(restrv) - call psb_bcast(ictxt,iszv) - call psb_bcast(ictxt,casize) - call psb_bcast(ictxt,mxplevs) - call psb_bcast(ictxt,mnaggratio) - call psb_bcast(ictxt,nprolv) - call psb_bcast(ictxt,nrestrv) - if (casize /= p%ag_data%min_coarse_size) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent min_coarse_size') - goto 9999 - end if - if (mxplevs /= p%ag_data%max_levs) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent max_levs') - goto 9999 - end if - if (mnaggratio /= p%ag_data%min_cr_ratio) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent min_cr_ratio') - goto 9999 - end if - if (iszv /= size(p%precv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of precv') - goto 9999 - end if - if (nprolv /= size(prolv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of prolv') - goto 9999 - end if - if (nrestrv /= size(restrv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of restrv') - goto 9999 - end if - if (nrestrv /= nprolv) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size prolv vs restrv') - goto 9999 - end if - - if (iszv <= 1) then - ! We should only ever get here for multilevel. - info=psb_err_from_subroutine_ - ch_err='size bpv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - endif - - if (nrestrv < 1) then - ! We should only ever get here for multilevel. - info=psb_err_from_subroutine_ - ch_err='size restrv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - endif - - ! - nplevs = nrestrv + 1 - p%ag_data%max_levs = nplevs - - ! - ! Fixed number of levels. - ! - nplevs = max(itwo,mxplevs) - - coarseparms = p%precv(iszv)%parms - baseparms = p%precv(1)%parms - medparms = p%precv(2)%parms - - allocate(coarse_sm, source=p%precv(iszv)%sm,stat=info) - if (info == psb_success_) & - & allocate(med_sm, source=p%precv(2)%sm,stat=info) - if (info == psb_success_) & - & allocate(base_sm, source=p%precv(1)%sm,stat=info) - if (info /= psb_success_) then - write(0,*) 'Error in saving smoothers',info - call psb_errpush(psb_err_internal_error_,name,a_err='Base level precbuild.') - goto 9999 - end if - - if (iszv /= nplevs) then - allocate(tprecv(nplevs),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - tprecv(1)%parms = baseparms - allocate(tprecv(1)%sm,source=base_sm,stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - do i=2,nplevs-1 - tprecv(i)%parms = medparms - allocate(tprecv(i)%sm,source=med_sm,stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - end do - tprecv(nplevs)%parms = coarseparms - allocate(tprecv(nplevs)%sm,source=coarse_sm,stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - do i=1,iszv - call p%precv(i)%free(info) - end do - call move_alloc(tprecv,p%precv) - iszv = size(p%precv) - end if - ! - ! Finest level first; remember to fix base_a and base_desc - ! - p%precv(1)%base_a => a - p%precv(1)%base_desc => desc_a - newsz = 0 - array_build_loop: do i=2, iszv - - ! - ! Sanity checks on the parameters - ! - if (i p%precv(i)%ac - p%precv(i)%base_desc => p%precv(i)%desc_ac - - - if (i>2) then - if (all(p%precv(i)%map%naggr == p%precv(i-1)%map%naggr)) then - newsz=i-1 - end if - call psb_bcast(ictxt,newsz) - if (newsz > 0) exit array_build_loop - end if - end do array_build_loop - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Internal extprol build' ) - goto 9999 - endif - - iszv = size(p%precv) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Exiting with',iszv,' levels' -#endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - - subroutine mld_s_extaggr_bld(a,desc_a,p,op_restr,op_prol,info) - use psb_base_mod - use mld_s_inner_mod - - implicit none - - ! Arguments - type(psb_sspmat_type), intent(in), target :: a - type(psb_sspmat_type), intent(inout) :: op_restr,op_prol - type(psb_desc_type), intent(in), target :: desc_a - type(mld_s_onelev_type), intent(inout),target :: p - integer(psb_ipk_), intent(out) :: info - - ! Local variables - character(len=20) :: name - integer(psb_mpk_) :: ictxt, np, me, ncol - integer(psb_ipk_) :: err_act,ntaggr,nzl - integer(psb_ipk_), allocatable :: ilaggr(:), nlaggr(:) - type(psb_sspmat_type) :: ac, am2, am3, am4 - type(psb_s_coo_sparse_mat) :: acoo, bcoo - type(psb_s_csr_sparse_mat) :: acsr1 - logical, parameter :: debug=.false. - - name='mld_s_extaggr_bld' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) -#if defined(LPK8) - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Need fix for LPK8') - goto 9999 -#else - allocate(nlaggr(np),ilaggr(1)) - nlaggr = 0 - ilaggr = 0 - p%parms%par_aggr_alg = mld_ext_aggr_ - call mld_check_def(p%parms%ml_cycle,'Multilevel cycle',& - & mld_mult_ml_,is_legal_ml_cycle) - call mld_check_def(p%parms%coarse_mat,'Coarse matrix',& - & mld_distr_mat_,is_legal_ml_coarse_mat) - - nlaggr(me+1) = op_restr%get_nrows() - if (op_restr%get_nrows() /= op_prol%get_ncols()) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent restr/prol sizes') - goto 9999 - end if - call psb_sum(ictxt,nlaggr) - ntaggr = sum(nlaggr) - ncol = desc_a%get_local_cols() - if (debug) write(0,*)me,' Sizes:',op_restr%get_nrows(),op_restr%get_ncols(),& - & op_prol%get_nrows(),op_prol%get_ncols(), a%get_nrows(),a%get_ncols() - ! - ! Compute local part of AC - ! - call op_prol%clone(am2,info) - if (info == psb_success_) call psb_sphalo(am2,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.) - if (info == psb_success_) call psb_rwextd(ncol,am2,info,b=am4) - if (info == psb_success_) call am4%free() - call psb_spspmm(a,am2,am3,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 2') - goto 9999 - end if - call psb_sphalo(am3,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.) - if (info == psb_success_) call psb_rwextd(ncol,am3,info,b=am4) - if (info == psb_success_) call am4%free() - if(info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Extend am3') - goto 9999 - end if - call psb_spspmm(op_restr,am3,ac,info) - if (info == psb_success_) call am3%free() - if (info == psb_success_) call ac%cscnv(info,type='csr',dupl=psb_dupl_add_) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Build ac = op_restr x am3') - goto 9999 - end if - - select case(p%parms%coarse_mat) - - case(mld_distr_mat_) - - call ac%mv_to(bcoo) - nzl = bcoo%get_nzeros() - - if (info == psb_success_) call psb_cdall(ictxt,p%desc_ac,info,nl=nlaggr(me+1)) - if (info == psb_success_) call psb_cdins(nzl,bcoo%ia,bcoo%ja,p%desc_ac,info) - if (info == psb_success_) call psb_cdasb(p%desc_ac,info) - if (info == psb_success_) call psb_glob_to_loc(bcoo%ia(1:nzl),p%desc_ac,info,iact='I') - if (info == psb_success_) call psb_glob_to_loc(bcoo%ja(1:nzl),p%desc_ac,info,iact='I') - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Creating p%desc_ac and converting ac') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Assembld aux descr. distr.' - call p%ac%mv_from(bcoo) - - call p%ac%set_nrows(p%desc_ac%get_local_rows()) - call p%ac%set_ncols(p%desc_ac%get_local_cols()) - call p%ac%set_asb() - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_sp_free') - goto 9999 - end if - - if (np>1) then - call op_prol%mv_to(acsr1) - nzl = acsr1%get_nzeros() - call psb_glob_to_loc(acsr1%ja(1:nzl),p%desc_ac,info,'I') - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_glob_to_loc') - goto 9999 - end if - call op_prol%mv_from(acsr1) - endif - call op_prol%set_ncols(p%desc_ac%get_local_cols()) - - if (np>1) then - call op_restr%cscnv(info,type='coo',dupl=psb_dupl_add_) - call op_restr%mv_to(acoo) - nzl = acoo%get_nzeros() - if (info == psb_success_) call psb_glob_to_loc(acoo%ia(1:nzl),p%desc_ac,info,'I') - call acoo%set_dupl(psb_dupl_add_) - if (info == psb_success_) call op_restr%mv_from(acoo) - if (info == psb_success_) call op_restr%cscnv(info,type='csr') - if(info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Converting op_restr to local') - goto 9999 - end if - end if - call op_restr%set_nrows(p%desc_ac%get_local_cols()) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ac ' - - case(mld_repl_mat_) - ! - ! - call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) - if (info == psb_success_) call psb_cdasb(p%desc_ac,info) - if (info == psb_success_) & - & call psb_gather(p%ac,ac,p%desc_ac,info,dupl=psb_dupl_add_,keeploc=.false.) - - if (info /= psb_success_) goto 9999 - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_coarse_mat_') - goto 9999 - end select - - call p%ac%cscnv(info,type='csr',dupl=psb_dupl_add_) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv') - goto 9999 - end if - - ! - ! Copy the prolongation/restriction matrices into the descriptor map. - ! op_restr => PR^T i.e. restriction operator - ! op_prol => PR i.e. prolongation operator - ! - - p%map = psb_linmap(psb_map_aggr_,desc_a,& - & p%desc_ac,op_restr,op_prol,ilaggr,nlaggr) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_Free') - goto 9999 - end if -#endif - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - end subroutine mld_s_extaggr_bld - -end subroutine mld_s_extprol_bld diff --git a/mlprec/impl/mld_s_hierarchy_bld.f90 b/mlprec/impl/mld_s_hierarchy_bld.f90 deleted file mode 100644 index b1c610e6..00000000 --- a/mlprec/impl/mld_s_hierarchy_bld.f90 +++ /dev/null @@ -1,539 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_s_hierarchy_bld.f90 -! -! Subroutine: mld_s_hierarchy_bld -! Version: real -! -! This routine builds the preconditioner according to the requirements made by -! the user trough the subroutines mld_precinit and mld_precset. -! -! A multilevel preconditioner is regarded as an array of 'one-level' data structures, -! each containing the part of the preconditioner associated to a certain level, -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level. No transfer operators are associated to level 1. -! -! -! Arguments: -! a - type(psb_sspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_sprec_type), input/output. -! The preconditioner data structure; upon exit it contains -! the multilevel hierarchy of prolongators, restrictors -! and coarse matrices. -! info - integer, output. -! Error code. -! -subroutine mld_s_hierarchy_bld(a,desc_a,prec,info) - - use psb_base_mod - use mld_s_inner_mod - use mld_s_prec_mod, mld_protect_name => mld_s_hierarchy_bld - - Implicit None - - ! Arguments - type(psb_sspmat_type),intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_sprec_type),intent(inout),target :: prec - integer(psb_ipk_), intent(out) :: info - - ! Local Variables - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz,& - & nplevs, mxplevs - integer(psb_lpk_) :: iaggsize, casize - real(psb_spk_) :: mnaggratio, sizeratio, athresh, aomega - class(mld_s_base_smoother_type), allocatable :: coarse_sm, med_sm, & - & med_sm2, coarse_sm2 - class(mld_s_base_aggregator_type), allocatable :: tmp_aggr - type(mld_sml_parms) :: medparms, coarseparms - integer(psb_lpk_), allocatable :: ilaggr(:), nlaggr(:) - type(psb_lsspmat_type) :: op_prol - type(mld_s_onelev_type), allocatable :: tprecv(:) - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - integer(psb_ipk_), save :: idx_bldtp=-1, idx_matasb=-1 - logical, parameter :: do_timings=.false. - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_s_hierarchy_bld' - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - prec%ictxt = ictxt - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' - if ((do_timings).and.(idx_bldtp==-1)) & - & idx_bldtp = psb_get_timer_idx("BLD_HIER: bld_tprol") - if ((do_timings).and.(idx_matasb==-1)) & - & idx_matasb = psb_get_timer_idx("BLD_HIER: mmat_asb") - ! - - if (.not.allocated(prec%precv)) then - !! Error: should have called mld_sprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - ! - ! Check to ensure all procs have the same - ! - newsz = -1 - mxplevs = prec%ag_data%max_levs - mnaggratio = prec%ag_data%min_cr_ratio - casize = prec%ag_data%min_coarse_size - iszv = size(prec%precv) - call psb_bcast(ictxt,iszv) - call psb_bcast(ictxt,casize) - call psb_bcast(ictxt,mxplevs) - call psb_bcast(ictxt,mnaggratio) - if (casize /= prec%ag_data%min_coarse_size) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent min_coarse_size') - goto 9999 - end if - if (mxplevs /= prec%ag_data%max_levs) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent max_levs') - goto 9999 - end if - if (mnaggratio /= prec%ag_data%min_cr_ratio) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent min_cr_ratio') - goto 9999 - end if - if (iszv /= size(prec%precv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of precv') - goto 9999 - end if - - if (iszv < 1) then - ! - ! This is wrong, cannot be size <1 - ! - info=psb_err_from_subroutine_ - ch_err='size bpv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - endif - if (iszv == 1) then - ! - ! This is OK, since it may be called by the user even if there - ! is only one level - ! - prec%precv(1)%base_a => a - prec%precv(1)%base_desc => desc_a - - call psb_erractionrestore(err_act) - return - endif - - ! - ! The strategy: - ! 1. The maximum number of levels should be already encoded in the - ! size of the array; - ! 2. If the user did not specify anything, then a default coarse size - ! is generated, and the number of levels is set to the maximum; - ! 3. If the size of the array is different from target number of levels, - ! reallocate; - ! 4. Build the matrix hierarchy, stopping early if either the target - ! coarse size is hit, or the gain falls below the min_cr_ratio - ! threshold. - ! - - if (casize < 0) then - ! - ! Default to the cubic root of the size at base level. - ! - casize = desc_a%get_global_rows() - casize = int((sone*casize)**(sone/(sone*3)),psb_lpk_) - casize = max(casize,lone) - casize = casize*40_psb_lpk_ - call psb_bcast(ictxt,casize) - if (casize > huge(prec%ag_data%min_coarse_size)) then - ! - ! computed coarse size does not fit in IPK_. - ! This is very unlikely, but make sure to put a positive number - ! - prec%ag_data%min_coarse_size = huge(prec%ag_data%min_coarse_size) - else - prec%ag_data%min_coarse_size = casize - end if - end if - nplevs = max(itwo,mxplevs) - - ! - ! The coarse parameters will be needed later - ! - coarseparms = prec%precv(iszv)%parms - call save_smoothers(prec%precv(iszv),coarse_sm,coarse_sm2,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Base level precbuild.') - goto 9999 - end if - ! - ! First set desired number of levels - ! - if (iszv /= nplevs) then - allocate(tprecv(nplevs),stat=info) - ! First all existing levels - do i=1, min(iszv,nplevs) - 1 - if (info == 0) tprecv(i)%parms = prec%precv(i)%parms - if (info == 0) call restore_smoothers(tprecv(i),& - & prec%precv(i)%sm,prec%precv(i)%sm2a,info) - if (info == 0) call move_alloc(prec%precv(i)%aggr,tprecv(i)%aggr) - end do - if (iszv < nplevs) then - ! Further intermediates, if needed - allocate(tmp_aggr,source=tprecv(iszv-1)%aggr,stat=info) - medparms = prec%precv(iszv-1)%parms - call save_smoothers(prec%precv(iszv-1),med_sm,med_sm2,info) - do i=iszv, nplevs - 1 - if (info == 0) tprecv(i)%parms = medparms - if (info == 0) call restore_smoothers(tprecv(i),med_sm,med_sm2,info) - if ((info == 0).and..not.allocated(tprecv(i)%aggr))& - & allocate(tprecv(i)%aggr,source=tmp_aggr,stat=info) - end do - deallocate(tmp_aggr,stat=info) - end if - - ! Then coarse - if (info == 0) tprecv(nplevs)%parms = coarseparms - if (info == 0) call restore_smoothers(tprecv(nplevs),coarse_sm,coarse_sm2,info) - if (info == 0) then - if (nplevs <= iszv) then - allocate(tprecv(nplevs)%aggr,source=prec%precv(nplevs)%aggr,stat=info) - else - allocate(tmp_aggr,source=tprecv(nplevs-1)%aggr,stat=info) - call move_alloc(tmp_aggr,tprecv(nplevs)%aggr) - end if - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - - do i=1,iszv - call prec%precv(i)%free(info) - end do - call move_alloc(tprecv,prec%precv) - iszv = size(prec%precv) - end if - - ! - ! Finest level first; create a GEN_BLOCK - ! copy of the descriptor. - ! - prec%precv(1)%base_a => a - call psb_cd_renum_block(desc_a,prec%precv(1)%desc_ac,info) - prec%precv(1)%base_desc => prec%precv(1)%desc_ac - newsz = 0 - array_build_loop: do i=2, iszv - ! - ! Check on the iprcparm contents: they should be the same - ! on all processes. - ! - call psb_bcast(ictxt,prec%precv(i)%parms) - - ! - ! Sanity checks on the parameters - ! - if (i= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Calling mlprcbld at level ',i - ! - ! Build the mapping between levels i-1 and i and the matrix - ! at level i - ! - if (do_timings) call psb_tic(idx_bldtp) - if (info == psb_success_)& - & call prec%precv(i)%bld_tprol(prec%precv(i-1)%base_a,& - & prec%precv(i-1)%base_desc,& - & ilaggr,nlaggr,op_prol,prec%ag_data,info) - if (do_timings) call psb_toc(idx_bldtp) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Map build') - goto 9999 - endif - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Return from ',i,' call to bld_tprol', info - ! - ! Save op_prol just in case - ! - call op_prol%clone(prec%precv(i)%tprol,info) - ! - ! Check for early termination of aggregation loop. - ! - iaggsize = sum(nlaggr) - - sizeratio = iaggsize - if (i==2) then - sizeratio = desc_a%get_global_rows()/sizeratio - else - sizeratio = sum(prec%precv(i-1)%map%naggr)/sizeratio - end if - prec%precv(i)%szratio = sizeratio - - if (iaggsize <= casize) newsz = i - if (i == iszv) newsz = i - - if (i>2) then - if (sizeratio < mnaggratio) then - if (sizeratio > 1) then - newsz = i - else - ! - ! We are not gaining - ! - newsz = i-1 - end if - end if - - if (all(nlaggr == prec%precv(i-1)%map%naggr)) then - newsz=i-1 - if (me == 0) then - write(debug_unit,*) trim(name),& - &': Warning: aggregates from level ',& - & newsz - write(debug_unit,*) trim(name),& - &': to level ',& - & iszv,' coincide.' - write(debug_unit,*) trim(name),& - &': Number of levels actually used :',newsz - write(debug_unit,*) - end if - end if - end if - call psb_bcast(ictxt,newsz) - - if (newsz > 0) then - ! - ! This is awkward, we are saving the aggregation parms, for the sake - ! of distr/repl matrix at coarse level. Should be rethought. - ! - athresh = prec%precv(newsz)%parms%aggr_thresh - aomega = prec%precv(newsz)%parms%aggr_omega_val - if (info == 0) prec%precv(newsz)%parms = coarseparms - prec%precv(newsz)%parms%aggr_thresh = athresh - prec%precv(newsz)%parms%aggr_omega_val = aomega - - if (info == 0) call restore_smoothers(prec%precv(newsz),& - & coarse_sm,coarse_sm2,info) - if (newsz < i) then - ! - ! We are going back and revisit a previous leve; - ! recover the aggregation. - ! - ilaggr = prec%precv(newsz)%map%iaggr - nlaggr = prec%precv(newsz)%map%naggr - call prec%precv(newsz)%tprol%clone(op_prol,info) - end if - if (do_timings) call psb_tic(idx_matasb) - if (info == psb_success_) call prec%precv(newsz)%mat_asb( & - & prec%precv(newsz-1)%base_a,prec%precv(newsz-1)%base_desc,& - & ilaggr,nlaggr,op_prol,info) - if (do_timings) call psb_toc(idx_matasb) - if (info /= 0) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Mat asb') - goto 9999 - endif - exit array_build_loop - else - if (do_timings) call psb_tic(idx_matasb) - if (info == psb_success_) call prec%precv(i)%mat_asb(& - & prec%precv(i-1)%base_a,prec%precv(i-1)%base_desc,& - & ilaggr,nlaggr,op_prol,info) - if (do_timings) call psb_toc(idx_matasb) - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Map build') - goto 9999 - endif - if (i 0) then - ! - ! We exited early from the build loop, need to fix - ! the size. - ! - allocate(tprecv(newsz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - do i=1,newsz - call prec%precv(i)%move_alloc(tprecv(i),info) - end do - do i=newsz+1, iszv - call prec%precv(i)%free(info) - end do - call move_alloc(tprecv,prec%precv) - ! Ignore errors from transfer - info = psb_success_ - ! - ! Restart - iszv = newsz - ! Fix the pointers, but the level 1 should - ! be treated differently - if (.not.associated(prec%precv(1)%base_desc,desc_a)) then - prec%precv(1)%base_desc => prec%precv(1)%desc_ac - end if - do i=2, iszv - prec%precv(i)%base_a => prec%precv(i)%ac - prec%precv(i)%base_desc => prec%precv(i)%desc_ac - prec%precv(i)%map%p_desc_U => prec%precv(i-1)%base_desc - prec%precv(i)%map%p_desc_V => prec%precv(i)%base_desc - end do - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Internal hierarchy build' ) - goto 9999 - endif - - iszv = size(prec%precv) - - call prec%cmp_complexity() - call prec%cmp_avg_cr() - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Exiting with',iszv,' levels' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - subroutine save_smoothers(level,save1, save2,info) - type(mld_s_onelev_type), intent(inout) :: level - class(mld_s_base_smoother_type), allocatable , intent(inout) :: save1, save2 - integer(psb_ipk_), intent(out) :: info - - info = 0 - if (allocated(save1)) then - call save1%free(info) - if (info == 0) deallocate(save1,stat=info) - if (info /= 0) return - end if - if (allocated(save2)) then - call save2%free(info) - if (info == 0) deallocate(save2,stat=info) - if (info /= 0) return - end if - allocate(save1, mold=level%sm,stat=info) - if (info == 0) call level%sm%clone_settings(save1,info) - if ((info == 0).and.allocated(level%sm2a)) then - allocate(save2, mold=level%sm2a,stat=info) - if (info == 0) call level%sm2a%clone_settings(save2,info) - end if - - return - end subroutine save_smoothers - - subroutine restore_smoothers(level,save1, save2,info) - type(mld_s_onelev_type), intent(inout), target :: level - class(mld_s_base_smoother_type), allocatable, intent(inout) :: save1, save2 - integer(psb_ipk_), intent(out) :: info - - info = 0 - - if (allocated(level%sm)) then - if (info == 0) call level%sm%free(info) - if (info == 0) deallocate(level%sm,stat=info) - end if - if (allocated(save1)) then - if (info == 0) allocate(level%sm,mold=save1,stat=info) - if (info == 0) call save1%clone_settings(level%sm,info) - end if - - if (info /= 0) return - - if (allocated(level%sm2a)) then - if (info == 0) call level%sm2a%free(info) - if (info == 0) deallocate(level%sm2a,stat=info) - end if - if (allocated(save2)) then - if (info == 0) allocate(level%sm2a,mold=save2,stat=info) - if (info == 0) call save2%clone_settings(level%sm2a,info) - if (info == 0) level%sm2 => level%sm2a - else - if (allocated(level%sm)) level%sm2 => level%sm - end if - - return - end subroutine restore_smoothers - -end subroutine mld_s_hierarchy_bld diff --git a/mlprec/impl/mld_s_smoothers_bld.f90 b/mlprec/impl/mld_s_smoothers_bld.f90 deleted file mode 100644 index 0abdcdab..00000000 --- a/mlprec/impl/mld_s_smoothers_bld.f90 +++ /dev/null @@ -1,313 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_s_smoothers_bld.f90 -! -! Subroutine: mld_s_smoothers_bld -! Version: real -! -! This routine performs the final phase of the multilevel preconditioner -! build process: builds the "smoother" objects at each level, -! based on the matrix hierarchy prepared by mld_s_hierarchy_bld. -! -! A multilevel preconditioner is regarded as an array of 'one-level' -! data structures, each containing the part of the -! preconditioner associated to a certain level, -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level. No transfer operators are associated to level 1. -! Each level provides a "build" method; for the base type, the "one-level" -! build procedure simply invokes the build method of the first smoother object, -! and also on the second object if allocated. -! -! -! Arguments: -! a - type(psb_sspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_sprec_type), input/output. -! The preconditioner data structure containing the local part -! of the preconditioner to be built. -! info - integer, output. -! Error code. -! -! amold - class(psb_s_base_sparse_mat), input, optional -! Mold for the inner format of matrices contained in the -! preconditioner -! -! -! vmold - class(psb_s_base_vect_type), input, optional -! Mold for the inner format of vectors contained in the -! preconditioner -! -! -! -subroutine mld_s_smoothers_bld(a,desc_a,prec,info,amold,vmold,imold) - - use psb_base_mod - !use mld_s_inner_mod - use mld_s_prec_mod, mld_protect_name => mld_s_smoothers_bld - - Implicit None - - ! Arguments - type(psb_sspmat_type),intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_sprec_type),intent(inout),target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local Variables - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, nplevs, mxplevs - real(psb_spk_) :: mnaggratio - integer(psb_ipk_) :: coarse_solve_id - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_s_smoothers_bld' - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' - ! - if (.not.allocated(prec%precv)) then - !! Error: should have called mld_sprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - ! - ! Check to ensure all procs have the same - ! - iszv = size(prec%precv) - call psb_bcast(ictxt,iszv) - if (iszv /= size(prec%precv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of precv') - goto 9999 - end if - - if (iszv < 1) then - ! We should never get here. - info=psb_err_from_subroutine_ - ch_err='size bpv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - endif - - ! - ! Issue a warning for inconsistent changes to COARSE_SOLVE - ! but only if it really is a multilevel - ! - if ((me == psb_root_).and.(iszv>1)) then - coarse_solve_id = prec%precv(iszv)%parms%coarse_solve - select case (coarse_solve_id) - case(mld_umf_,mld_slu_) - if (prec%precv(iszv)%sm%sv%get_id() /= coarse_solve_id) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id) - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) then - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else if (prec%precv(iszv)%parms%coarse_mat == mld_distr_mat_) then - write(psb_err_unit,*) ' but I am building BJAC with ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - end if - write(psb_err_unit,*) 'This may happen if: ' - write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' - write(psb_err_unit,*) ' 2. the solver ', mld_fact_names(coarse_solve_id),& - & ' was not configured at MLD2P4 build time, or' - write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' - end if - if (prec%precv(iszv)%parms%coarse_mat /= mld_repl_mat_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse matrix was requested as replicated', & - & ' but it has been changed to distributed.' - end if - - case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) - if (prec%precv(iszv)%sm%sv%get_id() /= psb_ilu_n_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id) - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) then - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else if (prec%precv(iszv)%parms%coarse_mat == mld_distr_mat_) then - write(psb_err_unit,*) ' but I am building BJAC with ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - end if - write(psb_err_unit,*) & - &'This may happen if coarse_subsolve has been reset' - end if - if (prec%precv(iszv)%parms%coarse_mat /= mld_repl_mat_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id),& - & ' but the coarse matrix has been changed to distributed' - end if - - case(mld_mumps_) - if (prec%precv(iszv)%sm%sv%get_id() /= mld_mumps_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id) - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) then - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else if (prec%precv(iszv)%parms%coarse_mat == mld_distr_mat_) then - write(psb_err_unit,*) ' but I am building BJAC with ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - end if - write(psb_err_unit,*) 'This may happen if: ' - write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' - write(psb_err_unit,*) ' 2. the solver ', mld_fact_names(coarse_solve_id),& - & ' was not configured at MLD2P4 build time, or' - write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' - end if - - case(mld_sludist_) - if (prec%precv(iszv)%sm%sv%get_id() /= coarse_solve_id) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id) - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) then - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else if (prec%precv(iszv)%parms%coarse_mat == mld_distr_mat_) then - write(psb_err_unit,*) ' but I am building BJAC with ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - end if - write(psb_err_unit,*) 'This may happen if: ' - write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' - write(psb_err_unit,*) ' 2. the solver ', mld_fact_names(coarse_solve_id), & - & ' was not configured at MLD2P4 build time, or' - write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' - end if - if (prec%precv(iszv)%parms%coarse_mat /= mld_distr_mat_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id),& - & ' but the coarse matrix has been changed to replicated' - end if - - case(mld_bjac_,mld_l1_bjac_,mld_jac_, mld_l1_jac_, mld_gs_, mld_fbgs_, mld_l1_gs_,mld_l1_fbgs_) - if (prec%precv(iszv)%parms%coarse_mat /= mld_distr_mat_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id),& - & ' but the coarse matrix has been changed to replicated' - end if - - case default - ! We should never get here. - info=psb_err_from_subroutine_ - ch_err='unkn coarse_solve' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - - end select - end if - - ! Sanity check: need to ensure that the MUMPS local/global NZ - ! are handled correctly; this is controlled by local vs global solver. - ! From this point of view, REPL is LOCAL because it owns everyting. - ! Should really find a better way of handling this. - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) & - & call prec%precv(iszv)%sm%sv%set('MUMPS_LOC_GLOB', mld_local_solver_,info) - ! - ! Now do the real build. - ! - - do i=1, iszv - ! - ! build the base preconditioner at level i - ! - call prec%precv(i)%bld(info,amold=amold,vmold=vmold,imold=imold,ilv=i) - - if (info /= psb_success_) then - write(ch_err,'(a,i7)') 'Error @ level',i - call psb_errpush(psb_err_internal_error_,name,& - & a_err=ch_err) - goto 9999 - endif - - end do - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Exiting with',iszv,' levels' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_smoothers_bld diff --git a/mlprec/impl/mld_scprecset.F90 b/mlprec/impl/mld_scprecset.F90 deleted file mode 100644 index 4575fd80..00000000 --- a/mlprec/impl/mld_scprecset.F90 +++ /dev/null @@ -1,971 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_sprecset.f90 -! -! Subroutine: mld_sprecseti -! Version: real -! -! This routine sets the integer parameters defining the preconditioner. More -! precisely, the integer parameter identified by 'what' is assigned the value -! contained in 'val'. -! For the multilevel preconditioners, the levels are numbered in increasing -! order starting from the finest one, i.e. level 1 is the finest level. -! -! To set character and real parameters, see mld_sprecsetc and mld_sprecsetr, -! respectively. -! -! -! Arguments: -! p - type(mld_sprec_type), input/output. -! The preconditioner data structure. -! what - integer, input. -! The number identifying the parameter to be set. -! A mnemonic constant has been associated to each of these -! numbers, as reported in the MLD2P4 User's and Reference Guide. -! val - integer, input. -! The value of the parameter to be set. The list of allowed -! values is reported in the MLD2P4 User's and Reference Guide. -! info - integer, output. -! Error code. -! ilev - integer, optional, input. -! For the multilevel preconditioner, the level at which the -! preconditioner parameter has to be set. -! If nlev is not present, the parameter identified by 'what' -! is set at all the appropriate levels. -! -! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to -! MLD2P4 developers. Indeed, by using ilev it is possible to set different values -! of the same parameter at different levels 1,...,nlev-1, even in cases where -! the parameter must have the same value at all the levels but the coarsest one. -! For this reason, the interface mld_precset to this routine has been built in -! such a way that ilev is not visible to the user (see mld_prec_mod.f90). -! -subroutine mld_scprecseti(p,what,val,info,ilev,ilmax,pos,idx) - - use psb_base_mod - use mld_s_prec_mod, mld_protect_name => mld_scprecseti - use mld_s_jac_smoother - use mld_s_as_smoother - use mld_s_diag_solver - use mld_s_l1_diag_solver - use mld_s_ilu_solver - use mld_s_id_solver - use mld_s_gs_solver -#if defined(HAVE_SLU_) - use mld_s_slu_solver -#endif -#if defined(HAVE_MUMPS_) - use mld_s_mumps_solver -#endif - - - implicit none - - ! Arguments - class(mld_sprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_, ilmax_, il - character(len=*), parameter :: name='mld_precseti' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmax_ = nlev_ - end if - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - select case(psb_toupper(what)) - case ('MIN_COARSE_SIZE') - p%ag_data%min_coarse_size = max(val,-1) - return - case('MAX_LEVS') - p%ag_data%max_levs = max(val,1) - return - case ('OUTER_SWEEPS') - p%outer_sweeps = max(val,1) - return - end select - - ! - ! Set preconditioner parameters at level ilev. - ! - if (present(ilev)) then - - select case(psb_toupper(what)) - case('SMOOTHER_TYPE','SUB_SOLVE','SMOOTHER_SWEEPS',& - & 'ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD',& - & 'AGGR_TYPE','AGGR_PROL','AGGR_OMEGA_ALG',& - & 'AGGR_EIG','SUB_RESTR','SUB_PROL', & - & 'SUB_OVR','SUB_FILLIN',& - & 'COARSE_MAT') - do il=ilev_, ilmax_ - call p%precv(il)%set(what,val,info,pos=pos) - end do - - case('COARSE_SUBSOLVE') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - call p%precv(ilev_)%set('SUB_SOLVE',val,info,pos=pos) - case('COARSE_SOLVE') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_SOLVE',val,info,pos=pos) - select case (val) - case(mld_bjac_,mld_l1_bjac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',val,info,pos=pos) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) -#else - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) -#endif - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info) - case(mld_slu_) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) - case(mld_mumps_) -#if defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(mld_umf_) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - - case(mld_sludist_) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(mld_jac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_diag_scale_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - - case(mld_l1_jac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_l1_diag_scale_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_gs_,mld_fbgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_gs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_bwgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_bwgs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_l1_gs_,mld_l1_fbgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_l1_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_gs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - end select - - endif - case('COARSE_SWEEPS') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - call p%precv(nlev_)%set('SMOOTHER_SWEEPS',val,info,pos=pos) - - case('COARSE_FILLIN') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - call p%precv(nlev_)%set('SUB_FILLIN',val,info,pos=pos) - - case default - do il=ilev_, ilmax_ - call p%precv(il)%set(what,val,info,pos=pos,idx=idx) - end do - end select - - - else if (.not.present(ilev)) then - ! - ! ilev not specified: set preconditioner parameters at all the appropriate - ! levels - ! - select case(psb_toupper(trim(what))) - case('SUB_SOLVE','SUB_RESTR','SUB_PROL',& - & 'SUB_OVR','SUB_FILLIN',& - & 'SMOOTHER_SWEEPS','SMOOTHER_TYPE') - do ilev_=1,max(1,nlev_-1) - call p%precv(ilev_)%set(what,val,info,pos=pos) - if (info /= 0) return - end do - - case('ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD','AGGR_PROL','AGGR_TYPE',& - & 'AGGR_OMEGA_ALG','AGGR_EIG','AGGR_FILTER') - do ilev_=1,nlev_ - call p%precv(ilev_)%set(what,val,info,pos=pos) - if (info /= 0) return - end do - - case('COARSE_MAT') - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_MAT',val,info,pos=pos) - end if - - case('COARSE_SOLVE') - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_SOLVE',val,info,pos=pos) - select case (val) - case(mld_bjac_,mld_l1_bjac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',val,info,pos=pos) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) -#else - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) -#endif - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info) - case(mld_slu_) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) - case(mld_mumps_) -#if defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(mld_umf_) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - - case(mld_sludist_) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(mld_jac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_diag_scale_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - - case(mld_l1_jac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_l1_diag_scale_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_gs_,mld_fbgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_gs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_bwgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_bwgs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_l1_gs_,mld_l1_fbgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_l1_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_gs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - end select - endif - - case('COARSE_SUBSOLVE') - if (nlev_ > 1) then - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - endif - - case('COARSE_SWEEPS') - - if (nlev_ > 1) then - call p%precv(nlev_)%set('SMOOTHER_SWEEPS',val,info,pos=pos) - end if - - case('COARSE_FILLIN') - if (nlev_ > 1) then - call p%precv(nlev_)%set('SUB_FILLIN',val,info,pos=pos) - end if - - case default - do ilev_=1,nlev_ - call p%precv(ilev_)%set(what,val,info,pos=pos,idx=idx) - end do - end select - - endif - -end subroutine mld_scprecseti - -! -! Subroutine: mld_sprecsetc -! Version: real -! -! This routine sets the character parameters defining the preconditioner. More -! precisely, the character parameter identified by 'what' is assigned the value -! contained in 'val'. -! For the multilevel preconditioners, the levels are numbered in increasing -! order starting from the finest one, i.e. level 1 is the finest level. -! -! To set integer and real parameters, see mld_sprecseti and mld_sprecsetr, -! respectively. -! -! -! Arguments: -! p - type(mld_sprec_type), input/output. -! The preconditioner data structure. -! what - integer, input. -! The number identifying the parameter to be set. -! A mnemonic constant has been associated to each of these -! numbers, as reported in the MLD2P4 User's and Reference Guide. -! string - character(len=*), input. -! The value of the parameter to be set. The list of allowed -! values is reported in the MLD2P4 User's and Reference Guide. -! info - integer, output. -! Error code. -! ilev - integer, optional, input. -! For the multilevel preconditioner, the level at which the -! preconditioner parameter has to be set. -! If nlev is not present, the parameter identified by 'what' -! is set at all the appropriate levels. -! -! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to -! MLD2P4 developers. Indeed, by using ilev it is possible to set different values -! of the same parameter at different levels 1,...,nlev-1, even in cases where -! the parameter must have the same value at all the levels but the coarsest one. -! For this reason, the interface mld_precset to this routine has been built in -! such a way that ilev is not visible to the user (see mld_prec_mod.f90). -! -subroutine mld_scprecsetc(p,what,string,info,ilev,ilmax,pos,idx) - - use psb_base_mod - use mld_s_prec_mod, mld_protect_name => mld_scprecsetc - use mld_s_jac_smoother - use mld_s_as_smoother - use mld_s_diag_solver - use mld_s_l1_diag_solver - use mld_s_ilu_solver - use mld_s_id_solver - use mld_s_gs_solver -#if defined(HAVE_SLU_) - use mld_s_slu_solver -#endif -#if defined(HAVE_MUMPS_) - use mld_s_mumps_solver -#endif - - - implicit none - - ! Arguments - class(mld_sprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - character(len=*), intent(in) :: string - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_,val,ilmax_, il - character(len=*), parameter :: name='mld_precsetc' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmax_ = nlev_ - end if - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - ! - ! Set preconditioner parameters at level ilev. - ! - if (present(ilev)) then - - select case(psb_toupper(what)) - case('SMOOTHER_TYPE','SUB_SOLVE',& - & 'ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD',& - & 'AGGR_TYPE','AGGR_PROL','AGGR_OMEGA_ALG',& - & 'AGGR_EIG','SUB_RESTR','SUB_PROL', & - & 'COARSE_MAT') - do il=ilev_, ilmax_ - call p%precv(il)%set(what,string,info,pos=pos) - end do - - case('COARSE_SUBSOLVE') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - call p%precv(ilev_)%set('SUB_SOLVE',string,info,pos=pos) - case('COARSE_SOLVE') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_SOLVE',string,info,pos=pos) - select case (psb_toupper(trim(string))) - case('BJAC', 'L1-BJAC') - call p%precv(nlev_)%set('SMOOTHER_TYPE',psb_toupper(trim(string)),info,pos=pos) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) -#else - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) -#endif - call p%precv(nlev_)%set('COARSE_MAT','dist',info) - case('SLU') -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('ILU','MILU','ILUT') - call p%precv(nlev_)%set('SMOOTHER_TYPE','bjac',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) - case('MUMPS') -#if defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('UMF') -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - - case('SLUDIST') -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('JAC','JACOBI') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','DIAG',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - - case('L1-JACOBI') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','L1-DIAG',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('GS','FWGS','FBGS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('BWGS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','BWGS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('L1-GS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','L1-BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - end select - - endif - - case default - do il=ilev_, ilmax_ - call p%precv(il)%set(what,string,info,pos=pos,idx=idx) - end do - end select - - - else if (.not.present(ilev)) then - ! - ! ilev not specified: set preconditioner parameters at all the appropriate - ! levels - ! - select case(psb_toupper(trim(what))) - case('SUB_SOLVE','SUB_RESTR','SUB_PROL',& - & 'SMOOTHER_TYPE') - do ilev_=1,max(1,nlev_-1) - call p%precv(ilev_)%set(what,string,info,pos=pos) - if (info /= 0) return - end do - - case('ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD','AGGR_PROL','AGGR_TYPE',& - & 'AGGR_OMEGA_ALG','AGGR_EIG','AGGR_FILTER') - do ilev_=1,nlev_ - call p%precv(ilev_)%set(what,string,info,pos=pos) - if (info /= 0) return - end do - - case('COARSE_MAT') - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_MAT',string,info,pos=pos) - end if - - case('COARSE_SOLVE') - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_SOLVE',string,info,pos=pos) - select case (psb_toupper(trim(string))) - case('BJAC', 'L1-BJAC') - call p%precv(nlev_)%set('SMOOTHER_TYPE',psb_toupper(trim(string)),info,pos=pos) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) -#else - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) -#endif - call p%precv(nlev_)%set('COARSE_MAT','DIST',info) - case('SLU') -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('ILU', 'ILUT','MILU') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) - case('MUMPS') -#if defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('UMF') -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - - case('SLUDIST') -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('JAC','JACOBI') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','DIAG',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('L1-JACOBI') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','L1-DIAG',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('GS','FWGS','FBGS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('BWGS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','BWGS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('L1-GS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','L1-BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - end select - endif - - case('COARSE_SUBSOLVE') - if (nlev_ > 1) then - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - endif - - case default - do ilev_=1,nlev_ - call p%precv(ilev_)%set(what,string,info,pos=pos,idx=idx) - end do - end select - - endif - - -end subroutine mld_scprecsetc - - -! -! Subroutine: mld_sprecsetr -! Version: real -! -! This routine sets the real parameters defining the preconditioner. More -! precisely, the real parameter identified by 'what' is assigned the value -! contained in 'val'. -! For the multilevel preconditioners, the levels are numbered in increasing -! order starting from the finest one, i.e. level 1 is the finest level. -! -! To set integer and character parameters, see mld_sprecseti and mld_sprecsetc, -! respectively. -! -! Arguments: -! p - type(mld_sprec_type), input/output. -! The preconditioner data structure. -! what - integer, input. -! The number identifying the parameter to be set. -! A mnemonic constant has been associated to each of these -! numbers, as reported in the MLD2P4 User's and Reference Guide. -! val - real(psb_spk_), input. -! The value of the parameter to be set. The list of allowed -! values is reported in the MLD2P4 User's and Reference Guide. -! info - integer, output. -! Error code. -! ilev - integer, optional, input. -! For the multilevel preconditioner, the level at which the -! preconditioner parameter has to be set. -! If nlev is not present, the parameter identified by 'what' -! is set at all the appropriate levels. -! -! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to -! MLD2P4 developers. Indeed, by using ilev it is possible to set different values -! of the same parameter at different levels 1,...,nlev-1, even in cases where -! the parameter must have the same value at all the levels but the coarsest one. -! For this reason, the interface mld_precset to this routine has been built in -! such a way that ilev is not visible to the user (see mld_prec_mod.f90). -! -subroutine mld_scprecsetr(p,what,val,info,ilev,ilmax,pos,idx) - - use psb_base_mod - use mld_s_prec_mod, mld_protect_name => mld_scprecsetr - - implicit none - - ! Arguments - class(mld_sprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - - ! Local variables - integer(psb_ipk_) :: ilev_,nlev_, ilmax_, il - real(psb_spk_) :: thr - character(len=*), parameter :: name='mld_precsetr' - - info = psb_success_ - - if (present(ilev)) then - ilev_ = ilev - else - ilev_ = 1 - end if - - select case(psb_toupper(what)) - case ('MIN_CR_RATIO') - p%ag_data%min_cr_ratio = max(sone,val) - return - end select - - if (.not.allocated(p%precv)) then - write(psb_err_unit,*) name,& - &': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - info = 3111 - return - endif - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmax_ = nlev_ - end if - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - - ! - ! Set preconditioner parameters at level ilev. - ! - if (present(ilev)) then - - do il=ilev_, ilmax_ - call p%precv(il)%set(what,val,info,pos=pos,idx=idx) - end do - - else if (.not.present(ilev)) then - ! - ! ilev not specified: set preconditioner parameters at all the appropriate levels - ! - - select case(psb_toupper(what)) - case('COARSE_ILUTHRS') - ilev_=nlev_ - call p%precv(ilev_)%set('SUB_ILUTHRS',val,info,pos=pos) - - case default - - do il=1,nlev_ - call p%precv(il)%set(what,val,info,pos=pos,idx=idx) - end do - end select - - endif - -end subroutine mld_scprecsetr - - diff --git a/mlprec/impl/mld_sfile_prec_descr.f90 b/mlprec/impl/mld_sfile_prec_descr.f90 deleted file mode 100644 index 7bb0a150..00000000 --- a/mlprec/impl/mld_sfile_prec_descr.f90 +++ /dev/null @@ -1,199 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_dfile_prec_descr.f90 -! -! -! Subroutine: mld_file_prec_descr -! Version: real -! -! This routine prints a description of the preconditioner to the standard -! output or to a file. It must be called after the preconditioner has been -! built by mld_precbld. -! -! Arguments: -! p - type(mld_Tprec_type), input. -! The preconditioner data structure to be printed out. -! info - integer, output. -! error code. -! iout - integer, input, optional. -! The id of the file where the preconditioner description -! will be printed. If iout is not present, then the standard -! output is condidered. -! root - integer, input, optional. -! The id of the process printing the message; -1 acts as a wildcard. -! Default is psb_root_ -! -subroutine mld_sfile_prec_descr(prec,iout,root) - use psb_base_mod - use mld_s_prec_mod, mld_protect_name => mld_sfile_prec_descr - use mld_s_inner_mod - use mld_s_gs_solver - - implicit none - ! Arguments - class(mld_sprec_type), intent(in) :: prec - integer(psb_ipk_), intent(in), optional :: iout - integer(psb_ipk_), intent(in), optional :: root - - ! Local variables - integer(psb_ipk_) :: ilev, nlev, ilmin, info, nswps - integer(psb_ipk_) :: ictxt, me, np - logical :: is_symgs - character(len=20), parameter :: name='mld_file_prec_descr' - integer(psb_ipk_) :: iout_ - integer(psb_ipk_) :: root_ - - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - end if - if (iout_ < 0) iout_ = psb_out_unit - - ictxt = prec%ictxt - - if (allocated(prec%precv)) then - - call psb_info(ictxt,me,np) - if (present(root)) then - root_ = root - else - root_ = psb_root_ - end if - if (root_ == -1) root_ = me - - ! - ! The preconditioner description is printed by processor psb_root_. - ! This agrees with the fact that all the parameters defining the - ! preconditioner have the same values on all the procs (this is - ! ensured by mld_precbld). - ! - if (me == root_) then - nlev = size(prec%precv) - do ilev = 1, nlev - if (.not.allocated(prec%precv(ilev)%sm)) then - info = 3111 - write(iout_,*) ' ',name,& - & ': error: inconsistent MLPREC part, should call MLD_PRECINIT' - return - endif - end do - - write(iout_,*) - write(iout_,'(a)') 'Preconditioner description' - - if (nlev == 1) then - ! - ! Here we have a gigantic kludge just to handle Symmetrized Gauss-Seidel. - ! Will need rethinking... - ! - if (allocated(prec%precv(1)%sm2a)) then - is_symgs = .false. - select type(sv2 => prec%precv(1)%sm2a%sv) - class is (mld_s_bwgs_solver_type) - select type(sv1 => prec%precv(1)%sm%sv) - class is (mld_s_gs_solver_type) - is_symgs = .true. - end select - end select - if (is_symgs) then - write(iout_,*) ' Forward-Backward (symmetrized) Hybrid Gauss-Seidel' - else - write(iout_,*) 'Pre Smoother: ' - call prec%precv(1)%sm%descr(info,iout=iout_) - write(iout_,*) 'Post smoother:' - call prec%precv(1)%sm2a%descr(info,iout=iout_) - end if - nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) - - else - call prec%precv(1)%sm%descr(info,iout=iout_) - nswps = prec%precv(1)%parms%sweeps_pre - end if - if (nswps > 1) write(iout_,*) ' Number of sweeps : ',nswps - write(iout_,*) - - else if (nlev > 1) then - ! - ! Print description of base preconditioner - ! - write(iout_,*) 'Multilevel Preconditioner' - write(iout_,*) 'Outer sweeps:',prec%outer_sweeps - write(iout_,*) - if (allocated(prec%precv(1)%sm2a)) then - write(iout_,*) 'Pre Smoother: ' - call prec%precv(1)%sm%descr(info,iout=iout_) - write(iout_,*) 'Post smoother:' - call prec%precv(1)%sm2a%descr(info,iout=iout_) - else - write(iout_,*) 'Smoother: ' - call prec%precv(1)%sm%descr(info,iout=iout_) - end if - ! - ! Print multilevel details - ! - write(iout_,*) - write(iout_,*) 'Multilevel hierarchy: ' - write(iout_,*) ' Number of levels : ',nlev - write(iout_,*) ' Operator complexity: ',prec%get_complexity() - write(iout_,*) ' Average coarsening : ',prec%get_avg_cr() - ilmin = 2 - if (nlev == 2) ilmin=1 - do ilev=ilmin,nlev - call prec%precv(ilev)%descr(ilev,nlev,ilmin,info,iout=iout_) - end do - write(iout_,*) - - else - write(iout_,*) trim(name), & - & ': invalid preconditioner array size ?',nlev - info = -2 - return - - end if - end if - - else - write(iout_,*) trim(name), & - & ': Error: no base preconditioner available, something is wrong!' - info = -2 - return - endif - -end subroutine mld_sfile_prec_descr diff --git a/mlprec/impl/mld_smlprec_aply.f90 b/mlprec/impl/mld_smlprec_aply.f90 deleted file mode 100644 index 9a65236f..00000000 --- a/mlprec/impl/mld_smlprec_aply.f90 +++ /dev/null @@ -1,1669 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_smlprec_aply.f90 -! -! Subroutine: mld_smlprec_aply -! Version: real -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -! This routine computes -! -! Y = beta*Y + alpha*op(ML^(-1))*X, -! where -! - ML is a multilevel preconditioner associated with -! a certain matrix A and stored in p, -! - op(ML^(-1)) is ML^(-1) or its transpose, according to the value of trans, -! - X and Y are vectors, -! - alpha and beta are scalars. -! -! The following multilevel strategies can be applied: -! -! - Additive multilevel Schwarz, -! - classical V-cycle, -! - classical W-cycle, -! - K-cycle both for symmetric and nonsymmetric matrices, where 2 iterations -! of FCG(1) or GCR, respectively, are applied at each level -! except the coarsest. -! -! For each level we have as many submatrices as processes (except for the coarsest -! level where we might have a replicated index space) and each process takes care -! of one submatrix. -! -! A multilevel preconditioner is regarded as an array of 'one-level' data structures, -! each containing the part of the preconditioner associated to a certain level -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! For each level lev, there is a smoother stored in -! p%precv(lev)%sm -! which in turn contains a solver -! p$precv(lev)%sm%sv -! Typically the solver acts only locally, and the smoother applies any required -! parallel communication/action. -! Each level has a matrix A(lev), obtained by 'tranferring' the original -! matrix A (i.e. the matrix to be preconditioned) to the level lev, through smoothed -! aggregation. -! -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level and A(1) is the matrix A. -! -! This routine is formulated in a recursive way, so it is quite compact. -! -! The V-cycle can be described as follows, where -! P(lev) denotes the smoothed prolongator from level lev to level -! lev-1, while R(lev) denotes the corresponding restriction operator -! (normally its transpose) from level lev-1 to level lev. -! M(lev) is the smoother at the current level. -! -! -! 1. Transfer the outer vector Xest to u(1) (inner X at level 1) -! -! 2. Invoke V-cycle(1,M,P,R,A,b,u) -! -! procedure V-cycle(lev,M,P,R,A,b,u) -! -! if (lev < nlev) then -! -! u(lev) = u(lev) + M(lev)*(b(lev)-A(lev)*u(lev)) -! -! b(lev+1) = R(lev+1)*(b(lev)-A(lev)*u(lev)) -! -! u(lev+1) = V-cycle(lev+1,M,P,R,A,b,u) -! -! u(lev) = u(lev) + P(lev+1) * u(lev+1) -! -! u(lev) = u(lev) + M(lev)*(b(lev)-A(lev)*u(lev)) -! -! else -! -! solve A(lev)*u(lev) = b(lev) -! -! end if -! -! return u(lev) -! end -! -! 3. Transfer u(1) to the external: -! Yext = beta*Yext + alpha*u(1) -! -! -! In the implementation, the recursive procedure is inner_ml_aply, which -! in turn uses mld_inner_add (for additive multilevel), -! mld_inner_mult (for V-cycle and W-cycle), and -! mld_inner_k_cycle (for symmetric and non-symmetric K-cycle). -! -! For a detailed description of the algorithms, see: -! -! - B.F. Smith, P.E. Bjorstad, W.D. Gropp, -! Domain decomposition: parallel multilevel methods for elliptic partial -! differential equations, Cambridge University Press, 1996. -! -! - W. L. Briggs, V. E. Henson, S. F. McCormick, -! A Multigrid Tutorial, Second Edition -! SIAM, 2000. -! -! - K. Stuben, -! An Introduction to Algebraic Multigrid, -! in A. Schuller, U. Trottenberg, C. Oosterlee, Multigrid, Academic Press, 2001. -! -! - Y. Notay, P. S. Vassilevski, -! Recursive Krylov-based multigrid cycles -! Numerical Linear Algebra with Applications, 15 (5), 2008, 473--487. -! -! -! Arguments: -! alpha - real(psb_spk_), input. -! The scalar alpha. -! p - type(mld_sprec_type), input. -! The multilevel preconditioner data structure containing the -! local part of the preconditioner to be applied. -! Note that nlev = size(p%precv) = number of levels. -! p%precv(lev)%sm - type(psb_sbaseprec_type) -! The pre-'smoother' for the current level -! p%precv(lev)%sm2 - type(psb_sbaseprec_type) -! The post-'smoother' for the current level -! may be the same or different from %sm -! p%precv(lev)%ac - type(psb_sspmat_type) -! The local part of the matrix A(lev). -! p%precv(lev)%parms - type(psb_sml_parms) -! Parameters controllin the multilevel prec. -! p%precv(lev)%desc_ac - type(psb_desc_type). -! The communication descriptor associated to the sparse -! matrix A(lev) -! p%precv(lev)%map - type(psb_inter_desc_type) -! Stores the linear operators mapping level (lev-1) -! to (lev) and vice versa. These are the restriction -! and prolongation operators described in the sequel. -! p%precv(lev)%base_a - type(psb_sspmat_type), pointer. -! Pointer (really a pointer!) to the base matrix of -! the current level, i.e. the local part of A(lev); -! so we have a unified treatment of residuals. We -! need this to avoid passing explicitly the matrix -! A(lev) to the routine which applies the -! preconditioner. -! p%precv(lev)%base_desc - type(psb_desc_type), pointer. -! Pointer to the communication descriptor associated -! to the sparse matrix pointed by base_a. -! -! x - real(psb_spk_), dimension(:), input. -! The local part of the vector X. -! beta - real(psb_spk_), input. -! The scalar beta. -! y - real(psb_spk_), dimension(:), input/output. -! The local part of the vector Y. -! desc_data - type(psb_desc_type), input. -! The communication descriptor associated to the matrix to be -! preconditioned. -! trans - character, optional. -! If trans='N','n' then op(M^(-1)) = M^(-1); -! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). -! work - real(psb_spk_), dimension (:), optional, target. -! Workspace. Its size must be at least 4*desc_data%get_local_cols(). -! info - integer, output. -! Error code. -! -! Note that when the LU factorization of the matrix A(lev) is computed instead of -! the ILU one, by using UMFPACK or SuperLU or MUMPS, the corresponding -! L and U factors are stored in data structures handled -! by the third party software. -! -subroutine mld_smlprec_aply_vect(alpha,p,x,beta,y,desc_data,trans,work,info) - - use psb_base_mod - use mld_base_prec_type - use mld_s_inner_mod, mld_protect_name => mld_smlprec_aply_vect - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_sprec_type), intent(inout) :: p - real(psb_spk_),intent(in) :: alpha,beta - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - character, intent(in) :: trans - real(psb_spk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: ictxt, np, me - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, nc2l, level, isweep, err_act - character(len=20) :: name - character :: trans_ - real(psb_spk_) :: beta_ - logical :: do_alloc_wrk - type(mld_smlprec_wrk_type), allocatable, target :: mlprec_wrk(:) - - name='mld_smlprec_aply' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (debug_level >= psb_debug_inner_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(p%precv) - - trans_ = psb_toupper(trans) - nlev = size(p%precv) - - do_alloc_wrk = .not.allocated(p%precv(1)%wrk) - - if (do_alloc_wrk) call p%allocate_wrk(info,vmold=x%v) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') - goto 9999 - end if - level = 1 - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & wv => p%precv(level)%wrk%wv(:)) - ! - ! At first iteration we must use the input BETA - ! - beta_ = beta - - - call psb_geaxpby(sone,x,szero,vx2l,base_desc,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='geaxbpy') - goto 9999 - end if - - do isweep = 1, p%outer_sweeps - 1 - ! - ! With the current implementation, y2l is zeroed internally at first smoother. - ! call p%wrk(level)%vy2l%zero() - ! - call inner_ml_aply(level,p,trans_,work,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Inner prec aply') - goto 9999 - end if - call psb_geaxpby(alpha,vy2l,beta_,y,base_desc,info) - ! all iterations after the first must use BETA = 1 - beta_ = sone - ! - ! Next iteration should use the current residual to compute a correction - ! - call psb_geaxpby(sone,x,szero,vx2l,base_desc,info) - call psb_spmm(-sone,base_a,y,sone,vx2l,base_desc,info) - end do - - ! - ! If outer_sweeps == 1 we have just skipped the loop, and it's - ! equivalent to a single application. - ! - - ! - ! With the current implementation, y2l is zeroed internally at first smoother. - ! call p%wrk(level)%vy2l%zero() - ! - call inner_ml_aply(level,p,trans_,work,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Inner prec aply') - goto 9999 - end if - call psb_geaxpby(alpha,vy2l,beta_,y,base_desc,info) - - end associate - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error final update') - goto 9999 - end if - if (do_alloc_wrk) call p%free_wrk(info) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - ! - ! - ! inner_ml_aply: apply AMG at a given level. - ! This routine dispatches the computation according to the type - ! specified at the current level. - ! Each of the corrections will inturn call recursively this routine. - ! - ! Assumptions: - ! On input: - ! mlprec_wkr(level)%vx2l contains the input vector (RHS) - ! mlprec_wkr(level)%vy2l contains the initial guess - ! - ! On output: - ! mlprec_wkr(level)%vy2l contains the solution - ! - ! Constraints: each of the called routines must properly handle - ! the input/output conditions for level+1 (i.e. apply - ! prolongation/restriction). - ! Note: for historical/convenience reasons the prolongator/restrictor - ! between level and level+1 are stored at level+1. - ! - ! - recursive subroutine inner_ml_aply(level,p,trans,work,info) - - implicit none - - ! Arguments - integer(psb_ipk_) :: level - type(mld_sprec_type), target, intent(inout) :: p - character, intent(in) :: trans - real(psb_spk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - - type(psb_s_vect_type) :: res - type(psb_s_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_ml_aply' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_ml') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' Start inner_ml_aply at level ',level, info - end if - - select case(p%precv(level)%parms%ml_cycle) - - case(mld_no_ml_) - ! - ! No preconditioning, should not really get here - ! - call psb_errpush(psb_err_internal_error_,name,& - & a_err='mld_no_ml_ in mlprc_aply?') - goto 9999 - - case(mld_add_ml_) - - call mld_s_inner_add(p, level, trans, work) - - case(mld_mult_ml_,mld_vcycle_ml_, mld_wcycle_ml_) - - call mld_s_inner_mult(p, level, trans, work) - - case(mld_kcycle_ml_, mld_kcyclesym_ml_) - - call mld_s_inner_k_cycle(p, level, trans, work) - - case default - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='invalid ml_cycle',& - & i_Err=(/p%precv(level)%parms%ml_cycle,izero,izero,izero,izero/)) - goto 9999 - - end select - if(debug_level > 1) then - write(debug_unit,*) me,' End inner_ml_aply at level ',level - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine inner_ml_aply - - - recursive subroutine mld_s_inner_add(p, level, trans, work) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_sprec_type), intent(inout) :: p - - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - real(psb_spk_),target :: work(:) - type(psb_s_vect_type) :: res - type(psb_s_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act, k - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_inner_add' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_add') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_add at level ',level - end if - - if ((level<1).or.(level>nlev)) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL>NLEV') - goto 9999 - end if - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & wv => p%precv(level)%wrk%wv) - - if (allocated(p%precv(level)%sm2a)) then - call psb_geaxpby(sone,vx2l,szero,vy2l,base_desc,info) - - sweeps = max(p%precv(level)%parms%sweeps_pre,p%precv(level)%parms%sweeps_post) - do k=1, sweeps - call p%precv(level)%sm%apply(sone,& - & vy2l,szero,vty,& - & base_desc, trans,& - & ione,work,wv,info,init='Z') - - call p%precv(level)%sm2a%apply(sone,& - & vty,szero,vy2l,& - & base_desc, trans,& - & ione,work,wv,info,init='Z') - end do - - else - sweeps = p%precv(level)%parms%sweeps_pre - call p%precv(level)%sm%apply(sone,& - & vx2l,szero,vy2l,& - & base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during ADD smoother_apply') - goto 9999 - end if - - if (level < nlev) then - ! Apply the restriction - call p%precv(level+1)%map%map_U2V(sone,vx2l,& - & szero,p%precv(level+1)%wrk%vx2l,& - & info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - - call inner_ml_aply(level+1,p,trans,work,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in recursive call') - goto 9999 - end if - - ! - ! Apply the prolongator - ! - call p%precv(level+1)%map%map_V2U(sone,& - & p%precv(level+1)%wrk%vy2l, sone,vy2l,& - & info,work=work,& - & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - - end if - end associate - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_s_inner_add - - recursive subroutine mld_s_inner_mult(p, level, trans, work) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_sprec_type), intent(inout) :: p - - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - real(psb_spk_),target :: work(:) - type(psb_s_vect_type) :: res - type(psb_s_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - name = 'inner_inner_mult' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_mult') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_mult at level ',level - end if - - sweeps_post = p%precv(level)%parms%sweeps_post - sweeps_pre = p%precv(level)%parms%sweeps_pre - pre = ((sweeps_pre>0).and.(trans=='N')).or.((sweeps_post>0).and.(trans/='N')) - post = ((sweeps_post>0).and.(trans=='N')).or.((sweeps_pre>0).and.(trans/='N')) - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & wv => p%precv(level)%wrk%wv) - if (level < nlev) then - ! - ! Apply the first smoother - ! The residual has been prepared before the recursive call. - ! - - if (pre) then - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(sone,& - & vx2l,szero,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(sone,& - & vx2l,szero,vy2l, base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during PRE smoother_apply') - goto 9999 - end if - endif - ! - ! Compute the residual for next level and call recursively - ! - if (pre) then - call psb_geaxpby(sone,vx2l,& - & szero,vty,& - & base_desc,info) - - if (info == psb_success_) call psb_spmm(-sone,base_a,& - & vy2l,sone,vty,& - & base_desc,info,work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - call p%precv(level+1)%map%map_U2V(sone,vty,& - & szero,p%precv(level+1)%wrk%vx2l,& - & info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - else - ! Shortcut: just transfer x2l. - call p%precv(level+1)%map%map_U2V(sone,vx2l,& - & szero,p%precv(level+1)%wrk%vx2l,& - & info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - endif - - call inner_ml_aply(level+1,p,trans,work,info) - - ! - ! Apply the prolongator - ! - call p%precv(level+1)%map%map_V2U(sone,& - & p%precv(level+1)%wrk%vy2l,sone,vy2l,& - & info,work=work,& - & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - if (p%precv(level)%parms%ml_cycle == mld_wcycle_ml_) then - - call psb_geaxpby(sone,vx2l, szero,vty,& - & base_desc,info) - if (info == psb_success_) call psb_spmm(-sone,base_a,& - & vy2l,sone,vty,& - & base_desc,info,work=work,trans=trans) - if (info == psb_success_) & - & call p%precv(level+1)%map%map_U2V(sone,vty,& - & szero,p%precv(level+1)%wrk%vx2l,info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during W-cycle restriction') - goto 9999 - end if - - call inner_ml_aply(level+1,p,trans,work,info) - - if (info == psb_success_) call p%precv(level+1)%map%map_V2U(sone, & - & p%precv(level+1)%wrk%vy2l,sone,vy2l,& - & info,work=work,& - & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during W recusion/prolongation') - goto 9999 - end if - - endif - - - if (post) then - call psb_geaxpby(sone,vx2l,& - & szero,vty,& - & base_desc,info) - if (info == psb_success_) call psb_spmm(-sone,base_a,& - & vy2l, sone,vty,base_desc,info,& - & work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - - ! - ! Apply the second smoother - ! - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(sone,& - & vty,sone,vy2l, base_desc, trans,& - & sweeps,work,wv,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(sone,& - & vty,sone,vy2l, base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during POST smoother_apply') - goto 9999 - end if - - endif - - else if (level == nlev) then - - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(sone,& - & vx2l,szero,vy2l,base_desc, trans,& - & sweeps,work,wv,info) - - else - - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL vs NLEV') - goto 9999 - end if - end associate - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_s_inner_mult - - recursive subroutine mld_s_inner_k_cycle(p, level, trans, work,u) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_sprec_type), intent(inout) :: p - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - real(psb_spk_),target :: work(:) - type(psb_s_vect_type),intent(inout), optional :: u - - - - type(psb_s_vect_type) :: res - type(psb_s_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_kcycle' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_add') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,name,' start at level ',level - end if - - if ((level<1).or.(level>nlev)) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL>NLEV') - goto 9999 - end if - - !K cycle - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & wv => p%precv(level)%wrk%wv(8:)) - if (level == nlev) then - ! - ! Apply smoother - ! - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(sone,& - & vx2l,szero,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - - else if (level < nlev) then - - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(sone,& - & vx2l,szero,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(sone,& - & vx2l,szero,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during 2-PRE smoother_apply') - goto 9999 - end if - - - ! - ! Compute the residual and call recursively - ! - - call psb_geaxpby(sone,vx2l,& - & szero,vty,& - & base_desc,info) - - if (info == psb_success_) call psb_spmm(-sone,base_a,& - & vy2l,sone,vty,base_desc,info,work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - - ! Apply the restriction - call p%precv(level + 1)%map%map_U2V(sone,vty,& - & szero,p%precv(level + 1)%wrk%vx2l,& - &info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - - !Set the preconditioner - - if (level <= nlev - 2 ) then - if (p%precv(level)%parms%ml_cycle == mld_kcyclesym_ml_) then - call mld_sinneritkcycle(p, level + 1, trans, work, 'FCG') - elseif (p%precv(level)%parms%ml_cycle == mld_kcycle_ml_) then - call mld_sinneritkcycle(p, level + 1, trans, work, 'GCR') - else - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Bad value for ml_cycle') - goto 9999 - endif - else - call inner_ml_aply(level + 1 ,p,trans,work,info) - endif - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in recursive call') - goto 9999 - end if - - ! - ! Apply the prolongator - ! - call p%precv(level+1)%map%map_V2U(sone,& - & p%precv(level+1)%wrk%vy2l,sone,vy2l,& - & info,work=work,& - & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - ! - ! Compute the residual - ! - call psb_geaxpby(sone,vx2l,& - & szero,vty,base_desc,info) - call psb_spmm(-sone,base_a,vy2l,& - & sone,vty,base_desc,info,& - & work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - ! - ! Apply the smoother - ! - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(sone,& - & vty,sone,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(sone,& - & vty,sone,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during POST smoother_apply') - goto 9999 - end if - else - - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL vs NLEV') - goto 9999 - - endif - end associate - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_s_inner_k_cycle - - - recursive subroutine mld_sinneritkcycle(p, level, trans, work, innersolv) - use psb_base_mod - use mld_prec_mod - use mld_s_inner_mod, mld_protect_name => mld_smlprec_aply - - implicit none - - !Input/Oputput variables - type(mld_sprec_type), intent(inout) :: p - - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - character(len=*), intent(in) :: innersolv - real(psb_spk_),target :: work(:) - - !Other variables - type(psb_s_vect_type) :: v, w, rhs, v1, x - type(psb_s_vect_type) :: d0, d1 - real(psb_spk_) :: delta_old, rhs_norm, alpha, tau, tau1, tau2, tau3, tau4, beta - - real(psb_spk_) :: l2_norm, delta, rtol=0.25, delta0, tnrm - real(psb_spk_), allocatable :: temp_v(:) - integer(psb_ipk_) :: info, nlev, i, iter, max_iter=2, idx - character(len=20) :: name = 'innerit_k_cycle' - - - if (size(p%precv(level)%wrk%wv)<7) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size') - goto 9999 - end if - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & v => p%precv(level)%wrk%wv(1), & - & w => p%precv(level)%wrk%wv(2),& - & rhs => p%precv(level)%wrk%wv(3), & - & v1 => p%precv(level)%wrk%wv(4), & - & x => p%precv(level)%wrk%wv(5), & - & d0 => p%precv(level)%wrk%wv(6), & - & d1 => p%precv(level)%wrk%wv(7)) - - call x%zero() - - ! rhs=vx2l and w=rhs - call psb_geaxpby(sone,vx2l,szero,rhs, base_desc,info) - call psb_geaxpby(sone,vx2l,szero,w, base_desc,info) - - if (psb_errstatus_fatal()) then - nc2l = base_desc%get_local_cols() - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - - delta0 = psb_genrm2(w, base_desc, info) - - !Apply the preconditioner - call vy2l%zero() - - idx=0 - call inner_ml_aply(level,p,trans,work,info) - - call psb_geaxpby(sone,vy2l,szero,d0,base_desc,info) - - call psb_spmm(sone,base_a,d0,szero,v,base_desc,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - - !FCG - if (psb_toupper(trim(innersolv)) == 'FCG') then - delta_old = psb_gedot(d0, w, base_desc, info) - tau = psb_gedot(d0, v, base_desc, info) - !GCR - else if (psb_toupper(trim(innersolv)) == 'GCR') then - delta_old = psb_gedot(v, w, base_desc, info) - tau = psb_gedot(v, v, base_desc, info) - else - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid inner solver') - goto 9999 - endif - - alpha = delta_old/tau - !Update residual w - call psb_geaxpby(-alpha, v, sone, w, base_desc, info) - - l2_norm = psb_genrm2(w, base_desc, info) - iter = 0 - - if (l2_norm <= rtol*delta0) then - !Update solution x - call psb_geaxpby(alpha, d0, sone, x, base_desc, info) - else - iter = iter + 1 - idx=mod(iter,2) - - !Apply preconditioner - call psb_geaxpby(sone,w,szero,vx2l,base_desc,info) - call inner_ml_aply(level,p,trans,work,info) - call psb_geaxpby(sone,vy2l,szero,d1,base_desc,info) - - !Sparse matrix vector product - - call psb_spmm(sone,base_a,d1,szero,v1,base_desc,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - - !tau1, tau2, tau3, tau4 - if (psb_toupper(trim(innersolv)) == 'FCG') then - tau1= psb_gedot(d1, v, base_desc, info) - tau2= psb_gedot(d1, v1, base_desc, info) - tau3= psb_gedot(d1, w, base_desc, info) - tau4= tau2 - (tau1*tau1)/tau - else if (psb_toupper(trim(innersolv)) == 'GCR') then - tau1= psb_gedot(v1, v, base_desc, info) - tau2= psb_gedot(v1, v1, base_desc, info) - tau3= psb_gedot(v1, w, base_desc, info) - tau4= tau2 - (tau1*tau1)/tau - else - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid inner solver') - goto 9999 - endif - - !Update solution - alpha=alpha-(tau1*tau3)/(tau*tau4) - call psb_geaxpby(alpha,d0,sone,x,base_desc,info) - alpha=tau3/tau4 - call psb_geaxpby(alpha,d1,sone,x,base_desc,info) - endif - - call psb_geaxpby(sone,x,szero,vy2l,base_desc,info) - end associate - -9999 continue - call psb_erractionrestore(err_act) - if (err_act.eq.psb_act_abort_) then - call psb_error() - return - end if - return - end subroutine mld_sinneritkcycle - -end subroutine mld_smlprec_aply_vect - - -! -! Old routine for arrays instead of psb_X_vector. To be deleted eventually. -! -! -subroutine mld_smlprec_aply(alpha,p,x,beta,y,desc_data,trans,work,info) - - use psb_base_mod - use mld_base_prec_type - use mld_s_inner_mod, mld_protect_name => mld_smlprec_aply - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_sprec_type), intent(inout) :: p - real(psb_spk_),intent(in) :: alpha,beta - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - character, intent(in) :: trans - real(psb_spk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: ictxt, np, me - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: debug_level, debug_unit, nlev,nc2l,nr2l,level - character(len=20) :: name - character :: trans_ - type mld_mlwrk_type - real(psb_spk_), allocatable :: tx(:), ty(:), x2l(:), y2l(:) - end type mld_mlwrk_type - type(mld_mlwrk_type), allocatable, target :: mlwrk(:) - - name='mld_smlprec_aply' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (debug_level >= psb_debug_inner_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(p%precv) - - trans_ = psb_toupper(trans) - - nlev = size(p%precv) - allocate(mlwrk(nlev),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') - goto 9999 - end if - level = 1 - - do level = 1, nlev - call psb_geasb(mlwrk(level)%x2l,& - & p%precv(level)%base_desc,info) - call psb_geasb(mlwrk(level)%y2l,& - & p%precv(level)%base_desc,info) - call psb_geasb(mlwrk(level)%tx,& - & p%precv(level)%base_desc,info) - call psb_geasb(mlwrk(level)%ty,& - & p%precv(level)%base_desc,info) - if (psb_errstatus_fatal()) then - nc2l = p%precv(level)%base_desc%get_local_cols() - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - end do - - mlwrk(level)%x2l(:) = x(:) - mlwrk(level)%y2l(:) = szero - - call inner_ml_aply(level,p,mlwrk,trans_,work,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Inner prec aply') - goto 9999 - end if - - call psb_geaxpby(alpha,mlwrk(level)%y2l,beta,y,& - & p%precv(level)%base_desc,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error final update') - goto 9999 - end if - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - - ! - ! - ! inner_ml_aply: apply AMG at a given level. - ! This routine dispatches the computation according to the type - ! specified at the current level. - ! Each of the corrections will inturn call recursively this routine. - ! - ! Assumptions: - ! On input: - ! mlprec_wkr(level)%vx2l contains the input vector (RHS) - ! mlprec_wkr(level)%vy2l contains the initial guess - ! - ! On output: - ! mlprec_wkr(level)%vy2l contains the solution - ! - ! Constraints: each of the called routines must properly handle - ! the input/output conditions for level+1 (i.e. apply - ! prolongation/restriction). - ! Note: for historical/convenience reasons the prolongator/restrictor - ! between level and level+1 are stored at level+1. - ! - ! - recursive subroutine inner_ml_aply(level,p,mlwrk,trans,work,info) - - implicit none - - ! Arguments - integer(psb_ipk_) :: level - type(mld_sprec_type), target, intent(inout) :: p - type(mld_mlwrk_type), intent(inout), target :: mlwrk(:) - character, intent(in) :: trans - real(psb_spk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - - type(psb_s_vect_type) :: res - type(psb_s_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_ml_aply' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_ml') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_ml_aply at level ',level - end if - - select case(p%precv(level)%parms%ml_cycle) - - case(mld_no_ml_) - ! - ! No preconditioning, should not really get here - ! - call psb_errpush(psb_err_internal_error_,name,& - & a_err='mld_no_ml_ in mlprc_aply?') - goto 9999 - - case(mld_add_ml_) - - call mld_s_inner_add(p, mlwrk, level, trans, work) - - case(mld_mult_ml_, mld_vcycle_ml_, mld_wcycle_ml_) - - call mld_s_inner_mult(p, mlwrk, level, trans, work) - -! !$ case(mld_kcycle_ml_, mld_kcyclesym_ml_) -! !$ -! !$ call mld_s_inner_k_cycle(p, mlwrk, level, trans, work) - - case default - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='invalid ml_cycle',& - & i_Err=(/p%precv(level)%parms%ml_cycle,izero,izero,izero,izero/)) - goto 9999 - - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine inner_ml_aply - - - recursive subroutine mld_s_inner_add(p, mlwrk, level, trans, work) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_sprec_type), intent(inout) :: p - - type(mld_mlwrk_type), target, intent(inout) :: mlwrk(:) - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - real(psb_spk_),target :: work(:) - type(psb_s_vect_type) :: res - type(psb_s_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_inner_add' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_add') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_add at level ',level - end if - - if ((level<1).or.(level>nlev)) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL>NLEV') - goto 9999 - end if - - sweeps = p%precv(level)%parms%sweeps_pre - call p%precv(level)%sm%apply(sone,& - & mlwrk(level)%x2l,szero,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during ADD smoother_apply') - goto 9999 - end if - - if (level < nlev) then - ! Apply the restriction - call p%precv(level+1)%map%map_U2V(sone,mlwrk(level)%x2l,& - & szero,mlwrk(level+1)%x2l,& - & info,work=work) - mlwrk(level+1)%y2l(:) = szero - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - - call inner_ml_aply(level+1,p,mlwrk,trans,work,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in recursive call') - goto 9999 - end if - - ! - ! Apply the prolongator and add correction. - ! - call p%precv(level+1)%map%map_V2U(sone,& - & mlwrk(level+1)%y2l,sone,mlwrk(level)%y2l,& - & info,work=work) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_s_inner_add - - recursive subroutine mld_s_inner_mult(p, mlwrk, level, trans, work) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_sprec_type), intent(inout) :: p - - type(mld_mlwrk_type), target, intent(inout) :: mlwrk(:) - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - real(psb_spk_),target :: work(:) - type(psb_s_vect_type) :: res - type(psb_s_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_inner_mult' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_mult') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_mult at level ',level - end if - - if ((level < nlev).or.(nlev == 1)) then - sweeps_post = p%precv(level)%parms%sweeps_post - sweeps_pre = p%precv(level)%parms%sweeps_pre - else - sweeps_post = p%precv(level-1)%parms%sweeps_post - sweeps_pre = p%precv(level-1)%parms%sweeps_pre - endif - - pre = ((sweeps_pre>0).and.(trans=='N')).or.((sweeps_post>0).and.(trans/='N')) - post = ((sweeps_post>0).and.(trans=='N')).or.((sweeps_pre>0).and.(trans/='N')) - - - if (level < nlev) then - - ! - ! Apply the first smoother - ! - - if (pre) then - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(sone,& - & mlwrk(level)%x2l,szero,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info,init='Y') - else - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(sone,& - & mlwrk(level)%x2l,szero,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info,init='Y') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during PRE smoother_apply') - goto 9999 - end if - endif - - ! - ! Compute the residual and call recursively - ! - if (pre) then - call psb_geaxpby(sone,mlwrk(level)%x2l,& - & szero,mlwrk(level)%ty,& - & p%precv(level)%base_desc,info) - - if (info == psb_success_) call psb_spmm(-sone,p%precv(level)%base_a,& - & mlwrk(level)%y2l,sone,mlwrk(level)%ty,& - & p%precv(level)%base_desc,info,work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - call p%precv(level+1)%map%map_U2V(sone,mlwrk(level)%ty,& - & szero,mlwrk(level+1)%x2l,info,work=work) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - else - ! Shortcut: just transfer x2l. - call p%precv(level+1)%map%map_U2V(sone,mlwrk(level)%x2l,& - & szero,mlwrk(level+1)%x2l,info,work=work) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - endif - ! First guess is zero - mlwrk(level+1)%y2l(:) = szero - - - call inner_ml_aply(level+1,p,mlwrk,trans,work,info) - - if (p%precv(level)%parms%ml_cycle == mld_wcycle_ml_) then - ! On second call will use output y2l as initial guess - if (info == psb_success_) call inner_ml_aply(level+1,p,mlwrk,trans,work,info) - endif - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in recursive call') - goto 9999 - end if - - - ! - ! Apply the prolongator - ! - call p%precv(level+1)%map%map_V2U(sone,mlwrk(level+1)%y2l,& - & sone,mlwrk(level)%y2l,info,work=work) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - ! - ! Compute the residual - ! - if (post) then - call psb_geaxpby(sone,mlwrk(level)%x2l,& - & szero,mlwrk(level)%tx,& - & p%precv(level)%base_desc,info) - call psb_spmm(-sone,p%precv(level)%base_a,mlwrk(level)%y2l,& - & sone,mlwrk(level)%tx,p%precv(level)%base_desc,info,& - & work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - ! - ! Apply the second smoother - ! - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(sone,& - & mlwrk(level)%tx,sone,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(sone,& - & mlwrk(level)%tx,sone,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during POST smoother_apply') - goto 9999 - end if - - endif - - else if (level == nlev) then - - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(sone,& - & mlwrk(level)%x2l,szero,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info) - - else - - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL vs NLEV') - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_s_inner_mult - - -end subroutine mld_smlprec_aply diff --git a/mlprec/impl/mld_smlprec_bld.f90 b/mlprec/impl/mld_smlprec_bld.f90 deleted file mode 100644 index 99b59f01..00000000 --- a/mlprec/impl/mld_smlprec_bld.f90 +++ /dev/null @@ -1,152 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_smlprec_bld.f90 -! -! Subroutine: mld_smlprec_bld -! Version: real -! -! This routine builds the preconditioner according to the requirements made by -! the user trough the subroutines mld_precinit and mld_precset. -! -! A multilevel preconditioner is regarded as an array of 'one-level' data structures, -! each containing the part of the preconditioner associated to a certain level, -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level. No transfer operators are associated to level 1. -! -! This routine simply calls mld_s_hierarchy_bld and mld_s_smoothers_bld; they -! can also be called explicitly from the user. -! -! -! Arguments: -! a - type(psb_sspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_sprec_type), input/output. -! The preconditioner data structure containing the local part -! of the preconditioner to be built. -! info - integer, output. -! Error code. -! -! amold - class(psb_s_base_sparse_mat), input, optional -! Mold for the inner format of matrices contained in the -! preconditioner -! -! -! vmold - class(psb_s_base_vect_type), input, optional -! Mold for the inner format of vectors contained in the -! preconditioner -! -! -! -subroutine mld_smlprec_bld(a,desc_a,p,info,amold,vmold,imold) - - use psb_base_mod - use mld_s_inner_mod, mld_protect_name => mld_smlprec_bld - use mld_s_prec_mod - - Implicit None - - ! Arguments - type(psb_sspmat_type),intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - type(mld_sprec_type),intent(inout),target :: p - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local Variables - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, casize, nplevs, mxplevs - real(psb_spk_) :: mnaggratio - integer(psb_ipk_) :: ipv(mld_ifpsz_), val - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_smlprec_bld' - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' - - call p%hierarchy_build(a,desc_a,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Error from hierarchy build') - goto 9999 - end if - - iszv = p%get_nlevs() - - call p%smoothers_build(a,desc_a,info,amold,vmold,imold) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Error from smoothers build') - goto 9999 - end if - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Exiting with',iszv,' levels' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_smlprec_bld diff --git a/mlprec/impl/mld_sprecaply.f90 b/mlprec/impl/mld_sprecaply.f90 deleted file mode 100644 index 4f8f07bd..00000000 --- a/mlprec/impl/mld_sprecaply.f90 +++ /dev/null @@ -1,600 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_sprecaply.f90 -! -! Subroutine: mld_sprecaply -! Version: real -! -! This routine applies the preconditioner built by mld_sprecbld, i.e. it computes -! -! Y = op(M^(-1)) * X, -! where -! - M is the preconditioner, -! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, -! - X and Y are vectors. -! This operation is performed at each iteration of a preconditioned Krylov solver. -! -! -! Arguments: -! prec - type(mld_sprec_type), input. -! The preconditioner data structure containing the local part -! of the preconditioner to be applied. -! x - real(psb_spk_), dimension(:), input. -! The local part of the vector X in Y=op(M^(-1))*X. -! y - real(psb_spk_), dimension(:), output. -! The local part of the vector Y in Y=op(M^(-1))*X. -! desc_data - type(psb_desc_type), input. -! The communication descriptor associated to the matrix to be -! preconditioned. -! info - integer, output. -! Error code. -! trans - character(len=1), optional. -! If trans='N','n' then op(M^(-1)) = M^(-1); -! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). -! work - real(psb_spk_), dimension (:), optional, target. -! Workspace. Its size must be at -! least 4*desc_data%get_local_cols(). -! -subroutine mld_sprecaply(prec,x,y,desc_data,info,trans,work) - - use psb_base_mod - use mld_s_inner_mod!, mld_protect_name => mld_sprecaply - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_sprec_type), intent(inout) :: prec - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_spk_),intent(inout), optional, target :: work(:) - - ! Local variables - character :: trans_ - real(psb_spk_), pointer :: work_(:) - real(psb_spk_), allocatable :: w1(:), w2(:) - - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: err_act,iwsz, k, nswps - character(len=20) :: name - - name='mld_sprecaply' - info = psb_success_ - call psb_erractionsave(err_act) - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (present(trans)) then - trans_=psb_toupper(trans) - else - trans_='N' - end if - - if (present(work)) then - work_ => work - else - iwsz = max(1,4*desc_data%get_local_cols()) - allocate(work_(iwsz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name, & - & i_err=(/iwsz,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - - end if - - if (.not.(allocated(prec%precv))) then - !! Error 1: should call mld_sprecbld - info=3112 - call psb_errpush(info,name) - goto 9999 - end if - - if (size(prec%precv) >1) then - ! - ! Number of levels > 1: apply the multilevel preconditioner - ! - call mld_mlprec_aply(sone,prec,x,szero,y,desc_data,trans_,work_,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_smlprec_aply') - goto 9999 - end if - - else if (size(prec%precv) == 1) then - ! - ! Number of levels = 1: apply the base preconditioner - ! - if (allocated(prec%precv(1)%sm2a)) then - nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) - ! - ! This is a kludge for handling the symmetrized GS case. - ! Will need some rethinking. - ! - call psb_geasb(w1,desc_data,info,scratch=.true.) - call psb_geasb(w2,desc_data,info,scratch=.true.) - - call psb_geaxpby(sone,x,szero,w1,desc_data,info) - select case(trans_) - case ('N') - do k=1, nswps - call prec%precv(1)%sm%apply(sone,w1,szero,w2,desc_data,trans_,& - & ione, work_,info) - call prec%precv(1)%sm2a%apply(sone,w2,szero,w1,desc_data,trans_,& - & ione, work_,info) - end do - - case('T','C') - do k=1, nswps - call prec%precv(1)%sm2a%apply(sone,w1,szero,w2,desc_data,trans_,& - & ione, work_,info) - call prec%precv(1)%sm%apply(sone,w2,szero,w1,desc_data,trans_,& - & ione, work_,info) - end do - case default - info = psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='Invalid trans') - goto 9999 - end select - call psb_geaxpby(sone,w1,szero,y,desc_data,info) - call psb_gefree(w1,desc_data,info) - call psb_gefree(w2,desc_data,info) - - else - nswps = prec%precv(1)%parms%sweeps_pre - call prec%precv(1)%sm%apply(sone,x,szero,y,desc_data,trans_,& - & nswps, work_,info) - end if - else - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='Invalid size of precv',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - endif - - ! If the original distribution has an overlap we should fix that. - call psb_halo(y,desc_data,info,data=psb_comm_mov_) - - - if (present(work)) then - else - deallocate(work_) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_sprecaply - - -! -! Subroutine: mld_sprecaply1 -! Version: real -! -! Applies the preconditioner built by mld_sprecbld, i.e. computes -! -! X = op(M^(-1)) * X, -! where -! - M is the preconditioner, -! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, -! - X is a vectors. -! This operation is performed at each iteration of a preconditioned Krylov solver. -! -! This routine differs from mld_sprecaply because the preconditioned vector X -! overwrites the original one. -! -! -! Arguments: -! prec - type(mld_sprec_type), input. -! The preconditioner data structure containing the local part -! of the preconditioner to be applied. -! x - real(psb_spk_), dimension(:), input/output. -! The local part of vector X in X := op(M^(-1)) * X. -! desc_data - type(psb_desc_type), input. -! The communication descriptor associated to the matrix to be -! preconditioned. -! info - integer, output. -! Error code. -! trans - character(len=1), optional. -! If trans='N','n' then op(M^(-1)) = M^(-1); -! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). -! -subroutine mld_sprecaply1(prec,x,desc_data,info,trans) - - use psb_base_mod - use mld_s_inner_mod!, mld_protect_name => mld_sprecaply1 - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_sprec_type), intent(inout) :: prec - real(psb_spk_),intent(inout) :: x(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: err_act - real(psb_spk_), pointer :: ww(:), w1(:) - character(len=20) :: name - - name='mld_sprecaply1' - info = psb_success_ - call psb_erractionsave(err_act) - - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - allocate(ww(size(x)),w1(size(x)),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name, & - & i_err=(/itwo*size(x),izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - - call prec%apply(x,ww,desc_data,info,trans=trans,work=w1) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_precaply') - goto 9999 - end if - - x(:) = ww(:) - deallocate(ww,w1,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_sprecaply1 - - - -subroutine mld_sprecaply2_vect(prec,x,y,desc_data,info,trans,work) - - use psb_base_mod - use mld_s_inner_mod!, mld_protect_name => mld_sprecaply2_vect - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_sprec_type), intent(inout) :: prec - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_spk_),intent(inout), optional, target :: work(:) - - ! Local variables - character :: trans_ - real(psb_spk_), pointer :: work_(:) - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: err_act,iwsz, k, nswps - logical :: do_alloc_wrk - character(len=20) :: name - - name='mld_sprecaply' - info = psb_success_ - call psb_erractionsave(err_act) - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (present(trans)) then - trans_=psb_toupper(trans) - else - trans_='N' - end if - - if (present(work)) then - work_ => work - else - iwsz = max(1,4*desc_data%get_local_cols()) - allocate(work_(iwsz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name, & - & i_err=(/iwsz,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - - end if - - if (.not.(allocated(prec%precv))) then - !! Error 1: should call mld_sprecbld - info=3112 - call psb_errpush(info,name) - goto 9999 - end if - - do_alloc_wrk = .not.allocated(prec%precv(1)%wrk) - if (do_alloc_wrk) call prec%allocate_wrk(info,vmold=x%v) - - if (size(prec%precv) >1) then - ! - ! Number of levels > 1: apply the multilevel preconditioner - ! - ! FIXME: generic name causes an ICE with Intel - call mld_smlprec_aply_vect(sone,prec,x,szero,y,desc_data,trans_,work_,info) - - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_smlprec_aply') - goto 9999 - end if - - else if (size(prec%precv) == 1) then - ! - ! Number of levels = 1: apply the base preconditioner - ! - nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) - - associate(w1 => prec%precv(1)%wrk%vx2l, w2 => prec%precv(1)%wrk%vy2l,& - & wv => prec%precv(1)%wrk%wv) - if (allocated(prec%precv(1)%sm2a)) then - ! - ! This is a kludge for handling the symmetrized GS case. - ! Will need some rethinking. - ! - call psb_geaxpby(sone,x,szero,w1,desc_data,info) - select case(trans_) - case ('N') - do k=1, nswps - if (info == 0) call prec%precv(1)%sm%apply(sone,w1,szero,w2,desc_data,trans_,& - & ione, work_,wv,info) - if (info == 0) call prec%precv(1)%sm2a%apply(sone,w2,szero,w1,desc_data,trans_,& - & ione, work_,wv,info) - end do - - case('T','C') - do k=1, nswps - if (info == 0) call prec%precv(1)%sm2a%apply(sone,w1,szero,w2,desc_data,trans_,& - & ione, work_,wv,info) - if (info == 0) call prec%precv(1)%sm%apply(sone,w2,szero,w1,desc_data,trans_,& - & ione, work_,wv,info) - end do - case default - info = psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='Invalid trans') - goto 9999 - end select - if (info == 0) call psb_geaxpby(sone,w1,szero,y,desc_data,info) - else - if (info == 0) call prec%precv(1)%sm%apply(sone,x,szero,y,desc_data,trans_,& - & nswps,work_,wv,info) - end if - end associate - if (psb_errstatus_fatal()) info = psb_err_internal_error_ - if (info /= 0) then - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='Smoother application',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - end if - - else - - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='Invalid size of precv',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - endif - - ! If the original distribution has an overlap we should fix that. - call psb_halo(y,desc_data,info,data=psb_comm_mov_) - - if (do_alloc_wrk) call prec%free_wrk(info) - - if (present(work)) then - else - deallocate(work_) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_sprecaply2_vect - - -subroutine mld_sprecaply1_vect(prec,x,desc_data,info,trans,work) - - use psb_base_mod - use mld_s_inner_mod!, mld_protect_name => mld_sprecaply1_vect - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_sprec_type), intent(inout) :: prec - type(psb_s_vect_type),intent(inout) :: x - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_spk_),intent(inout), optional, target :: work(:) - - ! Local variables - character :: trans_ - real(psb_spk_), pointer :: work_(:) - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: err_act,iwsz, k, nswps - logical :: do_alloc_wrk - character(len=20) :: name - - name='mld_sprecaply' - info = psb_success_ - call psb_erractionsave(err_act) - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (present(trans)) then - trans_=psb_toupper(trans) - else - trans_='N' - end if - - if (present(work)) then - work_ => work - else - iwsz = max(1,4*desc_data%get_local_cols()) - allocate(work_(iwsz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name, & - & i_err=(/iwsz,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - - end if - - if (.not.(allocated(prec%precv))) then - !! Error 1: should call mld_sprecbld - info=3112 - call psb_errpush(info,name) - goto 9999 - end if - - do_alloc_wrk = .not.allocated(prec%precv(1)%wrk) - if (do_alloc_wrk) call prec%allocate_wrk(info,vmold=x%v) - - associate(ww => prec%precv(1)%wrk%vtx, wv => prec%precv(1)%wrk%wv) - - if (size(prec%precv) >1) then - ! - ! Number of levels > 1: apply the multilevel preconditioner - ! - ! FIXME: generic name causes an ICE with Intel - call mld_smlprec_aply_vect(sone,prec,x,szero,ww,desc_data,trans_,work_,info) - if (info == 0) call psb_geaxpby(sone,ww,szero,x,desc_data,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_smlprec_aply') - goto 9999 - end if - - else if (size(prec%precv) == 1) then - ! - ! Number of levels = 1: apply the base preconditioner - ! - nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) - if (allocated(prec%precv(1)%sm2a)) then - ! - ! This is a kludge for handling the symmetrized GS case. - ! Will need some rethinking. - ! - select case(trans_) - case ('N') - do k=1, nswps - if (info == 0) call prec%precv(1)%sm%apply(sone,x,szero,ww,desc_data,trans_,& - & ione, work_,wv,info) - if (info == 0) call prec%precv(1)%sm2a%apply(sone,ww,szero,x,desc_data,trans_,& - & ione, work_,wv,info) - end do - case('T','C') - do k=1, nswps - if (info == 0) call prec%precv(1)%sm2a%apply(sone,x,szero,ww,desc_data,trans_,& - & ione, work_,wv,info) - if (info == 0) call prec%precv(1)%sm%apply(sone,ww,szero,x,desc_data,trans_,& - & ione, work_,wv,info) - end do - case default - info = psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='Invalid trans') - goto 9999 - end select - - else - if (info == 0) call prec%precv(1)%sm%apply(sone,x,szero,ww,desc_data,trans_,& - & nswps, work_,wv,info) - if (info == 0) call psb_geaxpby(sone,ww,szero,x,desc_data,info) - end if - - if (psb_errstatus_fatal()) info = psb_err_internal_error_ - if (info /=0) then - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='Smoother application',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - end if - - else - - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='Invalid size of precv',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - endif - end associate - - ! If the original distribution has an overlap we should fix that. - call psb_halo(x,desc_data,info,data=psb_comm_mov_) - - if (do_alloc_wrk) call prec%free_wrk(info) - - if (present(work)) then - else - deallocate(work_) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_sprecaply1_vect diff --git a/mlprec/impl/mld_sprecbld.f90 b/mlprec/impl/mld_sprecbld.f90 deleted file mode 100644 index 5a02c072..00000000 --- a/mlprec/impl/mld_sprecbld.f90 +++ /dev/null @@ -1,161 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_sprecbld.f90 -! -! Subroutine: mld_sprecbld -! Version: real -! Contains: subroutine init_baseprec_av -! -! This routine builds the preconditioner according to the requirements made by -! the user through the subroutines mld_precinit and mld_precset. -! -! -! Arguments: -! a - type(psb_sspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_sprec_type), input/output. -! The preconditioner data structure containing the local part -! of the preconditioner to be built. -! info - integer, output. -! Error code. -! -subroutine mld_sprecbld(a,desc_a,prec,info,amold,vmold,imold) - - use psb_base_mod - use mld_s_prec_mod, mld_protect_name => mld_sprecbld - - Implicit None - - ! Arguments - type(psb_sspmat_type),intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_sprec_type),intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local Variables - type(mld_sprec_type) :: t_prec - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k,err_act, iszv, newsz - integer(psb_ipk_) :: ipv(mld_ifpsz_), val - integer(psb_ipk_) :: int_err(5) - type(mld_dml_parms) :: prm - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_sprecbld' - info = psb_success_ - int_err(1) = 0 - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - prec%ictxt = ictxt - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' - ! - - if (.not.allocated(prec%precv)) then - !! Error: should have called mld_sprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - ! - ! Check to ensure all procs have the same - ! - newsz = -1 - iszv = size(prec%precv) - call psb_bcast(ictxt,iszv) - if (iszv /= size(prec%precv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of precv') - goto 9999 - end if - - if (iszv <= 0) then - ! Is this really possible? probably not. - info=psb_err_from_subroutine_ - ch_err='size bpv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - ! - ! Build the preconditioner - ! - call prec%hierarchy_build(a,desc_a,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Error from hierarchy build') - goto 9999 - end if - - call prec%smoothers_build(a,desc_a,info,amold,vmold,imold) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Error from smoothers build') - goto 9999 - end if - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_sprecbld diff --git a/mlprec/impl/mld_sprecinit.F90 b/mlprec/impl/mld_sprecinit.F90 deleted file mode 100644 index 218c5802..00000000 --- a/mlprec/impl/mld_sprecinit.F90 +++ /dev/null @@ -1,237 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_sprecinit.f90 -! -! Subroutine: mld_sprecinit -! Version: real -! -! This routine allocates and initializes the preconditioner data structure, -! according to the preconditioner type chosen by the user. -! -! A default preconditioner is set for each preconditioner type -! specified by the user: -! -! 'NOPREC' - no preconditioner -! -! 'DIAG', 'JACOBI' - diagonal/Jacobi -! -! 'L1-DIAG', 'L1-JACOBI' - diagonal/Jacobi with L1 norm correction -! -! 'GS', 'FBGS' - Hybrid Gauss-Seidel, also symmetrized -! -! 'BJAC' - block Jacobi preconditioner, with ILU(0) -! on the local blocks -! -! 'L1-BJAC' - block Jacobi preconditioner, with ILU(0) -! on the local blocks and L1 correction for off-diag blocks -! -! 'AS' - Additive Schwarz (AS), with -! overlap 1 and ILU(0) on the local submatrices -! -! 'ML' - Multilevel hybrid preconditioner (additive on the -! same level and multiplicative through the levels), -! with 2 levels, pre and post-smoothing, RAS with -! overlap 1 and ILU(0) on the local blocks is -! applied as post-smoother at each level, but the -! coarsest one; four sweeps of the block-Jacobi solver, -! with LU from UMFPACK on the blocks, are applied at -! the coarsest level, on the distributed coarse matrix. -! The smoothed aggregation algorithm with threshold 0 -! is used to build the coarse matrix. -! -! For the multilevel preconditioners, the levels are numbered in increasing -! order starting from the finest one, i.e. level 1 is the finest level. -! -! -! Arguments: -! p - type(mld_sprec_type), input/output. -! The preconditioner data structure. -! ptype - character(len=*), input. -! The type of preconditioner. Its values are 'NOPREC', -! 'DIAG', 'BJAC', 'AS', 'ML' (and the corresponding -! lowercase strings). -! info - integer, output. -! Error code. -! -subroutine mld_sprecinit(ictxt,prec,ptype,info) - - use psb_base_mod - use mld_s_prec_mod, mld_protect_name => mld_sprecinit - use mld_s_jac_smoother - use mld_s_as_smoother - use mld_s_id_solver - use mld_s_diag_solver - use mld_s_ilu_solver - use mld_s_gs_solver -#if defined(HAVE_SLU_) - use mld_s_slu_solver -#endif - - - implicit none - - ! Arguments - integer(psb_ipk_), intent(in) :: ictxt - class(mld_sprec_type), intent(inout) :: prec - character(len=*), intent(in) :: ptype - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: nlev_, ilev_ - real(psb_spk_) :: thr - character(len=*), parameter :: name='mld_precinit' - info = psb_success_ - - if (allocated(prec%precv)) then - call prec%free(info) - if (info /= psb_success_) then - ! Do we want to do something? - endif - endif - prec%ictxt = ictxt - prec%ag_data%min_coarse_size = -1 - - select case(psb_toupper(trim(ptype))) - case ('NOPREC','NONE') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_s_base_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_s_id_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('JAC','DIAG','JACOBI') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_s_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_s_diag_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('L1-DIAG','L1-JACOBI','L1_DIAG','L1_JACOBI') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_s_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_s_l1_diag_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('GS','FWGS') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_s_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_s_gs_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('BWGS') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_s_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_s_bwgs_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('FBGS') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - call prec%set('SMOOTHER_TYPE','FBGS',info) - call prec%precv(ilev_)%default() - - case ('BJAC') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_s_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_s_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('L1-BJAC','L1_BJAC') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_s_l1_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_s_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('AS') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_s_as_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_s_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - - case ('ML') - - nlev_ = prec%ag_data%max_levs - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - - do ilev_ = 1, nlev_ - call prec%precv(ilev_)%default() - end do - call prec%set('ML_CYCLE','VCYCLE',info) - call prec%set('SMOOTHER_TYPE','FBGS',info) -#if defined(HAVE_MUMPS_) - call prec%set('COARSE_SOLVE','MUMPS',info) -#elif defined(HAVE_SLU_) - call prec%set('COARSE_SOLVE','SLU',info) -#else - call prec%set('COARSE_SOLVE','ILU',info) -#endif - - case default - write(psb_err_unit,*) name,& - &': Warning: Unknown preconditioner type request "',ptype,'"' - info = psb_err_pivot_too_small_ - - end select - - -end subroutine mld_sprecinit diff --git a/mlprec/impl/mld_sprecset.F90 b/mlprec/impl/mld_sprecset.F90 deleted file mode 100644 index 6ee91285..00000000 --- a/mlprec/impl/mld_sprecset.F90 +++ /dev/null @@ -1,229 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_sprecset.f90 -! -subroutine mld_sprecsetsm(p,val,info,ilev,ilmax,pos) - - use psb_base_mod - use mld_s_prec_mod, mld_protect_name => mld_sprecsetsm - - implicit none - - ! Arguments - class(mld_sprec_type), intent(inout) :: p - class(mld_s_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ - character(len=*), parameter :: name='mld_precsetsm' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - ilmin_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmin_ = 1 - ilmax_ = nlev_ - end if - - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - do ilev_ = ilmin_, ilmax_ - call p%precv(ilev_)%set(val,info,pos=pos) - if (info /= 0) return - end do - -end subroutine mld_sprecsetsm - -subroutine mld_sprecsetsv(p,val,info,ilev,ilmax,pos) - - use psb_base_mod - use mld_s_prec_mod, mld_protect_name => mld_sprecsetsv - - implicit none - - ! Arguments - class(mld_sprec_type), intent(inout) :: p - class(mld_s_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ - character(len=*), parameter :: name='mld_precsetsv' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - ilmin_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmin_ = 1 - ilmax_ = nlev_ - end if - - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - do ilev_ = ilmin_, ilmax_ - call p%precv(ilev_)%set(val,info,pos=pos) - if (info /= 0) return - end do - -end subroutine mld_sprecsetsv - -subroutine mld_sprecsetag(p,val,info,ilev,ilmax,pos) - - use psb_base_mod - use mld_s_prec_mod, mld_protect_name => mld_sprecsetag - - implicit none - - ! Arguments - class(mld_sprec_type), intent(inout) :: p - class(mld_s_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev, ilmax - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ - character(len=*), parameter :: name='mld_precsetag' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - ilmin_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmin_ = 1 - ilmax_ = nlev_ - end if - - - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - do ilev_ = ilmin_, ilmax_ - call p%precv(ilev_)%set(val,info,pos=pos) - if (info /= 0) return - end do - -end subroutine mld_sprecsetag - diff --git a/mlprec/impl/mld_sslu_interface.c b/mlprec/impl/mld_sslu_interface.c deleted file mode 100644 index 1c57018f..00000000 --- a/mlprec/impl/mld_sslu_interface.c +++ /dev/null @@ -1,309 +0,0 @@ -/* - * - * MLD2P4 version 2.1 - * MultiLevel Domain Decomposition Parallel Preconditioners Package - * based on PSBLAS (Parallel Sparse BLAS version 3.5) - * - * (C) Copyright 2008-2018 - * - * Salvatore Filippone - * Pasqua D'Ambra - * Daniela di Serafino - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions, and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the MLD2P4 group or the names of its contributors may - * not be used to endorse or promote products derived from this - * software without specific written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * - * File: mld_slu_interface.c - * - * Functions: mld_sslu_fact, mld_sslu_solve, mld_sslu_free. - * - * This file is an interface to the SuperLU routines for sparse factorization and - * solve. It was obtained by modifying the c_fortran_dgssv.c file from the SuperLU - * source distribution; original copyright terms are reproduced below. - * - */ - - -/* ===================== - -Copyright (c) 2003, The Regents of the University of California, through -Lawrence Berkeley National Laboratory (subject to receipt of any required -approvals from U.S. Dept. of Energy) - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -(1) Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. -(2) Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. -(3) Neither the name of Lawrence Berkeley National Laboratory, U.S. Dept. of -Energy nor the names of its contributors may be used to endorse or promote -products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -/* - * -- SuperLU routine (version 3.0) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * October 15, 2003 - * - */ - -#ifdef Have_SLU_ -#include "slu_sdefs.h" - -#define HANDLE_SIZE 8 - -typedef struct { - SuperMatrix *L; - SuperMatrix *U; - int *perm_c; - int *perm_r; -} factors_t; - - -#else - -#include - -#endif - - - -int mld_sslu_fact(int n, int nnz, float *values, - int *colptr, int *rowind, void **f_factors) -{ -/* - * This routine can be called from Fortran. - * performs LU decomposition. - * - * f_factors (input/output) - * On output contains the pointer pointing to - * the structure of the factored matrices. - * - */ - -#ifdef Have_SLU_ - SuperMatrix A, AC; - SuperMatrix *L, *U; - int *perm_r; /* row permutations from partial pivoting */ - int *perm_c; /* column permutation vector */ - int *etree; /* column elimination tree */ - SCformat *Lstore; - NCformat *Ustore; - int i, panel_size, permc_spec, relax; - trans_t trans; - mem_usage_t mem_usage; - superlu_options_t options; - SuperLUStat_t stat; - factors_t *LUfactors; - GlobalLU_t Glu; /* Not needed on return. */ - int info; - - trans = NOTRANS; - - - /* Set the default input options. */ - set_default_options(&options); - - /* Initialize the statistics variables. */ - StatInit(&stat); - - sCreate_CompRow_Matrix(&A, n, n, nnz, values, rowind, colptr, - SLU_NR, SLU_S, SLU_GE); - L = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) ); - U = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) ); - if ( !(perm_r = intMalloc(n)) ) ABORT("Malloc fails for perm_r[]."); - if ( !(perm_c = intMalloc(n)) ) ABORT("Malloc fails for perm_c[]."); - if ( !(etree = intMalloc(n)) ) ABORT("Malloc fails for etree[]."); - - /* - * Get column permutation vector perm_c[], according to permc_spec: - * permc_spec = 0: natural ordering - * permc_spec = 1: minimum degree on structure of A'*A - * permc_spec = 2: minimum degree on structure of A'+A - * permc_spec = 3: approximate minimum degree for unsymmetric matrices - */ - options.ColPerm=2; - permc_spec = options.ColPerm; - get_perm_c(permc_spec, &A, perm_c); - - sp_preorder(&options, &A, perm_c, etree, &AC); - - panel_size = sp_ienv(1); - relax = sp_ienv(2); -#if defined(SLU_VERSION_5) - sgstrf(&options, &AC, relax, panel_size, - etree, NULL, 0, perm_c, perm_r, L, U, &Glu, &stat, &info); -#elif defined(SLU_VERSION_4) - sgstrf(&options, &AC, relax, panel_size, - etree, NULL, 0, perm_c, perm_r, L, U, &stat, &info); -#else - choke_on_me; -#endif - - if ( info == 0 ) { - Lstore = (SCformat *) L->Store; - Ustore = (NCformat *) U->Store; - sQuerySpace(L, U, &mem_usage); -#if 0 - printf("No of nonzeros in factor L = %d\n", Lstore->nnz); - printf("No of nonzeros in factor U = %d\n", Ustore->nnz); - printf("No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz); - printf("L\\U MB %.3f\ttotal MB needed %.3f\n", - mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); -#endif - } else { - printf("sgstrf() error returns INFO= %d\n", info); - if ( info <= n ) { /* factorization completes */ - sQuerySpace(L, U, &mem_usage); - printf("L\\U MB %.3f\ttotal MB needed %.3f\n", - mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); - } - } - - /* Save the LU factors in the factors handle */ - LUfactors = (factors_t*) SUPERLU_MALLOC(sizeof(factors_t)); - LUfactors->L = L; - LUfactors->U = U; - LUfactors->perm_c = perm_c; - LUfactors->perm_r = perm_r; - *f_factors = (void *) LUfactors; - - /* Free un-wanted storage */ - SUPERLU_FREE(etree); - Destroy_SuperMatrix_Store(&A); - Destroy_CompCol_Permuted(&AC); - StatFree(&stat); - return(info); -#else - fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); - return(-1); -#endif -} - - -int mld_sslu_solve(int itrans, int n, int nrhs, float *b, int ldb, - void *f_factors) -{ - /* - * This routine can be called from Fortran. - * performs triangular solve - * - */ - int info; -#ifdef Have_SLU_ - SuperMatrix B; - SuperMatrix *L, *U; - int *perm_r; /* row permutations from partial pivoting */ - int *perm_c; /* column permutation vector */ - int *etree; /* column elimination tree */ - SCformat *Lstore; - NCformat *Ustore; - int i, panel_size, permc_spec, relax; - trans_t trans; - SuperLUStat_t stat; - factors_t *LUfactors; - - if (itrans == 0) { - trans = NOTRANS; - } else if (itrans ==1) { - trans = TRANS; - } else if (itrans ==2) { - trans = CONJ; - } else { - trans = NOTRANS; - } - /* Initialize the statistics variables. */ - StatInit(&stat); - - /* Extract the LU factors in the factors handle */ - LUfactors = (factors_t*) f_factors; - L = LUfactors->L; - U = LUfactors->U; - perm_c = LUfactors->perm_c; - perm_r = LUfactors->perm_r; - - sCreate_Dense_Matrix(&B, n, nrhs, b, ldb, SLU_DN, SLU_S, SLU_GE); - /* Solve the system A*X=B, overwriting B with X. */ - sgstrs (trans, L, U, perm_c, perm_r, &B, &stat, &info); - - Destroy_SuperMatrix_Store(&B); - StatFree(&stat); -#else - fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); - info=-1; -#endif - return(info); -} - - -int mld_sslu_free(void *f_factors) -{ -/* - * This routine can be called from Fortran. - * - * free all storage in the end - * - */ -#ifdef Have_SLU_ - factors_t *LUfactors; - - /* Free the LU factors in the factors handle */ - LUfactors = (factors_t*) f_factors; - if (LUfactors != NULL) { - SUPERLU_FREE (LUfactors->perm_r); - SUPERLU_FREE (LUfactors->perm_c); - Destroy_SuperNode_Matrix(LUfactors->L); - Destroy_CompCol_Matrix(LUfactors->U); - SUPERLU_FREE (LUfactors->L); - SUPERLU_FREE (LUfactors->U); - SUPERLU_FREE (LUfactors); - } - return(0); -#else - fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); - return(-1); -#endif -} - - diff --git a/mlprec/impl/mld_z_extprol_bld.F90 b/mlprec/impl/mld_z_extprol_bld.F90 deleted file mode 100644 index 1fb7b727..00000000 --- a/mlprec/impl/mld_z_extprol_bld.F90 +++ /dev/null @@ -1,534 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_z_extprol_bld.f90 -! -! Subroutine: mld_z_extprol_bld -! Version: real -! -! This routine builds the preconditioner according to the requirements made by -! the user trough the subroutines mld_precinit and mld_precset. -! -! A multilevel preconditioner is regarded as an array of 'one-level' data structures, -! each containing the part of the preconditioner associated to a certain level, -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level. No transfer operators are associated to level 1. -! -! -! Arguments: -! a - type(psb_zspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_zprec_type), input/output. -! The preconditioner data structure containing the local part -! of the preconditioner to be built. -! info - integer, output. -! Error code. -! -! amold - class(psb_z_base_sparse_mat), input, optional -! Mold for the inner format of matrices contained in the -! preconditioner -! -! -! vmold - class(psb_z_base_vect_type), input, optional -! Mold for the inner format of vectors contained in the -! preconditioner -! -! -! -subroutine mld_z_extprol_bld(a,desc_a,p,prolv,restrv,info,amold,vmold,imold) - - use psb_base_mod - use mld_z_inner_mod - use mld_z_prec_mod, mld_protect_name => mld_z_extprol_bld - - Implicit None - - ! Arguments - type(psb_zspmat_type),intent(in), target :: a - type(psb_zspmat_type),intent(inout), target :: prolv(:) - type(psb_zspmat_type),intent(inout), target :: restrv(:) - type(psb_desc_type), intent(inout), target :: desc_a - type(mld_zprec_type),intent(inout),target :: p - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! !$ character, intent(in), optional :: upd - - ! Local Variables - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, casize, nplevs, mxplevs - integer(psb_ipk_) :: nprolv, nrestrv - real(psb_dpk_) :: mnaggratio - integer(psb_ipk_) :: ipv(mld_ifpsz_), val - class(mld_z_base_smoother_type), allocatable :: coarse_sm, base_sm, med_sm - type(mld_dml_parms) :: baseparms, medparms, coarseparms - type(mld_z_onelev_type), allocatable :: tprecv(:) - integer(psb_ipk_) :: int_err(5) - character :: upd_ - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - logical, parameter :: debug=.false. - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_z_extprol_bld' - info = psb_success_ - int_err(1) = 0 - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - p%ictxt = ictxt - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' -#if defined(LPK8) - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Need fix for LPK8') - goto 9999 -#else - - ! - ! For the time being we are commenting out the UPDATE argument - ! we plan to resurrect it later. - ! !$ if (present(upd)) then - ! !$ if (debug_level >= psb_debug_outer_) & - ! !$ & write(debug_unit,*) me,' ',trim(name),'UPD ', upd - ! !$ - ! !$ if ((psb_toupper(upd).eq.'F').or.(psb_toupper(upd).eq.'T')) then - ! !$ upd_=psb_toupper(upd) - ! !$ else - ! !$ upd_='F' - ! !$ endif - ! !$ else - ! !$ upd_='F' - ! !$ endif - upd_ = 'F' - - if (.not.allocated(p%precv)) then - !! Error: should have called mld_zprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - ! - ! Check to ensure all procs have the same - ! - newsz = -1 - mxplevs = p%ag_data%max_levs - mnaggratio = p%ag_data%min_cr_ratio - casize = p%ag_data%min_coarse_size - iszv = size(p%precv) - nprolv = size(prolv) - nrestrv = size(restrv) - call psb_bcast(ictxt,iszv) - call psb_bcast(ictxt,casize) - call psb_bcast(ictxt,mxplevs) - call psb_bcast(ictxt,mnaggratio) - call psb_bcast(ictxt,nprolv) - call psb_bcast(ictxt,nrestrv) - if (casize /= p%ag_data%min_coarse_size) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent min_coarse_size') - goto 9999 - end if - if (mxplevs /= p%ag_data%max_levs) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent max_levs') - goto 9999 - end if - if (mnaggratio /= p%ag_data%min_cr_ratio) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent min_cr_ratio') - goto 9999 - end if - if (iszv /= size(p%precv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of precv') - goto 9999 - end if - if (nprolv /= size(prolv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of prolv') - goto 9999 - end if - if (nrestrv /= size(restrv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of restrv') - goto 9999 - end if - if (nrestrv /= nprolv) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size prolv vs restrv') - goto 9999 - end if - - if (iszv <= 1) then - ! We should only ever get here for multilevel. - info=psb_err_from_subroutine_ - ch_err='size bpv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - endif - - if (nrestrv < 1) then - ! We should only ever get here for multilevel. - info=psb_err_from_subroutine_ - ch_err='size restrv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - endif - - ! - nplevs = nrestrv + 1 - p%ag_data%max_levs = nplevs - - ! - ! Fixed number of levels. - ! - nplevs = max(itwo,mxplevs) - - coarseparms = p%precv(iszv)%parms - baseparms = p%precv(1)%parms - medparms = p%precv(2)%parms - - allocate(coarse_sm, source=p%precv(iszv)%sm,stat=info) - if (info == psb_success_) & - & allocate(med_sm, source=p%precv(2)%sm,stat=info) - if (info == psb_success_) & - & allocate(base_sm, source=p%precv(1)%sm,stat=info) - if (info /= psb_success_) then - write(0,*) 'Error in saving smoothers',info - call psb_errpush(psb_err_internal_error_,name,a_err='Base level precbuild.') - goto 9999 - end if - - if (iszv /= nplevs) then - allocate(tprecv(nplevs),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - tprecv(1)%parms = baseparms - allocate(tprecv(1)%sm,source=base_sm,stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - do i=2,nplevs-1 - tprecv(i)%parms = medparms - allocate(tprecv(i)%sm,source=med_sm,stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - end do - tprecv(nplevs)%parms = coarseparms - allocate(tprecv(nplevs)%sm,source=coarse_sm,stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - do i=1,iszv - call p%precv(i)%free(info) - end do - call move_alloc(tprecv,p%precv) - iszv = size(p%precv) - end if - ! - ! Finest level first; remember to fix base_a and base_desc - ! - p%precv(1)%base_a => a - p%precv(1)%base_desc => desc_a - newsz = 0 - array_build_loop: do i=2, iszv - - ! - ! Sanity checks on the parameters - ! - if (i p%precv(i)%ac - p%precv(i)%base_desc => p%precv(i)%desc_ac - - - if (i>2) then - if (all(p%precv(i)%map%naggr == p%precv(i-1)%map%naggr)) then - newsz=i-1 - end if - call psb_bcast(ictxt,newsz) - if (newsz > 0) exit array_build_loop - end if - end do array_build_loop - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Internal extprol build' ) - goto 9999 - endif - - iszv = size(p%precv) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Exiting with',iszv,' levels' -#endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - - subroutine mld_z_extaggr_bld(a,desc_a,p,op_restr,op_prol,info) - use psb_base_mod - use mld_z_inner_mod - - implicit none - - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - type(psb_zspmat_type), intent(inout) :: op_restr,op_prol - type(psb_desc_type), intent(in), target :: desc_a - type(mld_z_onelev_type), intent(inout),target :: p - integer(psb_ipk_), intent(out) :: info - - ! Local variables - character(len=20) :: name - integer(psb_mpk_) :: ictxt, np, me, ncol - integer(psb_ipk_) :: err_act,ntaggr,nzl - integer(psb_ipk_), allocatable :: ilaggr(:), nlaggr(:) - type(psb_zspmat_type) :: ac, am2, am3, am4 - type(psb_z_coo_sparse_mat) :: acoo, bcoo - type(psb_z_csr_sparse_mat) :: acsr1 - logical, parameter :: debug=.false. - - name='mld_z_extaggr_bld' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt,me,np) -#if defined(LPK8) - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Need fix for LPK8') - goto 9999 -#else - allocate(nlaggr(np),ilaggr(1)) - nlaggr = 0 - ilaggr = 0 - p%parms%par_aggr_alg = mld_ext_aggr_ - call mld_check_def(p%parms%ml_cycle,'Multilevel cycle',& - & mld_mult_ml_,is_legal_ml_cycle) - call mld_check_def(p%parms%coarse_mat,'Coarse matrix',& - & mld_distr_mat_,is_legal_ml_coarse_mat) - - nlaggr(me+1) = op_restr%get_nrows() - if (op_restr%get_nrows() /= op_prol%get_ncols()) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent restr/prol sizes') - goto 9999 - end if - call psb_sum(ictxt,nlaggr) - ntaggr = sum(nlaggr) - ncol = desc_a%get_local_cols() - if (debug) write(0,*)me,' Sizes:',op_restr%get_nrows(),op_restr%get_ncols(),& - & op_prol%get_nrows(),op_prol%get_ncols(), a%get_nrows(),a%get_ncols() - ! - ! Compute local part of AC - ! - call op_prol%clone(am2,info) - if (info == psb_success_) call psb_sphalo(am2,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.) - if (info == psb_success_) call psb_rwextd(ncol,am2,info,b=am4) - if (info == psb_success_) call am4%free() - call psb_spspmm(a,am2,am3,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spspmm 2') - goto 9999 - end if - call psb_sphalo(am3,desc_a,am4,info,& - & colcnv=.false.,rowscale=.true.) - if (info == psb_success_) call psb_rwextd(ncol,am3,info,b=am4) - if (info == psb_success_) call am4%free() - if(info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Extend am3') - goto 9999 - end if - call psb_spspmm(op_restr,am3,ac,info) - if (info == psb_success_) call am3%free() - if (info == psb_success_) call ac%cscnv(info,type='csr',dupl=psb_dupl_add_) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Build ac = op_restr x am3') - goto 9999 - end if - - select case(p%parms%coarse_mat) - - case(mld_distr_mat_) - - call ac%mv_to(bcoo) - nzl = bcoo%get_nzeros() - - if (info == psb_success_) call psb_cdall(ictxt,p%desc_ac,info,nl=nlaggr(me+1)) - if (info == psb_success_) call psb_cdins(nzl,bcoo%ia,bcoo%ja,p%desc_ac,info) - if (info == psb_success_) call psb_cdasb(p%desc_ac,info) - if (info == psb_success_) call psb_glob_to_loc(bcoo%ia(1:nzl),p%desc_ac,info,iact='I') - if (info == psb_success_) call psb_glob_to_loc(bcoo%ja(1:nzl),p%desc_ac,info,iact='I') - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Creating p%desc_ac and converting ac') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Assembld aux descr. distr.' - call p%ac%mv_from(bcoo) - - call p%ac%set_nrows(p%desc_ac%get_local_rows()) - call p%ac%set_ncols(p%desc_ac%get_local_cols()) - call p%ac%set_asb() - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_sp_free') - goto 9999 - end if - - if (np>1) then - call op_prol%mv_to(acsr1) - nzl = acsr1%get_nzeros() - call psb_glob_to_loc(acsr1%ja(1:nzl),p%desc_ac,info,'I') - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='psb_glob_to_loc') - goto 9999 - end if - call op_prol%mv_from(acsr1) - endif - call op_prol%set_ncols(p%desc_ac%get_local_cols()) - - if (np>1) then - call op_restr%cscnv(info,type='coo',dupl=psb_dupl_add_) - call op_restr%mv_to(acoo) - nzl = acoo%get_nzeros() - if (info == psb_success_) call psb_glob_to_loc(acoo%ia(1:nzl),p%desc_ac,info,'I') - call acoo%set_dupl(psb_dupl_add_) - if (info == psb_success_) call op_restr%mv_from(acoo) - if (info == psb_success_) call op_restr%cscnv(info,type='csr') - if(info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Converting op_restr to local') - goto 9999 - end if - end if - call op_restr%set_nrows(p%desc_ac%get_local_cols()) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Done ac ' - - case(mld_repl_mat_) - ! - ! - call psb_cdall(ictxt,p%desc_ac,info,mg=ntaggr,repl=.true.) - if (info == psb_success_) call psb_cdasb(p%desc_ac,info) - if (info == psb_success_) & - & call psb_gather(p%ac,ac,p%desc_ac,info,dupl=psb_dupl_add_,keeploc=.false.) - - if (info /= psb_success_) goto 9999 - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='invalid mld_coarse_mat_') - goto 9999 - end select - - call p%ac%cscnv(info,type='csr',dupl=psb_dupl_add_) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='spcnv') - goto 9999 - end if - - ! - ! Copy the prolongation/restriction matrices into the descriptor map. - ! op_restr => PR^T i.e. restriction operator - ! op_prol => PR i.e. prolongation operator - ! - - p%map = psb_linmap(psb_map_aggr_,desc_a,& - & p%desc_ac,op_restr,op_prol,ilaggr,nlaggr) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='sp_Free') - goto 9999 - end if -#endif - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - end subroutine mld_z_extaggr_bld - -end subroutine mld_z_extprol_bld diff --git a/mlprec/impl/mld_z_hierarchy_bld.f90 b/mlprec/impl/mld_z_hierarchy_bld.f90 deleted file mode 100644 index be19ffbd..00000000 --- a/mlprec/impl/mld_z_hierarchy_bld.f90 +++ /dev/null @@ -1,539 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_z_hierarchy_bld.f90 -! -! Subroutine: mld_z_hierarchy_bld -! Version: complex -! -! This routine builds the preconditioner according to the requirements made by -! the user trough the subroutines mld_precinit and mld_precset. -! -! A multilevel preconditioner is regarded as an array of 'one-level' data structures, -! each containing the part of the preconditioner associated to a certain level, -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level. No transfer operators are associated to level 1. -! -! -! Arguments: -! a - type(psb_zspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_zprec_type), input/output. -! The preconditioner data structure; upon exit it contains -! the multilevel hierarchy of prolongators, restrictors -! and coarse matrices. -! info - integer, output. -! Error code. -! -subroutine mld_z_hierarchy_bld(a,desc_a,prec,info) - - use psb_base_mod - use mld_z_inner_mod - use mld_z_prec_mod, mld_protect_name => mld_z_hierarchy_bld - - Implicit None - - ! Arguments - type(psb_zspmat_type),intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_zprec_type),intent(inout),target :: prec - integer(psb_ipk_), intent(out) :: info - - ! Local Variables - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz,& - & nplevs, mxplevs - integer(psb_lpk_) :: iaggsize, casize - real(psb_dpk_) :: mnaggratio, sizeratio, athresh, aomega - class(mld_z_base_smoother_type), allocatable :: coarse_sm, med_sm, & - & med_sm2, coarse_sm2 - class(mld_z_base_aggregator_type), allocatable :: tmp_aggr - type(mld_dml_parms) :: medparms, coarseparms - integer(psb_lpk_), allocatable :: ilaggr(:), nlaggr(:) - type(psb_lzspmat_type) :: op_prol - type(mld_z_onelev_type), allocatable :: tprecv(:) - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - integer(psb_ipk_), save :: idx_bldtp=-1, idx_matasb=-1 - logical, parameter :: do_timings=.false. - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_z_hierarchy_bld' - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - prec%ictxt = ictxt - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' - if ((do_timings).and.(idx_bldtp==-1)) & - & idx_bldtp = psb_get_timer_idx("BLD_HIER: bld_tprol") - if ((do_timings).and.(idx_matasb==-1)) & - & idx_matasb = psb_get_timer_idx("BLD_HIER: mmat_asb") - ! - - if (.not.allocated(prec%precv)) then - !! Error: should have called mld_zprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - ! - ! Check to ensure all procs have the same - ! - newsz = -1 - mxplevs = prec%ag_data%max_levs - mnaggratio = prec%ag_data%min_cr_ratio - casize = prec%ag_data%min_coarse_size - iszv = size(prec%precv) - call psb_bcast(ictxt,iszv) - call psb_bcast(ictxt,casize) - call psb_bcast(ictxt,mxplevs) - call psb_bcast(ictxt,mnaggratio) - if (casize /= prec%ag_data%min_coarse_size) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent min_coarse_size') - goto 9999 - end if - if (mxplevs /= prec%ag_data%max_levs) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent max_levs') - goto 9999 - end if - if (mnaggratio /= prec%ag_data%min_cr_ratio) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent min_cr_ratio') - goto 9999 - end if - if (iszv /= size(prec%precv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of precv') - goto 9999 - end if - - if (iszv < 1) then - ! - ! This is wrong, cannot be size <1 - ! - info=psb_err_from_subroutine_ - ch_err='size bpv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - endif - if (iszv == 1) then - ! - ! This is OK, since it may be called by the user even if there - ! is only one level - ! - prec%precv(1)%base_a => a - prec%precv(1)%base_desc => desc_a - - call psb_erractionrestore(err_act) - return - endif - - ! - ! The strategy: - ! 1. The maximum number of levels should be already encoded in the - ! size of the array; - ! 2. If the user did not specify anything, then a default coarse size - ! is generated, and the number of levels is set to the maximum; - ! 3. If the size of the array is different from target number of levels, - ! reallocate; - ! 4. Build the matrix hierarchy, stopping early if either the target - ! coarse size is hit, or the gain falls below the min_cr_ratio - ! threshold. - ! - - if (casize < 0) then - ! - ! Default to the cubic root of the size at base level. - ! - casize = desc_a%get_global_rows() - casize = int((done*casize)**(done/(done*3)),psb_lpk_) - casize = max(casize,lone) - casize = casize*40_psb_lpk_ - call psb_bcast(ictxt,casize) - if (casize > huge(prec%ag_data%min_coarse_size)) then - ! - ! computed coarse size does not fit in IPK_. - ! This is very unlikely, but make sure to put a positive number - ! - prec%ag_data%min_coarse_size = huge(prec%ag_data%min_coarse_size) - else - prec%ag_data%min_coarse_size = casize - end if - end if - nplevs = max(itwo,mxplevs) - - ! - ! The coarse parameters will be needed later - ! - coarseparms = prec%precv(iszv)%parms - call save_smoothers(prec%precv(iszv),coarse_sm,coarse_sm2,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Base level precbuild.') - goto 9999 - end if - ! - ! First set desired number of levels - ! - if (iszv /= nplevs) then - allocate(tprecv(nplevs),stat=info) - ! First all existing levels - do i=1, min(iszv,nplevs) - 1 - if (info == 0) tprecv(i)%parms = prec%precv(i)%parms - if (info == 0) call restore_smoothers(tprecv(i),& - & prec%precv(i)%sm,prec%precv(i)%sm2a,info) - if (info == 0) call move_alloc(prec%precv(i)%aggr,tprecv(i)%aggr) - end do - if (iszv < nplevs) then - ! Further intermediates, if needed - allocate(tmp_aggr,source=tprecv(iszv-1)%aggr,stat=info) - medparms = prec%precv(iszv-1)%parms - call save_smoothers(prec%precv(iszv-1),med_sm,med_sm2,info) - do i=iszv, nplevs - 1 - if (info == 0) tprecv(i)%parms = medparms - if (info == 0) call restore_smoothers(tprecv(i),med_sm,med_sm2,info) - if ((info == 0).and..not.allocated(tprecv(i)%aggr))& - & allocate(tprecv(i)%aggr,source=tmp_aggr,stat=info) - end do - deallocate(tmp_aggr,stat=info) - end if - - ! Then coarse - if (info == 0) tprecv(nplevs)%parms = coarseparms - if (info == 0) call restore_smoothers(tprecv(nplevs),coarse_sm,coarse_sm2,info) - if (info == 0) then - if (nplevs <= iszv) then - allocate(tprecv(nplevs)%aggr,source=prec%precv(nplevs)%aggr,stat=info) - else - allocate(tmp_aggr,source=tprecv(nplevs-1)%aggr,stat=info) - call move_alloc(tmp_aggr,tprecv(nplevs)%aggr) - end if - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - - do i=1,iszv - call prec%precv(i)%free(info) - end do - call move_alloc(tprecv,prec%precv) - iszv = size(prec%precv) - end if - - ! - ! Finest level first; create a GEN_BLOCK - ! copy of the descriptor. - ! - prec%precv(1)%base_a => a - call psb_cd_renum_block(desc_a,prec%precv(1)%desc_ac,info) - prec%precv(1)%base_desc => prec%precv(1)%desc_ac - newsz = 0 - array_build_loop: do i=2, iszv - ! - ! Check on the iprcparm contents: they should be the same - ! on all processes. - ! - call psb_bcast(ictxt,prec%precv(i)%parms) - - ! - ! Sanity checks on the parameters - ! - if (i= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Calling mlprcbld at level ',i - ! - ! Build the mapping between levels i-1 and i and the matrix - ! at level i - ! - if (do_timings) call psb_tic(idx_bldtp) - if (info == psb_success_)& - & call prec%precv(i)%bld_tprol(prec%precv(i-1)%base_a,& - & prec%precv(i-1)%base_desc,& - & ilaggr,nlaggr,op_prol,prec%ag_data,info) - if (do_timings) call psb_toc(idx_bldtp) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Map build') - goto 9999 - endif - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Return from ',i,' call to bld_tprol', info - ! - ! Save op_prol just in case - ! - call op_prol%clone(prec%precv(i)%tprol,info) - ! - ! Check for early termination of aggregation loop. - ! - iaggsize = sum(nlaggr) - - sizeratio = iaggsize - if (i==2) then - sizeratio = desc_a%get_global_rows()/sizeratio - else - sizeratio = sum(prec%precv(i-1)%map%naggr)/sizeratio - end if - prec%precv(i)%szratio = sizeratio - - if (iaggsize <= casize) newsz = i - if (i == iszv) newsz = i - - if (i>2) then - if (sizeratio < mnaggratio) then - if (sizeratio > 1) then - newsz = i - else - ! - ! We are not gaining - ! - newsz = i-1 - end if - end if - - if (all(nlaggr == prec%precv(i-1)%map%naggr)) then - newsz=i-1 - if (me == 0) then - write(debug_unit,*) trim(name),& - &': Warning: aggregates from level ',& - & newsz - write(debug_unit,*) trim(name),& - &': to level ',& - & iszv,' coincide.' - write(debug_unit,*) trim(name),& - &': Number of levels actually used :',newsz - write(debug_unit,*) - end if - end if - end if - call psb_bcast(ictxt,newsz) - - if (newsz > 0) then - ! - ! This is awkward, we are saving the aggregation parms, for the sake - ! of distr/repl matrix at coarse level. Should be rethought. - ! - athresh = prec%precv(newsz)%parms%aggr_thresh - aomega = prec%precv(newsz)%parms%aggr_omega_val - if (info == 0) prec%precv(newsz)%parms = coarseparms - prec%precv(newsz)%parms%aggr_thresh = athresh - prec%precv(newsz)%parms%aggr_omega_val = aomega - - if (info == 0) call restore_smoothers(prec%precv(newsz),& - & coarse_sm,coarse_sm2,info) - if (newsz < i) then - ! - ! We are going back and revisit a previous leve; - ! recover the aggregation. - ! - ilaggr = prec%precv(newsz)%map%iaggr - nlaggr = prec%precv(newsz)%map%naggr - call prec%precv(newsz)%tprol%clone(op_prol,info) - end if - if (do_timings) call psb_tic(idx_matasb) - if (info == psb_success_) call prec%precv(newsz)%mat_asb( & - & prec%precv(newsz-1)%base_a,prec%precv(newsz-1)%base_desc,& - & ilaggr,nlaggr,op_prol,info) - if (do_timings) call psb_toc(idx_matasb) - if (info /= 0) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Mat asb') - goto 9999 - endif - exit array_build_loop - else - if (do_timings) call psb_tic(idx_matasb) - if (info == psb_success_) call prec%precv(i)%mat_asb(& - & prec%precv(i-1)%base_a,prec%precv(i-1)%base_desc,& - & ilaggr,nlaggr,op_prol,info) - if (do_timings) call psb_toc(idx_matasb) - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Map build') - goto 9999 - endif - if (i 0) then - ! - ! We exited early from the build loop, need to fix - ! the size. - ! - allocate(tprecv(newsz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='prec reallocation') - goto 9999 - endif - do i=1,newsz - call prec%precv(i)%move_alloc(tprecv(i),info) - end do - do i=newsz+1, iszv - call prec%precv(i)%free(info) - end do - call move_alloc(tprecv,prec%precv) - ! Ignore errors from transfer - info = psb_success_ - ! - ! Restart - iszv = newsz - ! Fix the pointers, but the level 1 should - ! be treated differently - if (.not.associated(prec%precv(1)%base_desc,desc_a)) then - prec%precv(1)%base_desc => prec%precv(1)%desc_ac - end if - do i=2, iszv - prec%precv(i)%base_a => prec%precv(i)%ac - prec%precv(i)%base_desc => prec%precv(i)%desc_ac - prec%precv(i)%map%p_desc_U => prec%precv(i-1)%base_desc - prec%precv(i)%map%p_desc_V => prec%precv(i)%base_desc - end do - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Internal hierarchy build' ) - goto 9999 - endif - - iszv = size(prec%precv) - - call prec%cmp_complexity() - call prec%cmp_avg_cr() - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Exiting with',iszv,' levels' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - subroutine save_smoothers(level,save1, save2,info) - type(mld_z_onelev_type), intent(inout) :: level - class(mld_z_base_smoother_type), allocatable , intent(inout) :: save1, save2 - integer(psb_ipk_), intent(out) :: info - - info = 0 - if (allocated(save1)) then - call save1%free(info) - if (info == 0) deallocate(save1,stat=info) - if (info /= 0) return - end if - if (allocated(save2)) then - call save2%free(info) - if (info == 0) deallocate(save2,stat=info) - if (info /= 0) return - end if - allocate(save1, mold=level%sm,stat=info) - if (info == 0) call level%sm%clone_settings(save1,info) - if ((info == 0).and.allocated(level%sm2a)) then - allocate(save2, mold=level%sm2a,stat=info) - if (info == 0) call level%sm2a%clone_settings(save2,info) - end if - - return - end subroutine save_smoothers - - subroutine restore_smoothers(level,save1, save2,info) - type(mld_z_onelev_type), intent(inout), target :: level - class(mld_z_base_smoother_type), allocatable, intent(inout) :: save1, save2 - integer(psb_ipk_), intent(out) :: info - - info = 0 - - if (allocated(level%sm)) then - if (info == 0) call level%sm%free(info) - if (info == 0) deallocate(level%sm,stat=info) - end if - if (allocated(save1)) then - if (info == 0) allocate(level%sm,mold=save1,stat=info) - if (info == 0) call save1%clone_settings(level%sm,info) - end if - - if (info /= 0) return - - if (allocated(level%sm2a)) then - if (info == 0) call level%sm2a%free(info) - if (info == 0) deallocate(level%sm2a,stat=info) - end if - if (allocated(save2)) then - if (info == 0) allocate(level%sm2a,mold=save2,stat=info) - if (info == 0) call save2%clone_settings(level%sm2a,info) - if (info == 0) level%sm2 => level%sm2a - else - if (allocated(level%sm)) level%sm2 => level%sm - end if - - return - end subroutine restore_smoothers - -end subroutine mld_z_hierarchy_bld diff --git a/mlprec/impl/mld_z_smoothers_bld.f90 b/mlprec/impl/mld_z_smoothers_bld.f90 deleted file mode 100644 index 8172ae76..00000000 --- a/mlprec/impl/mld_z_smoothers_bld.f90 +++ /dev/null @@ -1,313 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_z_smoothers_bld.f90 -! -! Subroutine: mld_z_smoothers_bld -! Version: complex -! -! This routine performs the final phase of the multilevel preconditioner -! build process: builds the "smoother" objects at each level, -! based on the matrix hierarchy prepared by mld_z_hierarchy_bld. -! -! A multilevel preconditioner is regarded as an array of 'one-level' -! data structures, each containing the part of the -! preconditioner associated to a certain level, -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level. No transfer operators are associated to level 1. -! Each level provides a "build" method; for the base type, the "one-level" -! build procedure simply invokes the build method of the first smoother object, -! and also on the second object if allocated. -! -! -! Arguments: -! a - type(psb_zspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_zprec_type), input/output. -! The preconditioner data structure containing the local part -! of the preconditioner to be built. -! info - integer, output. -! Error code. -! -! amold - class(psb_z_base_sparse_mat), input, optional -! Mold for the inner format of matrices contained in the -! preconditioner -! -! -! vmold - class(psb_z_base_vect_type), input, optional -! Mold for the inner format of vectors contained in the -! preconditioner -! -! -! -subroutine mld_z_smoothers_bld(a,desc_a,prec,info,amold,vmold,imold) - - use psb_base_mod - !use mld_z_inner_mod - use mld_z_prec_mod, mld_protect_name => mld_z_smoothers_bld - - Implicit None - - ! Arguments - type(psb_zspmat_type),intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_zprec_type),intent(inout),target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local Variables - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, nplevs, mxplevs - real(psb_dpk_) :: mnaggratio - integer(psb_ipk_) :: coarse_solve_id - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_z_smoothers_bld' - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' - ! - if (.not.allocated(prec%precv)) then - !! Error: should have called mld_zprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - ! - ! Check to ensure all procs have the same - ! - iszv = size(prec%precv) - call psb_bcast(ictxt,iszv) - if (iszv /= size(prec%precv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of precv') - goto 9999 - end if - - if (iszv < 1) then - ! We should never get here. - info=psb_err_from_subroutine_ - ch_err='size bpv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - endif - - ! - ! Issue a warning for inconsistent changes to COARSE_SOLVE - ! but only if it really is a multilevel - ! - if ((me == psb_root_).and.(iszv>1)) then - coarse_solve_id = prec%precv(iszv)%parms%coarse_solve - select case (coarse_solve_id) - case(mld_umf_,mld_slu_) - if (prec%precv(iszv)%sm%sv%get_id() /= coarse_solve_id) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id) - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) then - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else if (prec%precv(iszv)%parms%coarse_mat == mld_distr_mat_) then - write(psb_err_unit,*) ' but I am building BJAC with ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - end if - write(psb_err_unit,*) 'This may happen if: ' - write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' - write(psb_err_unit,*) ' 2. the solver ', mld_fact_names(coarse_solve_id),& - & ' was not configured at MLD2P4 build time, or' - write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' - end if - if (prec%precv(iszv)%parms%coarse_mat /= mld_repl_mat_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse matrix was requested as replicated', & - & ' but it has been changed to distributed.' - end if - - case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) - if (prec%precv(iszv)%sm%sv%get_id() /= psb_ilu_n_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id) - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) then - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else if (prec%precv(iszv)%parms%coarse_mat == mld_distr_mat_) then - write(psb_err_unit,*) ' but I am building BJAC with ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - end if - write(psb_err_unit,*) & - &'This may happen if coarse_subsolve has been reset' - end if - if (prec%precv(iszv)%parms%coarse_mat /= mld_repl_mat_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id),& - & ' but the coarse matrix has been changed to distributed' - end if - - case(mld_mumps_) - if (prec%precv(iszv)%sm%sv%get_id() /= mld_mumps_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id) - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) then - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else if (prec%precv(iszv)%parms%coarse_mat == mld_distr_mat_) then - write(psb_err_unit,*) ' but I am building BJAC with ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - end if - write(psb_err_unit,*) 'This may happen if: ' - write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' - write(psb_err_unit,*) ' 2. the solver ', mld_fact_names(coarse_solve_id),& - & ' was not configured at MLD2P4 build time, or' - write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' - end if - - case(mld_sludist_) - if (prec%precv(iszv)%sm%sv%get_id() /= coarse_solve_id) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id) - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) then - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else if (prec%precv(iszv)%parms%coarse_mat == mld_distr_mat_) then - write(psb_err_unit,*) ' but I am building BJAC with ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - else - write(psb_err_unit,*) ' but I am building ',& - & mld_fact_names(prec%precv(iszv)%sm%sv%get_id()) - end if - write(psb_err_unit,*) 'This may happen if: ' - write(psb_err_unit,*) ' 1. coarse_subsolve has been reset, or ' - write(psb_err_unit,*) ' 2. the solver ', mld_fact_names(coarse_solve_id), & - & ' was not configured at MLD2P4 build time, or' - write(psb_err_unit,*) ' 3. an unsupported solver setup was specified.' - end if - if (prec%precv(iszv)%parms%coarse_mat /= mld_distr_mat_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id),& - & ' but the coarse matrix has been changed to replicated' - end if - - case(mld_bjac_,mld_l1_bjac_,mld_jac_, mld_l1_jac_, mld_gs_, mld_fbgs_, mld_l1_gs_,mld_l1_fbgs_) - if (prec%precv(iszv)%parms%coarse_mat /= mld_distr_mat_) then - write(psb_err_unit,*) & - & 'MLD2P4: Warning: original coarse solver was requested as ',& - & mld_fact_names(coarse_solve_id),& - & ' but the coarse matrix has been changed to replicated' - end if - - case default - ! We should never get here. - info=psb_err_from_subroutine_ - ch_err='unkn coarse_solve' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - - end select - end if - - ! Sanity check: need to ensure that the MUMPS local/global NZ - ! are handled correctly; this is controlled by local vs global solver. - ! From this point of view, REPL is LOCAL because it owns everyting. - ! Should really find a better way of handling this. - if (prec%precv(iszv)%parms%coarse_mat == mld_repl_mat_) & - & call prec%precv(iszv)%sm%sv%set('MUMPS_LOC_GLOB', mld_local_solver_,info) - ! - ! Now do the real build. - ! - - do i=1, iszv - ! - ! build the base preconditioner at level i - ! - call prec%precv(i)%bld(info,amold=amold,vmold=vmold,imold=imold,ilv=i) - - if (info /= psb_success_) then - write(ch_err,'(a,i7)') 'Error @ level',i - call psb_errpush(psb_err_internal_error_,name,& - & a_err=ch_err) - goto 9999 - endif - - end do - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Exiting with',iszv,' levels' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_smoothers_bld diff --git a/mlprec/impl/mld_zcprecset.F90 b/mlprec/impl/mld_zcprecset.F90 deleted file mode 100644 index 86895701..00000000 --- a/mlprec/impl/mld_zcprecset.F90 +++ /dev/null @@ -1,1038 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_zprecset.f90 -! -! Subroutine: mld_zprecseti -! Version: complex -! -! This routine sets the integer parameters defining the preconditioner. More -! precisely, the integer parameter identified by 'what' is assigned the value -! contained in 'val'. -! For the multilevel preconditioners, the levels are numbered in increasing -! order starting from the finest one, i.e. level 1 is the finest level. -! -! To set character and complex parameters, see mld_zprecsetc and mld_zprecsetr, -! respectively. -! -! -! Arguments: -! p - type(mld_zprec_type), input/output. -! The preconditioner data structure. -! what - integer, input. -! The number identifying the parameter to be set. -! A mnemonic constant has been associated to each of these -! numbers, as reported in the MLD2P4 User's and Reference Guide. -! val - integer, input. -! The value of the parameter to be set. The list of allowed -! values is reported in the MLD2P4 User's and Reference Guide. -! info - integer, output. -! Error code. -! ilev - integer, optional, input. -! For the multilevel preconditioner, the level at which the -! preconditioner parameter has to be set. -! If nlev is not present, the parameter identified by 'what' -! is set at all the appropriate levels. -! -! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to -! MLD2P4 developers. Indeed, by using ilev it is possible to set different values -! of the same parameter at different levels 1,...,nlev-1, even in cases where -! the parameter must have the same value at all the levels but the coarsest one. -! For this reason, the interface mld_precset to this routine has been built in -! such a way that ilev is not visible to the user (see mld_prec_mod.f90). -! -subroutine mld_zcprecseti(p,what,val,info,ilev,ilmax,pos,idx) - - use psb_base_mod - use mld_z_prec_mod, mld_protect_name => mld_zcprecseti - use mld_z_jac_smoother - use mld_z_as_smoother - use mld_z_diag_solver - use mld_z_l1_diag_solver - use mld_z_ilu_solver - use mld_z_id_solver - use mld_z_gs_solver -#if defined(HAVE_UMF_) - use mld_z_umf_solver -#endif -#if defined(HAVE_SLUDIST_) - use mld_z_sludist_solver -#endif -#if defined(HAVE_SLU_) - use mld_z_slu_solver -#endif -#if defined(HAVE_MUMPS_) - use mld_z_mumps_solver -#endif - - - implicit none - - ! Arguments - class(mld_zprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_, ilmax_, il - character(len=*), parameter :: name='mld_precseti' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmax_ = nlev_ - end if - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - select case(psb_toupper(what)) - case ('MIN_COARSE_SIZE') - p%ag_data%min_coarse_size = max(val,-1) - return - case('MAX_LEVS') - p%ag_data%max_levs = max(val,1) - return - case ('OUTER_SWEEPS') - p%outer_sweeps = max(val,1) - return - end select - - ! - ! Set preconditioner parameters at level ilev. - ! - if (present(ilev)) then - - select case(psb_toupper(what)) - case('SMOOTHER_TYPE','SUB_SOLVE','SMOOTHER_SWEEPS',& - & 'ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD',& - & 'AGGR_TYPE','AGGR_PROL','AGGR_OMEGA_ALG',& - & 'AGGR_EIG','SUB_RESTR','SUB_PROL', & - & 'SUB_OVR','SUB_FILLIN',& - & 'COARSE_MAT') - do il=ilev_, ilmax_ - call p%precv(il)%set(what,val,info,pos=pos) - end do - - case('COARSE_SUBSOLVE') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - call p%precv(ilev_)%set('SUB_SOLVE',val,info,pos=pos) - case('COARSE_SOLVE') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_SOLVE',val,info,pos=pos) - select case (val) - case(mld_bjac_,mld_l1_bjac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',val,info,pos=pos) -#if defined(HAVE_UMF_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_umf_,info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) -#else - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) -#endif - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info) - case(mld_slu_) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) - case(mld_mumps_) -#if defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(mld_umf_) -#if defined(HAVE_UMF_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - - case(mld_sludist_) -#if defined(HAVE_SLUDIST_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#elif defined(HAVE_UMF_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_umf_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(mld_jac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_diag_scale_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - - case(mld_l1_jac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_l1_diag_scale_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_gs_,mld_fbgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_gs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_bwgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_bwgs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_l1_gs_,mld_l1_fbgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_l1_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_gs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - end select - - endif - case('COARSE_SWEEPS') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - call p%precv(nlev_)%set('SMOOTHER_SWEEPS',val,info,pos=pos) - - case('COARSE_FILLIN') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - call p%precv(nlev_)%set('SUB_FILLIN',val,info,pos=pos) - - case default - do il=ilev_, ilmax_ - call p%precv(il)%set(what,val,info,pos=pos,idx=idx) - end do - end select - - - else if (.not.present(ilev)) then - ! - ! ilev not specified: set preconditioner parameters at all the appropriate - ! levels - ! - select case(psb_toupper(trim(what))) - case('SUB_SOLVE','SUB_RESTR','SUB_PROL',& - & 'SUB_OVR','SUB_FILLIN',& - & 'SMOOTHER_SWEEPS','SMOOTHER_TYPE') - do ilev_=1,max(1,nlev_-1) - call p%precv(ilev_)%set(what,val,info,pos=pos) - if (info /= 0) return - end do - - case('ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD','AGGR_PROL','AGGR_TYPE',& - & 'AGGR_OMEGA_ALG','AGGR_EIG','AGGR_FILTER') - do ilev_=1,nlev_ - call p%precv(ilev_)%set(what,val,info,pos=pos) - if (info /= 0) return - end do - - case('COARSE_MAT') - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_MAT',val,info,pos=pos) - end if - - case('COARSE_SOLVE') - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_SOLVE',val,info,pos=pos) - select case (val) - case(mld_bjac_,mld_l1_bjac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',val,info,pos=pos) -#if defined(HAVE_UMF_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_umf_,info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) -#else - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) -#endif - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info) - case(mld_slu_) -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(psb_ilu_n_, psb_ilu_t_,psb_milu_n_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) - case(mld_mumps_) -#if defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(mld_umf_) -#if defined(HAVE_UMF_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - - case(mld_sludist_) -#if defined(HAVE_SLUDIST_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#elif defined(HAVE_UMF_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_umf_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_slu_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_repl_mat_,info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_mumps_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',psb_ilu_n_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) -#endif - case(mld_jac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_diag_scale_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - - case(mld_l1_jac_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_l1_diag_scale_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_gs_,mld_fbgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_gs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_bwgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_bwgs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - case(mld_l1_gs_,mld_l1_fbgs_) - call p%precv(nlev_)%set('SMOOTHER_TYPE',mld_l1_bjac_,info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',mld_gs_,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT',mld_distr_mat_,info,pos=pos) - end select - endif - - case('COARSE_SUBSOLVE') - if (nlev_ > 1) then - call p%precv(nlev_)%set('SUB_SOLVE',val,info,pos=pos) - endif - - case('COARSE_SWEEPS') - - if (nlev_ > 1) then - call p%precv(nlev_)%set('SMOOTHER_SWEEPS',val,info,pos=pos) - end if - - case('COARSE_FILLIN') - if (nlev_ > 1) then - call p%precv(nlev_)%set('SUB_FILLIN',val,info,pos=pos) - end if - - case default - do ilev_=1,nlev_ - call p%precv(ilev_)%set(what,val,info,pos=pos,idx=idx) - end do - end select - - endif - -end subroutine mld_zcprecseti - -! -! Subroutine: mld_zprecsetc -! Version: complex -! -! This routine sets the character parameters defining the preconditioner. More -! precisely, the character parameter identified by 'what' is assigned the value -! contained in 'val'. -! For the multilevel preconditioners, the levels are numbered in increasing -! order starting from the finest one, i.e. level 1 is the finest level. -! -! To set integer and complex parameters, see mld_zprecseti and mld_zprecsetr, -! respectively. -! -! -! Arguments: -! p - type(mld_zprec_type), input/output. -! The preconditioner data structure. -! what - integer, input. -! The number identifying the parameter to be set. -! A mnemonic constant has been associated to each of these -! numbers, as reported in the MLD2P4 User's and Reference Guide. -! string - character(len=*), input. -! The value of the parameter to be set. The list of allowed -! values is reported in the MLD2P4 User's and Reference Guide. -! info - integer, output. -! Error code. -! ilev - integer, optional, input. -! For the multilevel preconditioner, the level at which the -! preconditioner parameter has to be set. -! If nlev is not present, the parameter identified by 'what' -! is set at all the appropriate levels. -! -! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to -! MLD2P4 developers. Indeed, by using ilev it is possible to set different values -! of the same parameter at different levels 1,...,nlev-1, even in cases where -! the parameter must have the same value at all the levels but the coarsest one. -! For this reason, the interface mld_precset to this routine has been built in -! such a way that ilev is not visible to the user (see mld_prec_mod.f90). -! -subroutine mld_zcprecsetc(p,what,string,info,ilev,ilmax,pos,idx) - - use psb_base_mod - use mld_z_prec_mod, mld_protect_name => mld_zcprecsetc - use mld_z_jac_smoother - use mld_z_as_smoother - use mld_z_diag_solver - use mld_z_l1_diag_solver - use mld_z_ilu_solver - use mld_z_id_solver - use mld_z_gs_solver -#if defined(HAVE_UMF_) - use mld_z_umf_solver -#endif -#if defined(HAVE_SLUDIST_) - use mld_z_sludist_solver -#endif -#if defined(HAVE_SLU_) - use mld_z_slu_solver -#endif -#if defined(HAVE_MUMPS_) - use mld_z_mumps_solver -#endif - - - implicit none - - ! Arguments - class(mld_zprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - character(len=*), intent(in) :: string - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_,val,ilmax_, il - character(len=*), parameter :: name='mld_precsetc' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmax_ = nlev_ - end if - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - ! - ! Set preconditioner parameters at level ilev. - ! - if (present(ilev)) then - - select case(psb_toupper(what)) - case('SMOOTHER_TYPE','SUB_SOLVE',& - & 'ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD',& - & 'AGGR_TYPE','AGGR_PROL','AGGR_OMEGA_ALG',& - & 'AGGR_EIG','SUB_RESTR','SUB_PROL', & - & 'COARSE_MAT') - do il=ilev_, ilmax_ - call p%precv(il)%set(what,string,info,pos=pos) - end do - - case('COARSE_SUBSOLVE') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - call p%precv(ilev_)%set('SUB_SOLVE',string,info,pos=pos) - case('COARSE_SOLVE') - if (ilev_ /= nlev_) then - write(psb_err_unit,*) name,& - & ': Error: Inconsistent specification of WHAT vs. ILEV' - info = -2 - return - end if - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_SOLVE',string,info,pos=pos) - select case (psb_toupper(trim(string))) - case('BJAC', 'L1-BJAC') - call p%precv(nlev_)%set('SMOOTHER_TYPE',psb_toupper(trim(string)),info,pos=pos) -#if defined(HAVE_UMF_) - call p%precv(nlev_)%set('SUB_SOLVE','UMF',info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) -#else - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) -#endif - call p%precv(nlev_)%set('COARSE_MAT','dist',info) - case('SLU') -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('ILU','MILU','ILUT') - call p%precv(nlev_)%set('SMOOTHER_TYPE','bjac',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) - case('MUMPS') -#if defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('UMF') -#if defined(HAVE_UMF_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('SLUDIST') -#if defined(HAVE_SLUDIST_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#elif defined(HAVE_UMF_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','UMF',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('JAC','JACOBI') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','DIAG',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - - case('L1-JACOBI') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','L1-DIAG',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('GS','FWGS','FBGS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('BWGS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','BWGS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('L1-GS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','L1-BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - end select - - endif - - case default - do il=ilev_, ilmax_ - call p%precv(il)%set(what,string,info,pos=pos,idx=idx) - end do - end select - - - else if (.not.present(ilev)) then - ! - ! ilev not specified: set preconditioner parameters at all the appropriate - ! levels - ! - select case(psb_toupper(trim(what))) - case('SUB_SOLVE','SUB_RESTR','SUB_PROL',& - & 'SMOOTHER_TYPE') - do ilev_=1,max(1,nlev_-1) - call p%precv(ilev_)%set(what,string,info,pos=pos) - if (info /= 0) return - end do - - case('ML_CYCLE','PAR_AGGR_ALG','AGGR_ORD','AGGR_PROL','AGGR_TYPE',& - & 'AGGR_OMEGA_ALG','AGGR_EIG','AGGR_FILTER') - do ilev_=1,nlev_ - call p%precv(ilev_)%set(what,string,info,pos=pos) - if (info /= 0) return - end do - - case('COARSE_MAT') - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_MAT',string,info,pos=pos) - end if - - case('COARSE_SOLVE') - if (nlev_ > 1) then - call p%precv(nlev_)%set('COARSE_SOLVE',string,info,pos=pos) - select case (psb_toupper(trim(string))) - case('BJAC', 'L1-BJAC') - call p%precv(nlev_)%set('SMOOTHER_TYPE',psb_toupper(trim(string)),info,pos=pos) -#if defined(HAVE_UMF_) - call p%precv(nlev_)%set('SUB_SOLVE','UMF',info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) -#else - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) -#endif - call p%precv(nlev_)%set('COARSE_MAT','DIST',info) - case('SLU') -#if defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('ILU', 'ILUT','MILU') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) - case('MUMPS') -#if defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('UMF') -#if defined(HAVE_UMF_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - - case('SLUDIST') -#if defined(HAVE_SLUDIST_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#elif defined(HAVE_UMF_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','UMF',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_SLU_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','SLU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','REPL',info,pos=pos) -#elif defined(HAVE_MUMPS_) - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','MUMPS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#else - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','ILU',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) -#endif - case('JAC','JACOBI') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','DIAG',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('L1-JACOBI') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','L1-DIAG',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('GS','FWGS','FBGS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('BWGS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','BWGS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - case('L1-GS') - call p%precv(nlev_)%set('SMOOTHER_TYPE','L1-BJAC',info,pos=pos) - call p%precv(nlev_)%set('SUB_SOLVE','GS',info,pos=pos) - call p%precv(nlev_)%set('COARSE_MAT','DIST',info,pos=pos) - end select - endif - - case('COARSE_SUBSOLVE') - if (nlev_ > 1) then - call p%precv(nlev_)%set('SUB_SOLVE',string,info,pos=pos) - endif - - case default - do ilev_=1,nlev_ - call p%precv(ilev_)%set(what,string,info,pos=pos,idx=idx) - end do - end select - - endif - - -end subroutine mld_zcprecsetc - - -! -! Subroutine: mld_zprecsetr -! Version: complex -! -! This routine sets the complex parameters defining the preconditioner. More -! precisely, the complex parameter identified by 'what' is assigned the value -! contained in 'val'. -! For the multilevel preconditioners, the levels are numbered in increasing -! order starting from the finest one, i.e. level 1 is the finest level. -! -! To set integer and character parameters, see mld_zprecseti and mld_zprecsetc, -! respectively. -! -! Arguments: -! p - type(mld_zprec_type), input/output. -! The preconditioner data structure. -! what - integer, input. -! The number identifying the parameter to be set. -! A mnemonic constant has been associated to each of these -! numbers, as reported in the MLD2P4 User's and Reference Guide. -! val - real(psb_dpk_), input. -! The value of the parameter to be set. The list of allowed -! values is reported in the MLD2P4 User's and Reference Guide. -! info - integer, output. -! Error code. -! ilev - integer, optional, input. -! For the multilevel preconditioner, the level at which the -! preconditioner parameter has to be set. -! If nlev is not present, the parameter identified by 'what' -! is set at all the appropriate levels. -! -! NOTE: currently, the use of the argument ilev is not "safe" and is reserved to -! MLD2P4 developers. Indeed, by using ilev it is possible to set different values -! of the same parameter at different levels 1,...,nlev-1, even in cases where -! the parameter must have the same value at all the levels but the coarsest one. -! For this reason, the interface mld_precset to this routine has been built in -! such a way that ilev is not visible to the user (see mld_prec_mod.f90). -! -subroutine mld_zcprecsetr(p,what,val,info,ilev,ilmax,pos,idx) - - use psb_base_mod - use mld_z_prec_mod, mld_protect_name => mld_zcprecsetr - - implicit none - - ! Arguments - class(mld_zprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - - ! Local variables - integer(psb_ipk_) :: ilev_,nlev_, ilmax_, il - real(psb_dpk_) :: thr - character(len=*), parameter :: name='mld_precsetr' - - info = psb_success_ - - if (present(ilev)) then - ilev_ = ilev - else - ilev_ = 1 - end if - - select case(psb_toupper(what)) - case ('MIN_CR_RATIO') - p%ag_data%min_cr_ratio = max(done,val) - return - end select - - if (.not.allocated(p%precv)) then - write(psb_err_unit,*) name,& - &': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - info = 3111 - return - endif - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmax_ = nlev_ - end if - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - - ! - ! Set preconditioner parameters at level ilev. - ! - if (present(ilev)) then - - do il=ilev_, ilmax_ - call p%precv(il)%set(what,val,info,pos=pos,idx=idx) - end do - - else if (.not.present(ilev)) then - ! - ! ilev not specified: set preconditioner parameters at all the appropriate levels - ! - - select case(psb_toupper(what)) - case('COARSE_ILUTHRS') - ilev_=nlev_ - call p%precv(ilev_)%set('SUB_ILUTHRS',val,info,pos=pos) - - case default - - do il=1,nlev_ - call p%precv(il)%set(what,val,info,pos=pos,idx=idx) - end do - end select - - endif - -end subroutine mld_zcprecsetr - - diff --git a/mlprec/impl/mld_zfile_prec_descr.f90 b/mlprec/impl/mld_zfile_prec_descr.f90 deleted file mode 100644 index ab1789f0..00000000 --- a/mlprec/impl/mld_zfile_prec_descr.f90 +++ /dev/null @@ -1,199 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_dfile_prec_descr.f90 -! -! -! Subroutine: mld_file_prec_descr -! Version: complex -! -! This routine prints a description of the preconditioner to the standard -! output or to a file. It must be called after the preconditioner has been -! built by mld_precbld. -! -! Arguments: -! p - type(mld_Tprec_type), input. -! The preconditioner data structure to be printed out. -! info - integer, output. -! error code. -! iout - integer, input, optional. -! The id of the file where the preconditioner description -! will be printed. If iout is not present, then the standard -! output is condidered. -! root - integer, input, optional. -! The id of the process printing the message; -1 acts as a wildcard. -! Default is psb_root_ -! -subroutine mld_zfile_prec_descr(prec,iout,root) - use psb_base_mod - use mld_z_prec_mod, mld_protect_name => mld_zfile_prec_descr - use mld_z_inner_mod - use mld_z_gs_solver - - implicit none - ! Arguments - class(mld_zprec_type), intent(in) :: prec - integer(psb_ipk_), intent(in), optional :: iout - integer(psb_ipk_), intent(in), optional :: root - - ! Local variables - integer(psb_ipk_) :: ilev, nlev, ilmin, info, nswps - integer(psb_ipk_) :: ictxt, me, np - logical :: is_symgs - character(len=20), parameter :: name='mld_file_prec_descr' - integer(psb_ipk_) :: iout_ - integer(psb_ipk_) :: root_ - - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - end if - if (iout_ < 0) iout_ = psb_out_unit - - ictxt = prec%ictxt - - if (allocated(prec%precv)) then - - call psb_info(ictxt,me,np) - if (present(root)) then - root_ = root - else - root_ = psb_root_ - end if - if (root_ == -1) root_ = me - - ! - ! The preconditioner description is printed by processor psb_root_. - ! This agrees with the fact that all the parameters defining the - ! preconditioner have the same values on all the procs (this is - ! ensured by mld_precbld). - ! - if (me == root_) then - nlev = size(prec%precv) - do ilev = 1, nlev - if (.not.allocated(prec%precv(ilev)%sm)) then - info = 3111 - write(iout_,*) ' ',name,& - & ': error: inconsistent MLPREC part, should call MLD_PRECINIT' - return - endif - end do - - write(iout_,*) - write(iout_,'(a)') 'Preconditioner description' - - if (nlev == 1) then - ! - ! Here we have a gigantic kludge just to handle Symmetrized Gauss-Seidel. - ! Will need rethinking... - ! - if (allocated(prec%precv(1)%sm2a)) then - is_symgs = .false. - select type(sv2 => prec%precv(1)%sm2a%sv) - class is (mld_z_bwgs_solver_type) - select type(sv1 => prec%precv(1)%sm%sv) - class is (mld_z_gs_solver_type) - is_symgs = .true. - end select - end select - if (is_symgs) then - write(iout_,*) ' Forward-Backward (symmetrized) Hybrid Gauss-Seidel' - else - write(iout_,*) 'Pre Smoother: ' - call prec%precv(1)%sm%descr(info,iout=iout_) - write(iout_,*) 'Post smoother:' - call prec%precv(1)%sm2a%descr(info,iout=iout_) - end if - nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) - - else - call prec%precv(1)%sm%descr(info,iout=iout_) - nswps = prec%precv(1)%parms%sweeps_pre - end if - if (nswps > 1) write(iout_,*) ' Number of sweeps : ',nswps - write(iout_,*) - - else if (nlev > 1) then - ! - ! Print description of base preconditioner - ! - write(iout_,*) 'Multilevel Preconditioner' - write(iout_,*) 'Outer sweeps:',prec%outer_sweeps - write(iout_,*) - if (allocated(prec%precv(1)%sm2a)) then - write(iout_,*) 'Pre Smoother: ' - call prec%precv(1)%sm%descr(info,iout=iout_) - write(iout_,*) 'Post smoother:' - call prec%precv(1)%sm2a%descr(info,iout=iout_) - else - write(iout_,*) 'Smoother: ' - call prec%precv(1)%sm%descr(info,iout=iout_) - end if - ! - ! Print multilevel details - ! - write(iout_,*) - write(iout_,*) 'Multilevel hierarchy: ' - write(iout_,*) ' Number of levels : ',nlev - write(iout_,*) ' Operator complexity: ',prec%get_complexity() - write(iout_,*) ' Average coarsening : ',prec%get_avg_cr() - ilmin = 2 - if (nlev == 2) ilmin=1 - do ilev=ilmin,nlev - call prec%precv(ilev)%descr(ilev,nlev,ilmin,info,iout=iout_) - end do - write(iout_,*) - - else - write(iout_,*) trim(name), & - & ': invalid preconditioner array size ?',nlev - info = -2 - return - - end if - end if - - else - write(iout_,*) trim(name), & - & ': Error: no base preconditioner available, something is wrong!' - info = -2 - return - endif - -end subroutine mld_zfile_prec_descr diff --git a/mlprec/impl/mld_zmlprec_aply.f90 b/mlprec/impl/mld_zmlprec_aply.f90 deleted file mode 100644 index 848e905d..00000000 --- a/mlprec/impl/mld_zmlprec_aply.f90 +++ /dev/null @@ -1,1669 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_zmlprec_aply.f90 -! -! Subroutine: mld_zmlprec_aply -! Version: real -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -! This routine computes -! -! Y = beta*Y + alpha*op(ML^(-1))*X, -! where -! - ML is a multilevel preconditioner associated with -! a certain matrix A and stored in p, -! - op(ML^(-1)) is ML^(-1) or its transpose, according to the value of trans, -! - X and Y are vectors, -! - alpha and beta are scalars. -! -! The following multilevel strategies can be applied: -! -! - Additive multilevel Schwarz, -! - classical V-cycle, -! - classical W-cycle, -! - K-cycle both for symmetric and nonsymmetric matrices, where 2 iterations -! of FCG(1) or GCR, respectively, are applied at each level -! except the coarsest. -! -! For each level we have as many submatrices as processes (except for the coarsest -! level where we might have a replicated index space) and each process takes care -! of one submatrix. -! -! A multilevel preconditioner is regarded as an array of 'one-level' data structures, -! each containing the part of the preconditioner associated to a certain level -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! For each level lev, there is a smoother stored in -! p%precv(lev)%sm -! which in turn contains a solver -! p$precv(lev)%sm%sv -! Typically the solver acts only locally, and the smoother applies any required -! parallel communication/action. -! Each level has a matrix A(lev), obtained by 'tranferring' the original -! matrix A (i.e. the matrix to be preconditioned) to the level lev, through smoothed -! aggregation. -! -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level and A(1) is the matrix A. -! -! This routine is formulated in a recursive way, so it is quite compact. -! -! The V-cycle can be described as follows, where -! P(lev) denotes the smoothed prolongator from level lev to level -! lev-1, while R(lev) denotes the corresponding restriction operator -! (normally its transpose) from level lev-1 to level lev. -! M(lev) is the smoother at the current level. -! -! -! 1. Transfer the outer vector Xest to u(1) (inner X at level 1) -! -! 2. Invoke V-cycle(1,M,P,R,A,b,u) -! -! procedure V-cycle(lev,M,P,R,A,b,u) -! -! if (lev < nlev) then -! -! u(lev) = u(lev) + M(lev)*(b(lev)-A(lev)*u(lev)) -! -! b(lev+1) = R(lev+1)*(b(lev)-A(lev)*u(lev)) -! -! u(lev+1) = V-cycle(lev+1,M,P,R,A,b,u) -! -! u(lev) = u(lev) + P(lev+1) * u(lev+1) -! -! u(lev) = u(lev) + M(lev)*(b(lev)-A(lev)*u(lev)) -! -! else -! -! solve A(lev)*u(lev) = b(lev) -! -! end if -! -! return u(lev) -! end -! -! 3. Transfer u(1) to the external: -! Yext = beta*Yext + alpha*u(1) -! -! -! In the implementation, the recursive procedure is inner_ml_aply, which -! in turn uses mld_inner_add (for additive multilevel), -! mld_inner_mult (for V-cycle and W-cycle), and -! mld_inner_k_cycle (for symmetric and non-symmetric K-cycle). -! -! For a detailed description of the algorithms, see: -! -! - B.F. Smith, P.E. Bjorstad, W.D. Gropp, -! Domain decomposition: parallel multilevel methods for elliptic partial -! differential equations, Cambridge University Press, 1996. -! -! - W. L. Briggs, V. E. Henson, S. F. McCormick, -! A Multigrid Tutorial, Second Edition -! SIAM, 2000. -! -! - K. Stuben, -! An Introduction to Algebraic Multigrid, -! in A. Schuller, U. Trottenberg, C. Oosterlee, Multigrid, Academic Press, 2001. -! -! - Y. Notay, P. S. Vassilevski, -! Recursive Krylov-based multigrid cycles -! Numerical Linear Algebra with Applications, 15 (5), 2008, 473--487. -! -! -! Arguments: -! alpha - complex(psb_dpk_), input. -! The scalar alpha. -! p - type(mld_zprec_type), input. -! The multilevel preconditioner data structure containing the -! local part of the preconditioner to be applied. -! Note that nlev = size(p%precv) = number of levels. -! p%precv(lev)%sm - type(psb_zbaseprec_type) -! The pre-'smoother' for the current level -! p%precv(lev)%sm2 - type(psb_zbaseprec_type) -! The post-'smoother' for the current level -! may be the same or different from %sm -! p%precv(lev)%ac - type(psb_zspmat_type) -! The local part of the matrix A(lev). -! p%precv(lev)%parms - type(psb_dml_parms) -! Parameters controllin the multilevel prec. -! p%precv(lev)%desc_ac - type(psb_desc_type). -! The communication descriptor associated to the sparse -! matrix A(lev) -! p%precv(lev)%map - type(psb_inter_desc_type) -! Stores the linear operators mapping level (lev-1) -! to (lev) and vice versa. These are the restriction -! and prolongation operators described in the sequel. -! p%precv(lev)%base_a - type(psb_zspmat_type), pointer. -! Pointer (really a pointer!) to the base matrix of -! the current level, i.e. the local part of A(lev); -! so we have a unified treatment of residuals. We -! need this to avoid passing explicitly the matrix -! A(lev) to the routine which applies the -! preconditioner. -! p%precv(lev)%base_desc - type(psb_desc_type), pointer. -! Pointer to the communication descriptor associated -! to the sparse matrix pointed by base_a. -! -! x - complex(psb_dpk_), dimension(:), input. -! The local part of the vector X. -! beta - complex(psb_dpk_), input. -! The scalar beta. -! y - complex(psb_dpk_), dimension(:), input/output. -! The local part of the vector Y. -! desc_data - type(psb_desc_type), input. -! The communication descriptor associated to the matrix to be -! preconditioned. -! trans - character, optional. -! If trans='N','n' then op(M^(-1)) = M^(-1); -! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). -! work - complex(psb_dpk_), dimension (:), optional, target. -! Workspace. Its size must be at least 4*desc_data%get_local_cols(). -! info - integer, output. -! Error code. -! -! Note that when the LU factorization of the matrix A(lev) is computed instead of -! the ILU one, by using UMFPACK or SuperLU or MUMPS, the corresponding -! L and U factors are stored in data structures handled -! by the third party software. -! -subroutine mld_zmlprec_aply_vect(alpha,p,x,beta,y,desc_data,trans,work,info) - - use psb_base_mod - use mld_base_prec_type - use mld_z_inner_mod, mld_protect_name => mld_zmlprec_aply_vect - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_zprec_type), intent(inout) :: p - complex(psb_dpk_),intent(in) :: alpha,beta - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - character, intent(in) :: trans - complex(psb_dpk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: ictxt, np, me - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, nc2l, level, isweep, err_act - character(len=20) :: name - character :: trans_ - complex(psb_dpk_) :: beta_ - logical :: do_alloc_wrk - type(mld_zmlprec_wrk_type), allocatable, target :: mlprec_wrk(:) - - name='mld_zmlprec_aply' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (debug_level >= psb_debug_inner_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(p%precv) - - trans_ = psb_toupper(trans) - nlev = size(p%precv) - - do_alloc_wrk = .not.allocated(p%precv(1)%wrk) - - if (do_alloc_wrk) call p%allocate_wrk(info,vmold=x%v) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') - goto 9999 - end if - level = 1 - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & wv => p%precv(level)%wrk%wv(:)) - ! - ! At first iteration we must use the input BETA - ! - beta_ = beta - - - call psb_geaxpby(zone,x,zzero,vx2l,base_desc,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='geaxbpy') - goto 9999 - end if - - do isweep = 1, p%outer_sweeps - 1 - ! - ! With the current implementation, y2l is zeroed internally at first smoother. - ! call p%wrk(level)%vy2l%zero() - ! - call inner_ml_aply(level,p,trans_,work,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Inner prec aply') - goto 9999 - end if - call psb_geaxpby(alpha,vy2l,beta_,y,base_desc,info) - ! all iterations after the first must use BETA = 1 - beta_ = zone - ! - ! Next iteration should use the current residual to compute a correction - ! - call psb_geaxpby(zone,x,zzero,vx2l,base_desc,info) - call psb_spmm(-zone,base_a,y,zone,vx2l,base_desc,info) - end do - - ! - ! If outer_sweeps == 1 we have just skipped the loop, and it's - ! equivalent to a single application. - ! - - ! - ! With the current implementation, y2l is zeroed internally at first smoother. - ! call p%wrk(level)%vy2l%zero() - ! - call inner_ml_aply(level,p,trans_,work,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Inner prec aply') - goto 9999 - end if - call psb_geaxpby(alpha,vy2l,beta_,y,base_desc,info) - - end associate - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error final update') - goto 9999 - end if - if (do_alloc_wrk) call p%free_wrk(info) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - ! - ! - ! inner_ml_aply: apply AMG at a given level. - ! This routine dispatches the computation according to the type - ! specified at the current level. - ! Each of the corrections will inturn call recursively this routine. - ! - ! Assumptions: - ! On input: - ! mlprec_wkr(level)%vx2l contains the input vector (RHS) - ! mlprec_wkr(level)%vy2l contains the initial guess - ! - ! On output: - ! mlprec_wkr(level)%vy2l contains the solution - ! - ! Constraints: each of the called routines must properly handle - ! the input/output conditions for level+1 (i.e. apply - ! prolongation/restriction). - ! Note: for historical/convenience reasons the prolongator/restrictor - ! between level and level+1 are stored at level+1. - ! - ! - recursive subroutine inner_ml_aply(level,p,trans,work,info) - - implicit none - - ! Arguments - integer(psb_ipk_) :: level - type(mld_zprec_type), target, intent(inout) :: p - character, intent(in) :: trans - complex(psb_dpk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - - type(psb_z_vect_type) :: res - type(psb_z_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_ml_aply' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_ml') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' Start inner_ml_aply at level ',level, info - end if - - select case(p%precv(level)%parms%ml_cycle) - - case(mld_no_ml_) - ! - ! No preconditioning, should not really get here - ! - call psb_errpush(psb_err_internal_error_,name,& - & a_err='mld_no_ml_ in mlprc_aply?') - goto 9999 - - case(mld_add_ml_) - - call mld_z_inner_add(p, level, trans, work) - - case(mld_mult_ml_,mld_vcycle_ml_, mld_wcycle_ml_) - - call mld_z_inner_mult(p, level, trans, work) - - case(mld_kcycle_ml_, mld_kcyclesym_ml_) - - call mld_z_inner_k_cycle(p, level, trans, work) - - case default - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='invalid ml_cycle',& - & i_Err=(/p%precv(level)%parms%ml_cycle,izero,izero,izero,izero/)) - goto 9999 - - end select - if(debug_level > 1) then - write(debug_unit,*) me,' End inner_ml_aply at level ',level - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine inner_ml_aply - - - recursive subroutine mld_z_inner_add(p, level, trans, work) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_zprec_type), intent(inout) :: p - - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - complex(psb_dpk_),target :: work(:) - type(psb_z_vect_type) :: res - type(psb_z_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act, k - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_inner_add' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_add') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_add at level ',level - end if - - if ((level<1).or.(level>nlev)) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL>NLEV') - goto 9999 - end if - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & wv => p%precv(level)%wrk%wv) - - if (allocated(p%precv(level)%sm2a)) then - call psb_geaxpby(zone,vx2l,zzero,vy2l,base_desc,info) - - sweeps = max(p%precv(level)%parms%sweeps_pre,p%precv(level)%parms%sweeps_post) - do k=1, sweeps - call p%precv(level)%sm%apply(zone,& - & vy2l,zzero,vty,& - & base_desc, trans,& - & ione,work,wv,info,init='Z') - - call p%precv(level)%sm2a%apply(zone,& - & vty,zzero,vy2l,& - & base_desc, trans,& - & ione,work,wv,info,init='Z') - end do - - else - sweeps = p%precv(level)%parms%sweeps_pre - call p%precv(level)%sm%apply(zone,& - & vx2l,zzero,vy2l,& - & base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during ADD smoother_apply') - goto 9999 - end if - - if (level < nlev) then - ! Apply the restriction - call p%precv(level+1)%map%map_U2V(zone,vx2l,& - & zzero,p%precv(level+1)%wrk%vx2l,& - & info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - - call inner_ml_aply(level+1,p,trans,work,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in recursive call') - goto 9999 - end if - - ! - ! Apply the prolongator - ! - call p%precv(level+1)%map%map_V2U(zone,& - & p%precv(level+1)%wrk%vy2l, zone,vy2l,& - & info,work=work,& - & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - - end if - end associate - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_z_inner_add - - recursive subroutine mld_z_inner_mult(p, level, trans, work) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_zprec_type), intent(inout) :: p - - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - complex(psb_dpk_),target :: work(:) - type(psb_z_vect_type) :: res - type(psb_z_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - name = 'inner_inner_mult' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_mult') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_mult at level ',level - end if - - sweeps_post = p%precv(level)%parms%sweeps_post - sweeps_pre = p%precv(level)%parms%sweeps_pre - pre = ((sweeps_pre>0).and.(trans=='N')).or.((sweeps_post>0).and.(trans/='N')) - post = ((sweeps_post>0).and.(trans=='N')).or.((sweeps_pre>0).and.(trans/='N')) - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & wv => p%precv(level)%wrk%wv) - if (level < nlev) then - ! - ! Apply the first smoother - ! The residual has been prepared before the recursive call. - ! - - if (pre) then - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(zone,& - & vx2l,zzero,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(zone,& - & vx2l,zzero,vy2l, base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during PRE smoother_apply') - goto 9999 - end if - endif - ! - ! Compute the residual for next level and call recursively - ! - if (pre) then - call psb_geaxpby(zone,vx2l,& - & zzero,vty,& - & base_desc,info) - - if (info == psb_success_) call psb_spmm(-zone,base_a,& - & vy2l,zone,vty,& - & base_desc,info,work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - call p%precv(level+1)%map%map_U2V(zone,vty,& - & zzero,p%precv(level+1)%wrk%vx2l,& - & info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - else - ! Shortcut: just transfer x2l. - call p%precv(level+1)%map%map_U2V(zone,vx2l,& - & zzero,p%precv(level+1)%wrk%vx2l,& - & info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - endif - - call inner_ml_aply(level+1,p,trans,work,info) - - ! - ! Apply the prolongator - ! - call p%precv(level+1)%map%map_V2U(zone,& - & p%precv(level+1)%wrk%vy2l,zone,vy2l,& - & info,work=work,& - & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - if (p%precv(level)%parms%ml_cycle == mld_wcycle_ml_) then - - call psb_geaxpby(zone,vx2l, zzero,vty,& - & base_desc,info) - if (info == psb_success_) call psb_spmm(-zone,base_a,& - & vy2l,zone,vty,& - & base_desc,info,work=work,trans=trans) - if (info == psb_success_) & - & call p%precv(level+1)%map%map_U2V(zone,vty,& - & zzero,p%precv(level+1)%wrk%vx2l,info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during W-cycle restriction') - goto 9999 - end if - - call inner_ml_aply(level+1,p,trans,work,info) - - if (info == psb_success_) call p%precv(level+1)%map%map_V2U(zone, & - & p%precv(level+1)%wrk%vy2l,zone,vy2l,& - & info,work=work,& - & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during W recusion/prolongation') - goto 9999 - end if - - endif - - - if (post) then - call psb_geaxpby(zone,vx2l,& - & zzero,vty,& - & base_desc,info) - if (info == psb_success_) call psb_spmm(-zone,base_a,& - & vy2l, zone,vty,base_desc,info,& - & work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - - ! - ! Apply the second smoother - ! - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(zone,& - & vty,zone,vy2l, base_desc, trans,& - & sweeps,work,wv,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(zone,& - & vty,zone,vy2l, base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during POST smoother_apply') - goto 9999 - end if - - endif - - else if (level == nlev) then - - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(zone,& - & vx2l,zzero,vy2l,base_desc, trans,& - & sweeps,work,wv,info) - - else - - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL vs NLEV') - goto 9999 - end if - end associate - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_z_inner_mult - - recursive subroutine mld_z_inner_k_cycle(p, level, trans, work,u) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_zprec_type), intent(inout) :: p - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - complex(psb_dpk_),target :: work(:) - type(psb_z_vect_type),intent(inout), optional :: u - - - - type(psb_z_vect_type) :: res - type(psb_z_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_kcycle' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_add') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,name,' start at level ',level - end if - - if ((level<1).or.(level>nlev)) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL>NLEV') - goto 9999 - end if - - !K cycle - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & wv => p%precv(level)%wrk%wv(8:)) - if (level == nlev) then - ! - ! Apply smoother - ! - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(zone,& - & vx2l,zzero,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - - else if (level < nlev) then - - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(zone,& - & vx2l,zzero,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(zone,& - & vx2l,zzero,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during 2-PRE smoother_apply') - goto 9999 - end if - - - ! - ! Compute the residual and call recursively - ! - - call psb_geaxpby(zone,vx2l,& - & zzero,vty,& - & base_desc,info) - - if (info == psb_success_) call psb_spmm(-zone,base_a,& - & vy2l,zone,vty,base_desc,info,work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - - ! Apply the restriction - call p%precv(level + 1)%map%map_U2V(zone,vty,& - & zzero,p%precv(level + 1)%wrk%vx2l,& - &info,work=work,& - & vtx=wv(1),vty=p%precv(level+1)%wrk%wv(1)) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - - !Set the preconditioner - - if (level <= nlev - 2 ) then - if (p%precv(level)%parms%ml_cycle == mld_kcyclesym_ml_) then - call mld_zinneritkcycle(p, level + 1, trans, work, 'FCG') - elseif (p%precv(level)%parms%ml_cycle == mld_kcycle_ml_) then - call mld_zinneritkcycle(p, level + 1, trans, work, 'GCR') - else - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Bad value for ml_cycle') - goto 9999 - endif - else - call inner_ml_aply(level + 1 ,p,trans,work,info) - endif - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in recursive call') - goto 9999 - end if - - ! - ! Apply the prolongator - ! - call p%precv(level+1)%map%map_V2U(zone,& - & p%precv(level+1)%wrk%vy2l,zone,vy2l,& - & info,work=work,& - & vtx=p%precv(level+1)%wrk%wv(1),vty=wv(1)) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - ! - ! Compute the residual - ! - call psb_geaxpby(zone,vx2l,& - & zzero,vty,base_desc,info) - call psb_spmm(-zone,base_a,vy2l,& - & zone,vty,base_desc,info,& - & work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - ! - ! Apply the smoother - ! - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(zone,& - & vty,zone,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(zone,& - & vty,zone,vy2l,base_desc, trans,& - & sweeps,work,wv,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during POST smoother_apply') - goto 9999 - end if - else - - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL vs NLEV') - goto 9999 - - endif - end associate - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_z_inner_k_cycle - - - recursive subroutine mld_zinneritkcycle(p, level, trans, work, innersolv) - use psb_base_mod - use mld_prec_mod - use mld_z_inner_mod, mld_protect_name => mld_zmlprec_aply - - implicit none - - !Input/Oputput variables - type(mld_zprec_type), intent(inout) :: p - - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - character(len=*), intent(in) :: innersolv - complex(psb_dpk_),target :: work(:) - - !Other variables - type(psb_z_vect_type) :: v, w, rhs, v1, x - type(psb_z_vect_type) :: d0, d1 - complex(psb_dpk_) :: delta_old, rhs_norm, alpha, tau, tau1, tau2, tau3, tau4, beta - - real(psb_dpk_) :: l2_norm, delta, rtol=0.25, delta0, tnrm - complex(psb_dpk_), allocatable :: temp_v(:) - integer(psb_ipk_) :: info, nlev, i, iter, max_iter=2, idx - character(len=20) :: name = 'innerit_k_cycle' - - - if (size(p%precv(level)%wrk%wv)<7) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size') - goto 9999 - end if - - associate(vx2l => p%precv(level)%wrk%vx2l,vy2l => p%precv(level)%wrk%vy2l,& - & vtx => p%precv(level)%wrk%vtx,vty => p%precv(level)%wrk%vty,& - & base_a => p%precv(level)%base_a, base_desc=>p%precv(level)%base_desc,& - & v => p%precv(level)%wrk%wv(1), & - & w => p%precv(level)%wrk%wv(2),& - & rhs => p%precv(level)%wrk%wv(3), & - & v1 => p%precv(level)%wrk%wv(4), & - & x => p%precv(level)%wrk%wv(5), & - & d0 => p%precv(level)%wrk%wv(6), & - & d1 => p%precv(level)%wrk%wv(7)) - - call x%zero() - - ! rhs=vx2l and w=rhs - call psb_geaxpby(zone,vx2l,zzero,rhs, base_desc,info) - call psb_geaxpby(zone,vx2l,zzero,w, base_desc,info) - - if (psb_errstatus_fatal()) then - nc2l = base_desc%get_local_cols() - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - - delta0 = psb_genrm2(w, base_desc, info) - - !Apply the preconditioner - call vy2l%zero() - - idx=0 - call inner_ml_aply(level,p,trans,work,info) - - call psb_geaxpby(zone,vy2l,zzero,d0,base_desc,info) - - call psb_spmm(zone,base_a,d0,zzero,v,base_desc,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - - !FCG - if (psb_toupper(trim(innersolv)) == 'FCG') then - delta_old = psb_gedot(d0, w, base_desc, info) - tau = psb_gedot(d0, v, base_desc, info) - !GCR - else if (psb_toupper(trim(innersolv)) == 'GCR') then - delta_old = psb_gedot(v, w, base_desc, info) - tau = psb_gedot(v, v, base_desc, info) - else - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid inner solver') - goto 9999 - endif - - alpha = delta_old/tau - !Update residual w - call psb_geaxpby(-alpha, v, zone, w, base_desc, info) - - l2_norm = psb_genrm2(w, base_desc, info) - iter = 0 - - if (l2_norm <= rtol*delta0) then - !Update solution x - call psb_geaxpby(alpha, d0, zone, x, base_desc, info) - else - iter = iter + 1 - idx=mod(iter,2) - - !Apply preconditioner - call psb_geaxpby(zone,w,zzero,vx2l,base_desc,info) - call inner_ml_aply(level,p,trans,work,info) - call psb_geaxpby(zone,vy2l,zzero,d1,base_desc,info) - - !Sparse matrix vector product - - call psb_spmm(zone,base_a,d1,zzero,v1,base_desc,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - - !tau1, tau2, tau3, tau4 - if (psb_toupper(trim(innersolv)) == 'FCG') then - tau1= psb_gedot(d1, v, base_desc, info) - tau2= psb_gedot(d1, v1, base_desc, info) - tau3= psb_gedot(d1, w, base_desc, info) - tau4= tau2 - (tau1*tau1)/tau - else if (psb_toupper(trim(innersolv)) == 'GCR') then - tau1= psb_gedot(v1, v, base_desc, info) - tau2= psb_gedot(v1, v1, base_desc, info) - tau3= psb_gedot(v1, w, base_desc, info) - tau4= tau2 - (tau1*tau1)/tau - else - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid inner solver') - goto 9999 - endif - - !Update solution - alpha=alpha-(tau1*tau3)/(tau*tau4) - call psb_geaxpby(alpha,d0,zone,x,base_desc,info) - alpha=tau3/tau4 - call psb_geaxpby(alpha,d1,zone,x,base_desc,info) - endif - - call psb_geaxpby(zone,x,zzero,vy2l,base_desc,info) - end associate - -9999 continue - call psb_erractionrestore(err_act) - if (err_act.eq.psb_act_abort_) then - call psb_error() - return - end if - return - end subroutine mld_zinneritkcycle - -end subroutine mld_zmlprec_aply_vect - - -! -! Old routine for arrays instead of psb_X_vector. To be deleted eventually. -! -! -subroutine mld_zmlprec_aply(alpha,p,x,beta,y,desc_data,trans,work,info) - - use psb_base_mod - use mld_base_prec_type - use mld_z_inner_mod, mld_protect_name => mld_zmlprec_aply - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_zprec_type), intent(inout) :: p - complex(psb_dpk_),intent(in) :: alpha,beta - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - character, intent(in) :: trans - complex(psb_dpk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: ictxt, np, me - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: debug_level, debug_unit, nlev,nc2l,nr2l,level - character(len=20) :: name - character :: trans_ - type mld_mlwrk_type - complex(psb_dpk_), allocatable :: tx(:), ty(:), x2l(:), y2l(:) - end type mld_mlwrk_type - type(mld_mlwrk_type), allocatable, target :: mlwrk(:) - - name='mld_zmlprec_aply' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (debug_level >= psb_debug_inner_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' Entry ', size(p%precv) - - trans_ = psb_toupper(trans) - - nlev = size(p%precv) - allocate(mlwrk(nlev),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') - goto 9999 - end if - level = 1 - - do level = 1, nlev - call psb_geasb(mlwrk(level)%x2l,& - & p%precv(level)%base_desc,info) - call psb_geasb(mlwrk(level)%y2l,& - & p%precv(level)%base_desc,info) - call psb_geasb(mlwrk(level)%tx,& - & p%precv(level)%base_desc,info) - call psb_geasb(mlwrk(level)%ty,& - & p%precv(level)%base_desc,info) - if (psb_errstatus_fatal()) then - nc2l = p%precv(level)%base_desc%get_local_cols() - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nc2l,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - end do - - mlwrk(level)%x2l(:) = x(:) - mlwrk(level)%y2l(:) = zzero - - call inner_ml_aply(level,p,mlwrk,trans_,work,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Inner prec aply') - goto 9999 - end if - - call psb_geaxpby(alpha,mlwrk(level)%y2l,beta,y,& - & p%precv(level)%base_desc,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error final update') - goto 9999 - end if - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - - ! - ! - ! inner_ml_aply: apply AMG at a given level. - ! This routine dispatches the computation according to the type - ! specified at the current level. - ! Each of the corrections will inturn call recursively this routine. - ! - ! Assumptions: - ! On input: - ! mlprec_wkr(level)%vx2l contains the input vector (RHS) - ! mlprec_wkr(level)%vy2l contains the initial guess - ! - ! On output: - ! mlprec_wkr(level)%vy2l contains the solution - ! - ! Constraints: each of the called routines must properly handle - ! the input/output conditions for level+1 (i.e. apply - ! prolongation/restriction). - ! Note: for historical/convenience reasons the prolongator/restrictor - ! between level and level+1 are stored at level+1. - ! - ! - recursive subroutine inner_ml_aply(level,p,mlwrk,trans,work,info) - - implicit none - - ! Arguments - integer(psb_ipk_) :: level - type(mld_zprec_type), target, intent(inout) :: p - type(mld_mlwrk_type), intent(inout), target :: mlwrk(:) - character, intent(in) :: trans - complex(psb_dpk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - - type(psb_z_vect_type) :: res - type(psb_z_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_ml_aply' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_ml') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_ml_aply at level ',level - end if - - select case(p%precv(level)%parms%ml_cycle) - - case(mld_no_ml_) - ! - ! No preconditioning, should not really get here - ! - call psb_errpush(psb_err_internal_error_,name,& - & a_err='mld_no_ml_ in mlprc_aply?') - goto 9999 - - case(mld_add_ml_) - - call mld_z_inner_add(p, mlwrk, level, trans, work) - - case(mld_mult_ml_, mld_vcycle_ml_, mld_wcycle_ml_) - - call mld_z_inner_mult(p, mlwrk, level, trans, work) - -! !$ case(mld_kcycle_ml_, mld_kcyclesym_ml_) -! !$ -! !$ call mld_z_inner_k_cycle(p, mlwrk, level, trans, work) - - case default - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='invalid ml_cycle',& - & i_Err=(/p%precv(level)%parms%ml_cycle,izero,izero,izero,izero/)) - goto 9999 - - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine inner_ml_aply - - - recursive subroutine mld_z_inner_add(p, mlwrk, level, trans, work) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_zprec_type), intent(inout) :: p - - type(mld_mlwrk_type), target, intent(inout) :: mlwrk(:) - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - complex(psb_dpk_),target :: work(:) - type(psb_z_vect_type) :: res - type(psb_z_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_inner_add' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_add') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_add at level ',level - end if - - if ((level<1).or.(level>nlev)) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL>NLEV') - goto 9999 - end if - - sweeps = p%precv(level)%parms%sweeps_pre - call p%precv(level)%sm%apply(zone,& - & mlwrk(level)%x2l,zzero,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during ADD smoother_apply') - goto 9999 - end if - - if (level < nlev) then - ! Apply the restriction - call p%precv(level+1)%map%map_U2V(zone,mlwrk(level)%x2l,& - & zzero,mlwrk(level+1)%x2l,& - & info,work=work) - mlwrk(level+1)%y2l(:) = zzero - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - - call inner_ml_aply(level+1,p,mlwrk,trans,work,info) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in recursive call') - goto 9999 - end if - - ! - ! Apply the prolongator and add correction. - ! - call p%precv(level+1)%map%map_V2U(zone,& - & mlwrk(level+1)%y2l,zone,mlwrk(level)%y2l,& - & info,work=work) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_z_inner_add - - recursive subroutine mld_z_inner_mult(p, mlwrk, level, trans, work) - use psb_base_mod - use mld_prec_mod - - implicit none - - !Input/Oputput variables - type(mld_zprec_type), intent(inout) :: p - - type(mld_mlwrk_type), target, intent(inout) :: mlwrk(:) - integer(psb_ipk_), intent(in) :: level - character, intent(in) :: trans - complex(psb_dpk_),target :: work(:) - type(psb_z_vect_type) :: res - type(psb_z_vect_type), pointer :: current - integer(psb_ipk_) :: sweeps_post, sweeps_pre - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: i, err_act - integer(psb_ipk_) :: debug_level, debug_unit - integer(psb_ipk_) :: nlev, ilev, sweeps - logical :: pre, post - character(len=20) :: name - - - - name = 'inner_inner_mult' - info = psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - nlev = size(p%precv) - if ((level < 1) .or. (level > nlev)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong call level to inner_mult') - goto 9999 - end if - ictxt = p%precv(level)%base_desc%get_context() - call psb_info(ictxt, me, np) - - if(debug_level > 1) then - write(debug_unit,*) me,' inner_mult at level ',level - end if - - if ((level < nlev).or.(nlev == 1)) then - sweeps_post = p%precv(level)%parms%sweeps_post - sweeps_pre = p%precv(level)%parms%sweeps_pre - else - sweeps_post = p%precv(level-1)%parms%sweeps_post - sweeps_pre = p%precv(level-1)%parms%sweeps_pre - endif - - pre = ((sweeps_pre>0).and.(trans=='N')).or.((sweeps_post>0).and.(trans/='N')) - post = ((sweeps_post>0).and.(trans=='N')).or.((sweeps_pre>0).and.(trans/='N')) - - - if (level < nlev) then - - ! - ! Apply the first smoother - ! - - if (pre) then - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(zone,& - & mlwrk(level)%x2l,zzero,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info,init='Y') - else - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(zone,& - & mlwrk(level)%x2l,zzero,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info,init='Y') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during PRE smoother_apply') - goto 9999 - end if - endif - - ! - ! Compute the residual and call recursively - ! - if (pre) then - call psb_geaxpby(zone,mlwrk(level)%x2l,& - & zzero,mlwrk(level)%ty,& - & p%precv(level)%base_desc,info) - - if (info == psb_success_) call psb_spmm(-zone,p%precv(level)%base_a,& - & mlwrk(level)%y2l,zone,mlwrk(level)%ty,& - & p%precv(level)%base_desc,info,work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - call p%precv(level+1)%map%map_U2V(zone,mlwrk(level)%ty,& - & zzero,mlwrk(level+1)%x2l,info,work=work) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - else - ! Shortcut: just transfer x2l. - call p%precv(level+1)%map%map_U2V(zone,mlwrk(level)%x2l,& - & zzero,mlwrk(level+1)%x2l,info,work=work) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during restriction') - goto 9999 - end if - endif - ! First guess is zero - mlwrk(level+1)%y2l(:) = zzero - - - call inner_ml_aply(level+1,p,mlwrk,trans,work,info) - - if (p%precv(level)%parms%ml_cycle == mld_wcycle_ml_) then - ! On second call will use output y2l as initial guess - if (info == psb_success_) call inner_ml_aply(level+1,p,mlwrk,trans,work,info) - endif - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in recursive call') - goto 9999 - end if - - - ! - ! Apply the prolongator - ! - call p%precv(level+1)%map%map_V2U(zone,mlwrk(level+1)%y2l,& - & zone,mlwrk(level)%y2l,info,work=work) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during prolongation') - goto 9999 - end if - - ! - ! Compute the residual - ! - if (post) then - call psb_geaxpby(zone,mlwrk(level)%x2l,& - & zzero,mlwrk(level)%tx,& - & p%precv(level)%base_desc,info) - call psb_spmm(-zone,p%precv(level)%base_a,mlwrk(level)%y2l,& - & zone,mlwrk(level)%tx,p%precv(level)%base_desc,info,& - & work=work,trans=trans) - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during residue') - goto 9999 - end if - ! - ! Apply the second smoother - ! - if (trans == 'N') then - sweeps = p%precv(level)%parms%sweeps_post - if (info == psb_success_) call p%precv(level)%sm2%apply(zone,& - & mlwrk(level)%tx,zone,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info,init='Z') - else - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(zone,& - & mlwrk(level)%tx,zone,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info,init='Z') - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error during POST smoother_apply') - goto 9999 - end if - - endif - - else if (level == nlev) then - - sweeps = p%precv(level)%parms%sweeps_pre - if (info == psb_success_) call p%precv(level)%sm%apply(zone,& - & mlwrk(level)%x2l,zzero,mlwrk(level)%y2l,& - & p%precv(level)%base_desc, trans,& - & sweeps,work,info) - - else - - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid LEVEL vs NLEV') - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_z_inner_mult - - -end subroutine mld_zmlprec_aply diff --git a/mlprec/impl/mld_zmlprec_bld.f90 b/mlprec/impl/mld_zmlprec_bld.f90 deleted file mode 100644 index bed66b28..00000000 --- a/mlprec/impl/mld_zmlprec_bld.f90 +++ /dev/null @@ -1,152 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_zmlprec_bld.f90 -! -! Subroutine: mld_zmlprec_bld -! Version: complex -! -! This routine builds the preconditioner according to the requirements made by -! the user trough the subroutines mld_precinit and mld_precset. -! -! A multilevel preconditioner is regarded as an array of 'one-level' data structures, -! each containing the part of the preconditioner associated to a certain level, -! (for more details see the description of mld_Tonelev_type in mld_prec_type.f90). -! The levels are numbered in increasing order starting from the finest one, i.e. -! level 1 is the finest level. No transfer operators are associated to level 1. -! -! This routine simply calls mld_z_hierarchy_bld and mld_z_smoothers_bld; they -! can also be called explicitly from the user. -! -! -! Arguments: -! a - type(psb_zspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_zprec_type), input/output. -! The preconditioner data structure containing the local part -! of the preconditioner to be built. -! info - integer, output. -! Error code. -! -! amold - class(psb_z_base_sparse_mat), input, optional -! Mold for the inner format of matrices contained in the -! preconditioner -! -! -! vmold - class(psb_z_base_vect_type), input, optional -! Mold for the inner format of vectors contained in the -! preconditioner -! -! -! -subroutine mld_zmlprec_bld(a,desc_a,p,info,amold,vmold,imold) - - use psb_base_mod - use mld_z_inner_mod, mld_protect_name => mld_zmlprec_bld - use mld_z_prec_mod - - Implicit None - - ! Arguments - type(psb_zspmat_type),intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - type(mld_zprec_type),intent(inout),target :: p - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local Variables - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k, err_act, iszv, newsz, casize, nplevs, mxplevs - real(psb_dpk_) :: mnaggratio - integer(psb_ipk_) :: ipv(mld_ifpsz_), val - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_zmlprec_bld' - info = psb_success_ - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' - - call p%hierarchy_build(a,desc_a,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Error from hierarchy build') - goto 9999 - end if - - iszv = p%get_nlevs() - - call p%smoothers_build(a,desc_a,info,amold,vmold,imold) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Error from smoothers build') - goto 9999 - end if - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Exiting with',iszv,' levels' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_zmlprec_bld diff --git a/mlprec/impl/mld_zprecaply.f90 b/mlprec/impl/mld_zprecaply.f90 deleted file mode 100644 index 42d6bd0d..00000000 --- a/mlprec/impl/mld_zprecaply.f90 +++ /dev/null @@ -1,600 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_zprecaply.f90 -! -! Subroutine: mld_zprecaply -! Version: complex -! -! This routine applies the preconditioner built by mld_zprecbld, i.e. it computes -! -! Y = op(M^(-1)) * X, -! where -! - M is the preconditioner, -! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, -! - X and Y are vectors. -! This operation is performed at each iteration of a preconditioned Krylov solver. -! -! -! Arguments: -! prec - type(mld_zprec_type), input. -! The preconditioner data structure containing the local part -! of the preconditioner to be applied. -! x - complex(psb_dpk_), dimension(:), input. -! The local part of the vector X in Y=op(M^(-1))*X. -! y - complex(psb_dpk_), dimension(:), output. -! The local part of the vector Y in Y=op(M^(-1))*X. -! desc_data - type(psb_desc_type), input. -! The communication descriptor associated to the matrix to be -! preconditioned. -! info - integer, output. -! Error code. -! trans - character(len=1), optional. -! If trans='N','n' then op(M^(-1)) = M^(-1); -! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). -! work - complex(psb_dpk_), dimension (:), optional, target. -! Workspace. Its size must be at -! least 4*desc_data%get_local_cols(). -! -subroutine mld_zprecaply(prec,x,y,desc_data,info,trans,work) - - use psb_base_mod - use mld_z_inner_mod!, mld_protect_name => mld_zprecaply - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_zprec_type), intent(inout) :: prec - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_dpk_),intent(inout), optional, target :: work(:) - - ! Local variables - character :: trans_ - complex(psb_dpk_), pointer :: work_(:) - complex(psb_dpk_), allocatable :: w1(:), w2(:) - - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: err_act,iwsz, k, nswps - character(len=20) :: name - - name='mld_zprecaply' - info = psb_success_ - call psb_erractionsave(err_act) - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (present(trans)) then - trans_=psb_toupper(trans) - else - trans_='N' - end if - - if (present(work)) then - work_ => work - else - iwsz = max(1,4*desc_data%get_local_cols()) - allocate(work_(iwsz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name, & - & i_err=(/iwsz,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - - end if - - if (.not.(allocated(prec%precv))) then - !! Error 1: should call mld_zprecbld - info=3112 - call psb_errpush(info,name) - goto 9999 - end if - - if (size(prec%precv) >1) then - ! - ! Number of levels > 1: apply the multilevel preconditioner - ! - call mld_mlprec_aply(zone,prec,x,zzero,y,desc_data,trans_,work_,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_zmlprec_aply') - goto 9999 - end if - - else if (size(prec%precv) == 1) then - ! - ! Number of levels = 1: apply the base preconditioner - ! - if (allocated(prec%precv(1)%sm2a)) then - nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) - ! - ! This is a kludge for handling the symmetrized GS case. - ! Will need some rethinking. - ! - call psb_geasb(w1,desc_data,info,scratch=.true.) - call psb_geasb(w2,desc_data,info,scratch=.true.) - - call psb_geaxpby(zone,x,zzero,w1,desc_data,info) - select case(trans_) - case ('N') - do k=1, nswps - call prec%precv(1)%sm%apply(zone,w1,zzero,w2,desc_data,trans_,& - & ione, work_,info) - call prec%precv(1)%sm2a%apply(zone,w2,zzero,w1,desc_data,trans_,& - & ione, work_,info) - end do - - case('T','C') - do k=1, nswps - call prec%precv(1)%sm2a%apply(zone,w1,zzero,w2,desc_data,trans_,& - & ione, work_,info) - call prec%precv(1)%sm%apply(zone,w2,zzero,w1,desc_data,trans_,& - & ione, work_,info) - end do - case default - info = psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='Invalid trans') - goto 9999 - end select - call psb_geaxpby(zone,w1,zzero,y,desc_data,info) - call psb_gefree(w1,desc_data,info) - call psb_gefree(w2,desc_data,info) - - else - nswps = prec%precv(1)%parms%sweeps_pre - call prec%precv(1)%sm%apply(zone,x,zzero,y,desc_data,trans_,& - & nswps, work_,info) - end if - else - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='Invalid size of precv',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - endif - - ! If the original distribution has an overlap we should fix that. - call psb_halo(y,desc_data,info,data=psb_comm_mov_) - - - if (present(work)) then - else - deallocate(work_) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_zprecaply - - -! -! Subroutine: mld_zprecaply1 -! Version: complex -! -! Applies the preconditioner built by mld_zprecbld, i.e. computes -! -! X = op(M^(-1)) * X, -! where -! - M is the preconditioner, -! - op(M^(-1)) is M^(-1) or its transpose, according to the value of trans, -! - X is a vectors. -! This operation is performed at each iteration of a preconditioned Krylov solver. -! -! This routine differs from mld_zprecaply because the preconditioned vector X -! overwrites the original one. -! -! -! Arguments: -! prec - type(mld_zprec_type), input. -! The preconditioner data structure containing the local part -! of the preconditioner to be applied. -! x - complex(psb_dpk_), dimension(:), input/output. -! The local part of vector X in X := op(M^(-1)) * X. -! desc_data - type(psb_desc_type), input. -! The communication descriptor associated to the matrix to be -! preconditioned. -! info - integer, output. -! Error code. -! trans - character(len=1), optional. -! If trans='N','n' then op(M^(-1)) = M^(-1); -! if trans='T','t' then op(M^(-1)) = M^(-T) (transpose of M^(-1)). -! -subroutine mld_zprecaply1(prec,x,desc_data,info,trans) - - use psb_base_mod - use mld_z_inner_mod!, mld_protect_name => mld_zprecaply1 - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_zprec_type), intent(inout) :: prec - complex(psb_dpk_),intent(inout) :: x(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - - ! Local variables - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: err_act - complex(psb_dpk_), pointer :: ww(:), w1(:) - character(len=20) :: name - - name='mld_zprecaply1' - info = psb_success_ - call psb_erractionsave(err_act) - - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - allocate(ww(size(x)),w1(size(x)),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name, & - & i_err=(/itwo*size(x),izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - - call prec%apply(x,ww,desc_data,info,trans=trans,work=w1) - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_precaply') - goto 9999 - end if - - x(:) = ww(:) - deallocate(ww,w1,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - -end subroutine mld_zprecaply1 - - - -subroutine mld_zprecaply2_vect(prec,x,y,desc_data,info,trans,work) - - use psb_base_mod - use mld_z_inner_mod!, mld_protect_name => mld_zprecaply2_vect - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_zprec_type), intent(inout) :: prec - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_dpk_),intent(inout), optional, target :: work(:) - - ! Local variables - character :: trans_ - complex(psb_dpk_), pointer :: work_(:) - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: err_act,iwsz, k, nswps - logical :: do_alloc_wrk - character(len=20) :: name - - name='mld_zprecaply' - info = psb_success_ - call psb_erractionsave(err_act) - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (present(trans)) then - trans_=psb_toupper(trans) - else - trans_='N' - end if - - if (present(work)) then - work_ => work - else - iwsz = max(1,4*desc_data%get_local_cols()) - allocate(work_(iwsz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name, & - & i_err=(/iwsz,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - - end if - - if (.not.(allocated(prec%precv))) then - !! Error 1: should call mld_zprecbld - info=3112 - call psb_errpush(info,name) - goto 9999 - end if - - do_alloc_wrk = .not.allocated(prec%precv(1)%wrk) - if (do_alloc_wrk) call prec%allocate_wrk(info,vmold=x%v) - - if (size(prec%precv) >1) then - ! - ! Number of levels > 1: apply the multilevel preconditioner - ! - ! FIXME: generic name causes an ICE with Intel - call mld_zmlprec_aply_vect(zone,prec,x,zzero,y,desc_data,trans_,work_,info) - - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_zmlprec_aply') - goto 9999 - end if - - else if (size(prec%precv) == 1) then - ! - ! Number of levels = 1: apply the base preconditioner - ! - nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) - - associate(w1 => prec%precv(1)%wrk%vx2l, w2 => prec%precv(1)%wrk%vy2l,& - & wv => prec%precv(1)%wrk%wv) - if (allocated(prec%precv(1)%sm2a)) then - ! - ! This is a kludge for handling the symmetrized GS case. - ! Will need some rethinking. - ! - call psb_geaxpby(zone,x,zzero,w1,desc_data,info) - select case(trans_) - case ('N') - do k=1, nswps - if (info == 0) call prec%precv(1)%sm%apply(zone,w1,zzero,w2,desc_data,trans_,& - & ione, work_,wv,info) - if (info == 0) call prec%precv(1)%sm2a%apply(zone,w2,zzero,w1,desc_data,trans_,& - & ione, work_,wv,info) - end do - - case('T','C') - do k=1, nswps - if (info == 0) call prec%precv(1)%sm2a%apply(zone,w1,zzero,w2,desc_data,trans_,& - & ione, work_,wv,info) - if (info == 0) call prec%precv(1)%sm%apply(zone,w2,zzero,w1,desc_data,trans_,& - & ione, work_,wv,info) - end do - case default - info = psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='Invalid trans') - goto 9999 - end select - if (info == 0) call psb_geaxpby(zone,w1,zzero,y,desc_data,info) - else - if (info == 0) call prec%precv(1)%sm%apply(zone,x,zzero,y,desc_data,trans_,& - & nswps,work_,wv,info) - end if - end associate - if (psb_errstatus_fatal()) info = psb_err_internal_error_ - if (info /= 0) then - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='Smoother application',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - end if - - else - - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='Invalid size of precv',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - endif - - ! If the original distribution has an overlap we should fix that. - call psb_halo(y,desc_data,info,data=psb_comm_mov_) - - if (do_alloc_wrk) call prec%free_wrk(info) - - if (present(work)) then - else - deallocate(work_) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_zprecaply2_vect - - -subroutine mld_zprecaply1_vect(prec,x,desc_data,info,trans,work) - - use psb_base_mod - use mld_z_inner_mod!, mld_protect_name => mld_zprecaply1_vect - - implicit none - - ! Arguments - type(psb_desc_type),intent(in) :: desc_data - type(mld_zprec_type), intent(inout) :: prec - type(psb_z_vect_type),intent(inout) :: x - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_dpk_),intent(inout), optional, target :: work(:) - - ! Local variables - character :: trans_ - complex(psb_dpk_), pointer :: work_(:) - integer(psb_ipk_) :: ictxt,np,me - integer(psb_ipk_) :: err_act,iwsz, k, nswps - logical :: do_alloc_wrk - character(len=20) :: name - - name='mld_zprecaply' - info = psb_success_ - call psb_erractionsave(err_act) - - ictxt = desc_data%get_context() - call psb_info(ictxt, me, np) - - if (present(trans)) then - trans_=psb_toupper(trans) - else - trans_='N' - end if - - if (present(work)) then - work_ => work - else - iwsz = max(1,4*desc_data%get_local_cols()) - allocate(work_(iwsz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name, & - & i_err=(/iwsz,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - - end if - - if (.not.(allocated(prec%precv))) then - !! Error 1: should call mld_zprecbld - info=3112 - call psb_errpush(info,name) - goto 9999 - end if - - do_alloc_wrk = .not.allocated(prec%precv(1)%wrk) - if (do_alloc_wrk) call prec%allocate_wrk(info,vmold=x%v) - - associate(ww => prec%precv(1)%wrk%vtx, wv => prec%precv(1)%wrk%wv) - - if (size(prec%precv) >1) then - ! - ! Number of levels > 1: apply the multilevel preconditioner - ! - ! FIXME: generic name causes an ICE with Intel - call mld_zmlprec_aply_vect(zone,prec,x,zzero,ww,desc_data,trans_,work_,info) - if (info == 0) call psb_geaxpby(zone,ww,zzero,x,desc_data,info) - if(info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='mld_zmlprec_aply') - goto 9999 - end if - - else if (size(prec%precv) == 1) then - ! - ! Number of levels = 1: apply the base preconditioner - ! - nswps = max(prec%precv(1)%parms%sweeps_pre,prec%precv(1)%parms%sweeps_post) - if (allocated(prec%precv(1)%sm2a)) then - ! - ! This is a kludge for handling the symmetrized GS case. - ! Will need some rethinking. - ! - select case(trans_) - case ('N') - do k=1, nswps - if (info == 0) call prec%precv(1)%sm%apply(zone,x,zzero,ww,desc_data,trans_,& - & ione, work_,wv,info) - if (info == 0) call prec%precv(1)%sm2a%apply(zone,ww,zzero,x,desc_data,trans_,& - & ione, work_,wv,info) - end do - case('T','C') - do k=1, nswps - if (info == 0) call prec%precv(1)%sm2a%apply(zone,x,zzero,ww,desc_data,trans_,& - & ione, work_,wv,info) - if (info == 0) call prec%precv(1)%sm%apply(zone,ww,zzero,x,desc_data,trans_,& - & ione, work_,wv,info) - end do - case default - info = psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='Invalid trans') - goto 9999 - end select - - else - if (info == 0) call prec%precv(1)%sm%apply(zone,x,zzero,ww,desc_data,trans_,& - & nswps, work_,wv,info) - if (info == 0) call psb_geaxpby(zone,ww,zzero,x,desc_data,info) - end if - - if (psb_errstatus_fatal()) info = psb_err_internal_error_ - if (info /=0) then - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='Smoother application',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - end if - - else - - info = psb_err_from_subroutine_ai_ - call psb_errpush(info,name,a_err='Invalid size of precv',& - & i_Err=(/ione*size(prec%precv),izero,izero,izero,izero/)) - goto 9999 - endif - end associate - - ! If the original distribution has an overlap we should fix that. - call psb_halo(x,desc_data,info,data=psb_comm_mov_) - - if (do_alloc_wrk) call prec%free_wrk(info) - - if (present(work)) then - else - deallocate(work_) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_zprecaply1_vect diff --git a/mlprec/impl/mld_zprecbld.f90 b/mlprec/impl/mld_zprecbld.f90 deleted file mode 100644 index 28c2da23..00000000 --- a/mlprec/impl/mld_zprecbld.f90 +++ /dev/null @@ -1,161 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_zprecbld.f90 -! -! Subroutine: mld_zprecbld -! Version: complex -! Contains: subroutine init_baseprec_av -! -! This routine builds the preconditioner according to the requirements made by -! the user through the subroutines mld_precinit and mld_precset. -! -! -! Arguments: -! a - type(psb_zspmat_type). -! The sparse matrix structure containing the local part of the -! matrix to be preconditioned. -! desc_a - type(psb_desc_type), input. -! The communication descriptor of a. -! p - type(mld_zprec_type), input/output. -! The preconditioner data structure containing the local part -! of the preconditioner to be built. -! info - integer, output. -! Error code. -! -subroutine mld_zprecbld(a,desc_a,prec,info,amold,vmold,imold) - - use psb_base_mod - use mld_z_prec_mod, mld_protect_name => mld_zprecbld - - Implicit None - - ! Arguments - type(psb_zspmat_type),intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_zprec_type),intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local Variables - type(mld_zprec_type) :: t_prec - integer(psb_ipk_) :: ictxt, me,np - integer(psb_ipk_) :: err,i,k,err_act, iszv, newsz - integer(psb_ipk_) :: ipv(mld_ifpsz_), val - integer(psb_ipk_) :: int_err(5) - type(mld_dml_parms) :: prm - integer(psb_ipk_) :: debug_level, debug_unit - character(len=20) :: name, ch_err - - info=psb_success_ - err=0 - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - name = 'mld_zprecbld' - info = psb_success_ - int_err(1) = 0 - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - prec%ictxt = ictxt - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Entering ' - ! - - if (.not.allocated(prec%precv)) then - !! Error: should have called mld_zprecinit - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - ! - ! Check to ensure all procs have the same - ! - newsz = -1 - iszv = size(prec%precv) - call psb_bcast(ictxt,iszv) - if (iszv /= size(prec%precv)) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Inconsistent size of precv') - goto 9999 - end if - - if (iszv <= 0) then - ! Is this really possible? probably not. - info=psb_err_from_subroutine_ - ch_err='size bpv' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - ! - ! Build the preconditioner - ! - call prec%hierarchy_build(a,desc_a,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Error from hierarchy build') - goto 9999 - end if - - call prec%smoothers_build(a,desc_a,info,amold,vmold,imold) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,a_err='Error from smoothers build') - goto 9999 - end if - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_zprecbld diff --git a/mlprec/impl/mld_zprecinit.F90 b/mlprec/impl/mld_zprecinit.F90 deleted file mode 100644 index 851e0a4f..00000000 --- a/mlprec/impl/mld_zprecinit.F90 +++ /dev/null @@ -1,242 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_zprecinit.f90 -! -! Subroutine: mld_zprecinit -! Version: complex -! -! This routine allocates and initializes the preconditioner data structure, -! according to the preconditioner type chosen by the user. -! -! A default preconditioner is set for each preconditioner type -! specified by the user: -! -! 'NOPREC' - no preconditioner -! -! 'DIAG', 'JACOBI' - diagonal/Jacobi -! -! 'L1-DIAG', 'L1-JACOBI' - diagonal/Jacobi with L1 norm correction -! -! 'GS', 'FBGS' - Hybrid Gauss-Seidel, also symmetrized -! -! 'BJAC' - block Jacobi preconditioner, with ILU(0) -! on the local blocks -! -! 'L1-BJAC' - block Jacobi preconditioner, with ILU(0) -! on the local blocks and L1 correction for off-diag blocks -! -! 'AS' - Additive Schwarz (AS), with -! overlap 1 and ILU(0) on the local submatrices -! -! 'ML' - Multilevel hybrid preconditioner (additive on the -! same level and multiplicative through the levels), -! with 2 levels, pre and post-smoothing, RAS with -! overlap 1 and ILU(0) on the local blocks is -! applied as post-smoother at each level, but the -! coarsest one; four sweeps of the block-Jacobi solver, -! with LU from UMFPACK on the blocks, are applied at -! the coarsest level, on the distributed coarse matrix. -! The smoothed aggregation algorithm with threshold 0 -! is used to build the coarse matrix. -! -! For the multilevel preconditioners, the levels are numbered in increasing -! order starting from the finest one, i.e. level 1 is the finest level. -! -! -! Arguments: -! p - type(mld_zprec_type), input/output. -! The preconditioner data structure. -! ptype - character(len=*), input. -! The type of preconditioner. Its values are 'NOPREC', -! 'DIAG', 'BJAC', 'AS', 'ML' (and the corresponding -! lowercase strings). -! info - integer, output. -! Error code. -! -subroutine mld_zprecinit(ictxt,prec,ptype,info) - - use psb_base_mod - use mld_z_prec_mod, mld_protect_name => mld_zprecinit - use mld_z_jac_smoother - use mld_z_as_smoother - use mld_z_id_solver - use mld_z_diag_solver - use mld_z_ilu_solver - use mld_z_gs_solver -#if defined(HAVE_UMF_) - use mld_z_umf_solver -#endif -#if defined(HAVE_SLU_) - use mld_z_slu_solver -#endif - - - implicit none - - ! Arguments - integer(psb_ipk_), intent(in) :: ictxt - class(mld_zprec_type), intent(inout) :: prec - character(len=*), intent(in) :: ptype - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: nlev_, ilev_ - real(psb_dpk_) :: thr - character(len=*), parameter :: name='mld_precinit' - info = psb_success_ - - if (allocated(prec%precv)) then - call prec%free(info) - if (info /= psb_success_) then - ! Do we want to do something? - endif - endif - prec%ictxt = ictxt - prec%ag_data%min_coarse_size = -1 - - select case(psb_toupper(trim(ptype))) - case ('NOPREC','NONE') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_z_base_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_z_id_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('JAC','DIAG','JACOBI') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_z_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_z_diag_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('L1-DIAG','L1-JACOBI','L1_DIAG','L1_JACOBI') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_z_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_z_l1_diag_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('GS','FWGS') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_z_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_z_gs_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('BWGS') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_z_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_z_bwgs_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('FBGS') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - call prec%set('SMOOTHER_TYPE','FBGS',info) - call prec%precv(ilev_)%default() - - case ('BJAC') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_z_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_z_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('L1-BJAC','L1_BJAC') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_z_l1_jac_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_z_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - case ('AS') - nlev_ = 1 - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - allocate(mld_z_as_smoother_type :: prec%precv(ilev_)%sm, stat=info) - if (info /= psb_success_) return - allocate(mld_z_ilu_solver_type :: prec%precv(ilev_)%sm%sv, stat=info) - call prec%precv(ilev_)%default() - - - case ('ML') - - nlev_ = prec%ag_data%max_levs - ilev_ = 1 - allocate(prec%precv(nlev_),stat=info) - - do ilev_ = 1, nlev_ - call prec%precv(ilev_)%default() - end do - call prec%set('ML_CYCLE','VCYCLE',info) - call prec%set('SMOOTHER_TYPE','FBGS',info) -#if defined(HAVE_UMF_) - call prec%set('COARSE_SOLVE','UMF',info) -#elif defined(HAVE_MUMPS_) - call prec%set('COARSE_SOLVE','MUMPS',info) -#elif defined(HAVE_SLU_) - call prec%set('COARSE_SOLVE','SLU',info) -#else - call prec%set('COARSE_SOLVE','ILU',info) -#endif - - case default - write(psb_err_unit,*) name,& - &': Warning: Unknown preconditioner type request "',ptype,'"' - info = psb_err_pivot_too_small_ - - end select - - -end subroutine mld_zprecinit diff --git a/mlprec/impl/mld_zprecset.F90 b/mlprec/impl/mld_zprecset.F90 deleted file mode 100644 index ad4fcf03..00000000 --- a/mlprec/impl/mld_zprecset.F90 +++ /dev/null @@ -1,229 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_zprecset.f90 -! -subroutine mld_zprecsetsm(p,val,info,ilev,ilmax,pos) - - use psb_base_mod - use mld_z_prec_mod, mld_protect_name => mld_zprecsetsm - - implicit none - - ! Arguments - class(mld_zprec_type), intent(inout) :: p - class(mld_z_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ - character(len=*), parameter :: name='mld_precsetsm' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - ilmin_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmin_ = 1 - ilmax_ = nlev_ - end if - - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - do ilev_ = ilmin_, ilmax_ - call p%precv(ilev_)%set(val,info,pos=pos) - if (info /= 0) return - end do - -end subroutine mld_zprecsetsm - -subroutine mld_zprecsetsv(p,val,info,ilev,ilmax,pos) - - use psb_base_mod - use mld_z_prec_mod, mld_protect_name => mld_zprecsetsv - - implicit none - - ! Arguments - class(mld_zprec_type), intent(inout) :: p - class(mld_z_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ - character(len=*), parameter :: name='mld_precsetsv' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - ilmin_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmin_ = 1 - ilmax_ = nlev_ - end if - - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - do ilev_ = ilmin_, ilmax_ - call p%precv(ilev_)%set(val,info,pos=pos) - if (info /= 0) return - end do - -end subroutine mld_zprecsetsv - -subroutine mld_zprecsetag(p,val,info,ilev,ilmax,pos) - - use psb_base_mod - use mld_z_prec_mod, mld_protect_name => mld_zprecsetag - - implicit none - - ! Arguments - class(mld_zprec_type), intent(inout) :: p - class(mld_z_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev, ilmax - character(len=*), optional, intent(in) :: pos - - ! Local variables - integer(psb_ipk_) :: ilev_, nlev_, ilmin_, ilmax_ - character(len=*), parameter :: name='mld_precsetag' - - info = psb_success_ - - if (.not.allocated(p%precv)) then - info = 3111 - write(psb_err_unit,*) name,& - & ': Error: uninitialized preconditioner,',& - &' should call MLD_PRECINIT' - return - endif - nlev_ = size(p%precv) - - if (present(ilev)) then - ilev_ = ilev - ilmin_ = ilev - if (present(ilmax)) then - ilmax_ = ilmax - else - ilmax_ = ilev_ - end if - else - ilev_ = 1 - ilmin_ = 1 - ilmax_ = nlev_ - end if - - - if ((ilev_<1).or.(ilev_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - & ': Error: invalid ILEV/NLEV combination',ilev_, nlev_ - return - endif - if ((ilmax_<1).or.(ilmax_ > nlev_)) then - info = -1 - write(psb_err_unit,*) name,& - &': Error: invalid ILMAX/NLEV combination',ilmax_, nlev_ - return - endif - - do ilev_ = ilmin_, ilmax_ - call p%precv(ilev_)%set(val,info,pos=pos) - if (info /= 0) return - end do - -end subroutine mld_zprecsetag - diff --git a/mlprec/impl/mld_zslu_interface.c b/mlprec/impl/mld_zslu_interface.c deleted file mode 100644 index 7b7978ce..00000000 --- a/mlprec/impl/mld_zslu_interface.c +++ /dev/null @@ -1,327 +0,0 @@ -/* - * - * MLD2P4 version 2.1 - * MultiLevel Domain Decomposition Parallel Preconditioners Package - * based on PSBLAS (Parallel Sparse BLAS version 3.5) - * - * (C) Copyright 2008-2018 - * - * Salvatore Filippone - * Pasqua D'Ambra - * Daniela di Serafino - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions, and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the MLD2P4 group or the names of its contributors may - * not be used to endorse or promote products derived from this - * software without specific written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * - * File: mld_zslu_interface.c - * - * Functions: mld_zslu_fact, mld_zslu_solve, mld_zslu_free. - * - * This file is an interface to the SuperLU routines for sparse factorization and - * solve. It was obtained by modifying the c_fortran_zgssv.c file from the SuperLU - * source distribution; original copyright terms are reproduced below. - * - */ - - -/* ===================== - -Copyright (c) 2003, The Regents of the University of California, through -Lawrence Berkeley National Laboratory (subject to receipt of any required -approvals from U.S. Dept. of Energy) - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -(1) Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. -(2) Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. -(3) Neither the name of Lawrence Berkeley National Laboratory, U.S. Dept. of -Energy nor the names of its contributors may be used to endorse or promote -products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -/* - * -- SuperLU routine (version 3.0) -- - * Univ. of California Berkeley, Xerox Palo Alto Research Center, - * and Lawrence Berkeley National Lab. - * October 15, 2003 - * - */ - -#ifdef Have_SLU_ -#include "slu_zdefs.h" -#define HANDLE_SIZE 8 - -typedef struct { - SuperMatrix *L; - SuperMatrix *U; - int *perm_c; - int *perm_r; -} factors_t; - - -#else - -#include - -#endif - - - -int mld_zslu_fact(int n, int nnz, -#ifdef HAVE_SLU_ - doublecomplex *values, -#else - void *values, -#endif - int *colptr, int *rowind, void **f_factors) - -{ -/* - * This routine can be called from Fortran. - * performs LU decomposition. - * - * f_factors (input/output) - * On output contains the pointer pointing to - * the structure of the factored matrices. - * - */ - -#ifdef Have_SLU_ - SuperMatrix A, AC; - SuperMatrix *L, *U; - int *perm_r; /* row permutations from partial pivoting */ - int *perm_c; /* column permutation vector */ - int *etree; /* column elimination tree */ - SCformat *Lstore; - NCformat *Ustore; - int i, panel_size, permc_spec, relax; - trans_t trans; - mem_usage_t mem_usage; - superlu_options_t options; - SuperLUStat_t stat; - factors_t *LUfactors; - GlobalLU_t Glu; /* Not needed on return. */ - int info; - - trans = NOTRANS; - - - /* Set the default input options. */ - set_default_options(&options); - - /* Initialize the statistics variables. */ - StatInit(&stat); - - zCreate_CompCol_Matrix(&A, n, n, nnz, values, rowind, colptr, - SLU_NC, SLU_Z, SLU_GE); - L = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) ); - U = (SuperMatrix *) SUPERLU_MALLOC( sizeof(SuperMatrix) ); - if ( !(perm_r = intMalloc(n)) ) ABORT("Malloc fails for perm_r[]."); - if ( !(perm_c = intMalloc(n)) ) ABORT("Malloc fails for perm_c[]."); - if ( !(etree = intMalloc(n)) ) ABORT("Malloc fails for etree[]."); - - /* - * Get column permutation vector perm_c[], according to permc_spec: - * permc_spec = 0: natural ordering - * permc_spec = 1: minimum degree on structure of A'*A - * permc_spec = 2: minimum degree on structure of A'+A - * permc_spec = 3: approximate minimum degree for unsymmetric matrices - */ - options.ColPerm=2; - permc_spec = options.ColPerm; - get_perm_c(permc_spec, &A, perm_c); - - sp_preorder(&options, &A, perm_c, etree, &AC); - - panel_size = sp_ienv(1); - relax = sp_ienv(2); -#if defined(SLU_VERSION_5) - zgstrf(&options, &AC, relax, panel_size, etree, - NULL, 0, perm_c, perm_r, L, U, &Glu, &stat, &info); -#elif defined(SLU_VERSION_4) - zgstrf(&options, &AC, relax, panel_size, etree, - NULL, 0, perm_c, perm_r, L, U, &stat, &info); -#else - choke_on_me; -#endif - - if ( info == 0 ) { - Lstore = (SCformat *) L->Store; - Ustore = (NCformat *) U->Store; - zQuerySpace(L, U, &mem_usage); -#if 0 - printf("No of nonzeros in factor L = %d\n", Lstore->nnz); - printf("No of nonzeros in factor U = %d\n", Ustore->nnz); - printf("No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz); - printf("L\\U MB %.3f\ttotal MB needed %.3f\n", - mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); -#endif - } else { - printf("zgstrf() error returns INFO= %d\n", info); - if ( info <= n ) { /* factorization completes */ - zQuerySpace(L, U, &mem_usage); - printf("L\\U MB %.3f\ttotal MB needed %.3f\n", - mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); - } - } - - /* Save the LU factors in the factors handle */ - LUfactors = (factors_t*) SUPERLU_MALLOC(sizeof(factors_t)); - LUfactors->L = L; - LUfactors->U = U; - LUfactors->perm_c = perm_c; - LUfactors->perm_r = perm_r; - *f_factors = (void *) LUfactors; - - /* Free un-wanted storage */ - SUPERLU_FREE(etree); - Destroy_SuperMatrix_Store(&A); - Destroy_CompCol_Permuted(&AC); - StatFree(&stat); - return(info); -#else - fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); - return(-1); -#endif -} - - -int mld_zslu_solve(int itrans, int n, int nrhs, -#ifdef HAVE_SLU_ - doublecomplex *b, -#else - void *b, -#endif - int ldb,void *f_factors) -{ - /* - * This routine can be called from Fortran. - * performs triangular solve - * - */ - int info; -#ifdef Have_SLU_ - SuperMatrix B; - SuperMatrix *L, *U; - int *perm_r; /* row permutations from partial pivoting */ - int *perm_c; /* column permutation vector */ - int *etree; /* column elimination tree */ - SCformat *Lstore; - NCformat *Ustore; - int i, panel_size, permc_spec, relax; - trans_t trans; - double drop_tol = 0.0; - mem_usage_t mem_usage; - superlu_options_t options; - SuperLUStat_t stat; - factors_t *LUfactors; - - if (itrans == 0) { - trans = NOTRANS; - } else if (itrans ==1) { - trans = TRANS; - } else if (itrans ==2) { - trans = CONJ; - } else { - trans = NOTRANS; - } - /* Initialize the statistics variables. */ - StatInit(&stat); - - /* Extract the LU factors in the factors handle */ - LUfactors = (factors_t*) f_factors; - L = LUfactors->L; - U = LUfactors->U; - perm_c = LUfactors->perm_c; - perm_r = LUfactors->perm_r; - - zCreate_Dense_Matrix(&B, n, nrhs, b, ldb, SLU_DN, SLU_Z, SLU_GE); - /* Solve the system A*X=B, overwriting B with X. */ - zgstrs (trans, L, U, perm_c, perm_r, &B, &stat, &info); - if (info != 0) { - if (B.Stype != SLU_DN) fprintf(stderr,"zgstrs error kind 1: SLU_DN\n"); - if (B.Dtype != SLU_Z) fprintf(stderr,"zgstrs error kind 2: SLU_Z\n"); - if (B.Mtype != SLU_GE) fprintf(stderr,"zgstrs error kind 3: SLU_GE\n"); - } - - Destroy_SuperMatrix_Store(&B); - StatFree(&stat); -#else - fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); - info=-1; -#endif - return(info); -} - - -int mld_zslu_free(void *f_factors) -{ -/* - * This routine can be called from Fortran. - * - * free all storage in the end - * - */ -#ifdef Have_SLU_ - factors_t *LUfactors; - - /* Free the LU factors in the factors handle */ - LUfactors = (factors_t*) f_factors; - if (LUfactors != NULL) { - SUPERLU_FREE (LUfactors->perm_r); - SUPERLU_FREE (LUfactors->perm_c); - Destroy_SuperNode_Matrix(LUfactors->L); - Destroy_CompCol_Matrix(LUfactors->U); - SUPERLU_FREE (LUfactors->L); - SUPERLU_FREE (LUfactors->U); - SUPERLU_FREE (LUfactors); - } - return(0); -#else - fprintf(stderr," SLU Not Configured, fix make.inc and recompile\n"); - return(-1); -#endif -} - - diff --git a/mlprec/impl/mld_zslud_interface.c b/mlprec/impl/mld_zslud_interface.c deleted file mode 100644 index 8db9d899..00000000 --- a/mlprec/impl/mld_zslud_interface.c +++ /dev/null @@ -1,403 +0,0 @@ -/* - * - * MLD2P4 version 2.1 - * MultiLevel Domain Decomposition Parallel Preconditioners Package - * based on PSBLAS (Parallel Sparse BLAS version 3.5) - * - * (C) Copyright 2008-2018 - * - * Salvatore Filippone - * Ambra Abdullahi Hassan - * Alfredo Buttari CNRS-IRIT, Toulouse, FR - * Pasqua D'Ambra - * Daniela di Serafino - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions, and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the MLD2P4 group or the names of its contributors may - * not be used to endorse or promote products derived from this - * software without specific written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * - * File: mld_zslud_interface.c - * - * Functions: mld_zsludist_fact, mld_zsludist_solve, mld_zsludist_free. - * - * This file is an interface to the SuperLU_dist routines for sparse factorization and - * solve. It was obtained by modifying the c_fortran_zgssv.c file from the SuperLU_dist - * source distribution; original copyright terms are reproduced below. - * - */ - -/* ===================== - -Copyright (c) 2003, The Regents of the University of California, through -Lawrence Berkeley National Laboratory (subject to receipt of any required -approvals from U.S. Dept. of Energy) - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -(1) Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. -(2) Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. -(3) Neither the name of Lawrence Berkeley National Laboratory, U.S. Dept. of -Energy nor the names of its contributors may be used to endorse or promote -products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -/* - * -- Distributed SuperLU routine (version 2.0) -- - * Lawrence Berkeley National Lab, Univ. of California Berkeley. - * March 15, 2003 - * - */ - -#ifdef Have_SLUDist_ -#include -#include "superlu_zdefs.h" - -#define HANDLE_SIZE 8 - -#if defined(SLUD_VERSION_63) -typedef struct { - SuperMatrix *A; - zLUstruct_t *LUstruct; - gridinfo_t *grid; - zScalePermstruct_t *ScalePermstruct; -} factors_t; -#else -typedef struct { - SuperMatrix *A; - LUstruct_t *LUstruct; - gridinfo_t *grid; - ScalePermstruct_t *ScalePermstruct; -} factors_t; -#endif - -#else - -#include - -#endif - - -int mld_zsludist_fact(int n, int nl, int nnzl, int ffstr, -#ifdef Have_SLUDist_ - doublecomplex *values, int *rowptr, int *colind, - void **f_factors, -#else - void *values, int *rowptr, int *colind, - void **f_factors, -#endif - int nprow, int npcol) - -{ -/* - * This routine can be called from Fortran. - * performs LU decomposition. - * - * f_factors (input/output) void** - * On output contains the pointer pointing to - * the structure of the factored matrices. - * - */ - -#ifdef Have_SLUDist_ - SuperMatrix *A; - NRformat_loc *Astore; - -#if defined(SLUD_VERSION_63) - zScalePermstruct_t *ScalePermstruct; - zLUstruct_t *LUstruct; - zSOLVEstruct_t SOLVEstruct; -#else - ScalePermstruct_t *ScalePermstruct; - LUstruct_t *LUstruct; - SOLVEstruct_t SOLVEstruct; -#endif - gridinfo_t *grid; - int i, panel_size, permc_spec, relax, info; - trans_t trans; - double drop_tol = 0.0,berr[1]; -#if defined(SLUD_VERSION_63) || defined(SLUD_VERSION_6)||defined(SLUD_VERSION_5) - superlu_dist_options_t options; -#elif defined(SLUD_VERSION_4)||defined(SLUD_VERSION_3) - superlu_options_t options; -#else - choke_on_me; -#endif - SuperLUStat_t stat; - factors_t *LUfactors; - int fst_row; - int *icol,*irpt; - doublecomplex *ival,b[1]; - - trans = NOTRANS; - grid = (gridinfo_t *) SUPERLU_MALLOC(sizeof(gridinfo_t)); - superlu_gridinit(MPI_COMM_WORLD, nprow, npcol, grid); - /* Initialize the statistics variables. */ - PStatInit(&stat); - fst_row = (ffstr); - - A = (SuperMatrix *) malloc(sizeof(SuperMatrix)); - zCreate_CompRowLoc_Matrix_dist(A, n, n, nnzl, nl, fst_row, - values, colind, rowptr, - SLU_NR_loc, SLU_Z, SLU_GE); - - /* Initialize ScalePermstruct and LUstruct. */ -#if defined(SLUD_VERSION_63) - ScalePermstruct = (zScalePermstruct_t *) SUPERLU_MALLOC(sizeof(zScalePermstruct_t)); - LUstruct = (zLUstruct_t *) SUPERLU_MALLOC(sizeof(zLUstruct_t)); - zScalePermstructInit(n,n, ScalePermstruct); -#else - ScalePermstruct = (ScalePermstruct_t *) SUPERLU_MALLOC(sizeof(ScalePermstruct_t)); - LUstruct = (LUstruct_t *) SUPERLU_MALLOC(sizeof(LUstruct_t)); - ScalePermstructInit(n,n, ScalePermstruct); -#endif -#if defined(SLUD_VERSION_63) - zLUstructInit(n, LUstruct); -#elif defined(SLUD_VERSION_4) || defined(SLUD_VERSION_5) || defined(SLUD_VERSION_6) - LUstructInit(n, LUstruct); -#elif defined(SLUD_VERSION_3) - LUstructInit(n,n, LUstruct); -#else - choke_on_me; -#endif - - /* Set the default input options. */ - set_default_options_dist(&options); - options.IterRefine=NO; - options.PrintStat=NO; - - pzgssvx(&options, A, ScalePermstruct, b, nl, 0, - grid, LUstruct, &SOLVEstruct, berr, &stat, &info); - - if ( info == 0 ) { - ; - } else { - printf("pzgssvx() error returns INFO= %d\n", info); - if ( info <= n ) { /* factorization completes */ - ; - } - } - if (options.SolveInitialized) { - zSolveFinalize(&options,&SOLVEstruct); - } - - - /* Save the LU factors in the factors handle */ - LUfactors = (factors_t *) SUPERLU_MALLOC(sizeof(factors_t)); - LUfactors->LUstruct = LUstruct; - LUfactors->grid = grid; - LUfactors->A = A; - LUfactors->ScalePermstruct = ScalePermstruct; -/* fprintf(stderr,"slud factor: LUFactors %p \n",LUfactors); */ -/* fprintf(stderr,"slud factor: A %p %p\n",A,LUfactors->A); */ -/* fprintf(stderr,"slud factor: grid %p %p\n",grid,LUfactors->grid); */ -/* fprintf(stderr,"slud factor: LUstruct %p %p\n",LUstruct,LUfactors->LUstruct); */ - *f_factors = (void *) LUfactors; - PStatFree(&stat); - return(info); -#else - fprintf(stderr," SLUDist Not Configured, fix make.inc and recompile\n"); - return(-1); -#endif -} - - -int mld_zsludist_solve(int itrans, int n, int nrhs, -#ifdef Have_SLUDist_ - doublecomplex *b, -#else - void *b, -#endif - int ldb, void *f_factors) - -{ -/* - * This routine can be called from Fortran. - * performs triangular solve - * - */ -#ifdef Have_SLUDist_ - SuperMatrix *A; -#if defined(SLUD_VERSION_63) - zScalePermstruct_t *ScalePermstruct; - zLUstruct_t *LUstruct; - zSOLVEstruct_t SOLVEstruct; -#else - ScalePermstruct_t *ScalePermstruct; - LUstruct_t *LUstruct; - SOLVEstruct_t SOLVEstruct; -#endif - gridinfo_t *grid; - int i, panel_size, permc_spec, relax, info; - trans_t trans; - double drop_tol = 0.0; - double *berr; -#if defined(SLUD_VERSION_63) || defined(SLUD_VERSION_6) ||defined(SLUD_VERSION_5) - superlu_dist_options_t options; -#elif defined(SLUD_VERSION_4)|| defined(SLUD_VERSION_3) - superlu_options_t options; -#else - choke_on_me; -#endif - SuperLUStat_t stat; - factors_t *LUfactors; - - LUfactors = (factors_t *) f_factors ; - A = LUfactors->A ; - LUstruct = LUfactors->LUstruct ; - grid = LUfactors->grid ; - - ScalePermstruct = LUfactors->ScalePermstruct; -/* fprintf(stderr,"slud solve: LUFactors %p \n",LUfactors); */ -/* fprintf(stderr,"slud solve: A %p %p\n",A,LUfactors->A); */ -/* fprintf(stderr,"slud solve: grid %p %p\n",grid,LUfactors->grid); */ -/* fprintf(stderr,"slud solve: LUstruct %p %p\n",LUstruct,LUfactors->LUstruct); */ - - - if (itrans == 0) { - trans = NOTRANS; - } else if (itrans ==1) { - trans = TRANS; - } else if (itrans ==2) { - trans = CONJ; - } else { - trans = NOTRANS; - } - -/* fprintf(stderr,"Entry to sludist_solve\n"); */ - berr = (double *) malloc((nrhs) *sizeof(double)); - - /* Initialize the statistics variables. */ - PStatInit(&stat); - - /* Set the default input options. */ - set_default_options_dist(&options); - options.IterRefine = NO; - options.Fact = FACTORED; - options.PrintStat = NO; - - pzgssvx(&options, A, ScalePermstruct, b, ldb, nrhs, - grid, LUstruct, &SOLVEstruct, berr, &stat, &info); - -/* fprintf(stderr,"Double check: after solve %d %lf\n",*info,berr[0]); */ - if (options.SolveInitialized) { - zSolveFinalize(&options,&SOLVEstruct); - } - PStatFree(&stat); - free(berr); - return(info); -#else - fprintf(stderr," SLUDist Not Configured, fix make.inc and recompile\n"); - return(-1); -#endif - -} - - -int mld_zsludist_free(void *f_factors) -{ -/* - * This routine can be called from Fortran. - * - * free all storage in the end - * - */ -#ifdef Have_SLUDist_ - SuperMatrix *A; -#if defined(SLUD_VERSION_63) - zScalePermstruct_t *ScalePermstruct; - zLUstruct_t *LUstruct; - zSOLVEstruct_t SOLVEstruct; -#else - ScalePermstruct_t *ScalePermstruct; - LUstruct_t *LUstruct; - SOLVEstruct_t SOLVEstruct; -#endif - gridinfo_t *grid; - int i, panel_size, permc_spec, relax; - trans_t trans; - double drop_tol = 0.0; - double *berr; -#if defined(SLUD_VERSION_63)||defined(SLUD_VERSION_6)||defined(SLUD_VERSION_5) - superlu_dist_options_t options; -#elif defined(SLUD_VERSION_4)||defined(SLUD_VERSION_3) - superlu_options_t options; -#else - choke_on_me; -#endif - SuperLUStat_t stat; - factors_t *LUfactors; - - - if (f_factors == NULL) - return(0); - LUfactors = (factors_t *) f_factors ; - A = LUfactors->A ; - LUstruct = LUfactors->LUstruct ; - grid = LUfactors->grid ; - ScalePermstruct = LUfactors->ScalePermstruct; - - // Memory leak: with SuperLU_Dist 3.3 - // we either have a leak or a segfault here. - // To be investigated further. - //Destroy_CompRowLoc_Matrix_dist(A); -#if defined(SLUD_VERSION_63) - zScalePermstructFree(ScalePermstruct); - zLUstructFree(LUstruct); -#else - ScalePermstructFree(ScalePermstruct); - LUstructFree(LUstruct); -#endif - superlu_gridexit(grid); - - free(grid); - free(LUstruct); - free(LUfactors); - return(0); - -#else - fprintf(stderr," SLUDist Not Configured, fix make.inc and recompile\n"); - return(-1); -#endif -} - - diff --git a/mlprec/impl/mld_zumf_interface.c b/mlprec/impl/mld_zumf_interface.c deleted file mode 100644 index 23b48600..00000000 --- a/mlprec/impl/mld_zumf_interface.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * - * MLD2P4 version 2.1 - * MultiLevel Domain Decomposition Parallel Preconditioners Package - * based on PSBLAS (Parallel Sparse BLAS version 3.5) - * - * (C) Copyright 2008-2018 - * - * Salvatore Filippone - * Pasqua D'Ambra - * Daniela di Serafino - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions, and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the MLD2P4 group or the names of its contributors may - * not be used to endorse or promote products derived from this - * software without specific written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * - * File: mld_zumf_interface.c - * - * Functions: mld_zumf_fact_, mld_zumf_solve_, mld_zumf_free_. - * - * This file is an interface to the UMFPACK routines for sparse factorization and - * solve. It was obtained by adapting umfpack_zi_demo under the original UMFPACK - * copyright terms reproduced below. - * - */ - -/* ===================== -UMFPACK Version 4.4 (Jan. 28, 2005), Copyright (c) 2005 by Timothy A. -Davis. All Rights Reserved. - -UMFPACK License: - - Your use or distribution of UMFPACK or any modified version of - UMFPACK implies that you agree to this License. - - THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY - EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - - Permission is hereby granted to use or copy this program, provided - that the Copyright, this License, and the Availability of the original - version is retained on all copies. User documentation of any code that - uses UMFPACK or any modified version of UMFPACK code must cite the - Copyright, this License, the Availability note, and "Used by permission." - Permission to modify the code and to distribute modified code is granted, - provided the Copyright, this License, and the Availability note are - retained, and a notice that the code was modified is included. This - software was developed with support from the National Science Foundation, - and is provided to you free of charge. - -Availability: - - http://www.cise.ufl.edu/research/sparse/umfpack - -*/ - - -#include -#ifdef Have_UMF_ -#include "umfpack.h" -#endif - - -int mld_zumf_fact(int n, int nnz, - double *values, int *rowind, int *colptr, - void **symptr, void **numptr, - long long int *ssize, - long long int *nsize) - -{ - -#ifdef Have_UMF_ - double Info [UMFPACK_INFO], Control [UMFPACK_CONTROL]; - void *Symbolic, *Numeric ; - int i, info; - - - umfpack_zi_defaults(Control); - - info = umfpack_zi_symbolic (n, n, colptr, rowind, values, NULL, &Symbolic, - Control, Info); - - - if ( info == UMFPACK_OK ) { - info = 0; - } else { - printf("umfpack_zi_symbolic() error returns INFO= %d\n", info); - umfpack_zi_report_status(Control,info); - *symptr = (void *) NULL; - *numptr = (void *) NULL; - return -11; - } - - *symptr = Symbolic; - *ssize = Info[UMFPACK_SYMBOLIC_SIZE]; - *ssize *= Info[UMFPACK_SIZE_OF_UNIT]; - - info = umfpack_zi_numeric (colptr, rowind, values, NULL, Symbolic, &Numeric, - Control, Info) ; - - - if ( info == UMFPACK_OK ) { - info = 0; - *numptr = Numeric; - *nsize = Info[UMFPACK_NUMERIC_SIZE]; - *nsize *= Info[UMFPACK_SIZE_OF_UNIT]; - - } else { - printf("umfpack_zi_numeric() error returns INFO= %d\n", info); - umfpack_zi_report_status(Control,info); - info = -12; - *numptr = NULL; - } - - - return info; - -#else - fprintf(stderr," UMF Not Configured, fix make.inc and recompile\n"); - return -1; -#endif -} - - -int mld_zumf_solve(int itrans, int n, - double *x, double *b, int ldb, - void *numptr) - -{ -#ifdef Have_UMF_ - double Info [UMFPACK_INFO], Control [UMFPACK_CONTROL]; - void *Symbolic, *Numeric ; - int i,trans, info; - - - umfpack_di_defaults(Control); - Control[UMFPACK_IRSTEP]=0; - - - if (itrans == 0) { - trans = UMFPACK_A; - } else if (itrans ==1) { - trans = UMFPACK_At; - } else { - trans = UMFPACK_A; - } - - info = umfpack_zi_solve(trans,NULL,NULL,NULL,NULL, - x,NULL,b,NULL, numptr,Control,Info); - return info; -#else - fprintf(stderr," UMF Not Configured, fix make.inc and recompile\n"); - return -1; -#endif - -} - - -int mld_zumf_free(void *symptr, void *numptr) - -{ -#ifdef Have_UMF_ - void *Symbolic, *Numeric ; - Symbolic = symptr; - Numeric = numptr; - - umfpack_zi_free_numeric(&Numeric); - umfpack_zi_free_symbolic(&Symbolic); - return 0; -#else - fprintf(stderr," UMF Not Configured, fix make.inc and recompile\n"); - return -1; -#endif -} - - diff --git a/mlprec/impl/smoother/Makefile b/mlprec/impl/smoother/Makefile index d223fb92..9004f395 100644 --- a/mlprec/impl/smoother/Makefile +++ b/mlprec/impl/smoother/Makefile @@ -7,188 +7,188 @@ FINCLUDES=$(FMFLAG)$(HERE) $(FMFLAG)$(MODDIR) $(FMFLAG)$(INCDIR) $(PSBLAS_INCLUD -OBJS=mld_c_as_smoother_apply.o \ -mld_c_as_smoother_apply_vect.o \ -mld_c_as_smoother_bld.o \ -mld_c_as_smoother_check.o \ -mld_c_as_smoother_clone.o \ -mld_c_as_smoother_clone_settings.o \ -mld_c_as_smoother_clear_data.o \ -mld_c_as_smoother_cnv.o \ -mld_c_as_smoother_csetc.o \ -mld_c_as_smoother_cseti.o \ -mld_c_as_smoother_dmp.o \ -mld_c_as_smoother_free.o \ -mld_c_as_smoother_prol_a.o \ -mld_c_as_smoother_prol_v.o \ -mld_c_as_smoother_restr_a.o \ -mld_c_as_smoother_restr_v.o \ -mld_c_base_smoother_apply.o \ -mld_c_base_smoother_apply_vect.o \ -mld_c_base_smoother_bld.o \ -mld_c_base_smoother_check.o \ -mld_c_base_smoother_clone.o \ -mld_c_base_smoother_clone_settings.o \ -mld_c_base_smoother_clear_data.o \ -mld_c_base_smoother_cnv.o \ -mld_c_base_smoother_csetc.o \ -mld_c_base_smoother_cseti.o \ -mld_c_base_smoother_csetr.o \ -mld_c_base_smoother_descr.o \ -mld_c_base_smoother_dmp.o \ -mld_c_base_smoother_free.o \ -mld_c_jac_smoother_apply.o \ -mld_c_jac_smoother_apply_vect.o \ -mld_c_jac_smoother_bld.o \ -mld_c_jac_smoother_descr.o \ -mld_c_jac_smoother_dmp.o \ -mld_c_jac_smoother_clone.o \ -mld_c_jac_smoother_clone_settings.o \ -mld_c_jac_smoother_clear_data.o \ -mld_c_jac_smoother_cnv.o \ -mld_c_jac_smoother_csetc.o \ -mld_c_jac_smoother_cseti.o \ -mld_c_jac_smoother_csetr.o \ -mld_c_l1_jac_smoother_bld.o \ -mld_c_l1_jac_smoother_descr.o \ -mld_c_l1_jac_smoother_clone.o \ -mld_d_as_smoother_apply.o \ -mld_d_as_smoother_apply_vect.o \ -mld_d_as_smoother_bld.o \ -mld_d_as_smoother_check.o \ -mld_d_as_smoother_clone.o \ -mld_d_as_smoother_clone_settings.o \ -mld_d_as_smoother_clear_data.o \ -mld_d_as_smoother_cnv.o \ -mld_d_as_smoother_csetc.o \ -mld_d_as_smoother_cseti.o \ -mld_d_as_smoother_dmp.o \ -mld_d_as_smoother_free.o \ -mld_d_as_smoother_prol_a.o \ -mld_d_as_smoother_prol_v.o \ -mld_d_as_smoother_restr_a.o \ -mld_d_as_smoother_restr_v.o \ -mld_d_base_smoother_apply.o \ -mld_d_base_smoother_apply_vect.o \ -mld_d_base_smoother_bld.o \ -mld_d_base_smoother_check.o \ -mld_d_base_smoother_clone.o \ -mld_d_base_smoother_clone_settings.o \ -mld_d_base_smoother_clear_data.o \ -mld_d_base_smoother_cnv.o \ -mld_d_base_smoother_csetc.o \ -mld_d_base_smoother_cseti.o \ -mld_d_base_smoother_csetr.o \ -mld_d_base_smoother_descr.o \ -mld_d_base_smoother_dmp.o \ -mld_d_base_smoother_free.o \ -mld_d_jac_smoother_apply.o \ -mld_d_jac_smoother_apply_vect.o \ -mld_d_jac_smoother_bld.o \ -mld_d_jac_smoother_descr.o \ -mld_d_jac_smoother_dmp.o \ -mld_d_jac_smoother_clone.o \ -mld_d_jac_smoother_clone_settings.o \ -mld_d_jac_smoother_clear_data.o \ -mld_d_jac_smoother_cnv.o \ -mld_d_jac_smoother_csetc.o \ -mld_d_jac_smoother_cseti.o \ -mld_d_jac_smoother_csetr.o \ -mld_d_l1_jac_smoother_bld.o \ -mld_d_l1_jac_smoother_descr.o \ -mld_d_l1_jac_smoother_clone.o \ -mld_s_as_smoother_apply.o \ -mld_s_as_smoother_apply_vect.o \ -mld_s_as_smoother_bld.o \ -mld_s_as_smoother_check.o \ -mld_s_as_smoother_clone.o \ -mld_s_as_smoother_clone_settings.o \ -mld_s_as_smoother_clear_data.o \ -mld_s_as_smoother_cnv.o \ -mld_s_as_smoother_csetc.o \ -mld_s_as_smoother_cseti.o \ -mld_s_as_smoother_dmp.o \ -mld_s_as_smoother_free.o \ -mld_s_as_smoother_prol_a.o \ -mld_s_as_smoother_prol_v.o \ -mld_s_as_smoother_restr_a.o \ -mld_s_as_smoother_restr_v.o \ -mld_s_base_smoother_apply.o \ -mld_s_base_smoother_apply_vect.o \ -mld_s_base_smoother_bld.o \ -mld_s_base_smoother_check.o \ -mld_s_base_smoother_clone.o \ -mld_s_base_smoother_clone_settings.o \ -mld_s_base_smoother_clear_data.o \ -mld_s_base_smoother_cnv.o \ -mld_s_base_smoother_csetc.o \ -mld_s_base_smoother_cseti.o \ -mld_s_base_smoother_csetr.o \ -mld_s_base_smoother_descr.o \ -mld_s_base_smoother_dmp.o \ -mld_s_base_smoother_free.o \ -mld_s_jac_smoother_apply.o \ -mld_s_jac_smoother_apply_vect.o \ -mld_s_jac_smoother_bld.o \ -mld_s_jac_smoother_descr.o \ -mld_s_jac_smoother_dmp.o \ -mld_s_jac_smoother_clone.o \ -mld_s_jac_smoother_clone_settings.o \ -mld_s_jac_smoother_clear_data.o \ -mld_s_jac_smoother_cnv.o \ -mld_s_jac_smoother_csetc.o \ -mld_s_jac_smoother_cseti.o \ -mld_s_jac_smoother_csetr.o \ -mld_s_l1_jac_smoother_bld.o \ -mld_s_l1_jac_smoother_descr.o \ -mld_s_l1_jac_smoother_clone.o \ -mld_z_as_smoother_apply.o \ -mld_z_as_smoother_apply_vect.o \ -mld_z_as_smoother_bld.o \ -mld_z_as_smoother_check.o \ -mld_z_as_smoother_clone.o \ -mld_z_as_smoother_clone_settings.o \ -mld_z_as_smoother_clear_data.o \ -mld_z_as_smoother_cnv.o \ -mld_z_as_smoother_csetc.o \ -mld_z_as_smoother_cseti.o \ -mld_z_as_smoother_dmp.o \ -mld_z_as_smoother_free.o \ -mld_z_as_smoother_prol_a.o \ -mld_z_as_smoother_prol_v.o \ -mld_z_as_smoother_restr_a.o \ -mld_z_as_smoother_restr_v.o \ -mld_z_base_smoother_apply.o \ -mld_z_base_smoother_apply_vect.o \ -mld_z_base_smoother_bld.o \ -mld_z_base_smoother_check.o \ -mld_z_base_smoother_clone.o \ -mld_z_base_smoother_clone_settings.o \ -mld_z_base_smoother_clear_data.o \ -mld_z_base_smoother_cnv.o \ -mld_z_base_smoother_csetc.o \ -mld_z_base_smoother_cseti.o \ -mld_z_base_smoother_csetr.o \ -mld_z_base_smoother_descr.o \ -mld_z_base_smoother_dmp.o \ -mld_z_base_smoother_free.o \ -mld_z_jac_smoother_apply.o \ -mld_z_jac_smoother_apply_vect.o \ -mld_z_jac_smoother_bld.o \ -mld_z_jac_smoother_descr.o \ -mld_z_jac_smoother_dmp.o \ -mld_z_jac_smoother_clone.o \ -mld_z_jac_smoother_clone_settings.o \ -mld_z_jac_smoother_clear_data.o \ -mld_z_jac_smoother_cnv.o \ -mld_z_jac_smoother_csetc.o \ -mld_z_jac_smoother_cseti.o \ -mld_z_jac_smoother_csetr.o \ -mld_z_l1_jac_smoother_bld.o \ -mld_z_l1_jac_smoother_descr.o \ -mld_z_l1_jac_smoother_clone.o \ +OBJS=amg_c_as_smoother_apply.o \ +amg_c_as_smoother_apply_vect.o \ +amg_c_as_smoother_bld.o \ +amg_c_as_smoother_check.o \ +amg_c_as_smoother_clone.o \ +amg_c_as_smoother_clone_settings.o \ +amg_c_as_smoother_clear_data.o \ +amg_c_as_smoother_cnv.o \ +amg_c_as_smoother_csetc.o \ +amg_c_as_smoother_cseti.o \ +amg_c_as_smoother_dmp.o \ +amg_c_as_smoother_free.o \ +amg_c_as_smoother_prol_a.o \ +amg_c_as_smoother_prol_v.o \ +amg_c_as_smoother_restr_a.o \ +amg_c_as_smoother_restr_v.o \ +amg_c_base_smoother_apply.o \ +amg_c_base_smoother_apply_vect.o \ +amg_c_base_smoother_bld.o \ +amg_c_base_smoother_check.o \ +amg_c_base_smoother_clone.o \ +amg_c_base_smoother_clone_settings.o \ +amg_c_base_smoother_clear_data.o \ +amg_c_base_smoother_cnv.o \ +amg_c_base_smoother_csetc.o \ +amg_c_base_smoother_cseti.o \ +amg_c_base_smoother_csetr.o \ +amg_c_base_smoother_descr.o \ +amg_c_base_smoother_dmp.o \ +amg_c_base_smoother_free.o \ +amg_c_jac_smoother_apply.o \ +amg_c_jac_smoother_apply_vect.o \ +amg_c_jac_smoother_bld.o \ +amg_c_jac_smoother_descr.o \ +amg_c_jac_smoother_dmp.o \ +amg_c_jac_smoother_clone.o \ +amg_c_jac_smoother_clone_settings.o \ +amg_c_jac_smoother_clear_data.o \ +amg_c_jac_smoother_cnv.o \ +amg_c_jac_smoother_csetc.o \ +amg_c_jac_smoother_cseti.o \ +amg_c_jac_smoother_csetr.o \ +amg_c_l1_jac_smoother_bld.o \ +amg_c_l1_jac_smoother_descr.o \ +amg_c_l1_jac_smoother_clone.o \ +amg_d_as_smoother_apply.o \ +amg_d_as_smoother_apply_vect.o \ +amg_d_as_smoother_bld.o \ +amg_d_as_smoother_check.o \ +amg_d_as_smoother_clone.o \ +amg_d_as_smoother_clone_settings.o \ +amg_d_as_smoother_clear_data.o \ +amg_d_as_smoother_cnv.o \ +amg_d_as_smoother_csetc.o \ +amg_d_as_smoother_cseti.o \ +amg_d_as_smoother_dmp.o \ +amg_d_as_smoother_free.o \ +amg_d_as_smoother_prol_a.o \ +amg_d_as_smoother_prol_v.o \ +amg_d_as_smoother_restr_a.o \ +amg_d_as_smoother_restr_v.o \ +amg_d_base_smoother_apply.o \ +amg_d_base_smoother_apply_vect.o \ +amg_d_base_smoother_bld.o \ +amg_d_base_smoother_check.o \ +amg_d_base_smoother_clone.o \ +amg_d_base_smoother_clone_settings.o \ +amg_d_base_smoother_clear_data.o \ +amg_d_base_smoother_cnv.o \ +amg_d_base_smoother_csetc.o \ +amg_d_base_smoother_cseti.o \ +amg_d_base_smoother_csetr.o \ +amg_d_base_smoother_descr.o \ +amg_d_base_smoother_dmp.o \ +amg_d_base_smoother_free.o \ +amg_d_jac_smoother_apply.o \ +amg_d_jac_smoother_apply_vect.o \ +amg_d_jac_smoother_bld.o \ +amg_d_jac_smoother_descr.o \ +amg_d_jac_smoother_dmp.o \ +amg_d_jac_smoother_clone.o \ +amg_d_jac_smoother_clone_settings.o \ +amg_d_jac_smoother_clear_data.o \ +amg_d_jac_smoother_cnv.o \ +amg_d_jac_smoother_csetc.o \ +amg_d_jac_smoother_cseti.o \ +amg_d_jac_smoother_csetr.o \ +amg_d_l1_jac_smoother_bld.o \ +amg_d_l1_jac_smoother_descr.o \ +amg_d_l1_jac_smoother_clone.o \ +amg_s_as_smoother_apply.o \ +amg_s_as_smoother_apply_vect.o \ +amg_s_as_smoother_bld.o \ +amg_s_as_smoother_check.o \ +amg_s_as_smoother_clone.o \ +amg_s_as_smoother_clone_settings.o \ +amg_s_as_smoother_clear_data.o \ +amg_s_as_smoother_cnv.o \ +amg_s_as_smoother_csetc.o \ +amg_s_as_smoother_cseti.o \ +amg_s_as_smoother_dmp.o \ +amg_s_as_smoother_free.o \ +amg_s_as_smoother_prol_a.o \ +amg_s_as_smoother_prol_v.o \ +amg_s_as_smoother_restr_a.o \ +amg_s_as_smoother_restr_v.o \ +amg_s_base_smoother_apply.o \ +amg_s_base_smoother_apply_vect.o \ +amg_s_base_smoother_bld.o \ +amg_s_base_smoother_check.o \ +amg_s_base_smoother_clone.o \ +amg_s_base_smoother_clone_settings.o \ +amg_s_base_smoother_clear_data.o \ +amg_s_base_smoother_cnv.o \ +amg_s_base_smoother_csetc.o \ +amg_s_base_smoother_cseti.o \ +amg_s_base_smoother_csetr.o \ +amg_s_base_smoother_descr.o \ +amg_s_base_smoother_dmp.o \ +amg_s_base_smoother_free.o \ +amg_s_jac_smoother_apply.o \ +amg_s_jac_smoother_apply_vect.o \ +amg_s_jac_smoother_bld.o \ +amg_s_jac_smoother_descr.o \ +amg_s_jac_smoother_dmp.o \ +amg_s_jac_smoother_clone.o \ +amg_s_jac_smoother_clone_settings.o \ +amg_s_jac_smoother_clear_data.o \ +amg_s_jac_smoother_cnv.o \ +amg_s_jac_smoother_csetc.o \ +amg_s_jac_smoother_cseti.o \ +amg_s_jac_smoother_csetr.o \ +amg_s_l1_jac_smoother_bld.o \ +amg_s_l1_jac_smoother_descr.o \ +amg_s_l1_jac_smoother_clone.o \ +amg_z_as_smoother_apply.o \ +amg_z_as_smoother_apply_vect.o \ +amg_z_as_smoother_bld.o \ +amg_z_as_smoother_check.o \ +amg_z_as_smoother_clone.o \ +amg_z_as_smoother_clone_settings.o \ +amg_z_as_smoother_clear_data.o \ +amg_z_as_smoother_cnv.o \ +amg_z_as_smoother_csetc.o \ +amg_z_as_smoother_cseti.o \ +amg_z_as_smoother_dmp.o \ +amg_z_as_smoother_free.o \ +amg_z_as_smoother_prol_a.o \ +amg_z_as_smoother_prol_v.o \ +amg_z_as_smoother_restr_a.o \ +amg_z_as_smoother_restr_v.o \ +amg_z_base_smoother_apply.o \ +amg_z_base_smoother_apply_vect.o \ +amg_z_base_smoother_bld.o \ +amg_z_base_smoother_check.o \ +amg_z_base_smoother_clone.o \ +amg_z_base_smoother_clone_settings.o \ +amg_z_base_smoother_clear_data.o \ +amg_z_base_smoother_cnv.o \ +amg_z_base_smoother_csetc.o \ +amg_z_base_smoother_cseti.o \ +amg_z_base_smoother_csetr.o \ +amg_z_base_smoother_descr.o \ +amg_z_base_smoother_dmp.o \ +amg_z_base_smoother_free.o \ +amg_z_jac_smoother_apply.o \ +amg_z_jac_smoother_apply_vect.o \ +amg_z_jac_smoother_bld.o \ +amg_z_jac_smoother_descr.o \ +amg_z_jac_smoother_dmp.o \ +amg_z_jac_smoother_clone.o \ +amg_z_jac_smoother_clone_settings.o \ +amg_z_jac_smoother_clear_data.o \ +amg_z_jac_smoother_cnv.o \ +amg_z_jac_smoother_csetc.o \ +amg_z_jac_smoother_cseti.o \ +amg_z_jac_smoother_csetr.o \ +amg_z_l1_jac_smoother_bld.o \ +amg_z_l1_jac_smoother_descr.o \ +amg_z_l1_jac_smoother_clone.o \ -LIBNAME=libmld_prec.a +LIBNAME=libamg_prec.a lib: $(OBJS) $(AR) $(HERE)/$(LIBNAME) $(OBJS) diff --git a/mlprec/impl/smoother/amg_c_as_smoother_apply.f90 b/mlprec/impl/smoother/amg_c_as_smoother_apply.f90 new file mode 100644 index 00000000..e5dec898 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_as_smoother_apply.f90 @@ -0,0 +1,235 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_as_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,info,init,initu) + use psb_base_mod + use amg_c_as_smoother, amg_protect_nam => amg_c_as_smoother_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_as_smoother_type), intent(inout) :: sm + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col, nrow_d, i + complex(psb_spk_), pointer :: aux(:) + complex(psb_spk_), allocatable :: tx(:),ty(:), ww(:) + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5) + character :: trans_, init_ + character(len=20) :: name='c_as_smoother_apply', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = desc_data%get_context() + call psb_info(ictxt,me,np) + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + n_row = sm%desc_data%get_local_rows() + n_col = sm%desc_data%get_local_cols() + nrow_d = desc_data%get_local_rows() + isz = max(n_row,N_COL) + + if ((4*isz) <= size(work)) then + aux => work(1:) + else + allocate(aux(4*isz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name,& + & i_err=(/4*isz,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + endif + + if ((.not.sm%sv%is_iterative()).and.(sweeps == 1).and.(sm%novr==0)) then + ! + ! Shortcut: in this case there is nothing else to be done. + ! + call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + else if (sweeps >= 0) then + ! + ! + ! Apply multiple sweeps of an AS solver + ! to compute an approximate solution of a linear system. + ! + ! + call psb_geasb(tx,sm%desc_data,info) + call psb_geasb(ty,sm%desc_data,info) + call psb_geasb(ww,sm%desc_data,info) + + ! + ! Unroll the first iteration and fold it inside SELECT CASE + ! this will save one SPMM when INIT=Z, and will be + ! significant when sweeps=1 (a common case) + ! + call psb_geaxpby(cone,x,czero,tx,desc_data,info) + if (info == 0) call sm%apply_restr(tx,trans_,aux,info) + if (info == 0) call psb_geaxpby(cone,tx,czero,ww,sm%desc_data,info) + + select case (init_) + case('Z') + call sm%sv%apply(cone,ww,czero,ty,sm%desc_data,trans_,aux,info,init='Z') + + case('Y') + call psb_geaxpby(cone,y,czero,ty,desc_data,info) + if (info == 0) call sm%apply_restr(ty,trans_,aux,info) + if (info == 0) call psb_spmm(-cone,sm%nd,ty,cone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + call sm%sv%apply(cone,ww,czero,ty,desc_data,trans_,aux,info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(cone,initu,czero,ty,desc_data,info) + if (info == 0) call sm%apply_restr(ty,trans_,aux,info) + if (info == 0) call psb_spmm(-cone,sm%nd,ty,cone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + call sm%sv%apply(cone,ww,czero,ty,desc_data,trans_,aux,info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + if (info == 0) call sm%apply_prol(ty,trans_,aux,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the + ! block diagonal part and the remaining part of the local matrix + ! and Y(j) is the approximate solution at sweep j. + ! + if (info == 0) call psb_geaxpby(cone,tx,czero,ww,sm%desc_data,info) + if (info == 0) call psb_spmm(-cone,sm%nd,ty,cone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(cone,ww,czero,ty,sm%desc_data,trans_,aux,info,init='Y') + + if (info /= psb_success_) exit + if (info == 0) call sm%apply_prol(ty,trans_,aux,info) + + end do + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + ! + ! Compute y = beta*y + alpha*ty (ty == K^(-1)*tx) + ! + call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + + else + + info = psb_err_iarg_neg_ + call psb_errpush(info,name,& + & i_err=(/itwo,sweeps,izero,izero,izero/)) + goto 9999 + + endif + + + if (.not.(4*isz <= size(work))) then + deallocate(aux,stat=info) + endif + if (info ==0) deallocate(ww,tx,ty,stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_as_smoother_apply diff --git a/mlprec/impl/smoother/amg_c_as_smoother_apply_vect.f90 b/mlprec/impl/smoother/amg_c_as_smoother_apply_vect.f90 new file mode 100644 index 00000000..81aa565c --- /dev/null +++ b/mlprec/impl/smoother/amg_c_as_smoother_apply_vect.f90 @@ -0,0 +1,259 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_as_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,wv,info,init,initu) + use psb_base_mod + use amg_c_as_smoother, amg_protect_nam => amg_c_as_smoother_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_as_smoother_type), intent(inout) :: sm + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col, nrow_d, i + complex(psb_spk_), pointer :: aux(:) + type(psb_c_vect_type) :: tx, ty, ww + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5) + character :: trans_, init_ + logical :: do_realloc_wv + character(len=20) :: name='c_as_smoother_apply_v', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = desc_data%get_context() + call psb_info(ictxt,me,np) + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + n_row = sm%desc_data%get_local_rows() + n_col = sm%desc_data%get_local_cols() + nrow_d = desc_data%get_local_rows() + isz = max(n_row,N_COL) + + if (4*isz <= size(work)) then + aux => work(:) + else + allocate(aux(4*isz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name,& + & i_err=(/4*isz,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + endif + + if ((.not.sm%sv%is_iterative()).and.(sweeps == 1).and.(sm%novr==0)) then + ! + ! Shortcut: in this case there is nothing else to be done. + ! + call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,wv,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + else if (sweeps >= 0) then + ! + ! + ! Apply multiple sweeps of an AS solver + ! to compute an approximate solution of a linear system. + ! + ! + if (size(wv) < 3) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='invalid wv size in smoother_apply') + goto 9999 + end if + + ! + ! This is tricky. This smoother has a descriptor sm%desc_data + ! for an index space potentially different from + ! that of desc_data. Hence the size of the work vectors + ! could be wrong. We need to check and reallocate as needed. + ! + do_realloc_wv = (wv(1)%get_nrows() < sm%desc_data%get_local_cols()).or.& + & (wv(2)%get_nrows() < sm%desc_data%get_local_cols()).or.& + & (wv(3)%get_nrows() < sm%desc_data%get_local_cols()) + + if (do_realloc_wv) then + call psb_geasb(wv(1),sm%desc_data,info,scratch=.true.,mold=wv(2)%v) + call psb_geasb(wv(2),sm%desc_data,info,scratch=.true.,mold=wv(1)%v) + call psb_geasb(wv(3),sm%desc_data,info,scratch=.true.,mold=wv(1)%v) + end if + + associate(tx => wv(1), ty => wv(2), ww => wv(3)) + + ! Need to zero tx because of the apply_restr call. + call tx%zero() + ! + ! Unroll the first iteration and fold it inside SELECT CASE + ! this will save one SPMM when INIT=Z, and will be + ! significant when sweeps=1 (a common case) + ! + call psb_geaxpby(cone,x,czero,tx,desc_data,info) + if (info == 0) call sm%apply_restr(tx,trans_,aux,info) + if (info == 0) call psb_geaxpby(cone,tx,czero,ww,sm%desc_data,info) + + select case (init_) + case('Z') + call sm%sv%apply(cone,ww,czero,ty,sm%desc_data,trans_,aux,wv(4:),info,init='Z') + + case('Y') + call psb_geaxpby(cone,y,czero,ty,desc_data,info) + if (info == 0) call sm%apply_restr(ty,trans_,aux,info) + if (info == 0) call psb_spmm(-cone,sm%nd,ty,cone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + call sm%sv%apply(cone,ww,czero,ty,desc_data,trans_,aux,wv(4:),info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(cone,initu,czero,ty,desc_data,info) + if (info == 0) call sm%apply_restr(ty,trans_,aux,info) + if (info == 0) call psb_spmm(-cone,sm%nd,ty,cone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + call sm%sv%apply(cone,ww,czero,ty,desc_data,trans_,aux,wv(4:),info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + if (info == 0) call sm%apply_prol(ty,trans_,aux,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the + ! block diagonal part and the remaining part of the local matrix + ! and Y(j) is the approximate solution at sweep j. + ! + if (info == 0) call psb_geaxpby(cone,tx,czero,ww,sm%desc_data,info) + if (info == 0) call psb_spmm(-cone,sm%nd,ty,cone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(cone,ww,czero,ty,sm%desc_data,trans_,aux,wv(4:),info,init='Y') + + if (info /= psb_success_) exit + if (info == 0) call sm%apply_prol(ty,trans_,aux,info) + + end do + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + ! + ! Compute y = beta*y + alpha*ty (ty == K^(-1)*tx) + ! + call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + end associate + + else + + info = psb_err_iarg_neg_ + call psb_errpush(info,name,& + & i_err=(/itwo,sweeps,izero,izero,izero/)) + goto 9999 + + endif + + + if (.not.(4*isz <= size(work))) then + deallocate(aux,stat=info) + endif + + if (info /= 0) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_as_smoother_apply_vect diff --git a/mlprec/impl/smoother/amg_c_as_smoother_bld.f90 b/mlprec/impl/smoother/amg_c_as_smoother_bld.f90 new file mode 100644 index 00000000..21ee898c --- /dev/null +++ b/mlprec/impl/smoother/amg_c_as_smoother_bld.f90 @@ -0,0 +1,183 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_as_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_c_as_smoother, amg_protect_nam => amg_c_as_smoother_bld + Implicit None + + ! Arguments + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local variables + type(psb_cspmat_type) :: blck, atmp + integer(psb_ipk_) :: n_row,n_col, nrow_a, nhalo, novr, data_ + complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='c_as_smoother_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + novr = sm%novr + if (novr < 0) then + info=psb_err_invalid_ovr_num_ + call psb_errpush(info,name,& + & i_err=(/novr,izero,izero,izero,izero,izero/)) + goto 9999 + endif + + if ((novr == 0).or.(np == 1)) then + call psb_cdcpy(desc_a,sm%desc_data,info) + If(debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' done cdcpy' + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_cdcpy' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Early return: P>=3 N_OVR=0' + call blck%csall(izero,izero,info,ione) + else + + ! + ! Build the auxiliary descriptor desc_p%matrix_data(psb_n_row_). + ! This is done by psb_cdbldext (interface to psb_cdovr), which is + ! independent of CSR, and has been placed in the tools directory + ! of PSBLAS, instead of the mlprec directory of MLD2P4, because it + ! might be used independently of the AS preconditioner, to build + ! a descriptor for an extended stencil in a PDE solver. + ! + call psb_cdbldext(a,desc_a,novr,sm%desc_data,info,extype=psb_ovt_asov_) + if(debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' From cdbldext _:',sm%desc_data%get_local_rows(),& + & sm%desc_data%get_local_cols() + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_cdbldext' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Before sphalo ' + + ! + ! Retrieve the remote sparse matrix rows required for the AS extended + ! matrix + data_ = psb_comm_ext_ + Call psb_sphalo(a,sm%desc_data,blck,info,data=data_,rowscale=.true.) + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_sphalo' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + if (debug_level >=psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'After psb_sphalo ',& + & blck%get_nrows(), blck%get_nzeros() + + End if + if (info == psb_success_) & + & call sm%sv%build(a,sm%desc_data,info,& + & blck,amold=amold,vmold=vmold) + + nrow_a = a%get_nrows() + n_row = sm%desc_data%get_local_rows() + n_col = sm%desc_data%get_local_cols() + + if (info == psb_success_) call a%csclip(sm%nd,info,& + & jmin=nrow_a+1,rscale=.false.,cscale=.false.) + if (info == psb_success_) call blck%csclip(atmp,info,& + & jmin=nrow_a+1,rscale=.false.,cscale=.false.) + if (info == psb_success_) call psb_rwextd(n_row,sm%nd,info,b=atmp) + + if (info == psb_success_) then + if (present(amold)) then + call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + else + call sm%nd%cscnv(info,& + & type='csr',dupl=psb_dupl_add_) + end if + end if + if (info == psb_success_) then + if (present(imold)) then + call sm%desc_data%cnv(imold) + end if + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='clip & psb_spcnv csr 4') + goto 9999 + end if + sm%nd_nnz_tot = sm%nd%get_nzeros() + call psb_sum(ictxt,sm%nd_nnz_tot) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_as_smoother_bld diff --git a/mlprec/impl/smoother/amg_c_as_smoother_check.f90 b/mlprec/impl/smoother/amg_c_as_smoother_check.f90 new file mode 100644 index 00000000..d9bcfcc8 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_as_smoother_check.f90 @@ -0,0 +1,78 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_as_smoother_check(sm,info) + + use psb_base_mod + use amg_c_as_smoother, amg_protect_nam => amg_c_as_smoother_check + + Implicit None + + ! Arguments + class(amg_c_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + Integer(Psb_ipk_) :: err_act + character(len=20) :: name='c_as_smoother_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + call amg_check_def(sm%restr,& + & 'Restrictor',psb_halo_,is_legal_restrict) + call amg_check_def(sm%prol,& + & 'Prolongator',psb_none_,is_legal_prolong) + call amg_check_def(sm%novr,& + & 'Overlap layers ',izero,is_int_non_negative) + + + if (allocated(sm%sv)) then + call sm%sv%check(info) + else + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_as_smoother_check diff --git a/mlprec/impl/smoother/amg_c_as_smoother_clear_data.f90 b/mlprec/impl/smoother/amg_c_as_smoother_clear_data.f90 new file mode 100644 index 00000000..5e363aef --- /dev/null +++ b/mlprec/impl/smoother/amg_c_as_smoother_clear_data.f90 @@ -0,0 +1,70 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_as_smoother_clear_data(sm,info) + + use psb_base_mod + use amg_c_as_smoother, amg_protect_name => amg_c_as_smoother_clear_data + Implicit None + ! Arguments + class(amg_c_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_as_smoother_clear_data' + + call psb_erractionsave(err_act) + + info = 0 + call sm%nd%free() + sm%nd_nnz_tot = 0 + call sm%desc_data%free(info) + if ((info==0).and.allocated(sm%sv)) then + call sm%sv%clear_data(info) + end if + if (info /= 0) then + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_as_smoother_clear_data diff --git a/mlprec/impl/smoother/amg_c_as_smoother_clone.f90 b/mlprec/impl/smoother/amg_c_as_smoother_clone.f90 new file mode 100644 index 00000000..c6b7dcbd --- /dev/null +++ b/mlprec/impl/smoother/amg_c_as_smoother_clone.f90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_as_smoother_clone(sm,smout,info) + + use psb_base_mod + use amg_c_as_smoother, amg_protect_name => amg_c_as_smoother_clone + + Implicit None + + ! Arguments + class(amg_c_as_smoother_type), intent(inout) :: sm + class(amg_c_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(smout)) then + call smout%free(info) + if (info == psb_success_) deallocate(smout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_c_as_smoother_type :: smout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(smo => smout) + type is (amg_c_as_smoother_type) + smo%novr = sm%novr + smo%restr = sm%restr + smo%prol = sm%prol + smo%nd_nnz_tot = sm%nd_nnz_tot + call sm%nd%clone(smo%nd,info) + if (info == psb_success_) & + & call sm%desc_data%clone(smo%desc_data,info) + if ((info==psb_success_).and.(allocated(sm%sv))) then + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == psb_success_) call sm%sv%clone(smo%sv,info) + end if + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_as_smoother_clone diff --git a/mlprec/impl/smoother/amg_c_as_smoother_clone_settings.f90 b/mlprec/impl/smoother/amg_c_as_smoother_clone_settings.f90 new file mode 100644 index 00000000..a5c2085b --- /dev/null +++ b/mlprec/impl/smoother/amg_c_as_smoother_clone_settings.f90 @@ -0,0 +1,95 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! asd on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_as_smoother_clone_settings(sm,smout,info) + + use psb_base_mod + use amg_c_as_smoother, amg_protect_name => amg_c_as_smoother_clone_settings + Implicit None + ! Arguments + class(amg_c_as_smoother_type), intent(inout) :: sm + class(amg_c_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_as_smoother_clone_settings' + + call psb_erractionsave(err_act) + + info = psb_success_ + + select type(smout) + class is(amg_c_as_smoother_type) + smout%novr = sm%novr + smout%restr = sm%restr + smout%prol = sm%prol + if (allocated(smout%sv)) then + if (.not.same_type_as(sm%sv,smout%sv)) then + call smout%sv%free(info) + if (info == 0) deallocate(smout%sv,stat=info) + end if + end if + if (info /= 0) then + info = psb_err_internal_error_ + else + if (allocated(smout%sv)) then + if (same_type_as(sm%sv,smout%sv)) then + call sm%sv%clone_settings(smout%sv,info) + else + info = psb_err_internal_error_ + end if + else + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == 0) call sm%sv%clone_settings(smout%sv,info) + if (info /= 0) info = psb_err_internal_error_ + end if + end if + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_as_smoother_clone_settings diff --git a/mlprec/impl/smoother/amg_c_as_smoother_cnv.f90 b/mlprec/impl/smoother/amg_c_as_smoother_cnv.f90 new file mode 100644 index 00000000..b4ccdd8d --- /dev/null +++ b/mlprec/impl/smoother/amg_c_as_smoother_cnv.f90 @@ -0,0 +1,96 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_as_smoother_cnv(sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_c_as_smoother, amg_protect_nam => amg_c_as_smoother_cnv + Implicit None + + ! Arguments + class(amg_c_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local variables + type(psb_dspmat_type) :: blck, atmp + integer(psb_ipk_) :: n_row,n_col, nrow_a, nhalo, novr, data_, nzeros + real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_as_smoother_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = sm%desc_data%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + if (allocated(sm%sv)) & + & call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) + + if (info == psb_success_) then + if (present(amold)) then + if (sm%nd%is_asb()) call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + end if + end if + if (info == psb_success_) then + if (present(imold)) then + call sm%desc_data%cnv(imold) + end if + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='clip & psb_spcnv csr 4') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_as_smoother_cnv diff --git a/mlprec/impl/smoother/amg_c_as_smoother_csetc.f90 b/mlprec/impl/smoother/amg_c_as_smoother_csetc.f90 new file mode 100644 index 00000000..1c4b1726 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_as_smoother_csetc.f90 @@ -0,0 +1,78 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_as_smoother_csetc(sm,what,val,info,idx) + + use psb_base_mod + use amg_c_as_smoother, amg_protect_nam => amg_c_as_smoother_csetc + Implicit None + ! Arguments + class(amg_c_as_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='c_as_smoother_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + + + ival = sm%stringval(val) + select case(psb_toupper(what)) + case('SUB_RESTR') + sm%restr = ival + case('SUB_PROL') + sm%prol = ival + case default + call sm%amg_c_base_smoother_type%set(what,val,info,idx=idx) + end select + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info, name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_as_smoother_csetc diff --git a/mlprec/impl/smoother/amg_c_as_smoother_cseti.f90 b/mlprec/impl/smoother/amg_c_as_smoother_cseti.f90 new file mode 100644 index 00000000..40c74958 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_as_smoother_cseti.f90 @@ -0,0 +1,73 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_as_smoother_cseti(sm,what,val,info,idx) + + use psb_base_mod + use amg_c_as_smoother, amg_protect_nam => amg_c_as_smoother_cseti + Implicit None + + ! Arguments + class(amg_c_as_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_as_smoother_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) + case('SUB_OVR') + sm%novr = val + case('SUB_RESTR') + sm%restr = val + case('SUB_PROL') + sm%prol = val + case default + call sm%amg_c_base_smoother_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_as_smoother_cseti diff --git a/mlprec/impl/smoother/amg_c_as_smoother_dmp.f90 b/mlprec/impl/smoother/amg_c_as_smoother_dmp.f90 new file mode 100644 index 00000000..f0b1c4bf --- /dev/null +++ b/mlprec/impl/smoother/amg_c_as_smoother_dmp.f90 @@ -0,0 +1,92 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_as_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + + use psb_base_mod + use amg_c_as_smoother, amg_protect_nam => amg_c_as_smoother_dmp + implicit none + class(amg_c_as_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: smoother_, global_num_ + ! len of prefix_ + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_smth_c" + end if + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(smoother)) then + smoother_ = smoother + else + smoother_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + if (global_num_) then + write(0,*) iam,' Warning: no global num with AS smoothers dump' + end if + if (smoother_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_nd.mtx' + if (sm%nd%is_asb()) & + & call sm%nd%print(fname,head=head) + end if + ! At base level do nothing for the smoother + if (allocated(sm%sv)) & + & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) + +end subroutine amg_c_as_smoother_dmp diff --git a/mlprec/impl/smoother/amg_c_as_smoother_free.f90 b/mlprec/impl/smoother/amg_c_as_smoother_free.f90 new file mode 100644 index 00000000..2da897c2 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_as_smoother_free.f90 @@ -0,0 +1,71 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_as_smoother_free(sm,info) + + use psb_base_mod + use amg_c_as_smoother, amg_protect_nam => amg_c_as_smoother_free + Implicit None + ! Arguments + class(amg_c_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_as_smoother_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + + + if (allocated(sm%sv)) then + call sm%sv%free(info) + if (info == psb_success_) deallocate(sm%sv,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + end if + call sm%nd%free() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_as_smoother_free diff --git a/mlprec/impl/smoother/amg_c_as_smoother_prol_a.f90 b/mlprec/impl/smoother/amg_c_as_smoother_prol_a.f90 new file mode 100644 index 00000000..d4b73d20 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_as_smoother_prol_a.f90 @@ -0,0 +1,149 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_as_smoother_prol_a(sm,x,trans,work,info,data) + use psb_base_mod + use amg_c_as_smoother, amg_protect_nam => amg_c_as_smoother_prol_a + implicit none + class(amg_c_as_smoother_type), intent(inout) :: sm + complex(psb_spk_), intent(inout) :: x(:) + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + !Local + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ + character :: trans_ + character(len=20) :: name='c_as_smther_prol_a', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = sm%desc_data%get_context() + call psb_info(ictxt,me,np) + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + info = psb_err_iarg_invalid_i_ + call psb_errpush(info,name) + goto 9999 + end select + + if (present(data)) then + data_ = data + else + data_ = psb_comm_ext_ + end if + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + + select case(trans_) + case('N') + + select case (sm%prol) + + case(psb_none_) + ! + ! Would work anyway, but since it is supposed to do nothing ... + ! call psb_ovrl(x,sm%desc_data,info,& + ! & update=sm%prol,work=work) + + + case(psb_sum_,psb_avg_) + ! + ! Update the overlap of x + ! + call psb_ovrl(x,sm%desc_data,info,& + & update=sm%prol,work=work) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_prol_') + goto 9999 + end select + + case('T','C') + ! + ! With transpose, we have to do it here + ! + if (sm%restr == psb_halo_) then + call psb_ovrl(x,sm%desc_data,info,& + & update=psb_sum_,work=work) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + else if (sm%restr /= psb_none_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_restr_') + goto 9999 + end if + + case default + info=psb_err_iarg_invalid_i_ + int_err(1)=6 + ch_err(2:2)=trans + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_as_smoother_prol_a + + diff --git a/mlprec/impl/smoother/amg_c_as_smoother_prol_v.f90 b/mlprec/impl/smoother/amg_c_as_smoother_prol_v.f90 new file mode 100644 index 00000000..07c3e18e --- /dev/null +++ b/mlprec/impl/smoother/amg_c_as_smoother_prol_v.f90 @@ -0,0 +1,149 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_as_smoother_prol_v(sm,x,trans,work,info,data) + use psb_base_mod + use amg_c_as_smoother, amg_protect_nam => amg_c_as_smoother_prol_v + implicit none + class(amg_c_as_smoother_type), intent(inout) :: sm + type(psb_c_vect_type),intent(inout) :: x + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + !Local + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ + character :: trans_ + character(len=20) :: name='c_as_smther_prol_v', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = sm%desc_data%get_context() + call psb_info(ictxt,me,np) + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + info = psb_err_iarg_invalid_i_ + call psb_errpush(info,name) + goto 9999 + end select + + if (present(data)) then + data_ = data + else + data_ = psb_comm_ext_ + end if + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + + select case(trans_) + case('N') + + select case (sm%prol) + + case(psb_none_) + ! + ! Would work anyway, but since it is supposed to do nothing ... + ! call psb_ovrl(x,sm%desc_data,info,& + ! & update=sm%prol,work=work) + + + case(psb_sum_,psb_avg_) + ! + ! Update the overlap of x + ! + call psb_ovrl(x,sm%desc_data,info,& + & update=sm%prol,work=work) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_prol_') + goto 9999 + end select + + case('T','C') + ! + ! With transpose, we have to do it here + ! + if (sm%restr == psb_halo_) then + call psb_ovrl(x,sm%desc_data,info,& + & update=psb_sum_,work=work) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + else if (sm%restr /= psb_none_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_restr_') + goto 9999 + end if + + case default + info=psb_err_iarg_invalid_i_ + int_err(1)=6 + ch_err(2:2)=trans + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_as_smoother_prol_v + + diff --git a/mlprec/impl/smoother/amg_c_as_smoother_restr_a.f90 b/mlprec/impl/smoother/amg_c_as_smoother_restr_a.f90 new file mode 100644 index 00000000..27d695aa --- /dev/null +++ b/mlprec/impl/smoother/amg_c_as_smoother_restr_a.f90 @@ -0,0 +1,168 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_as_smoother_restr_a(sm,x,trans,work,info,data) + use psb_base_mod + use amg_c_as_smoother, amg_protect_nam => amg_c_as_smoother_restr_a + implicit none + class(amg_c_as_smoother_type), intent(inout) :: sm + complex(psb_spk_), intent(inout) :: x(:) + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + !Local + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ + character :: trans_ + character(len=20) :: name='c_as_smther_restr_a', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = sm%desc_data%get_context() + call psb_info(ictxt,me,np) + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + info = psb_err_iarg_invalid_i_ + call psb_errpush(info,name) + goto 9999 + end select + + if (present(data)) then + data_ = data + else + data_ = psb_comm_ext_ + end if + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + select case(trans_) + case('N') + ! + ! Get the overlap entries x + ! + if (sm%restr == psb_halo_) then + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + else if (sm%restr /= psb_none_) then + call psb_errpush(psb_err_internal_error_,name,& + &a_err='Invalid amg_sub_restr_') + goto 9999 + end if + + + case('T','C') + ! + ! With transpose, we have to do it here + ! + + select case (sm%prol) + + case(psb_none_) + ! + ! Do nothing + + case(psb_sum_) + ! + ! The transpose of sum is halo + ! + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + + case(psb_avg_) + ! + ! Tricky one: first we have to scale the overlap entries, + ! which we can do by assignind mode=0, i.e. no communication + ! (hence only scaling), then we do the halo + ! + call psb_ovrl(x,sm%desc_data,info,& + & update=psb_avg_,work=work,mode=izero) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_prol_') + goto 9999 + end select + + + case default + info=psb_err_iarg_invalid_i_ + int_err(1)=6 + ch_err(2:2)=trans + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_as_smoother_restr_a + + diff --git a/mlprec/impl/smoother/amg_c_as_smoother_restr_v.f90 b/mlprec/impl/smoother/amg_c_as_smoother_restr_v.f90 new file mode 100644 index 00000000..5079e3eb --- /dev/null +++ b/mlprec/impl/smoother/amg_c_as_smoother_restr_v.f90 @@ -0,0 +1,168 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_as_smoother_restr_v(sm,x,trans,work,info,data) + use psb_base_mod + use amg_c_as_smoother, amg_protect_nam => amg_c_as_smoother_restr_v + implicit none + class(amg_c_as_smoother_type), intent(inout) :: sm + type(psb_c_vect_type),intent(inout) :: x + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + !Local + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ + character :: trans_ + character(len=20) :: name='c_as_smther_restr_v', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = sm%desc_data%get_context() + call psb_info(ictxt,me,np) + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + info = psb_err_iarg_invalid_i_ + call psb_errpush(info,name) + goto 9999 + end select + + if (present(data)) then + data_ = data + else + data_ = psb_comm_ext_ + end if + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + select case(trans_) + case('N') + ! + ! Get the overlap entries x + ! + if (sm%restr == psb_halo_) then + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + else if (sm%restr /= psb_none_) then + call psb_errpush(psb_err_internal_error_,name,& + &a_err='Invalid amg_sub_restr_') + goto 9999 + end if + + + case('T','C') + ! + ! With transpose, we have to do it here + ! + + select case (sm%prol) + + case(psb_none_) + ! + ! Do nothing + + case(psb_sum_) + ! + ! The transpose of sum is halo + ! + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + + case(psb_avg_) + ! + ! Tricky one: first we have to scale the overlap entries, + ! which we can do by assignind mode=0, i.e. no communication + ! (hence only scaling), then we do the halo + ! + call psb_ovrl(x,sm%desc_data,info,& + & update=psb_avg_,work=work,mode=izero) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_prol_') + goto 9999 + end select + + + case default + info=psb_err_iarg_invalid_i_ + int_err(1)=6 + ch_err(2:2)=trans + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_as_smoother_restr_v + + diff --git a/mlprec/impl/smoother/amg_c_base_smoother_apply.f90 b/mlprec/impl/smoother/amg_c_base_smoother_apply.f90 new file mode 100644 index 00000000..6f08989d --- /dev/null +++ b/mlprec/impl/smoother/amg_c_base_smoother_apply.f90 @@ -0,0 +1,87 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_smoother_apply(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,info,init,initu) + use psb_base_mod + use amg_c_base_smoother_mod, amg_protect_name => amg_c_base_smoother_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_base_smoother_type), intent(inout) :: sm + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_smoother_apply' + + call psb_erractionsave(err_act) + info = psb_success_ + if (sweeps == 0) then + + ! + ! K^0 = I + ! zero sweeps of any smoother is just the identity. + ! + call psb_geaxpby(alpha,x,beta,y,desc_data,info) + + else + if (allocated(sm%sv)) then + call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,info,init=init, initu=initu) + else + info = 1121 + endif + end if + if (info /= psb_success_) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_base_smoother_apply diff --git a/mlprec/impl/smoother/amg_c_base_smoother_apply_vect.f90 b/mlprec/impl/smoother/amg_c_base_smoother_apply_vect.f90 new file mode 100644 index 00000000..d34a2d59 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_base_smoother_apply_vect.f90 @@ -0,0 +1,88 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,wv,info,init,initu) + use psb_base_mod + use amg_c_base_smoother_mod, amg_protect_name => amg_c_base_smoother_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_base_smoother_type), intent(inout) :: sm + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + ! + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_smoother_apply' + + call psb_erractionsave(err_act) + info = psb_success_ + if (sweeps == 0) then + + ! + ! K^0 = I + ! zero sweeps of any smoother is just the identity. + ! + call psb_geaxpby(alpha,x,beta,y,desc_data,info) + + else + if (allocated(sm%sv)) then + call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,wv,info,init=init, initu=initu) + else + info = 1121 + endif + end if + if (info /= psb_success_) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_base_smoother_apply_vect diff --git a/mlprec/impl/smoother/amg_c_base_smoother_bld.f90 b/mlprec/impl/smoother/amg_c_base_smoother_bld.f90 new file mode 100644 index 00000000..1c9ec00f --- /dev/null +++ b/mlprec/impl/smoother/amg_c_base_smoother_bld.f90 @@ -0,0 +1,72 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_c_base_smoother_mod, amg_protect_name => amg_c_base_smoother_bld + Implicit None + + ! Arguments + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_smoother_bld' + + call psb_erractionsave(err_act) + + info = psb_success_ + if (allocated(sm%sv)) then + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + else + info = 1121 + call psb_errpush(info,name) + endif + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_smoother_bld diff --git a/mlprec/impl/smoother/amg_c_base_smoother_check.f90 b/mlprec/impl/smoother/amg_c_base_smoother_check.f90 new file mode 100644 index 00000000..e733ae9b --- /dev/null +++ b/mlprec/impl/smoother/amg_c_base_smoother_check.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_smoother_check(sm,info) + + use psb_base_mod + use amg_c_base_smoother_mod, amg_protect_name => amg_c_base_smoother_check + Implicit None + + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + Integer(Psb_ipk_) :: err_act + character(len=20) :: name='c_base_smoother_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%check(info) + else + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_smoother_check diff --git a/mlprec/impl/smoother/amg_c_base_smoother_clear_data.f90 b/mlprec/impl/smoother/amg_c_base_smoother_clear_data.f90 new file mode 100644 index 00000000..51ba86f4 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_base_smoother_clear_data.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_smoother_clear_data(sm,info) + + use psb_base_mod + use amg_c_base_smoother_mod, amg_protect_name => amg_c_base_smoother_clear_data + Implicit None + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_smoother_clear_data' + + call psb_erractionsave(err_act) + + info = 0 + if (allocated(sm%sv)) then + call sm%sv%clear_data(info) + if (info /= 0) then + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_smoother_clear_data diff --git a/mlprec/impl/smoother/amg_c_base_smoother_clone.f90 b/mlprec/impl/smoother/amg_c_base_smoother_clone.f90 new file mode 100644 index 00000000..31ddb8bc --- /dev/null +++ b/mlprec/impl/smoother/amg_c_base_smoother_clone.f90 @@ -0,0 +1,62 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_smoother_clone(sm,smout,info) + + use psb_base_mod + use amg_c_base_smoother_mod, amg_protect_name => amg_c_base_smoother_clone + Implicit None + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + class(amg_c_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_smoother_clone' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_smoother_clone diff --git a/mlprec/impl/smoother/amg_c_base_smoother_clone_settings.f90 b/mlprec/impl/smoother/amg_c_base_smoother_clone_settings.f90 new file mode 100644 index 00000000..93fb6090 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_base_smoother_clone_settings.f90 @@ -0,0 +1,89 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_smoother_clone_settings(sm,smout,info) + + use psb_base_mod + use amg_c_base_smoother_mod, amg_protect_name => amg_c_base_smoother_clone_settings + Implicit None + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + class(amg_c_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_smoother_clone_settings' + + call psb_erractionsave(err_act) + + info=psb_success_ + if (same_type_as(sm,smout)) then + if (allocated(smout%sv)) then + if (.not.same_type_as(sm%sv,smout%sv)) then + call smout%sv%free(info) + if (info == 0) deallocate(smout%sv,stat=info) + end if + end if + if (info /= 0) then + info = psb_err_internal_error_ + else + if (allocated(smout%sv)) then + if (same_type_as(sm%sv,smout%sv)) then + call sm%sv%clone_settings(smout%sv,info) + else + info = psb_err_internal_error_ + end if + else + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == 0) call sm%sv%clone_settings(smout%sv,info) + if (info /= 0) info = psb_err_internal_error_ + end if + end if + else + info = psb_err_internal_error_ + end if + if (info /= 0) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_smoother_clone_settings diff --git a/mlprec/impl/smoother/amg_c_base_smoother_cnv.f90 b/mlprec/impl/smoother/amg_c_base_smoother_cnv.f90 new file mode 100644 index 00000000..78f37816 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_base_smoother_cnv.f90 @@ -0,0 +1,70 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_smoother_cnv(sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_c_base_smoother_mod, amg_protect_name => amg_c_base_smoother_cnv + Implicit None + + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_smoother_cnv' + + call psb_erractionsave(err_act) + + info = psb_success_ + if (allocated(sm%sv)) then + call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) + else + info = 1121 + call psb_errpush(info,name) + endif + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_smoother_cnv diff --git a/mlprec/impl/smoother/amg_c_base_smoother_csetc.f90 b/mlprec/impl/smoother/amg_c_base_smoother_csetc.f90 new file mode 100644 index 00000000..c420c249 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_base_smoother_csetc.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_smoother_csetc(sm,what,val,info,idx) + + use psb_base_mod + use amg_c_base_smoother_mod, amg_protect_name => amg_c_base_smoother_csetc + Implicit None + + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='c_base_smoother_csetc' + + call psb_erractionsave(err_act) + + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%set(what,val,info,idx=idx) + end if + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_smoother_csetc diff --git a/mlprec/impl/smoother/amg_c_base_smoother_cseti.f90 b/mlprec/impl/smoother/amg_c_base_smoother_cseti.f90 new file mode 100644 index 00000000..f0f7ded2 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_base_smoother_cseti.f90 @@ -0,0 +1,65 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_smoother_cseti(sm,what,val,info,idx) + + use psb_base_mod + use amg_c_base_smoother_mod, amg_protect_name => amg_c_base_smoother_cseti + Implicit None + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_smoother_cseti' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%set(what,val,info,idx=idx) + end if + if (info /= psb_success_) goto 9999 + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_smoother_cseti diff --git a/mlprec/impl/smoother/amg_c_base_smoother_csetr.f90 b/mlprec/impl/smoother/amg_c_base_smoother_csetr.f90 new file mode 100644 index 00000000..de878051 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_base_smoother_csetr.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_smoother_csetr(sm,what,val,info,idx) + + use psb_base_mod + use amg_c_base_smoother_mod, amg_protect_name => amg_c_base_smoother_csetr + Implicit None + + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_smoother_csetr' + + call psb_erractionsave(err_act) + + + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%set(what,val,info,idx=idx) + end if + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_smoother_csetr diff --git a/mlprec/impl/smoother/amg_c_base_smoother_descr.f90 b/mlprec/impl/smoother/amg_c_base_smoother_descr.f90 new file mode 100644 index 00000000..8461b1b4 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_base_smoother_descr.f90 @@ -0,0 +1,101 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_smoother_descr(sm,info,iout,coarse) + + use psb_base_mod + use amg_c_base_smoother_mod, amg_protect_name => amg_c_base_smoother_descr + use amg_c_id_solver + Implicit None + + ! Arguments + class(amg_c_base_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt, me, np + character(len=20), parameter :: name='amg_c_base_smoother_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse_ + + + call psb_erractionsave(err_act) + info = psb_success_ + + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + + if (coarse_) then + if (allocated(sm%sv)) call sm%sv%descr(info,iout,coarse) + else + if (allocated(sm%sv)) then + select type (sv => sm%sv) + class is (amg_c_id_solver_type) + write(iout_,*) 'No preconditioner/smoother' + class default + write(iout_,*) 'Decoupled preconditioner/smoother with local solver' + call sm%sv%descr(info,iout,coarse) + end select + else + write(iout_,*) 'No preconditioner/smoother' + end if + end if + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='Local solver') + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_smoother_descr diff --git a/mlprec/impl/smoother/amg_c_base_smoother_dmp.f90 b/mlprec/impl/smoother/amg_c_base_smoother_dmp.f90 new file mode 100644 index 00000000..3efda725 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_base_smoother_dmp.f90 @@ -0,0 +1,85 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + + use psb_base_mod + use amg_c_base_smoother_mod, amg_protect_name => amg_c_base_smoother_dmp + implicit none + class(amg_c_base_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: smoother_, global_num_ + ! len of prefix_ + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_smth_c" + end if + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + if (present(smoother)) then + smoother_ = smoother + else + smoother_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + ! At base level do nothing for the smoother + if (allocated(sm%sv)) & + & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) + +end subroutine amg_c_base_smoother_dmp diff --git a/mlprec/impl/smoother/amg_c_base_smoother_free.f90 b/mlprec/impl/smoother/amg_c_base_smoother_free.f90 new file mode 100644 index 00000000..098b36c7 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_base_smoother_free.f90 @@ -0,0 +1,68 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_smoother_free(sm,info) + + use psb_base_mod + use amg_c_base_smoother_mod, amg_protect_name => amg_c_base_smoother_free + Implicit None + + ! Arguments + class(amg_c_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_smoother_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%free(info) + if (info == psb_success_) deallocate(sm%sv,stat=info) + end if + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_smoother_free diff --git a/mlprec/impl/smoother/amg_c_jac_smoother_apply.f90 b/mlprec/impl/smoother/amg_c_jac_smoother_apply.f90 new file mode 100644 index 00000000..589314bf --- /dev/null +++ b/mlprec/impl/smoother/amg_c_jac_smoother_apply.f90 @@ -0,0 +1,273 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_jac_smoother_apply(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,info,init,initu) + use psb_base_mod + use amg_c_jac_smoother, amg_protect_name => amg_c_jac_smoother_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_jac_smoother_type), intent(inout) :: sm + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col + complex(psb_spk_), allocatable :: tx(:),ty(:) + complex(psb_spk_), pointer :: aux(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='c_jac_smoother_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = desc_data%get_context() + call psb_info(ictxt,me,np) + + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (4*n_col <= size(work)) then + aux => work(:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + endif + + if ((.not.sm%sv%is_iterative()).and.((sweeps == 1).or.(sm%nd_nnz_tot==0))) then + ! if .not.sv%is_iterative, there's no need to pass init + call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + else if (sweeps >= 0) then + if (associated(sm%pa)) then + ! + ! This means we are dealing with a pure Jacobi smoother/solver. + ! + call psb_geasb(tx,desc_data,info) + call psb_geasb(ty,desc_data,info) + select case (init_) + case('Z') + + call sm%sv%apply(cone,x,czero,ty,desc_data,trans_,aux,info,init='Z') + + case('Y') + call psb_geaxpby(cone,x,czero,tx,desc_data,info) + call psb_geaxpby(cone,y,czero,ty,desc_data,info) + call psb_spmm(-cone,sm%pa,ty,cone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(cone,x,czero,tx,desc_data,info) + call psb_geaxpby(cone,initu,czero,ty,desc_data,info) + call psb_spmm(-cone,sm%pa,ty,cone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = Y(j)+ D^(-1)*(X-A*Y(j)), + ! where is the diagonal and A the matrix. + ! + call psb_geaxpby(cone,x,czero,tx,desc_data,info) + call psb_spmm(-cone,sm%pa,ty,cone,tx,desc_data,info,work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(cone,tx,cone,ty,desc_data,trans_,aux,info,init='Y') + + if (info /= psb_success_) exit + end do + + + if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + else + ! + ! + ! Apply multiple sweeps of a block-Jacobi solver + ! to compute an approximate solution of a linear system. + ! + ! + call psb_geasb(tx,desc_data,info) + call psb_geasb(ty,desc_data,info) + + ! + ! Unroll the first iteration and fold it inside SELECT CASE + ! this will save one AXPBY and one SPMM when INIT=Z, and will be + ! significant when sweeps=1 (a common case) + ! + select case (init_) + case('Z') + + call sm%sv%apply(cone,x,czero,ty,desc_data,trans_,aux,info,init='Z') + + case('Y') + call psb_geaxpby(cone,x,czero,tx,desc_data,info) + call psb_geaxpby(cone,y,czero,ty,desc_data,info) + call psb_spmm(-cone,sm%nd,ty,cone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(cone,x,czero,tx,desc_data,info) + call psb_geaxpby(cone,initu,czero,ty,desc_data,info) + call psb_spmm(-cone,sm%nd,ty,cone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the + ! block diagonal part and the remaining part of the local matrix + ! and Y(j) is the approximate solution at sweep j. + ! + call psb_geaxpby(cone,x,czero,tx,desc_data,info) + call psb_spmm(-cone,sm%nd,ty,cone,tx,desc_data,info,work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,info,init='Y') + + if (info /= psb_success_) exit + end do + + if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + end if + + deallocate(tx,ty,stat=info) + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='final cleanup with Jacobi sweeps > 1') + goto 9999 + end if + + else + + info = psb_err_iarg_neg_ + call psb_errpush(info,name,& + & i_err=(/itwo,sweeps,izero,izero,izero/)) + goto 9999 + + endif + + if (.not.(4*n_col <= size(work))) then + deallocate(aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_jac_smoother_apply diff --git a/mlprec/impl/smoother/amg_c_jac_smoother_apply_vect.f90 b/mlprec/impl/smoother/amg_c_jac_smoother_apply_vect.f90 new file mode 100644 index 00000000..42d3fdbc --- /dev/null +++ b/mlprec/impl/smoother/amg_c_jac_smoother_apply_vect.f90 @@ -0,0 +1,320 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_jac_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,wv,info,init,initu) + + use psb_base_mod + use amg_c_diag_solver + use psb_base_krylov_conv_mod, only : log_conv + use amg_c_jac_smoother, amg_protect_name => amg_c_jac_smoother_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_jac_smoother_type), intent(inout) :: sm + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + ! + integer(psb_ipk_) :: n_row,n_col + type(psb_c_vect_type) :: tx, ty, r + complex(psb_spk_), pointer :: aux(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + real(psb_dpk_) :: res, resdenum + character(len=20) :: name='c_jac_smoother_apply_v' + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = desc_data%get_context() + call psb_info(ictxt,me,np) + + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (4*n_col <= size(work)) then + aux => work(:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + endif + + if(sm%checkres) then + call psb_geall(r,desc_data,info) + call psb_geasb(r,desc_data,info) + resdenum = psb_genrm2(x,desc_data,info) + end if + + if ((.not.sm%sv%is_iterative()).and.((sweeps == 1).or.(sm%nd_nnz_tot==0))) then + ! if .not.sv%is_iterative, there's no need to pass init + call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,wv,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + else if (sweeps >= 0) then + select type (smsv => sm%sv) + class is (amg_c_diag_solver_type) + ! + ! This means we are dealing with a pure Jacobi smoother/solver. + ! + associate(tx => wv(1), ty => wv(2)) + select case (init_) + case('Z') + + call sm%sv%apply(cone,x,czero,ty,desc_data,trans_,aux,wv(3:),info,init='Z') + + case('Y') + call psb_geaxpby(cone,x,czero,tx,desc_data,info) + call psb_geaxpby(cone,y,czero,ty,desc_data,info) + call psb_spmm(-cone,sm%pa,ty,cone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(cone,x,czero,tx,desc_data,info) + call psb_geaxpby(cone,initu,czero,ty,desc_data,info) + call psb_spmm(-cone,sm%pa,ty,cone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = Y(j)+ D^(-1)*(X-A*Y(j)), + ! where is the diagonal and A the matrix. + ! + call psb_geaxpby(cone,x,czero,tx,desc_data,info) + call psb_spmm(-cone,sm%pa,ty,cone,tx,desc_data,info,work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(cone,tx,cone,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + if (info /= psb_success_) exit + + if ( sm%checkres.and.(mod(i,sm%checkiter) == 0) ) then + call psb_geaxpby(cone,x,czero,r,r,desc_data,info) + call psb_spmm(-cone,sm%pa,ty,cone,r,desc_data,info) + res = psb_genrm2(r,desc_data,info) + if( sm%printres ) then + call log_conv("BJAC",me,i,sm%printiter,res,resdenum,sm%tol) + end if + if ( res < sm%tol*resdenum ) then + if( (sm%printres).and.(mod(sm%printiter,sm%checkiter)/=0) ) & + & call log_conv("BJAC",me,i,1,res,resdenum,sm%tol) + exit + end if + end if + + end do + + + if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + + end associate + + class default + ! + ! + ! Apply multiple sweeps of a block-Jacobi solver + ! to compute an approximate solution of a linear system. + ! + ! + if (size(wv) < 2) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size in smoother_apply') + goto 9999 + end if + associate(tx => wv(1), ty => wv(2)) + + ! + ! Unroll the first iteration and fold it inside SELECT CASE + ! this will save one AXPBY and one SPMM when INIT=Z, and will be + ! significant when sweeps=1 (a common case) + ! + select case (init_) + case('Z') + + call sm%sv%apply(cone,x,czero,ty,desc_data,trans_,aux,wv(3:),info,init='Z') + + case('Y') + call psb_geaxpby(cone,x,czero,tx,desc_data,info) + call psb_geaxpby(cone,y,czero,ty,desc_data,info) + call psb_spmm(-cone,sm%nd,ty,cone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(cone,x,czero,tx,desc_data,info) + call psb_geaxpby(cone,initu,czero,ty,desc_data,info) + call psb_spmm(-cone,sm%nd,ty,cone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the + ! block diagonal part and the remaining part of the local matrix + ! and Y(j) is the approximate solution at sweep j. + ! + call psb_geaxpby(cone,x,czero,tx,desc_data,info) + call psb_spmm(-cone,sm%nd,ty,cone,tx,desc_data,info,work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + if (info /= psb_success_) exit + + if ( sm%checkres.and.(mod(i,sm%checkiter) == 0) ) then + call psb_geaxpby(cone,x,czero,r,r,desc_data,info) + call psb_spmm(-cone,sm%pa,ty,cone,r,desc_data,info) + res = psb_genrm2(r,desc_data,info) + if( sm%printres ) then + call log_conv("BJAC",me,i,sm%printiter,res,resdenum,sm%tol) + end if + if (res < sm%tol*resdenum ) then + if( (sm%printres).and.( mod(sm%printiter,sm%checkiter) /=0 ) ) & + & call log_conv("BJAC",me,i,1,res,resdenum,sm%tol) + exit + end if + end if + + end do + + if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + end associate + end select + + else + + info = psb_err_iarg_neg_ + call psb_errpush(info,name,& + & i_err=(/itwo,sweeps,izero,izero,izero/)) + goto 9999 + + endif + + if (.not.(4*n_col <= size(work))) then + deallocate(aux) + endif + + if(sm%checkres) then + call psb_gefree(r,desc_data,info) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_jac_smoother_apply_vect diff --git a/mlprec/impl/smoother/amg_c_jac_smoother_bld.f90 b/mlprec/impl/smoother/amg_c_jac_smoother_bld.f90 new file mode 100644 index 00000000..6f007509 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_jac_smoother_bld.f90 @@ -0,0 +1,127 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_c_diag_solver + use amg_c_jac_smoother, amg_protect_name => amg_c_jac_smoother_bld + Implicit None + + ! Arguments + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + type(psb_cspmat_type) :: tmpa + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota, nzeros + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='c_jac_smoother_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + n_col = desc_a%get_local_cols() + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + + if( sm%checkres ) sm%pa => a + + select type (smsv => sm%sv) + class is (amg_c_diag_solver_type) + call sm%nd%free() + sm%pa => a + sm%nd_nnz_tot = nztota + call psb_sum(ictxt,sm%nd_nnz_tot) + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + + class default + if (smsv%is_global()) then + ! Do not put anything into SM%ND since the solver + ! is acting globally. + call sm%nd%free() + sm%nd_nnz_tot = 0 + call psb_sum(ictxt,sm%nd_nnz_tot) + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + else + call a%csclip(sm%nd,info,& + & jmin=nrow_a+1,rscale=.false.,cscale=.false.) + if (info == psb_success_) then + if (present(amold)) then + call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + else + call sm%nd%cscnv(info,& + & type='csr',dupl=psb_dupl_add_) + endif + end if + sm%nd_nnz_tot = sm%nd%get_nzeros() + call psb_sum(ictxt,sm%nd_nnz_tot) + call a%csclip(tmpa,info,& + & jmax=nrow_a,rscale=.false.,cscale=.false.) + call sm%sv%build(tmpa,desc_a,info,amold=amold,vmold=vmold) + end if + end select + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='clip & psb_spcnv csr 4') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_jac_smoother_bld diff --git a/mlprec/impl/smoother/amg_c_jac_smoother_clear_data.f90 b/mlprec/impl/smoother/amg_c_jac_smoother_clear_data.f90 new file mode 100644 index 00000000..7bb7d877 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_jac_smoother_clear_data.f90 @@ -0,0 +1,70 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_jac_smoother_clear_data(sm,info) + + use psb_base_mod + use amg_c_jac_smoother, amg_protect_name => amg_c_jac_smoother_clear_data + Implicit None + ! Arguments + class(amg_c_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_jac_smoother_clear_data' + + call psb_erractionsave(err_act) + + info = 0 + call sm%nd%free() + sm%nd_nnz_tot = 0 + sm%pa => null() + if ((info==0).and.allocated(sm%sv)) then + call sm%sv%clear_data(info) + end if + if (info /= 0) then + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_jac_smoother_clear_data diff --git a/mlprec/impl/smoother/amg_c_jac_smoother_clone.f90 b/mlprec/impl/smoother/amg_c_jac_smoother_clone.f90 new file mode 100644 index 00000000..e1dbb7b6 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_jac_smoother_clone.f90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_jac_smoother_clone(sm,smout,info) + + use psb_base_mod + use amg_c_jac_smoother, amg_protect_name => amg_c_jac_smoother_clone + + Implicit None + + ! Arguments + class(amg_c_jac_smoother_type), intent(inout) :: sm + class(amg_c_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(smout)) then + call smout%free(info) + if (info == psb_success_) deallocate(smout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_c_jac_smoother_type :: smout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(smo => smout) + type is (amg_c_jac_smoother_type) + smo%nd_nnz_tot = sm%nd_nnz_tot + smo%checkres = sm%checkres + smo%printres = sm%printres + smo%checkiter = sm%checkiter + smo%printiter = sm%printiter + smo%tol = sm%tol + call sm%nd%clone(smo%nd,info) + if ((info==psb_success_).and.(allocated(sm%sv))) then + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == psb_success_) call sm%sv%clone(smo%sv,info) + end if + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_jac_smoother_clone diff --git a/mlprec/impl/smoother/amg_c_jac_smoother_clone_settings.f90 b/mlprec/impl/smoother/amg_c_jac_smoother_clone_settings.f90 new file mode 100644 index 00000000..85cec903 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_jac_smoother_clone_settings.f90 @@ -0,0 +1,101 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! asd on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_jac_smoother_clone_settings(sm,smout,info) + + use psb_base_mod + use amg_c_jac_smoother, amg_protect_name => amg_c_jac_smoother_clone_settings + Implicit None + ! Arguments + class(amg_c_jac_smoother_type), intent(inout) :: sm + class(amg_c_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_jac_smoother_clone_settings' + + call psb_erractionsave(err_act) + + info = psb_success_ + + select type(smout) + class is(amg_c_jac_smoother_type) + + smout%pa => null() + smout%nd_nnz_tot = 0 + smout%checkres = sm%checkres + smout%printres = sm%printres + smout%checkiter = sm%checkiter + smout%printiter = sm%printiter + smout%tol = sm%tol + + if (allocated(smout%sv)) then + if (.not.same_type_as(sm%sv,smout%sv)) then + call smout%sv%free(info) + if (info == 0) deallocate(smout%sv,stat=info) + end if + end if + if (info /= 0) then + info = psb_err_internal_error_ + else + if (allocated(smout%sv)) then + if (same_type_as(sm%sv,smout%sv)) then + call sm%sv%clone_settings(smout%sv,info) + else + info = psb_err_internal_error_ + end if + else + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == 0) call sm%sv%clone_settings(smout%sv,info) + if (info /= 0) info = psb_err_internal_error_ + end if + end if + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_jac_smoother_clone_settings diff --git a/mlprec/impl/smoother/amg_c_jac_smoother_cnv.f90 b/mlprec/impl/smoother/amg_c_jac_smoother_cnv.f90 new file mode 100644 index 00000000..7334cbfc --- /dev/null +++ b/mlprec/impl/smoother/amg_c_jac_smoother_cnv.f90 @@ -0,0 +1,90 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_jac_smoother_cnv(sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_c_diag_solver + use amg_c_jac_smoother, amg_protect_name => amg_c_jac_smoother_cnv + Implicit None + + ! Arguments + class(amg_c_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_jac_smoother_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + + if (info == psb_success_) then + if (sm%nd%is_asb()) then + if (present(amold)) then + call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + else + call sm%nd%cscnv(info,& + & type='csr',dupl=psb_dupl_add_) + endif + end if + end if + + if (info == psb_success_) then + if (allocated(sm%sv)) & + & call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='solver cnv') + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_jac_smoother_cnv diff --git a/mlprec/impl/smoother/amg_c_jac_smoother_csetc.f90 b/mlprec/impl/smoother/amg_c_jac_smoother_csetc.f90 new file mode 100644 index 00000000..1941efab --- /dev/null +++ b/mlprec/impl/smoother/amg_c_jac_smoother_csetc.f90 @@ -0,0 +1,90 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_jac_smoother_csetc(sm,what,val,info,idx) + + use psb_base_mod + use amg_c_jac_smoother, amg_protect_nam => amg_c_jac_smoother_csetc + Implicit None + ! Arguments + class(amg_c_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='c_jac_smoother_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(trim(what))) + case('SMOOTHER_STOP') + select case(psb_toupper(trim(val))) + case('T','TRUE') + sm%checkres = .true. + case('F','FALSE') + sm%checkres = .false. + case default + write(0,*) 'Unknown value for smoother_stop : "',psb_toupper(trim(val)),'"' + end select + case('SMOOTHER_TRACE') + select case(psb_toupper(trim(val))) + case('T','TRUE') + sm%printres = .true. + case('F','FALSE') + sm%printres = .false. + case default + write(0,*) 'Unknown value for smoother_trace : "',psb_toupper(trim(val)),'"' + end select + case default + call sm%amg_c_base_smoother_type%set(what,val,info,idx=idx) + end select + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info, name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_jac_smoother_csetc diff --git a/mlprec/impl/smoother/amg_c_jac_smoother_cseti.f90 b/mlprec/impl/smoother/amg_c_jac_smoother_cseti.f90 new file mode 100644 index 00000000..66d993b6 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_jac_smoother_cseti.f90 @@ -0,0 +1,71 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_jac_smoother_cseti(sm,what,val,info,idx) + + use psb_base_mod + use amg_c_jac_smoother, amg_protect_nam => amg_c_jac_smoother_cseti + Implicit None + + ! Arguments + class(amg_c_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_jac_smoother_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) + case('SMOOTHER_RESIDUAL') + sm%checkiter = val + case('SMOOTHER_ITRACE') + sm%printiter = val + case default + call sm%amg_c_base_smoother_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_jac_smoother_cseti diff --git a/mlprec/impl/smoother/amg_c_jac_smoother_csetr.f90 b/mlprec/impl/smoother/amg_c_jac_smoother_csetr.f90 new file mode 100644 index 00000000..022f42cb --- /dev/null +++ b/mlprec/impl/smoother/amg_c_jac_smoother_csetr.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_jac_smoother_csetr(sm,what,val,info,idx) + + use psb_base_mod + use amg_c_jac_smoother, amg_protect_nam => amg_c_jac_smoother_csetr + Implicit None + + ! Arguments + class(amg_c_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_jac_smoother_csetr' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) + case('SMOOTHER_STOPTOL') + sm%tol = val + case default + call sm%amg_c_base_smoother_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_jac_smoother_csetr diff --git a/mlprec/impl/smoother/amg_c_jac_smoother_descr.f90 b/mlprec/impl/smoother/amg_c_jac_smoother_descr.f90 new file mode 100644 index 00000000..48bd813d --- /dev/null +++ b/mlprec/impl/smoother/amg_c_jac_smoother_descr.f90 @@ -0,0 +1,103 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_jac_smoother_descr(sm,info,iout,coarse) + + use psb_base_mod + use amg_c_diag_solver + use amg_c_jac_smoother, amg_protect_name => amg_c_jac_smoother_descr + use amg_c_diag_solver + use amg_c_gs_solver + + Implicit None + + ! Arguments + class(amg_c_jac_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_c_jac_smoother_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (.not.coarse_) then + if (allocated(sm%sv)) then + select type(smv=>sm%sv) + class is (amg_c_diag_solver_type) + write(iout_,*) ' Point Jacobi ' + write(iout_,*) ' Local diagonal:' + call smv%descr(info,iout_,coarse=coarse) + class is (amg_c_bwgs_solver_type) + write(iout_,*) ' Hybrid Backward Gauss-Seidel ' + class is (amg_c_gs_solver_type) + write(iout_,*) ' Hybrid Forward Gauss-Seidel ' + class default + write(iout_,*) ' Block Jacobi ' + write(iout_,*) ' Local solver details:' + call smv%descr(info,iout_,coarse=coarse) + end select + + else + write(iout_,*) ' Block Jacobi ' + end if + else + if (allocated(sm%sv)) then + call sm%sv%descr(info,iout_,coarse=coarse) + end if + end if + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return +end subroutine amg_c_jac_smoother_descr diff --git a/mlprec/impl/smoother/amg_c_jac_smoother_dmp.f90 b/mlprec/impl/smoother/amg_c_jac_smoother_dmp.f90 new file mode 100644 index 00000000..7a81da84 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_jac_smoother_dmp.f90 @@ -0,0 +1,97 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_jac_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + + use psb_base_mod + use amg_c_jac_smoother, amg_protect_nam => amg_c_jac_smoother_dmp + implicit none + class(amg_c_jac_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + integer(psb_lpk_), allocatable :: iv(:) + logical :: smoother_, global_num_ + ! len of prefix_ + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_smth_c" + end if + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(smoother)) then + smoother_ = smoother + else + smoother_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + if (smoother_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_nd.mtx' + if (global_num_) then + iv = desc%get_global_indices(owned=.false.) + if (sm%nd%is_asb()) & + & call sm%nd%print(fname,head=head,iv=iv) + else + if (sm%nd%is_asb()) & + & call sm%nd%print(fname,head=head) + end if + end if + ! At base level do nothing for the smoother + if (allocated(sm%sv)) & + & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) + +end subroutine amg_c_jac_smoother_dmp diff --git a/mlprec/impl/smoother/amg_c_l1_jac_smoother_bld.f90 b/mlprec/impl/smoother/amg_c_l1_jac_smoother_bld.f90 new file mode 100644 index 00000000..46ce204e --- /dev/null +++ b/mlprec/impl/smoother/amg_c_l1_jac_smoother_bld.f90 @@ -0,0 +1,176 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_l1_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_c_diag_solver + use amg_c_jac_smoother, amg_protect_name => amg_c_l1_jac_smoother_bld + Implicit None + + ! Arguments + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_l1_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota, nzeros + real(psb_spk_), allocatable :: arwsum(:) + type(psb_cspmat_type) :: tmpa + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='c_l1_jac_smoother_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + n_col = desc_a%get_local_cols() + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + + if( sm%checkres ) sm%pa => a + + select type (smsv => sm%sv) + class is (amg_c_diag_solver_type) + call sm%nd%free() + sm%pa => a + sm%nd_nnz_tot = nztota + + call psb_sum(ictxt,sm%nd_nnz_tot) + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + + class default + if (smsv%is_global()) then + ! Do not put anything into SM%ND since the solver + ! is acting globally. + call sm%nd%free() + sm%nd_nnz_tot = 0 + call psb_sum(ictxt,sm%nd_nnz_tot) + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + else + + call a%csclip(tmpa,info,& + & jmax=nrow_a,rscale=.false.,cscale=.false.) + + call a%csclip(sm%nd,info,& + & jmin=nrow_a+1,rscale=.false.,cscale=.false.) + + arwsum = sm%nd%arwsum(info) + + call combine_dl1(-sone,arwsum,sm%nd,info) + call combine_dl1(sone,arwsum,tmpa,info) + + sm%nd_nnz_tot = sm%nd%get_nzeros() + call psb_sum(ictxt,sm%nd_nnz_tot) + + call sm%sv%build(tmpa,desc_a,info,amold=amold,vmold=vmold) + + if (info == psb_success_) then + if (present(amold)) then + call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + else + call sm%nd%cscnv(info,& + & type='csr',dupl=psb_dupl_add_) + endif + end if + end if + end select + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='clip & psb_spcnv csr 4') + goto 9999 + end if + + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='solver build') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + + subroutine combine_dl1(alpha,dl1,mat,info) + implicit none + real(psb_spk_), intent(in) :: alpha, dl1(:) + type(psb_cspmat_type), intent(inout) :: mat + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: k, nz, nrm, dp + type(psb_c_coo_sparse_mat) :: tcoo + + call mat%mv_to(tcoo) + nz = tcoo%get_nzeros() + nrm = min(size(dl1),tcoo%get_nrows(),tcoo%get_ncols()) +!!$ write(0,*) 'Check on combine_dl1: ',nrm, tcoo%get_nrows(),tcoo%get_ncols(), nz + call tcoo%ensure_size(nz+nrm) + call tcoo%set_dupl(psb_dupl_add_) + do k=1,nrm + if (dl1(k) /= szero) then + nz = nz + 1 + tcoo%ia(nz) = k + tcoo%ja(nz) = k + tcoo%val(nz) = alpha*dl1(k) + end if + end do + call tcoo%set_nzeros(nz) + call tcoo%fix(info) + call mat%mv_from(tcoo) + end subroutine combine_dl1 + + +end subroutine amg_c_l1_jac_smoother_bld diff --git a/mlprec/impl/smoother/amg_c_l1_jac_smoother_clone.f90 b/mlprec/impl/smoother/amg_c_l1_jac_smoother_clone.f90 new file mode 100644 index 00000000..e99ba035 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_l1_jac_smoother_clone.f90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_l1_jac_smoother_clone(sm,smout,info) + + use psb_base_mod + use amg_c_jac_smoother, amg_protect_name => amg_c_l1_jac_smoother_clone + + Implicit None + + ! Arguments + class(amg_c_l1_jac_smoother_type), intent(inout) :: sm + class(amg_c_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(smout)) then + call smout%free(info) + if (info == psb_success_) deallocate(smout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_c_l1_jac_smoother_type :: smout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(smo => smout) + type is (amg_c_l1_jac_smoother_type) + smo%nd_nnz_tot = sm%nd_nnz_tot + smo%checkres = sm%checkres + smo%printres = sm%printres + smo%checkiter = sm%checkiter + smo%printiter = sm%printiter + smo%tol = sm%tol + call sm%nd%clone(smo%nd,info) + if ((info==psb_success_).and.(allocated(sm%sv))) then + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == psb_success_) call sm%sv%clone(smo%sv,info) + end if + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_l1_jac_smoother_clone diff --git a/mlprec/impl/smoother/amg_c_l1_jac_smoother_descr.f90 b/mlprec/impl/smoother/amg_c_l1_jac_smoother_descr.f90 new file mode 100644 index 00000000..4ec8bb99 --- /dev/null +++ b/mlprec/impl/smoother/amg_c_l1_jac_smoother_descr.f90 @@ -0,0 +1,103 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_l1_jac_smoother_descr(sm,info,iout,coarse) + + use psb_base_mod + use amg_c_diag_solver + use amg_c_jac_smoother, amg_protect_name => amg_c_l1_jac_smoother_descr + use amg_c_diag_solver + use amg_c_gs_solver + + Implicit None + + ! Arguments + class(amg_c_l1_jac_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_c_l1_jac_smoother_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (.not.coarse_) then + if (allocated(sm%sv)) then + select type(smv=>sm%sv) + class is (amg_c_diag_solver_type) + write(iout_,*) ' Point Jacobi ' + write(iout_,*) ' Local diagonal:' + call smv%descr(info,iout_,coarse=coarse) + class is (amg_c_bwgs_solver_type) + write(iout_,*) ' L1-Hybrid Backward Gauss-Seidel ' + class is (amg_c_gs_solver_type) + write(iout_,*) ' L1-Hybrid Forward Gauss-Seidel ' + class default + write(iout_,*) ' L1-Block Jacobi ' + write(iout_,*) ' Local solver details:' + call smv%descr(info,iout_,coarse=coarse) + end select + + else + write(iout_,*) ' L1-Block Jacobi ' + end if + else + if (allocated(sm%sv)) then + call sm%sv%descr(info,iout_,coarse=coarse) + end if + end if + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return +end subroutine amg_c_l1_jac_smoother_descr diff --git a/mlprec/impl/smoother/amg_d_as_smoother_apply.f90 b/mlprec/impl/smoother/amg_d_as_smoother_apply.f90 new file mode 100644 index 00000000..4afc54bc --- /dev/null +++ b/mlprec/impl/smoother/amg_d_as_smoother_apply.f90 @@ -0,0 +1,235 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_as_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,info,init,initu) + use psb_base_mod + use amg_d_as_smoother, amg_protect_nam => amg_d_as_smoother_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_as_smoother_type), intent(inout) :: sm + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col, nrow_d, i + real(psb_dpk_), pointer :: aux(:) + real(psb_dpk_), allocatable :: tx(:),ty(:), ww(:) + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5) + character :: trans_, init_ + character(len=20) :: name='d_as_smoother_apply', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = desc_data%get_context() + call psb_info(ictxt,me,np) + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + n_row = sm%desc_data%get_local_rows() + n_col = sm%desc_data%get_local_cols() + nrow_d = desc_data%get_local_rows() + isz = max(n_row,N_COL) + + if ((4*isz) <= size(work)) then + aux => work(1:) + else + allocate(aux(4*isz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name,& + & i_err=(/4*isz,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + endif + + if ((.not.sm%sv%is_iterative()).and.(sweeps == 1).and.(sm%novr==0)) then + ! + ! Shortcut: in this case there is nothing else to be done. + ! + call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + else if (sweeps >= 0) then + ! + ! + ! Apply multiple sweeps of an AS solver + ! to compute an approximate solution of a linear system. + ! + ! + call psb_geasb(tx,sm%desc_data,info) + call psb_geasb(ty,sm%desc_data,info) + call psb_geasb(ww,sm%desc_data,info) + + ! + ! Unroll the first iteration and fold it inside SELECT CASE + ! this will save one SPMM when INIT=Z, and will be + ! significant when sweeps=1 (a common case) + ! + call psb_geaxpby(done,x,dzero,tx,desc_data,info) + if (info == 0) call sm%apply_restr(tx,trans_,aux,info) + if (info == 0) call psb_geaxpby(done,tx,dzero,ww,sm%desc_data,info) + + select case (init_) + case('Z') + call sm%sv%apply(done,ww,dzero,ty,sm%desc_data,trans_,aux,info,init='Z') + + case('Y') + call psb_geaxpby(done,y,dzero,ty,desc_data,info) + if (info == 0) call sm%apply_restr(ty,trans_,aux,info) + if (info == 0) call psb_spmm(-done,sm%nd,ty,done,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + call sm%sv%apply(done,ww,dzero,ty,desc_data,trans_,aux,info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(done,initu,dzero,ty,desc_data,info) + if (info == 0) call sm%apply_restr(ty,trans_,aux,info) + if (info == 0) call psb_spmm(-done,sm%nd,ty,done,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + call sm%sv%apply(done,ww,dzero,ty,desc_data,trans_,aux,info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + if (info == 0) call sm%apply_prol(ty,trans_,aux,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the + ! block diagonal part and the remaining part of the local matrix + ! and Y(j) is the approximate solution at sweep j. + ! + if (info == 0) call psb_geaxpby(done,tx,dzero,ww,sm%desc_data,info) + if (info == 0) call psb_spmm(-done,sm%nd,ty,done,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(done,ww,dzero,ty,sm%desc_data,trans_,aux,info,init='Y') + + if (info /= psb_success_) exit + if (info == 0) call sm%apply_prol(ty,trans_,aux,info) + + end do + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + ! + ! Compute y = beta*y + alpha*ty (ty == K^(-1)*tx) + ! + call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + + else + + info = psb_err_iarg_neg_ + call psb_errpush(info,name,& + & i_err=(/itwo,sweeps,izero,izero,izero/)) + goto 9999 + + endif + + + if (.not.(4*isz <= size(work))) then + deallocate(aux,stat=info) + endif + if (info ==0) deallocate(ww,tx,ty,stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_as_smoother_apply diff --git a/mlprec/impl/smoother/amg_d_as_smoother_apply_vect.f90 b/mlprec/impl/smoother/amg_d_as_smoother_apply_vect.f90 new file mode 100644 index 00000000..cda58d49 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_as_smoother_apply_vect.f90 @@ -0,0 +1,259 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_as_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,wv,info,init,initu) + use psb_base_mod + use amg_d_as_smoother, amg_protect_nam => amg_d_as_smoother_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_as_smoother_type), intent(inout) :: sm + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col, nrow_d, i + real(psb_dpk_), pointer :: aux(:) + type(psb_d_vect_type) :: tx, ty, ww + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5) + character :: trans_, init_ + logical :: do_realloc_wv + character(len=20) :: name='d_as_smoother_apply_v', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = desc_data%get_context() + call psb_info(ictxt,me,np) + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + n_row = sm%desc_data%get_local_rows() + n_col = sm%desc_data%get_local_cols() + nrow_d = desc_data%get_local_rows() + isz = max(n_row,N_COL) + + if (4*isz <= size(work)) then + aux => work(:) + else + allocate(aux(4*isz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name,& + & i_err=(/4*isz,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + endif + + if ((.not.sm%sv%is_iterative()).and.(sweeps == 1).and.(sm%novr==0)) then + ! + ! Shortcut: in this case there is nothing else to be done. + ! + call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,wv,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + else if (sweeps >= 0) then + ! + ! + ! Apply multiple sweeps of an AS solver + ! to compute an approximate solution of a linear system. + ! + ! + if (size(wv) < 3) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='invalid wv size in smoother_apply') + goto 9999 + end if + + ! + ! This is tricky. This smoother has a descriptor sm%desc_data + ! for an index space potentially different from + ! that of desc_data. Hence the size of the work vectors + ! could be wrong. We need to check and reallocate as needed. + ! + do_realloc_wv = (wv(1)%get_nrows() < sm%desc_data%get_local_cols()).or.& + & (wv(2)%get_nrows() < sm%desc_data%get_local_cols()).or.& + & (wv(3)%get_nrows() < sm%desc_data%get_local_cols()) + + if (do_realloc_wv) then + call psb_geasb(wv(1),sm%desc_data,info,scratch=.true.,mold=wv(2)%v) + call psb_geasb(wv(2),sm%desc_data,info,scratch=.true.,mold=wv(1)%v) + call psb_geasb(wv(3),sm%desc_data,info,scratch=.true.,mold=wv(1)%v) + end if + + associate(tx => wv(1), ty => wv(2), ww => wv(3)) + + ! Need to zero tx because of the apply_restr call. + call tx%zero() + ! + ! Unroll the first iteration and fold it inside SELECT CASE + ! this will save one SPMM when INIT=Z, and will be + ! significant when sweeps=1 (a common case) + ! + call psb_geaxpby(done,x,dzero,tx,desc_data,info) + if (info == 0) call sm%apply_restr(tx,trans_,aux,info) + if (info == 0) call psb_geaxpby(done,tx,dzero,ww,sm%desc_data,info) + + select case (init_) + case('Z') + call sm%sv%apply(done,ww,dzero,ty,sm%desc_data,trans_,aux,wv(4:),info,init='Z') + + case('Y') + call psb_geaxpby(done,y,dzero,ty,desc_data,info) + if (info == 0) call sm%apply_restr(ty,trans_,aux,info) + if (info == 0) call psb_spmm(-done,sm%nd,ty,done,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + call sm%sv%apply(done,ww,dzero,ty,desc_data,trans_,aux,wv(4:),info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(done,initu,dzero,ty,desc_data,info) + if (info == 0) call sm%apply_restr(ty,trans_,aux,info) + if (info == 0) call psb_spmm(-done,sm%nd,ty,done,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + call sm%sv%apply(done,ww,dzero,ty,desc_data,trans_,aux,wv(4:),info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + if (info == 0) call sm%apply_prol(ty,trans_,aux,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the + ! block diagonal part and the remaining part of the local matrix + ! and Y(j) is the approximate solution at sweep j. + ! + if (info == 0) call psb_geaxpby(done,tx,dzero,ww,sm%desc_data,info) + if (info == 0) call psb_spmm(-done,sm%nd,ty,done,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(done,ww,dzero,ty,sm%desc_data,trans_,aux,wv(4:),info,init='Y') + + if (info /= psb_success_) exit + if (info == 0) call sm%apply_prol(ty,trans_,aux,info) + + end do + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + ! + ! Compute y = beta*y + alpha*ty (ty == K^(-1)*tx) + ! + call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + end associate + + else + + info = psb_err_iarg_neg_ + call psb_errpush(info,name,& + & i_err=(/itwo,sweeps,izero,izero,izero/)) + goto 9999 + + endif + + + if (.not.(4*isz <= size(work))) then + deallocate(aux,stat=info) + endif + + if (info /= 0) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_as_smoother_apply_vect diff --git a/mlprec/impl/smoother/amg_d_as_smoother_bld.f90 b/mlprec/impl/smoother/amg_d_as_smoother_bld.f90 new file mode 100644 index 00000000..d66c26a4 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_as_smoother_bld.f90 @@ -0,0 +1,183 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_as_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_d_as_smoother, amg_protect_nam => amg_d_as_smoother_bld + Implicit None + + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local variables + type(psb_dspmat_type) :: blck, atmp + integer(psb_ipk_) :: n_row,n_col, nrow_a, nhalo, novr, data_ + real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_as_smoother_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + novr = sm%novr + if (novr < 0) then + info=psb_err_invalid_ovr_num_ + call psb_errpush(info,name,& + & i_err=(/novr,izero,izero,izero,izero,izero/)) + goto 9999 + endif + + if ((novr == 0).or.(np == 1)) then + call psb_cdcpy(desc_a,sm%desc_data,info) + If(debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' done cdcpy' + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_cdcpy' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Early return: P>=3 N_OVR=0' + call blck%csall(izero,izero,info,ione) + else + + ! + ! Build the auxiliary descriptor desc_p%matrix_data(psb_n_row_). + ! This is done by psb_cdbldext (interface to psb_cdovr), which is + ! independent of CSR, and has been placed in the tools directory + ! of PSBLAS, instead of the mlprec directory of MLD2P4, because it + ! might be used independently of the AS preconditioner, to build + ! a descriptor for an extended stencil in a PDE solver. + ! + call psb_cdbldext(a,desc_a,novr,sm%desc_data,info,extype=psb_ovt_asov_) + if(debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' From cdbldext _:',sm%desc_data%get_local_rows(),& + & sm%desc_data%get_local_cols() + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_cdbldext' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Before sphalo ' + + ! + ! Retrieve the remote sparse matrix rows required for the AS extended + ! matrix + data_ = psb_comm_ext_ + Call psb_sphalo(a,sm%desc_data,blck,info,data=data_,rowscale=.true.) + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_sphalo' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + if (debug_level >=psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'After psb_sphalo ',& + & blck%get_nrows(), blck%get_nzeros() + + End if + if (info == psb_success_) & + & call sm%sv%build(a,sm%desc_data,info,& + & blck,amold=amold,vmold=vmold) + + nrow_a = a%get_nrows() + n_row = sm%desc_data%get_local_rows() + n_col = sm%desc_data%get_local_cols() + + if (info == psb_success_) call a%csclip(sm%nd,info,& + & jmin=nrow_a+1,rscale=.false.,cscale=.false.) + if (info == psb_success_) call blck%csclip(atmp,info,& + & jmin=nrow_a+1,rscale=.false.,cscale=.false.) + if (info == psb_success_) call psb_rwextd(n_row,sm%nd,info,b=atmp) + + if (info == psb_success_) then + if (present(amold)) then + call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + else + call sm%nd%cscnv(info,& + & type='csr',dupl=psb_dupl_add_) + end if + end if + if (info == psb_success_) then + if (present(imold)) then + call sm%desc_data%cnv(imold) + end if + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='clip & psb_spcnv csr 4') + goto 9999 + end if + sm%nd_nnz_tot = sm%nd%get_nzeros() + call psb_sum(ictxt,sm%nd_nnz_tot) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_as_smoother_bld diff --git a/mlprec/impl/smoother/amg_d_as_smoother_check.f90 b/mlprec/impl/smoother/amg_d_as_smoother_check.f90 new file mode 100644 index 00000000..0a4fc47d --- /dev/null +++ b/mlprec/impl/smoother/amg_d_as_smoother_check.f90 @@ -0,0 +1,78 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_as_smoother_check(sm,info) + + use psb_base_mod + use amg_d_as_smoother, amg_protect_nam => amg_d_as_smoother_check + + Implicit None + + ! Arguments + class(amg_d_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + Integer(Psb_ipk_) :: err_act + character(len=20) :: name='d_as_smoother_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + call amg_check_def(sm%restr,& + & 'Restrictor',psb_halo_,is_legal_restrict) + call amg_check_def(sm%prol,& + & 'Prolongator',psb_none_,is_legal_prolong) + call amg_check_def(sm%novr,& + & 'Overlap layers ',izero,is_int_non_negative) + + + if (allocated(sm%sv)) then + call sm%sv%check(info) + else + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_as_smoother_check diff --git a/mlprec/impl/smoother/amg_d_as_smoother_clear_data.f90 b/mlprec/impl/smoother/amg_d_as_smoother_clear_data.f90 new file mode 100644 index 00000000..70930a56 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_as_smoother_clear_data.f90 @@ -0,0 +1,70 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_as_smoother_clear_data(sm,info) + + use psb_base_mod + use amg_d_as_smoother, amg_protect_name => amg_d_as_smoother_clear_data + Implicit None + ! Arguments + class(amg_d_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_as_smoother_clear_data' + + call psb_erractionsave(err_act) + + info = 0 + call sm%nd%free() + sm%nd_nnz_tot = 0 + call sm%desc_data%free(info) + if ((info==0).and.allocated(sm%sv)) then + call sm%sv%clear_data(info) + end if + if (info /= 0) then + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_as_smoother_clear_data diff --git a/mlprec/impl/smoother/amg_d_as_smoother_clone.f90 b/mlprec/impl/smoother/amg_d_as_smoother_clone.f90 new file mode 100644 index 00000000..9fd2b861 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_as_smoother_clone.f90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_as_smoother_clone(sm,smout,info) + + use psb_base_mod + use amg_d_as_smoother, amg_protect_name => amg_d_as_smoother_clone + + Implicit None + + ! Arguments + class(amg_d_as_smoother_type), intent(inout) :: sm + class(amg_d_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(smout)) then + call smout%free(info) + if (info == psb_success_) deallocate(smout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_d_as_smoother_type :: smout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(smo => smout) + type is (amg_d_as_smoother_type) + smo%novr = sm%novr + smo%restr = sm%restr + smo%prol = sm%prol + smo%nd_nnz_tot = sm%nd_nnz_tot + call sm%nd%clone(smo%nd,info) + if (info == psb_success_) & + & call sm%desc_data%clone(smo%desc_data,info) + if ((info==psb_success_).and.(allocated(sm%sv))) then + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == psb_success_) call sm%sv%clone(smo%sv,info) + end if + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_as_smoother_clone diff --git a/mlprec/impl/smoother/amg_d_as_smoother_clone_settings.f90 b/mlprec/impl/smoother/amg_d_as_smoother_clone_settings.f90 new file mode 100644 index 00000000..47bf0c9a --- /dev/null +++ b/mlprec/impl/smoother/amg_d_as_smoother_clone_settings.f90 @@ -0,0 +1,95 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! asd on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_as_smoother_clone_settings(sm,smout,info) + + use psb_base_mod + use amg_d_as_smoother, amg_protect_name => amg_d_as_smoother_clone_settings + Implicit None + ! Arguments + class(amg_d_as_smoother_type), intent(inout) :: sm + class(amg_d_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_as_smoother_clone_settings' + + call psb_erractionsave(err_act) + + info = psb_success_ + + select type(smout) + class is(amg_d_as_smoother_type) + smout%novr = sm%novr + smout%restr = sm%restr + smout%prol = sm%prol + if (allocated(smout%sv)) then + if (.not.same_type_as(sm%sv,smout%sv)) then + call smout%sv%free(info) + if (info == 0) deallocate(smout%sv,stat=info) + end if + end if + if (info /= 0) then + info = psb_err_internal_error_ + else + if (allocated(smout%sv)) then + if (same_type_as(sm%sv,smout%sv)) then + call sm%sv%clone_settings(smout%sv,info) + else + info = psb_err_internal_error_ + end if + else + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == 0) call sm%sv%clone_settings(smout%sv,info) + if (info /= 0) info = psb_err_internal_error_ + end if + end if + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_as_smoother_clone_settings diff --git a/mlprec/impl/smoother/amg_d_as_smoother_cnv.f90 b/mlprec/impl/smoother/amg_d_as_smoother_cnv.f90 new file mode 100644 index 00000000..aca07865 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_as_smoother_cnv.f90 @@ -0,0 +1,96 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_as_smoother_cnv(sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_d_as_smoother, amg_protect_nam => amg_d_as_smoother_cnv + Implicit None + + ! Arguments + class(amg_d_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local variables + type(psb_dspmat_type) :: blck, atmp + integer(psb_ipk_) :: n_row,n_col, nrow_a, nhalo, novr, data_, nzeros + real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_as_smoother_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = sm%desc_data%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + if (allocated(sm%sv)) & + & call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) + + if (info == psb_success_) then + if (present(amold)) then + if (sm%nd%is_asb()) call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + end if + end if + if (info == psb_success_) then + if (present(imold)) then + call sm%desc_data%cnv(imold) + end if + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='clip & psb_spcnv csr 4') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_as_smoother_cnv diff --git a/mlprec/impl/smoother/amg_d_as_smoother_csetc.f90 b/mlprec/impl/smoother/amg_d_as_smoother_csetc.f90 new file mode 100644 index 00000000..a16c1cd2 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_as_smoother_csetc.f90 @@ -0,0 +1,78 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_as_smoother_csetc(sm,what,val,info,idx) + + use psb_base_mod + use amg_d_as_smoother, amg_protect_nam => amg_d_as_smoother_csetc + Implicit None + ! Arguments + class(amg_d_as_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='d_as_smoother_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + + + ival = sm%stringval(val) + select case(psb_toupper(what)) + case('SUB_RESTR') + sm%restr = ival + case('SUB_PROL') + sm%prol = ival + case default + call sm%amg_d_base_smoother_type%set(what,val,info,idx=idx) + end select + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info, name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_as_smoother_csetc diff --git a/mlprec/impl/smoother/amg_d_as_smoother_cseti.f90 b/mlprec/impl/smoother/amg_d_as_smoother_cseti.f90 new file mode 100644 index 00000000..b6c99556 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_as_smoother_cseti.f90 @@ -0,0 +1,73 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_as_smoother_cseti(sm,what,val,info,idx) + + use psb_base_mod + use amg_d_as_smoother, amg_protect_nam => amg_d_as_smoother_cseti + Implicit None + + ! Arguments + class(amg_d_as_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_as_smoother_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) + case('SUB_OVR') + sm%novr = val + case('SUB_RESTR') + sm%restr = val + case('SUB_PROL') + sm%prol = val + case default + call sm%amg_d_base_smoother_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_as_smoother_cseti diff --git a/mlprec/impl/smoother/amg_d_as_smoother_dmp.f90 b/mlprec/impl/smoother/amg_d_as_smoother_dmp.f90 new file mode 100644 index 00000000..b6555a71 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_as_smoother_dmp.f90 @@ -0,0 +1,92 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_as_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + + use psb_base_mod + use amg_d_as_smoother, amg_protect_nam => amg_d_as_smoother_dmp + implicit none + class(amg_d_as_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: smoother_, global_num_ + ! len of prefix_ + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_smth_d" + end if + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(smoother)) then + smoother_ = smoother + else + smoother_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + if (global_num_) then + write(0,*) iam,' Warning: no global num with AS smoothers dump' + end if + if (smoother_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_nd.mtx' + if (sm%nd%is_asb()) & + & call sm%nd%print(fname,head=head) + end if + ! At base level do nothing for the smoother + if (allocated(sm%sv)) & + & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) + +end subroutine amg_d_as_smoother_dmp diff --git a/mlprec/impl/smoother/amg_d_as_smoother_free.f90 b/mlprec/impl/smoother/amg_d_as_smoother_free.f90 new file mode 100644 index 00000000..c260ea4f --- /dev/null +++ b/mlprec/impl/smoother/amg_d_as_smoother_free.f90 @@ -0,0 +1,71 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_as_smoother_free(sm,info) + + use psb_base_mod + use amg_d_as_smoother, amg_protect_nam => amg_d_as_smoother_free + Implicit None + ! Arguments + class(amg_d_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_as_smoother_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + + + if (allocated(sm%sv)) then + call sm%sv%free(info) + if (info == psb_success_) deallocate(sm%sv,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + end if + call sm%nd%free() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_as_smoother_free diff --git a/mlprec/impl/smoother/amg_d_as_smoother_prol_a.f90 b/mlprec/impl/smoother/amg_d_as_smoother_prol_a.f90 new file mode 100644 index 00000000..abfa787e --- /dev/null +++ b/mlprec/impl/smoother/amg_d_as_smoother_prol_a.f90 @@ -0,0 +1,149 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_as_smoother_prol_a(sm,x,trans,work,info,data) + use psb_base_mod + use amg_d_as_smoother, amg_protect_nam => amg_d_as_smoother_prol_a + implicit none + class(amg_d_as_smoother_type), intent(inout) :: sm + real(psb_dpk_), intent(inout) :: x(:) + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + !Local + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ + character :: trans_ + character(len=20) :: name='d_as_smther_prol_a', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = sm%desc_data%get_context() + call psb_info(ictxt,me,np) + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + info = psb_err_iarg_invalid_i_ + call psb_errpush(info,name) + goto 9999 + end select + + if (present(data)) then + data_ = data + else + data_ = psb_comm_ext_ + end if + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + + select case(trans_) + case('N') + + select case (sm%prol) + + case(psb_none_) + ! + ! Would work anyway, but since it is supposed to do nothing ... + ! call psb_ovrl(x,sm%desc_data,info,& + ! & update=sm%prol,work=work) + + + case(psb_sum_,psb_avg_) + ! + ! Update the overlap of x + ! + call psb_ovrl(x,sm%desc_data,info,& + & update=sm%prol,work=work) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_prol_') + goto 9999 + end select + + case('T','C') + ! + ! With transpose, we have to do it here + ! + if (sm%restr == psb_halo_) then + call psb_ovrl(x,sm%desc_data,info,& + & update=psb_sum_,work=work) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + else if (sm%restr /= psb_none_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_restr_') + goto 9999 + end if + + case default + info=psb_err_iarg_invalid_i_ + int_err(1)=6 + ch_err(2:2)=trans + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_as_smoother_prol_a + + diff --git a/mlprec/impl/smoother/amg_d_as_smoother_prol_v.f90 b/mlprec/impl/smoother/amg_d_as_smoother_prol_v.f90 new file mode 100644 index 00000000..1a6941e0 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_as_smoother_prol_v.f90 @@ -0,0 +1,149 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_as_smoother_prol_v(sm,x,trans,work,info,data) + use psb_base_mod + use amg_d_as_smoother, amg_protect_nam => amg_d_as_smoother_prol_v + implicit none + class(amg_d_as_smoother_type), intent(inout) :: sm + type(psb_d_vect_type),intent(inout) :: x + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + !Local + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ + character :: trans_ + character(len=20) :: name='d_as_smther_prol_v', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = sm%desc_data%get_context() + call psb_info(ictxt,me,np) + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + info = psb_err_iarg_invalid_i_ + call psb_errpush(info,name) + goto 9999 + end select + + if (present(data)) then + data_ = data + else + data_ = psb_comm_ext_ + end if + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + + select case(trans_) + case('N') + + select case (sm%prol) + + case(psb_none_) + ! + ! Would work anyway, but since it is supposed to do nothing ... + ! call psb_ovrl(x,sm%desc_data,info,& + ! & update=sm%prol,work=work) + + + case(psb_sum_,psb_avg_) + ! + ! Update the overlap of x + ! + call psb_ovrl(x,sm%desc_data,info,& + & update=sm%prol,work=work) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_prol_') + goto 9999 + end select + + case('T','C') + ! + ! With transpose, we have to do it here + ! + if (sm%restr == psb_halo_) then + call psb_ovrl(x,sm%desc_data,info,& + & update=psb_sum_,work=work) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + else if (sm%restr /= psb_none_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_restr_') + goto 9999 + end if + + case default + info=psb_err_iarg_invalid_i_ + int_err(1)=6 + ch_err(2:2)=trans + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_as_smoother_prol_v + + diff --git a/mlprec/impl/smoother/amg_d_as_smoother_restr_a.f90 b/mlprec/impl/smoother/amg_d_as_smoother_restr_a.f90 new file mode 100644 index 00000000..3cf7cebd --- /dev/null +++ b/mlprec/impl/smoother/amg_d_as_smoother_restr_a.f90 @@ -0,0 +1,168 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_as_smoother_restr_a(sm,x,trans,work,info,data) + use psb_base_mod + use amg_d_as_smoother, amg_protect_nam => amg_d_as_smoother_restr_a + implicit none + class(amg_d_as_smoother_type), intent(inout) :: sm + real(psb_dpk_), intent(inout) :: x(:) + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + !Local + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ + character :: trans_ + character(len=20) :: name='d_as_smther_restr_a', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = sm%desc_data%get_context() + call psb_info(ictxt,me,np) + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + info = psb_err_iarg_invalid_i_ + call psb_errpush(info,name) + goto 9999 + end select + + if (present(data)) then + data_ = data + else + data_ = psb_comm_ext_ + end if + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + select case(trans_) + case('N') + ! + ! Get the overlap entries x + ! + if (sm%restr == psb_halo_) then + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + else if (sm%restr /= psb_none_) then + call psb_errpush(psb_err_internal_error_,name,& + &a_err='Invalid amg_sub_restr_') + goto 9999 + end if + + + case('T','C') + ! + ! With transpose, we have to do it here + ! + + select case (sm%prol) + + case(psb_none_) + ! + ! Do nothing + + case(psb_sum_) + ! + ! The transpose of sum is halo + ! + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + + case(psb_avg_) + ! + ! Tricky one: first we have to scale the overlap entries, + ! which we can do by assignind mode=0, i.e. no communication + ! (hence only scaling), then we do the halo + ! + call psb_ovrl(x,sm%desc_data,info,& + & update=psb_avg_,work=work,mode=izero) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_prol_') + goto 9999 + end select + + + case default + info=psb_err_iarg_invalid_i_ + int_err(1)=6 + ch_err(2:2)=trans + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_as_smoother_restr_a + + diff --git a/mlprec/impl/smoother/amg_d_as_smoother_restr_v.f90 b/mlprec/impl/smoother/amg_d_as_smoother_restr_v.f90 new file mode 100644 index 00000000..5bf7d012 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_as_smoother_restr_v.f90 @@ -0,0 +1,168 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_as_smoother_restr_v(sm,x,trans,work,info,data) + use psb_base_mod + use amg_d_as_smoother, amg_protect_nam => amg_d_as_smoother_restr_v + implicit none + class(amg_d_as_smoother_type), intent(inout) :: sm + type(psb_d_vect_type),intent(inout) :: x + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + !Local + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ + character :: trans_ + character(len=20) :: name='d_as_smther_restr_v', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = sm%desc_data%get_context() + call psb_info(ictxt,me,np) + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + info = psb_err_iarg_invalid_i_ + call psb_errpush(info,name) + goto 9999 + end select + + if (present(data)) then + data_ = data + else + data_ = psb_comm_ext_ + end if + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + select case(trans_) + case('N') + ! + ! Get the overlap entries x + ! + if (sm%restr == psb_halo_) then + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + else if (sm%restr /= psb_none_) then + call psb_errpush(psb_err_internal_error_,name,& + &a_err='Invalid amg_sub_restr_') + goto 9999 + end if + + + case('T','C') + ! + ! With transpose, we have to do it here + ! + + select case (sm%prol) + + case(psb_none_) + ! + ! Do nothing + + case(psb_sum_) + ! + ! The transpose of sum is halo + ! + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + + case(psb_avg_) + ! + ! Tricky one: first we have to scale the overlap entries, + ! which we can do by assignind mode=0, i.e. no communication + ! (hence only scaling), then we do the halo + ! + call psb_ovrl(x,sm%desc_data,info,& + & update=psb_avg_,work=work,mode=izero) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_prol_') + goto 9999 + end select + + + case default + info=psb_err_iarg_invalid_i_ + int_err(1)=6 + ch_err(2:2)=trans + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_as_smoother_restr_v + + diff --git a/mlprec/impl/smoother/amg_d_base_smoother_apply.f90 b/mlprec/impl/smoother/amg_d_base_smoother_apply.f90 new file mode 100644 index 00000000..c9b603d3 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_base_smoother_apply.f90 @@ -0,0 +1,87 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_smoother_apply(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,info,init,initu) + use psb_base_mod + use amg_d_base_smoother_mod, amg_protect_name => amg_d_base_smoother_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_base_smoother_type), intent(inout) :: sm + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_smoother_apply' + + call psb_erractionsave(err_act) + info = psb_success_ + if (sweeps == 0) then + + ! + ! K^0 = I + ! zero sweeps of any smoother is just the identity. + ! + call psb_geaxpby(alpha,x,beta,y,desc_data,info) + + else + if (allocated(sm%sv)) then + call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,info,init=init, initu=initu) + else + info = 1121 + endif + end if + if (info /= psb_success_) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_base_smoother_apply diff --git a/mlprec/impl/smoother/amg_d_base_smoother_apply_vect.f90 b/mlprec/impl/smoother/amg_d_base_smoother_apply_vect.f90 new file mode 100644 index 00000000..c77c46d6 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_base_smoother_apply_vect.f90 @@ -0,0 +1,88 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,wv,info,init,initu) + use psb_base_mod + use amg_d_base_smoother_mod, amg_protect_name => amg_d_base_smoother_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_base_smoother_type), intent(inout) :: sm + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + ! + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_smoother_apply' + + call psb_erractionsave(err_act) + info = psb_success_ + if (sweeps == 0) then + + ! + ! K^0 = I + ! zero sweeps of any smoother is just the identity. + ! + call psb_geaxpby(alpha,x,beta,y,desc_data,info) + + else + if (allocated(sm%sv)) then + call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,wv,info,init=init, initu=initu) + else + info = 1121 + endif + end if + if (info /= psb_success_) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_base_smoother_apply_vect diff --git a/mlprec/impl/smoother/amg_d_base_smoother_bld.f90 b/mlprec/impl/smoother/amg_d_base_smoother_bld.f90 new file mode 100644 index 00000000..db55e103 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_base_smoother_bld.f90 @@ -0,0 +1,72 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_d_base_smoother_mod, amg_protect_name => amg_d_base_smoother_bld + Implicit None + + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_smoother_bld' + + call psb_erractionsave(err_act) + + info = psb_success_ + if (allocated(sm%sv)) then + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + else + info = 1121 + call psb_errpush(info,name) + endif + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_smoother_bld diff --git a/mlprec/impl/smoother/amg_d_base_smoother_check.f90 b/mlprec/impl/smoother/amg_d_base_smoother_check.f90 new file mode 100644 index 00000000..75f3a561 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_base_smoother_check.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_smoother_check(sm,info) + + use psb_base_mod + use amg_d_base_smoother_mod, amg_protect_name => amg_d_base_smoother_check + Implicit None + + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + Integer(Psb_ipk_) :: err_act + character(len=20) :: name='d_base_smoother_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%check(info) + else + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_smoother_check diff --git a/mlprec/impl/smoother/amg_d_base_smoother_clear_data.f90 b/mlprec/impl/smoother/amg_d_base_smoother_clear_data.f90 new file mode 100644 index 00000000..d2b6e8ea --- /dev/null +++ b/mlprec/impl/smoother/amg_d_base_smoother_clear_data.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_smoother_clear_data(sm,info) + + use psb_base_mod + use amg_d_base_smoother_mod, amg_protect_name => amg_d_base_smoother_clear_data + Implicit None + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_smoother_clear_data' + + call psb_erractionsave(err_act) + + info = 0 + if (allocated(sm%sv)) then + call sm%sv%clear_data(info) + if (info /= 0) then + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_smoother_clear_data diff --git a/mlprec/impl/smoother/amg_d_base_smoother_clone.f90 b/mlprec/impl/smoother/amg_d_base_smoother_clone.f90 new file mode 100644 index 00000000..5d48516d --- /dev/null +++ b/mlprec/impl/smoother/amg_d_base_smoother_clone.f90 @@ -0,0 +1,62 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_smoother_clone(sm,smout,info) + + use psb_base_mod + use amg_d_base_smoother_mod, amg_protect_name => amg_d_base_smoother_clone + Implicit None + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + class(amg_d_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_smoother_clone' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_smoother_clone diff --git a/mlprec/impl/smoother/amg_d_base_smoother_clone_settings.f90 b/mlprec/impl/smoother/amg_d_base_smoother_clone_settings.f90 new file mode 100644 index 00000000..3e1afd76 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_base_smoother_clone_settings.f90 @@ -0,0 +1,89 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_smoother_clone_settings(sm,smout,info) + + use psb_base_mod + use amg_d_base_smoother_mod, amg_protect_name => amg_d_base_smoother_clone_settings + Implicit None + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + class(amg_d_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_smoother_clone_settings' + + call psb_erractionsave(err_act) + + info=psb_success_ + if (same_type_as(sm,smout)) then + if (allocated(smout%sv)) then + if (.not.same_type_as(sm%sv,smout%sv)) then + call smout%sv%free(info) + if (info == 0) deallocate(smout%sv,stat=info) + end if + end if + if (info /= 0) then + info = psb_err_internal_error_ + else + if (allocated(smout%sv)) then + if (same_type_as(sm%sv,smout%sv)) then + call sm%sv%clone_settings(smout%sv,info) + else + info = psb_err_internal_error_ + end if + else + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == 0) call sm%sv%clone_settings(smout%sv,info) + if (info /= 0) info = psb_err_internal_error_ + end if + end if + else + info = psb_err_internal_error_ + end if + if (info /= 0) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_smoother_clone_settings diff --git a/mlprec/impl/smoother/amg_d_base_smoother_cnv.f90 b/mlprec/impl/smoother/amg_d_base_smoother_cnv.f90 new file mode 100644 index 00000000..f579d9d7 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_base_smoother_cnv.f90 @@ -0,0 +1,70 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_smoother_cnv(sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_d_base_smoother_mod, amg_protect_name => amg_d_base_smoother_cnv + Implicit None + + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_smoother_cnv' + + call psb_erractionsave(err_act) + + info = psb_success_ + if (allocated(sm%sv)) then + call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) + else + info = 1121 + call psb_errpush(info,name) + endif + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_smoother_cnv diff --git a/mlprec/impl/smoother/amg_d_base_smoother_csetc.f90 b/mlprec/impl/smoother/amg_d_base_smoother_csetc.f90 new file mode 100644 index 00000000..e0677067 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_base_smoother_csetc.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_smoother_csetc(sm,what,val,info,idx) + + use psb_base_mod + use amg_d_base_smoother_mod, amg_protect_name => amg_d_base_smoother_csetc + Implicit None + + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='d_base_smoother_csetc' + + call psb_erractionsave(err_act) + + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%set(what,val,info,idx=idx) + end if + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_smoother_csetc diff --git a/mlprec/impl/smoother/amg_d_base_smoother_cseti.f90 b/mlprec/impl/smoother/amg_d_base_smoother_cseti.f90 new file mode 100644 index 00000000..4baac510 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_base_smoother_cseti.f90 @@ -0,0 +1,65 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_smoother_cseti(sm,what,val,info,idx) + + use psb_base_mod + use amg_d_base_smoother_mod, amg_protect_name => amg_d_base_smoother_cseti + Implicit None + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_smoother_cseti' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%set(what,val,info,idx=idx) + end if + if (info /= psb_success_) goto 9999 + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_smoother_cseti diff --git a/mlprec/impl/smoother/amg_d_base_smoother_csetr.f90 b/mlprec/impl/smoother/amg_d_base_smoother_csetr.f90 new file mode 100644 index 00000000..ed1c9107 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_base_smoother_csetr.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_smoother_csetr(sm,what,val,info,idx) + + use psb_base_mod + use amg_d_base_smoother_mod, amg_protect_name => amg_d_base_smoother_csetr + Implicit None + + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_smoother_csetr' + + call psb_erractionsave(err_act) + + + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%set(what,val,info,idx=idx) + end if + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_smoother_csetr diff --git a/mlprec/impl/smoother/amg_d_base_smoother_descr.f90 b/mlprec/impl/smoother/amg_d_base_smoother_descr.f90 new file mode 100644 index 00000000..700be52c --- /dev/null +++ b/mlprec/impl/smoother/amg_d_base_smoother_descr.f90 @@ -0,0 +1,101 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_smoother_descr(sm,info,iout,coarse) + + use psb_base_mod + use amg_d_base_smoother_mod, amg_protect_name => amg_d_base_smoother_descr + use amg_d_id_solver + Implicit None + + ! Arguments + class(amg_d_base_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt, me, np + character(len=20), parameter :: name='amg_d_base_smoother_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse_ + + + call psb_erractionsave(err_act) + info = psb_success_ + + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + + if (coarse_) then + if (allocated(sm%sv)) call sm%sv%descr(info,iout,coarse) + else + if (allocated(sm%sv)) then + select type (sv => sm%sv) + class is (amg_d_id_solver_type) + write(iout_,*) 'No preconditioner/smoother' + class default + write(iout_,*) 'Decoupled preconditioner/smoother with local solver' + call sm%sv%descr(info,iout,coarse) + end select + else + write(iout_,*) 'No preconditioner/smoother' + end if + end if + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='Local solver') + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_smoother_descr diff --git a/mlprec/impl/smoother/amg_d_base_smoother_dmp.f90 b/mlprec/impl/smoother/amg_d_base_smoother_dmp.f90 new file mode 100644 index 00000000..f27ed2c5 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_base_smoother_dmp.f90 @@ -0,0 +1,85 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + + use psb_base_mod + use amg_d_base_smoother_mod, amg_protect_name => amg_d_base_smoother_dmp + implicit none + class(amg_d_base_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: smoother_, global_num_ + ! len of prefix_ + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_smth_d" + end if + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + if (present(smoother)) then + smoother_ = smoother + else + smoother_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + ! At base level do nothing for the smoother + if (allocated(sm%sv)) & + & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) + +end subroutine amg_d_base_smoother_dmp diff --git a/mlprec/impl/smoother/amg_d_base_smoother_free.f90 b/mlprec/impl/smoother/amg_d_base_smoother_free.f90 new file mode 100644 index 00000000..8b6a0cbc --- /dev/null +++ b/mlprec/impl/smoother/amg_d_base_smoother_free.f90 @@ -0,0 +1,68 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_smoother_free(sm,info) + + use psb_base_mod + use amg_d_base_smoother_mod, amg_protect_name => amg_d_base_smoother_free + Implicit None + + ! Arguments + class(amg_d_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_smoother_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%free(info) + if (info == psb_success_) deallocate(sm%sv,stat=info) + end if + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_smoother_free diff --git a/mlprec/impl/smoother/amg_d_jac_smoother_apply.f90 b/mlprec/impl/smoother/amg_d_jac_smoother_apply.f90 new file mode 100644 index 00000000..1f1ea1fb --- /dev/null +++ b/mlprec/impl/smoother/amg_d_jac_smoother_apply.f90 @@ -0,0 +1,273 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_jac_smoother_apply(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,info,init,initu) + use psb_base_mod + use amg_d_jac_smoother, amg_protect_name => amg_d_jac_smoother_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_jac_smoother_type), intent(inout) :: sm + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col + real(psb_dpk_), allocatable :: tx(:),ty(:) + real(psb_dpk_), pointer :: aux(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='d_jac_smoother_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = desc_data%get_context() + call psb_info(ictxt,me,np) + + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (4*n_col <= size(work)) then + aux => work(:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + endif + + if ((.not.sm%sv%is_iterative()).and.((sweeps == 1).or.(sm%nd_nnz_tot==0))) then + ! if .not.sv%is_iterative, there's no need to pass init + call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + else if (sweeps >= 0) then + if (associated(sm%pa)) then + ! + ! This means we are dealing with a pure Jacobi smoother/solver. + ! + call psb_geasb(tx,desc_data,info) + call psb_geasb(ty,desc_data,info) + select case (init_) + case('Z') + + call sm%sv%apply(done,x,dzero,ty,desc_data,trans_,aux,info,init='Z') + + case('Y') + call psb_geaxpby(done,x,dzero,tx,desc_data,info) + call psb_geaxpby(done,y,dzero,ty,desc_data,info) + call psb_spmm(-done,sm%pa,ty,done,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(done,x,dzero,tx,desc_data,info) + call psb_geaxpby(done,initu,dzero,ty,desc_data,info) + call psb_spmm(-done,sm%pa,ty,done,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = Y(j)+ D^(-1)*(X-A*Y(j)), + ! where is the diagonal and A the matrix. + ! + call psb_geaxpby(done,x,dzero,tx,desc_data,info) + call psb_spmm(-done,sm%pa,ty,done,tx,desc_data,info,work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(done,tx,done,ty,desc_data,trans_,aux,info,init='Y') + + if (info /= psb_success_) exit + end do + + + if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + else + ! + ! + ! Apply multiple sweeps of a block-Jacobi solver + ! to compute an approximate solution of a linear system. + ! + ! + call psb_geasb(tx,desc_data,info) + call psb_geasb(ty,desc_data,info) + + ! + ! Unroll the first iteration and fold it inside SELECT CASE + ! this will save one AXPBY and one SPMM when INIT=Z, and will be + ! significant when sweeps=1 (a common case) + ! + select case (init_) + case('Z') + + call sm%sv%apply(done,x,dzero,ty,desc_data,trans_,aux,info,init='Z') + + case('Y') + call psb_geaxpby(done,x,dzero,tx,desc_data,info) + call psb_geaxpby(done,y,dzero,ty,desc_data,info) + call psb_spmm(-done,sm%nd,ty,done,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(done,x,dzero,tx,desc_data,info) + call psb_geaxpby(done,initu,dzero,ty,desc_data,info) + call psb_spmm(-done,sm%nd,ty,done,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the + ! block diagonal part and the remaining part of the local matrix + ! and Y(j) is the approximate solution at sweep j. + ! + call psb_geaxpby(done,x,dzero,tx,desc_data,info) + call psb_spmm(-done,sm%nd,ty,done,tx,desc_data,info,work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,info,init='Y') + + if (info /= psb_success_) exit + end do + + if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + end if + + deallocate(tx,ty,stat=info) + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='final cleanup with Jacobi sweeps > 1') + goto 9999 + end if + + else + + info = psb_err_iarg_neg_ + call psb_errpush(info,name,& + & i_err=(/itwo,sweeps,izero,izero,izero/)) + goto 9999 + + endif + + if (.not.(4*n_col <= size(work))) then + deallocate(aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_jac_smoother_apply diff --git a/mlprec/impl/smoother/amg_d_jac_smoother_apply_vect.f90 b/mlprec/impl/smoother/amg_d_jac_smoother_apply_vect.f90 new file mode 100644 index 00000000..f73ff857 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_jac_smoother_apply_vect.f90 @@ -0,0 +1,320 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_jac_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,wv,info,init,initu) + + use psb_base_mod + use amg_d_diag_solver + use psb_base_krylov_conv_mod, only : log_conv + use amg_d_jac_smoother, amg_protect_name => amg_d_jac_smoother_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_jac_smoother_type), intent(inout) :: sm + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + ! + integer(psb_ipk_) :: n_row,n_col + type(psb_d_vect_type) :: tx, ty, r + real(psb_dpk_), pointer :: aux(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + real(psb_dpk_) :: res, resdenum + character(len=20) :: name='d_jac_smoother_apply_v' + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = desc_data%get_context() + call psb_info(ictxt,me,np) + + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (4*n_col <= size(work)) then + aux => work(:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + endif + + if(sm%checkres) then + call psb_geall(r,desc_data,info) + call psb_geasb(r,desc_data,info) + resdenum = psb_genrm2(x,desc_data,info) + end if + + if ((.not.sm%sv%is_iterative()).and.((sweeps == 1).or.(sm%nd_nnz_tot==0))) then + ! if .not.sv%is_iterative, there's no need to pass init + call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,wv,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + else if (sweeps >= 0) then + select type (smsv => sm%sv) + class is (amg_d_diag_solver_type) + ! + ! This means we are dealing with a pure Jacobi smoother/solver. + ! + associate(tx => wv(1), ty => wv(2)) + select case (init_) + case('Z') + + call sm%sv%apply(done,x,dzero,ty,desc_data,trans_,aux,wv(3:),info,init='Z') + + case('Y') + call psb_geaxpby(done,x,dzero,tx,desc_data,info) + call psb_geaxpby(done,y,dzero,ty,desc_data,info) + call psb_spmm(-done,sm%pa,ty,done,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(done,x,dzero,tx,desc_data,info) + call psb_geaxpby(done,initu,dzero,ty,desc_data,info) + call psb_spmm(-done,sm%pa,ty,done,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = Y(j)+ D^(-1)*(X-A*Y(j)), + ! where is the diagonal and A the matrix. + ! + call psb_geaxpby(done,x,dzero,tx,desc_data,info) + call psb_spmm(-done,sm%pa,ty,done,tx,desc_data,info,work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(done,tx,done,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + if (info /= psb_success_) exit + + if ( sm%checkres.and.(mod(i,sm%checkiter) == 0) ) then + call psb_geaxpby(done,x,dzero,r,r,desc_data,info) + call psb_spmm(-done,sm%pa,ty,done,r,desc_data,info) + res = psb_genrm2(r,desc_data,info) + if( sm%printres ) then + call log_conv("BJAC",me,i,sm%printiter,res,resdenum,sm%tol) + end if + if ( res < sm%tol*resdenum ) then + if( (sm%printres).and.(mod(sm%printiter,sm%checkiter)/=0) ) & + & call log_conv("BJAC",me,i,1,res,resdenum,sm%tol) + exit + end if + end if + + end do + + + if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + + end associate + + class default + ! + ! + ! Apply multiple sweeps of a block-Jacobi solver + ! to compute an approximate solution of a linear system. + ! + ! + if (size(wv) < 2) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size in smoother_apply') + goto 9999 + end if + associate(tx => wv(1), ty => wv(2)) + + ! + ! Unroll the first iteration and fold it inside SELECT CASE + ! this will save one AXPBY and one SPMM when INIT=Z, and will be + ! significant when sweeps=1 (a common case) + ! + select case (init_) + case('Z') + + call sm%sv%apply(done,x,dzero,ty,desc_data,trans_,aux,wv(3:),info,init='Z') + + case('Y') + call psb_geaxpby(done,x,dzero,tx,desc_data,info) + call psb_geaxpby(done,y,dzero,ty,desc_data,info) + call psb_spmm(-done,sm%nd,ty,done,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(done,x,dzero,tx,desc_data,info) + call psb_geaxpby(done,initu,dzero,ty,desc_data,info) + call psb_spmm(-done,sm%nd,ty,done,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the + ! block diagonal part and the remaining part of the local matrix + ! and Y(j) is the approximate solution at sweep j. + ! + call psb_geaxpby(done,x,dzero,tx,desc_data,info) + call psb_spmm(-done,sm%nd,ty,done,tx,desc_data,info,work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + if (info /= psb_success_) exit + + if ( sm%checkres.and.(mod(i,sm%checkiter) == 0) ) then + call psb_geaxpby(done,x,dzero,r,r,desc_data,info) + call psb_spmm(-done,sm%pa,ty,done,r,desc_data,info) + res = psb_genrm2(r,desc_data,info) + if( sm%printres ) then + call log_conv("BJAC",me,i,sm%printiter,res,resdenum,sm%tol) + end if + if (res < sm%tol*resdenum ) then + if( (sm%printres).and.( mod(sm%printiter,sm%checkiter) /=0 ) ) & + & call log_conv("BJAC",me,i,1,res,resdenum,sm%tol) + exit + end if + end if + + end do + + if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + end associate + end select + + else + + info = psb_err_iarg_neg_ + call psb_errpush(info,name,& + & i_err=(/itwo,sweeps,izero,izero,izero/)) + goto 9999 + + endif + + if (.not.(4*n_col <= size(work))) then + deallocate(aux) + endif + + if(sm%checkres) then + call psb_gefree(r,desc_data,info) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_jac_smoother_apply_vect diff --git a/mlprec/impl/smoother/amg_d_jac_smoother_bld.f90 b/mlprec/impl/smoother/amg_d_jac_smoother_bld.f90 new file mode 100644 index 00000000..0806d223 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_jac_smoother_bld.f90 @@ -0,0 +1,127 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_d_diag_solver + use amg_d_jac_smoother, amg_protect_name => amg_d_jac_smoother_bld + Implicit None + + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + type(psb_dspmat_type) :: tmpa + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota, nzeros + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_jac_smoother_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + n_col = desc_a%get_local_cols() + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + + if( sm%checkres ) sm%pa => a + + select type (smsv => sm%sv) + class is (amg_d_diag_solver_type) + call sm%nd%free() + sm%pa => a + sm%nd_nnz_tot = nztota + call psb_sum(ictxt,sm%nd_nnz_tot) + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + + class default + if (smsv%is_global()) then + ! Do not put anything into SM%ND since the solver + ! is acting globally. + call sm%nd%free() + sm%nd_nnz_tot = 0 + call psb_sum(ictxt,sm%nd_nnz_tot) + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + else + call a%csclip(sm%nd,info,& + & jmin=nrow_a+1,rscale=.false.,cscale=.false.) + if (info == psb_success_) then + if (present(amold)) then + call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + else + call sm%nd%cscnv(info,& + & type='csr',dupl=psb_dupl_add_) + endif + end if + sm%nd_nnz_tot = sm%nd%get_nzeros() + call psb_sum(ictxt,sm%nd_nnz_tot) + call a%csclip(tmpa,info,& + & jmax=nrow_a,rscale=.false.,cscale=.false.) + call sm%sv%build(tmpa,desc_a,info,amold=amold,vmold=vmold) + end if + end select + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='clip & psb_spcnv csr 4') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_jac_smoother_bld diff --git a/mlprec/impl/smoother/amg_d_jac_smoother_clear_data.f90 b/mlprec/impl/smoother/amg_d_jac_smoother_clear_data.f90 new file mode 100644 index 00000000..5a89b80f --- /dev/null +++ b/mlprec/impl/smoother/amg_d_jac_smoother_clear_data.f90 @@ -0,0 +1,70 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_jac_smoother_clear_data(sm,info) + + use psb_base_mod + use amg_d_jac_smoother, amg_protect_name => amg_d_jac_smoother_clear_data + Implicit None + ! Arguments + class(amg_d_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_jac_smoother_clear_data' + + call psb_erractionsave(err_act) + + info = 0 + call sm%nd%free() + sm%nd_nnz_tot = 0 + sm%pa => null() + if ((info==0).and.allocated(sm%sv)) then + call sm%sv%clear_data(info) + end if + if (info /= 0) then + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_jac_smoother_clear_data diff --git a/mlprec/impl/smoother/amg_d_jac_smoother_clone.f90 b/mlprec/impl/smoother/amg_d_jac_smoother_clone.f90 new file mode 100644 index 00000000..dcdb3099 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_jac_smoother_clone.f90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_jac_smoother_clone(sm,smout,info) + + use psb_base_mod + use amg_d_jac_smoother, amg_protect_name => amg_d_jac_smoother_clone + + Implicit None + + ! Arguments + class(amg_d_jac_smoother_type), intent(inout) :: sm + class(amg_d_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(smout)) then + call smout%free(info) + if (info == psb_success_) deallocate(smout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_d_jac_smoother_type :: smout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(smo => smout) + type is (amg_d_jac_smoother_type) + smo%nd_nnz_tot = sm%nd_nnz_tot + smo%checkres = sm%checkres + smo%printres = sm%printres + smo%checkiter = sm%checkiter + smo%printiter = sm%printiter + smo%tol = sm%tol + call sm%nd%clone(smo%nd,info) + if ((info==psb_success_).and.(allocated(sm%sv))) then + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == psb_success_) call sm%sv%clone(smo%sv,info) + end if + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_jac_smoother_clone diff --git a/mlprec/impl/smoother/amg_d_jac_smoother_clone_settings.f90 b/mlprec/impl/smoother/amg_d_jac_smoother_clone_settings.f90 new file mode 100644 index 00000000..1433a417 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_jac_smoother_clone_settings.f90 @@ -0,0 +1,101 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! asd on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_jac_smoother_clone_settings(sm,smout,info) + + use psb_base_mod + use amg_d_jac_smoother, amg_protect_name => amg_d_jac_smoother_clone_settings + Implicit None + ! Arguments + class(amg_d_jac_smoother_type), intent(inout) :: sm + class(amg_d_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_jac_smoother_clone_settings' + + call psb_erractionsave(err_act) + + info = psb_success_ + + select type(smout) + class is(amg_d_jac_smoother_type) + + smout%pa => null() + smout%nd_nnz_tot = 0 + smout%checkres = sm%checkres + smout%printres = sm%printres + smout%checkiter = sm%checkiter + smout%printiter = sm%printiter + smout%tol = sm%tol + + if (allocated(smout%sv)) then + if (.not.same_type_as(sm%sv,smout%sv)) then + call smout%sv%free(info) + if (info == 0) deallocate(smout%sv,stat=info) + end if + end if + if (info /= 0) then + info = psb_err_internal_error_ + else + if (allocated(smout%sv)) then + if (same_type_as(sm%sv,smout%sv)) then + call sm%sv%clone_settings(smout%sv,info) + else + info = psb_err_internal_error_ + end if + else + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == 0) call sm%sv%clone_settings(smout%sv,info) + if (info /= 0) info = psb_err_internal_error_ + end if + end if + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_jac_smoother_clone_settings diff --git a/mlprec/impl/smoother/amg_d_jac_smoother_cnv.f90 b/mlprec/impl/smoother/amg_d_jac_smoother_cnv.f90 new file mode 100644 index 00000000..f20e76db --- /dev/null +++ b/mlprec/impl/smoother/amg_d_jac_smoother_cnv.f90 @@ -0,0 +1,90 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_jac_smoother_cnv(sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_d_diag_solver + use amg_d_jac_smoother, amg_protect_name => amg_d_jac_smoother_cnv + Implicit None + + ! Arguments + class(amg_d_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_jac_smoother_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + + if (info == psb_success_) then + if (sm%nd%is_asb()) then + if (present(amold)) then + call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + else + call sm%nd%cscnv(info,& + & type='csr',dupl=psb_dupl_add_) + endif + end if + end if + + if (info == psb_success_) then + if (allocated(sm%sv)) & + & call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='solver cnv') + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_jac_smoother_cnv diff --git a/mlprec/impl/smoother/amg_d_jac_smoother_csetc.f90 b/mlprec/impl/smoother/amg_d_jac_smoother_csetc.f90 new file mode 100644 index 00000000..6a051171 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_jac_smoother_csetc.f90 @@ -0,0 +1,90 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_jac_smoother_csetc(sm,what,val,info,idx) + + use psb_base_mod + use amg_d_jac_smoother, amg_protect_nam => amg_d_jac_smoother_csetc + Implicit None + ! Arguments + class(amg_d_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='d_jac_smoother_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(trim(what))) + case('SMOOTHER_STOP') + select case(psb_toupper(trim(val))) + case('T','TRUE') + sm%checkres = .true. + case('F','FALSE') + sm%checkres = .false. + case default + write(0,*) 'Unknown value for smoother_stop : "',psb_toupper(trim(val)),'"' + end select + case('SMOOTHER_TRACE') + select case(psb_toupper(trim(val))) + case('T','TRUE') + sm%printres = .true. + case('F','FALSE') + sm%printres = .false. + case default + write(0,*) 'Unknown value for smoother_trace : "',psb_toupper(trim(val)),'"' + end select + case default + call sm%amg_d_base_smoother_type%set(what,val,info,idx=idx) + end select + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info, name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_jac_smoother_csetc diff --git a/mlprec/impl/smoother/amg_d_jac_smoother_cseti.f90 b/mlprec/impl/smoother/amg_d_jac_smoother_cseti.f90 new file mode 100644 index 00000000..6aec4a66 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_jac_smoother_cseti.f90 @@ -0,0 +1,71 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_jac_smoother_cseti(sm,what,val,info,idx) + + use psb_base_mod + use amg_d_jac_smoother, amg_protect_nam => amg_d_jac_smoother_cseti + Implicit None + + ! Arguments + class(amg_d_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_jac_smoother_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) + case('SMOOTHER_RESIDUAL') + sm%checkiter = val + case('SMOOTHER_ITRACE') + sm%printiter = val + case default + call sm%amg_d_base_smoother_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_jac_smoother_cseti diff --git a/mlprec/impl/smoother/amg_d_jac_smoother_csetr.f90 b/mlprec/impl/smoother/amg_d_jac_smoother_csetr.f90 new file mode 100644 index 00000000..5d725d2a --- /dev/null +++ b/mlprec/impl/smoother/amg_d_jac_smoother_csetr.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_jac_smoother_csetr(sm,what,val,info,idx) + + use psb_base_mod + use amg_d_jac_smoother, amg_protect_nam => amg_d_jac_smoother_csetr + Implicit None + + ! Arguments + class(amg_d_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_jac_smoother_csetr' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) + case('SMOOTHER_STOPTOL') + sm%tol = val + case default + call sm%amg_d_base_smoother_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_jac_smoother_csetr diff --git a/mlprec/impl/smoother/amg_d_jac_smoother_descr.f90 b/mlprec/impl/smoother/amg_d_jac_smoother_descr.f90 new file mode 100644 index 00000000..0d95dbf0 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_jac_smoother_descr.f90 @@ -0,0 +1,103 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_jac_smoother_descr(sm,info,iout,coarse) + + use psb_base_mod + use amg_d_diag_solver + use amg_d_jac_smoother, amg_protect_name => amg_d_jac_smoother_descr + use amg_d_diag_solver + use amg_d_gs_solver + + Implicit None + + ! Arguments + class(amg_d_jac_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_d_jac_smoother_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (.not.coarse_) then + if (allocated(sm%sv)) then + select type(smv=>sm%sv) + class is (amg_d_diag_solver_type) + write(iout_,*) ' Point Jacobi ' + write(iout_,*) ' Local diagonal:' + call smv%descr(info,iout_,coarse=coarse) + class is (amg_d_bwgs_solver_type) + write(iout_,*) ' Hybrid Backward Gauss-Seidel ' + class is (amg_d_gs_solver_type) + write(iout_,*) ' Hybrid Forward Gauss-Seidel ' + class default + write(iout_,*) ' Block Jacobi ' + write(iout_,*) ' Local solver details:' + call smv%descr(info,iout_,coarse=coarse) + end select + + else + write(iout_,*) ' Block Jacobi ' + end if + else + if (allocated(sm%sv)) then + call sm%sv%descr(info,iout_,coarse=coarse) + end if + end if + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return +end subroutine amg_d_jac_smoother_descr diff --git a/mlprec/impl/smoother/amg_d_jac_smoother_dmp.f90 b/mlprec/impl/smoother/amg_d_jac_smoother_dmp.f90 new file mode 100644 index 00000000..6d4c2426 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_jac_smoother_dmp.f90 @@ -0,0 +1,97 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_jac_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + + use psb_base_mod + use amg_d_jac_smoother, amg_protect_nam => amg_d_jac_smoother_dmp + implicit none + class(amg_d_jac_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + integer(psb_lpk_), allocatable :: iv(:) + logical :: smoother_, global_num_ + ! len of prefix_ + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_smth_d" + end if + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(smoother)) then + smoother_ = smoother + else + smoother_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + if (smoother_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_nd.mtx' + if (global_num_) then + iv = desc%get_global_indices(owned=.false.) + if (sm%nd%is_asb()) & + & call sm%nd%print(fname,head=head,iv=iv) + else + if (sm%nd%is_asb()) & + & call sm%nd%print(fname,head=head) + end if + end if + ! At base level do nothing for the smoother + if (allocated(sm%sv)) & + & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) + +end subroutine amg_d_jac_smoother_dmp diff --git a/mlprec/impl/smoother/amg_d_l1_jac_smoother_bld.f90 b/mlprec/impl/smoother/amg_d_l1_jac_smoother_bld.f90 new file mode 100644 index 00000000..547b8d1a --- /dev/null +++ b/mlprec/impl/smoother/amg_d_l1_jac_smoother_bld.f90 @@ -0,0 +1,176 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_l1_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_d_diag_solver + use amg_d_jac_smoother, amg_protect_name => amg_d_l1_jac_smoother_bld + Implicit None + + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_l1_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota, nzeros + real(psb_dpk_), allocatable :: arwsum(:) + type(psb_dspmat_type) :: tmpa + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_l1_jac_smoother_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + n_col = desc_a%get_local_cols() + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + + if( sm%checkres ) sm%pa => a + + select type (smsv => sm%sv) + class is (amg_d_diag_solver_type) + call sm%nd%free() + sm%pa => a + sm%nd_nnz_tot = nztota + + call psb_sum(ictxt,sm%nd_nnz_tot) + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + + class default + if (smsv%is_global()) then + ! Do not put anything into SM%ND since the solver + ! is acting globally. + call sm%nd%free() + sm%nd_nnz_tot = 0 + call psb_sum(ictxt,sm%nd_nnz_tot) + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + else + + call a%csclip(tmpa,info,& + & jmax=nrow_a,rscale=.false.,cscale=.false.) + + call a%csclip(sm%nd,info,& + & jmin=nrow_a+1,rscale=.false.,cscale=.false.) + + arwsum = sm%nd%arwsum(info) + + call combine_dl1(-done,arwsum,sm%nd,info) + call combine_dl1(done,arwsum,tmpa,info) + + sm%nd_nnz_tot = sm%nd%get_nzeros() + call psb_sum(ictxt,sm%nd_nnz_tot) + + call sm%sv%build(tmpa,desc_a,info,amold=amold,vmold=vmold) + + if (info == psb_success_) then + if (present(amold)) then + call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + else + call sm%nd%cscnv(info,& + & type='csr',dupl=psb_dupl_add_) + endif + end if + end if + end select + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='clip & psb_spcnv csr 4') + goto 9999 + end if + + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='solver build') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + + subroutine combine_dl1(alpha,dl1,mat,info) + implicit none + real(psb_dpk_), intent(in) :: alpha, dl1(:) + type(psb_dspmat_type), intent(inout) :: mat + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: k, nz, nrm, dp + type(psb_d_coo_sparse_mat) :: tcoo + + call mat%mv_to(tcoo) + nz = tcoo%get_nzeros() + nrm = min(size(dl1),tcoo%get_nrows(),tcoo%get_ncols()) +!!$ write(0,*) 'Check on combine_dl1: ',nrm, tcoo%get_nrows(),tcoo%get_ncols(), nz + call tcoo%ensure_size(nz+nrm) + call tcoo%set_dupl(psb_dupl_add_) + do k=1,nrm + if (dl1(k) /= dzero) then + nz = nz + 1 + tcoo%ia(nz) = k + tcoo%ja(nz) = k + tcoo%val(nz) = alpha*dl1(k) + end if + end do + call tcoo%set_nzeros(nz) + call tcoo%fix(info) + call mat%mv_from(tcoo) + end subroutine combine_dl1 + + +end subroutine amg_d_l1_jac_smoother_bld diff --git a/mlprec/impl/smoother/amg_d_l1_jac_smoother_clone.f90 b/mlprec/impl/smoother/amg_d_l1_jac_smoother_clone.f90 new file mode 100644 index 00000000..01553412 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_l1_jac_smoother_clone.f90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_l1_jac_smoother_clone(sm,smout,info) + + use psb_base_mod + use amg_d_jac_smoother, amg_protect_name => amg_d_l1_jac_smoother_clone + + Implicit None + + ! Arguments + class(amg_d_l1_jac_smoother_type), intent(inout) :: sm + class(amg_d_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(smout)) then + call smout%free(info) + if (info == psb_success_) deallocate(smout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_d_l1_jac_smoother_type :: smout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(smo => smout) + type is (amg_d_l1_jac_smoother_type) + smo%nd_nnz_tot = sm%nd_nnz_tot + smo%checkres = sm%checkres + smo%printres = sm%printres + smo%checkiter = sm%checkiter + smo%printiter = sm%printiter + smo%tol = sm%tol + call sm%nd%clone(smo%nd,info) + if ((info==psb_success_).and.(allocated(sm%sv))) then + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == psb_success_) call sm%sv%clone(smo%sv,info) + end if + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_l1_jac_smoother_clone diff --git a/mlprec/impl/smoother/amg_d_l1_jac_smoother_descr.f90 b/mlprec/impl/smoother/amg_d_l1_jac_smoother_descr.f90 new file mode 100644 index 00000000..f17ba734 --- /dev/null +++ b/mlprec/impl/smoother/amg_d_l1_jac_smoother_descr.f90 @@ -0,0 +1,103 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_l1_jac_smoother_descr(sm,info,iout,coarse) + + use psb_base_mod + use amg_d_diag_solver + use amg_d_jac_smoother, amg_protect_name => amg_d_l1_jac_smoother_descr + use amg_d_diag_solver + use amg_d_gs_solver + + Implicit None + + ! Arguments + class(amg_d_l1_jac_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_d_l1_jac_smoother_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (.not.coarse_) then + if (allocated(sm%sv)) then + select type(smv=>sm%sv) + class is (amg_d_diag_solver_type) + write(iout_,*) ' Point Jacobi ' + write(iout_,*) ' Local diagonal:' + call smv%descr(info,iout_,coarse=coarse) + class is (amg_d_bwgs_solver_type) + write(iout_,*) ' L1-Hybrid Backward Gauss-Seidel ' + class is (amg_d_gs_solver_type) + write(iout_,*) ' L1-Hybrid Forward Gauss-Seidel ' + class default + write(iout_,*) ' L1-Block Jacobi ' + write(iout_,*) ' Local solver details:' + call smv%descr(info,iout_,coarse=coarse) + end select + + else + write(iout_,*) ' L1-Block Jacobi ' + end if + else + if (allocated(sm%sv)) then + call sm%sv%descr(info,iout_,coarse=coarse) + end if + end if + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return +end subroutine amg_d_l1_jac_smoother_descr diff --git a/mlprec/impl/smoother/amg_s_as_smoother_apply.f90 b/mlprec/impl/smoother/amg_s_as_smoother_apply.f90 new file mode 100644 index 00000000..489397f8 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_as_smoother_apply.f90 @@ -0,0 +1,235 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_as_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,info,init,initu) + use psb_base_mod + use amg_s_as_smoother, amg_protect_nam => amg_s_as_smoother_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_as_smoother_type), intent(inout) :: sm + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col, nrow_d, i + real(psb_spk_), pointer :: aux(:) + real(psb_spk_), allocatable :: tx(:),ty(:), ww(:) + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5) + character :: trans_, init_ + character(len=20) :: name='s_as_smoother_apply', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = desc_data%get_context() + call psb_info(ictxt,me,np) + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + n_row = sm%desc_data%get_local_rows() + n_col = sm%desc_data%get_local_cols() + nrow_d = desc_data%get_local_rows() + isz = max(n_row,N_COL) + + if ((4*isz) <= size(work)) then + aux => work(1:) + else + allocate(aux(4*isz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name,& + & i_err=(/4*isz,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + endif + + if ((.not.sm%sv%is_iterative()).and.(sweeps == 1).and.(sm%novr==0)) then + ! + ! Shortcut: in this case there is nothing else to be done. + ! + call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + else if (sweeps >= 0) then + ! + ! + ! Apply multiple sweeps of an AS solver + ! to compute an approximate solution of a linear system. + ! + ! + call psb_geasb(tx,sm%desc_data,info) + call psb_geasb(ty,sm%desc_data,info) + call psb_geasb(ww,sm%desc_data,info) + + ! + ! Unroll the first iteration and fold it inside SELECT CASE + ! this will save one SPMM when INIT=Z, and will be + ! significant when sweeps=1 (a common case) + ! + call psb_geaxpby(sone,x,szero,tx,desc_data,info) + if (info == 0) call sm%apply_restr(tx,trans_,aux,info) + if (info == 0) call psb_geaxpby(sone,tx,szero,ww,sm%desc_data,info) + + select case (init_) + case('Z') + call sm%sv%apply(sone,ww,szero,ty,sm%desc_data,trans_,aux,info,init='Z') + + case('Y') + call psb_geaxpby(sone,y,szero,ty,desc_data,info) + if (info == 0) call sm%apply_restr(ty,trans_,aux,info) + if (info == 0) call psb_spmm(-sone,sm%nd,ty,sone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + call sm%sv%apply(sone,ww,szero,ty,desc_data,trans_,aux,info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(sone,initu,szero,ty,desc_data,info) + if (info == 0) call sm%apply_restr(ty,trans_,aux,info) + if (info == 0) call psb_spmm(-sone,sm%nd,ty,sone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + call sm%sv%apply(sone,ww,szero,ty,desc_data,trans_,aux,info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + if (info == 0) call sm%apply_prol(ty,trans_,aux,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the + ! block diagonal part and the remaining part of the local matrix + ! and Y(j) is the approximate solution at sweep j. + ! + if (info == 0) call psb_geaxpby(sone,tx,szero,ww,sm%desc_data,info) + if (info == 0) call psb_spmm(-sone,sm%nd,ty,sone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(sone,ww,szero,ty,sm%desc_data,trans_,aux,info,init='Y') + + if (info /= psb_success_) exit + if (info == 0) call sm%apply_prol(ty,trans_,aux,info) + + end do + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + ! + ! Compute y = beta*y + alpha*ty (ty == K^(-1)*tx) + ! + call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + + else + + info = psb_err_iarg_neg_ + call psb_errpush(info,name,& + & i_err=(/itwo,sweeps,izero,izero,izero/)) + goto 9999 + + endif + + + if (.not.(4*isz <= size(work))) then + deallocate(aux,stat=info) + endif + if (info ==0) deallocate(ww,tx,ty,stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_as_smoother_apply diff --git a/mlprec/impl/smoother/amg_s_as_smoother_apply_vect.f90 b/mlprec/impl/smoother/amg_s_as_smoother_apply_vect.f90 new file mode 100644 index 00000000..ad2ca81c --- /dev/null +++ b/mlprec/impl/smoother/amg_s_as_smoother_apply_vect.f90 @@ -0,0 +1,259 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_as_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,wv,info,init,initu) + use psb_base_mod + use amg_s_as_smoother, amg_protect_nam => amg_s_as_smoother_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_as_smoother_type), intent(inout) :: sm + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col, nrow_d, i + real(psb_spk_), pointer :: aux(:) + type(psb_s_vect_type) :: tx, ty, ww + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5) + character :: trans_, init_ + logical :: do_realloc_wv + character(len=20) :: name='s_as_smoother_apply_v', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = desc_data%get_context() + call psb_info(ictxt,me,np) + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + n_row = sm%desc_data%get_local_rows() + n_col = sm%desc_data%get_local_cols() + nrow_d = desc_data%get_local_rows() + isz = max(n_row,N_COL) + + if (4*isz <= size(work)) then + aux => work(:) + else + allocate(aux(4*isz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name,& + & i_err=(/4*isz,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + endif + + if ((.not.sm%sv%is_iterative()).and.(sweeps == 1).and.(sm%novr==0)) then + ! + ! Shortcut: in this case there is nothing else to be done. + ! + call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,wv,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + else if (sweeps >= 0) then + ! + ! + ! Apply multiple sweeps of an AS solver + ! to compute an approximate solution of a linear system. + ! + ! + if (size(wv) < 3) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='invalid wv size in smoother_apply') + goto 9999 + end if + + ! + ! This is tricky. This smoother has a descriptor sm%desc_data + ! for an index space potentially different from + ! that of desc_data. Hence the size of the work vectors + ! could be wrong. We need to check and reallocate as needed. + ! + do_realloc_wv = (wv(1)%get_nrows() < sm%desc_data%get_local_cols()).or.& + & (wv(2)%get_nrows() < sm%desc_data%get_local_cols()).or.& + & (wv(3)%get_nrows() < sm%desc_data%get_local_cols()) + + if (do_realloc_wv) then + call psb_geasb(wv(1),sm%desc_data,info,scratch=.true.,mold=wv(2)%v) + call psb_geasb(wv(2),sm%desc_data,info,scratch=.true.,mold=wv(1)%v) + call psb_geasb(wv(3),sm%desc_data,info,scratch=.true.,mold=wv(1)%v) + end if + + associate(tx => wv(1), ty => wv(2), ww => wv(3)) + + ! Need to zero tx because of the apply_restr call. + call tx%zero() + ! + ! Unroll the first iteration and fold it inside SELECT CASE + ! this will save one SPMM when INIT=Z, and will be + ! significant when sweeps=1 (a common case) + ! + call psb_geaxpby(sone,x,szero,tx,desc_data,info) + if (info == 0) call sm%apply_restr(tx,trans_,aux,info) + if (info == 0) call psb_geaxpby(sone,tx,szero,ww,sm%desc_data,info) + + select case (init_) + case('Z') + call sm%sv%apply(sone,ww,szero,ty,sm%desc_data,trans_,aux,wv(4:),info,init='Z') + + case('Y') + call psb_geaxpby(sone,y,szero,ty,desc_data,info) + if (info == 0) call sm%apply_restr(ty,trans_,aux,info) + if (info == 0) call psb_spmm(-sone,sm%nd,ty,sone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + call sm%sv%apply(sone,ww,szero,ty,desc_data,trans_,aux,wv(4:),info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(sone,initu,szero,ty,desc_data,info) + if (info == 0) call sm%apply_restr(ty,trans_,aux,info) + if (info == 0) call psb_spmm(-sone,sm%nd,ty,sone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + call sm%sv%apply(sone,ww,szero,ty,desc_data,trans_,aux,wv(4:),info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + if (info == 0) call sm%apply_prol(ty,trans_,aux,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the + ! block diagonal part and the remaining part of the local matrix + ! and Y(j) is the approximate solution at sweep j. + ! + if (info == 0) call psb_geaxpby(sone,tx,szero,ww,sm%desc_data,info) + if (info == 0) call psb_spmm(-sone,sm%nd,ty,sone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(sone,ww,szero,ty,sm%desc_data,trans_,aux,wv(4:),info,init='Y') + + if (info /= psb_success_) exit + if (info == 0) call sm%apply_prol(ty,trans_,aux,info) + + end do + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + ! + ! Compute y = beta*y + alpha*ty (ty == K^(-1)*tx) + ! + call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + end associate + + else + + info = psb_err_iarg_neg_ + call psb_errpush(info,name,& + & i_err=(/itwo,sweeps,izero,izero,izero/)) + goto 9999 + + endif + + + if (.not.(4*isz <= size(work))) then + deallocate(aux,stat=info) + endif + + if (info /= 0) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_as_smoother_apply_vect diff --git a/mlprec/impl/smoother/amg_s_as_smoother_bld.f90 b/mlprec/impl/smoother/amg_s_as_smoother_bld.f90 new file mode 100644 index 00000000..c78ab88e --- /dev/null +++ b/mlprec/impl/smoother/amg_s_as_smoother_bld.f90 @@ -0,0 +1,183 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_as_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_s_as_smoother, amg_protect_nam => amg_s_as_smoother_bld + Implicit None + + ! Arguments + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local variables + type(psb_sspmat_type) :: blck, atmp + integer(psb_ipk_) :: n_row,n_col, nrow_a, nhalo, novr, data_ + real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='s_as_smoother_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + novr = sm%novr + if (novr < 0) then + info=psb_err_invalid_ovr_num_ + call psb_errpush(info,name,& + & i_err=(/novr,izero,izero,izero,izero,izero/)) + goto 9999 + endif + + if ((novr == 0).or.(np == 1)) then + call psb_cdcpy(desc_a,sm%desc_data,info) + If(debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' done cdcpy' + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_cdcpy' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Early return: P>=3 N_OVR=0' + call blck%csall(izero,izero,info,ione) + else + + ! + ! Build the auxiliary descriptor desc_p%matrix_data(psb_n_row_). + ! This is done by psb_cdbldext (interface to psb_cdovr), which is + ! independent of CSR, and has been placed in the tools directory + ! of PSBLAS, instead of the mlprec directory of MLD2P4, because it + ! might be used independently of the AS preconditioner, to build + ! a descriptor for an extended stencil in a PDE solver. + ! + call psb_cdbldext(a,desc_a,novr,sm%desc_data,info,extype=psb_ovt_asov_) + if(debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' From cdbldext _:',sm%desc_data%get_local_rows(),& + & sm%desc_data%get_local_cols() + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_cdbldext' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Before sphalo ' + + ! + ! Retrieve the remote sparse matrix rows required for the AS extended + ! matrix + data_ = psb_comm_ext_ + Call psb_sphalo(a,sm%desc_data,blck,info,data=data_,rowscale=.true.) + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_sphalo' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + if (debug_level >=psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'After psb_sphalo ',& + & blck%get_nrows(), blck%get_nzeros() + + End if + if (info == psb_success_) & + & call sm%sv%build(a,sm%desc_data,info,& + & blck,amold=amold,vmold=vmold) + + nrow_a = a%get_nrows() + n_row = sm%desc_data%get_local_rows() + n_col = sm%desc_data%get_local_cols() + + if (info == psb_success_) call a%csclip(sm%nd,info,& + & jmin=nrow_a+1,rscale=.false.,cscale=.false.) + if (info == psb_success_) call blck%csclip(atmp,info,& + & jmin=nrow_a+1,rscale=.false.,cscale=.false.) + if (info == psb_success_) call psb_rwextd(n_row,sm%nd,info,b=atmp) + + if (info == psb_success_) then + if (present(amold)) then + call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + else + call sm%nd%cscnv(info,& + & type='csr',dupl=psb_dupl_add_) + end if + end if + if (info == psb_success_) then + if (present(imold)) then + call sm%desc_data%cnv(imold) + end if + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='clip & psb_spcnv csr 4') + goto 9999 + end if + sm%nd_nnz_tot = sm%nd%get_nzeros() + call psb_sum(ictxt,sm%nd_nnz_tot) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_as_smoother_bld diff --git a/mlprec/impl/smoother/amg_s_as_smoother_check.f90 b/mlprec/impl/smoother/amg_s_as_smoother_check.f90 new file mode 100644 index 00000000..ffe77d3a --- /dev/null +++ b/mlprec/impl/smoother/amg_s_as_smoother_check.f90 @@ -0,0 +1,78 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_as_smoother_check(sm,info) + + use psb_base_mod + use amg_s_as_smoother, amg_protect_nam => amg_s_as_smoother_check + + Implicit None + + ! Arguments + class(amg_s_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + Integer(Psb_ipk_) :: err_act + character(len=20) :: name='s_as_smoother_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + call amg_check_def(sm%restr,& + & 'Restrictor',psb_halo_,is_legal_restrict) + call amg_check_def(sm%prol,& + & 'Prolongator',psb_none_,is_legal_prolong) + call amg_check_def(sm%novr,& + & 'Overlap layers ',izero,is_int_non_negative) + + + if (allocated(sm%sv)) then + call sm%sv%check(info) + else + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_as_smoother_check diff --git a/mlprec/impl/smoother/amg_s_as_smoother_clear_data.f90 b/mlprec/impl/smoother/amg_s_as_smoother_clear_data.f90 new file mode 100644 index 00000000..e4842dcf --- /dev/null +++ b/mlprec/impl/smoother/amg_s_as_smoother_clear_data.f90 @@ -0,0 +1,70 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_as_smoother_clear_data(sm,info) + + use psb_base_mod + use amg_s_as_smoother, amg_protect_name => amg_s_as_smoother_clear_data + Implicit None + ! Arguments + class(amg_s_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_as_smoother_clear_data' + + call psb_erractionsave(err_act) + + info = 0 + call sm%nd%free() + sm%nd_nnz_tot = 0 + call sm%desc_data%free(info) + if ((info==0).and.allocated(sm%sv)) then + call sm%sv%clear_data(info) + end if + if (info /= 0) then + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_as_smoother_clear_data diff --git a/mlprec/impl/smoother/amg_s_as_smoother_clone.f90 b/mlprec/impl/smoother/amg_s_as_smoother_clone.f90 new file mode 100644 index 00000000..e565ce90 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_as_smoother_clone.f90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_as_smoother_clone(sm,smout,info) + + use psb_base_mod + use amg_s_as_smoother, amg_protect_name => amg_s_as_smoother_clone + + Implicit None + + ! Arguments + class(amg_s_as_smoother_type), intent(inout) :: sm + class(amg_s_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(smout)) then + call smout%free(info) + if (info == psb_success_) deallocate(smout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_s_as_smoother_type :: smout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(smo => smout) + type is (amg_s_as_smoother_type) + smo%novr = sm%novr + smo%restr = sm%restr + smo%prol = sm%prol + smo%nd_nnz_tot = sm%nd_nnz_tot + call sm%nd%clone(smo%nd,info) + if (info == psb_success_) & + & call sm%desc_data%clone(smo%desc_data,info) + if ((info==psb_success_).and.(allocated(sm%sv))) then + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == psb_success_) call sm%sv%clone(smo%sv,info) + end if + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_as_smoother_clone diff --git a/mlprec/impl/smoother/amg_s_as_smoother_clone_settings.f90 b/mlprec/impl/smoother/amg_s_as_smoother_clone_settings.f90 new file mode 100644 index 00000000..458d0864 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_as_smoother_clone_settings.f90 @@ -0,0 +1,95 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! asd on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_as_smoother_clone_settings(sm,smout,info) + + use psb_base_mod + use amg_s_as_smoother, amg_protect_name => amg_s_as_smoother_clone_settings + Implicit None + ! Arguments + class(amg_s_as_smoother_type), intent(inout) :: sm + class(amg_s_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_as_smoother_clone_settings' + + call psb_erractionsave(err_act) + + info = psb_success_ + + select type(smout) + class is(amg_s_as_smoother_type) + smout%novr = sm%novr + smout%restr = sm%restr + smout%prol = sm%prol + if (allocated(smout%sv)) then + if (.not.same_type_as(sm%sv,smout%sv)) then + call smout%sv%free(info) + if (info == 0) deallocate(smout%sv,stat=info) + end if + end if + if (info /= 0) then + info = psb_err_internal_error_ + else + if (allocated(smout%sv)) then + if (same_type_as(sm%sv,smout%sv)) then + call sm%sv%clone_settings(smout%sv,info) + else + info = psb_err_internal_error_ + end if + else + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == 0) call sm%sv%clone_settings(smout%sv,info) + if (info /= 0) info = psb_err_internal_error_ + end if + end if + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_as_smoother_clone_settings diff --git a/mlprec/impl/smoother/amg_s_as_smoother_cnv.f90 b/mlprec/impl/smoother/amg_s_as_smoother_cnv.f90 new file mode 100644 index 00000000..c3874204 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_as_smoother_cnv.f90 @@ -0,0 +1,96 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_as_smoother_cnv(sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_s_as_smoother, amg_protect_nam => amg_s_as_smoother_cnv + Implicit None + + ! Arguments + class(amg_s_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local variables + type(psb_dspmat_type) :: blck, atmp + integer(psb_ipk_) :: n_row,n_col, nrow_a, nhalo, novr, data_, nzeros + real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_as_smoother_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = sm%desc_data%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + if (allocated(sm%sv)) & + & call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) + + if (info == psb_success_) then + if (present(amold)) then + if (sm%nd%is_asb()) call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + end if + end if + if (info == psb_success_) then + if (present(imold)) then + call sm%desc_data%cnv(imold) + end if + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='clip & psb_spcnv csr 4') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_as_smoother_cnv diff --git a/mlprec/impl/smoother/amg_s_as_smoother_csetc.f90 b/mlprec/impl/smoother/amg_s_as_smoother_csetc.f90 new file mode 100644 index 00000000..95f681e7 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_as_smoother_csetc.f90 @@ -0,0 +1,78 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_as_smoother_csetc(sm,what,val,info,idx) + + use psb_base_mod + use amg_s_as_smoother, amg_protect_nam => amg_s_as_smoother_csetc + Implicit None + ! Arguments + class(amg_s_as_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='s_as_smoother_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + + + ival = sm%stringval(val) + select case(psb_toupper(what)) + case('SUB_RESTR') + sm%restr = ival + case('SUB_PROL') + sm%prol = ival + case default + call sm%amg_s_base_smoother_type%set(what,val,info,idx=idx) + end select + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info, name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_as_smoother_csetc diff --git a/mlprec/impl/smoother/amg_s_as_smoother_cseti.f90 b/mlprec/impl/smoother/amg_s_as_smoother_cseti.f90 new file mode 100644 index 00000000..6148ca0b --- /dev/null +++ b/mlprec/impl/smoother/amg_s_as_smoother_cseti.f90 @@ -0,0 +1,73 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_as_smoother_cseti(sm,what,val,info,idx) + + use psb_base_mod + use amg_s_as_smoother, amg_protect_nam => amg_s_as_smoother_cseti + Implicit None + + ! Arguments + class(amg_s_as_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_as_smoother_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) + case('SUB_OVR') + sm%novr = val + case('SUB_RESTR') + sm%restr = val + case('SUB_PROL') + sm%prol = val + case default + call sm%amg_s_base_smoother_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_as_smoother_cseti diff --git a/mlprec/impl/smoother/amg_s_as_smoother_dmp.f90 b/mlprec/impl/smoother/amg_s_as_smoother_dmp.f90 new file mode 100644 index 00000000..6aa31daa --- /dev/null +++ b/mlprec/impl/smoother/amg_s_as_smoother_dmp.f90 @@ -0,0 +1,92 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_as_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + + use psb_base_mod + use amg_s_as_smoother, amg_protect_nam => amg_s_as_smoother_dmp + implicit none + class(amg_s_as_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: smoother_, global_num_ + ! len of prefix_ + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_smth_s" + end if + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(smoother)) then + smoother_ = smoother + else + smoother_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + if (global_num_) then + write(0,*) iam,' Warning: no global num with AS smoothers dump' + end if + if (smoother_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_nd.mtx' + if (sm%nd%is_asb()) & + & call sm%nd%print(fname,head=head) + end if + ! At base level do nothing for the smoother + if (allocated(sm%sv)) & + & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) + +end subroutine amg_s_as_smoother_dmp diff --git a/mlprec/impl/smoother/amg_s_as_smoother_free.f90 b/mlprec/impl/smoother/amg_s_as_smoother_free.f90 new file mode 100644 index 00000000..3b4d8ed5 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_as_smoother_free.f90 @@ -0,0 +1,71 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_as_smoother_free(sm,info) + + use psb_base_mod + use amg_s_as_smoother, amg_protect_nam => amg_s_as_smoother_free + Implicit None + ! Arguments + class(amg_s_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_as_smoother_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + + + if (allocated(sm%sv)) then + call sm%sv%free(info) + if (info == psb_success_) deallocate(sm%sv,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + end if + call sm%nd%free() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_as_smoother_free diff --git a/mlprec/impl/smoother/amg_s_as_smoother_prol_a.f90 b/mlprec/impl/smoother/amg_s_as_smoother_prol_a.f90 new file mode 100644 index 00000000..68c209ad --- /dev/null +++ b/mlprec/impl/smoother/amg_s_as_smoother_prol_a.f90 @@ -0,0 +1,149 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_as_smoother_prol_a(sm,x,trans,work,info,data) + use psb_base_mod + use amg_s_as_smoother, amg_protect_nam => amg_s_as_smoother_prol_a + implicit none + class(amg_s_as_smoother_type), intent(inout) :: sm + real(psb_spk_), intent(inout) :: x(:) + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + !Local + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ + character :: trans_ + character(len=20) :: name='s_as_smther_prol_a', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = sm%desc_data%get_context() + call psb_info(ictxt,me,np) + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + info = psb_err_iarg_invalid_i_ + call psb_errpush(info,name) + goto 9999 + end select + + if (present(data)) then + data_ = data + else + data_ = psb_comm_ext_ + end if + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + + select case(trans_) + case('N') + + select case (sm%prol) + + case(psb_none_) + ! + ! Would work anyway, but since it is supposed to do nothing ... + ! call psb_ovrl(x,sm%desc_data,info,& + ! & update=sm%prol,work=work) + + + case(psb_sum_,psb_avg_) + ! + ! Update the overlap of x + ! + call psb_ovrl(x,sm%desc_data,info,& + & update=sm%prol,work=work) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_prol_') + goto 9999 + end select + + case('T','C') + ! + ! With transpose, we have to do it here + ! + if (sm%restr == psb_halo_) then + call psb_ovrl(x,sm%desc_data,info,& + & update=psb_sum_,work=work) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + else if (sm%restr /= psb_none_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_restr_') + goto 9999 + end if + + case default + info=psb_err_iarg_invalid_i_ + int_err(1)=6 + ch_err(2:2)=trans + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_as_smoother_prol_a + + diff --git a/mlprec/impl/smoother/amg_s_as_smoother_prol_v.f90 b/mlprec/impl/smoother/amg_s_as_smoother_prol_v.f90 new file mode 100644 index 00000000..64849561 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_as_smoother_prol_v.f90 @@ -0,0 +1,149 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_as_smoother_prol_v(sm,x,trans,work,info,data) + use psb_base_mod + use amg_s_as_smoother, amg_protect_nam => amg_s_as_smoother_prol_v + implicit none + class(amg_s_as_smoother_type), intent(inout) :: sm + type(psb_s_vect_type),intent(inout) :: x + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + !Local + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ + character :: trans_ + character(len=20) :: name='s_as_smther_prol_v', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = sm%desc_data%get_context() + call psb_info(ictxt,me,np) + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + info = psb_err_iarg_invalid_i_ + call psb_errpush(info,name) + goto 9999 + end select + + if (present(data)) then + data_ = data + else + data_ = psb_comm_ext_ + end if + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + + select case(trans_) + case('N') + + select case (sm%prol) + + case(psb_none_) + ! + ! Would work anyway, but since it is supposed to do nothing ... + ! call psb_ovrl(x,sm%desc_data,info,& + ! & update=sm%prol,work=work) + + + case(psb_sum_,psb_avg_) + ! + ! Update the overlap of x + ! + call psb_ovrl(x,sm%desc_data,info,& + & update=sm%prol,work=work) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_prol_') + goto 9999 + end select + + case('T','C') + ! + ! With transpose, we have to do it here + ! + if (sm%restr == psb_halo_) then + call psb_ovrl(x,sm%desc_data,info,& + & update=psb_sum_,work=work) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + else if (sm%restr /= psb_none_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_restr_') + goto 9999 + end if + + case default + info=psb_err_iarg_invalid_i_ + int_err(1)=6 + ch_err(2:2)=trans + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_as_smoother_prol_v + + diff --git a/mlprec/impl/smoother/amg_s_as_smoother_restr_a.f90 b/mlprec/impl/smoother/amg_s_as_smoother_restr_a.f90 new file mode 100644 index 00000000..e68f3bc9 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_as_smoother_restr_a.f90 @@ -0,0 +1,168 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_as_smoother_restr_a(sm,x,trans,work,info,data) + use psb_base_mod + use amg_s_as_smoother, amg_protect_nam => amg_s_as_smoother_restr_a + implicit none + class(amg_s_as_smoother_type), intent(inout) :: sm + real(psb_spk_), intent(inout) :: x(:) + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + !Local + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ + character :: trans_ + character(len=20) :: name='s_as_smther_restr_a', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = sm%desc_data%get_context() + call psb_info(ictxt,me,np) + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + info = psb_err_iarg_invalid_i_ + call psb_errpush(info,name) + goto 9999 + end select + + if (present(data)) then + data_ = data + else + data_ = psb_comm_ext_ + end if + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + select case(trans_) + case('N') + ! + ! Get the overlap entries x + ! + if (sm%restr == psb_halo_) then + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + else if (sm%restr /= psb_none_) then + call psb_errpush(psb_err_internal_error_,name,& + &a_err='Invalid amg_sub_restr_') + goto 9999 + end if + + + case('T','C') + ! + ! With transpose, we have to do it here + ! + + select case (sm%prol) + + case(psb_none_) + ! + ! Do nothing + + case(psb_sum_) + ! + ! The transpose of sum is halo + ! + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + + case(psb_avg_) + ! + ! Tricky one: first we have to scale the overlap entries, + ! which we can do by assignind mode=0, i.e. no communication + ! (hence only scaling), then we do the halo + ! + call psb_ovrl(x,sm%desc_data,info,& + & update=psb_avg_,work=work,mode=izero) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_prol_') + goto 9999 + end select + + + case default + info=psb_err_iarg_invalid_i_ + int_err(1)=6 + ch_err(2:2)=trans + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_as_smoother_restr_a + + diff --git a/mlprec/impl/smoother/amg_s_as_smoother_restr_v.f90 b/mlprec/impl/smoother/amg_s_as_smoother_restr_v.f90 new file mode 100644 index 00000000..17d0d470 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_as_smoother_restr_v.f90 @@ -0,0 +1,168 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_as_smoother_restr_v(sm,x,trans,work,info,data) + use psb_base_mod + use amg_s_as_smoother, amg_protect_nam => amg_s_as_smoother_restr_v + implicit none + class(amg_s_as_smoother_type), intent(inout) :: sm + type(psb_s_vect_type),intent(inout) :: x + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + !Local + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ + character :: trans_ + character(len=20) :: name='s_as_smther_restr_v', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = sm%desc_data%get_context() + call psb_info(ictxt,me,np) + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + info = psb_err_iarg_invalid_i_ + call psb_errpush(info,name) + goto 9999 + end select + + if (present(data)) then + data_ = data + else + data_ = psb_comm_ext_ + end if + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + select case(trans_) + case('N') + ! + ! Get the overlap entries x + ! + if (sm%restr == psb_halo_) then + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + else if (sm%restr /= psb_none_) then + call psb_errpush(psb_err_internal_error_,name,& + &a_err='Invalid amg_sub_restr_') + goto 9999 + end if + + + case('T','C') + ! + ! With transpose, we have to do it here + ! + + select case (sm%prol) + + case(psb_none_) + ! + ! Do nothing + + case(psb_sum_) + ! + ! The transpose of sum is halo + ! + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + + case(psb_avg_) + ! + ! Tricky one: first we have to scale the overlap entries, + ! which we can do by assignind mode=0, i.e. no communication + ! (hence only scaling), then we do the halo + ! + call psb_ovrl(x,sm%desc_data,info,& + & update=psb_avg_,work=work,mode=izero) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_prol_') + goto 9999 + end select + + + case default + info=psb_err_iarg_invalid_i_ + int_err(1)=6 + ch_err(2:2)=trans + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_as_smoother_restr_v + + diff --git a/mlprec/impl/smoother/amg_s_base_smoother_apply.f90 b/mlprec/impl/smoother/amg_s_base_smoother_apply.f90 new file mode 100644 index 00000000..28c7ea49 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_base_smoother_apply.f90 @@ -0,0 +1,87 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_smoother_apply(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,info,init,initu) + use psb_base_mod + use amg_s_base_smoother_mod, amg_protect_name => amg_s_base_smoother_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_base_smoother_type), intent(inout) :: sm + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_smoother_apply' + + call psb_erractionsave(err_act) + info = psb_success_ + if (sweeps == 0) then + + ! + ! K^0 = I + ! zero sweeps of any smoother is just the identity. + ! + call psb_geaxpby(alpha,x,beta,y,desc_data,info) + + else + if (allocated(sm%sv)) then + call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,info,init=init, initu=initu) + else + info = 1121 + endif + end if + if (info /= psb_success_) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_base_smoother_apply diff --git a/mlprec/impl/smoother/amg_s_base_smoother_apply_vect.f90 b/mlprec/impl/smoother/amg_s_base_smoother_apply_vect.f90 new file mode 100644 index 00000000..041126f6 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_base_smoother_apply_vect.f90 @@ -0,0 +1,88 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,wv,info,init,initu) + use psb_base_mod + use amg_s_base_smoother_mod, amg_protect_name => amg_s_base_smoother_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_base_smoother_type), intent(inout) :: sm + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + ! + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_smoother_apply' + + call psb_erractionsave(err_act) + info = psb_success_ + if (sweeps == 0) then + + ! + ! K^0 = I + ! zero sweeps of any smoother is just the identity. + ! + call psb_geaxpby(alpha,x,beta,y,desc_data,info) + + else + if (allocated(sm%sv)) then + call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,wv,info,init=init, initu=initu) + else + info = 1121 + endif + end if + if (info /= psb_success_) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_base_smoother_apply_vect diff --git a/mlprec/impl/smoother/amg_s_base_smoother_bld.f90 b/mlprec/impl/smoother/amg_s_base_smoother_bld.f90 new file mode 100644 index 00000000..fdc2317d --- /dev/null +++ b/mlprec/impl/smoother/amg_s_base_smoother_bld.f90 @@ -0,0 +1,72 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_s_base_smoother_mod, amg_protect_name => amg_s_base_smoother_bld + Implicit None + + ! Arguments + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_smoother_bld' + + call psb_erractionsave(err_act) + + info = psb_success_ + if (allocated(sm%sv)) then + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + else + info = 1121 + call psb_errpush(info,name) + endif + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_smoother_bld diff --git a/mlprec/impl/smoother/amg_s_base_smoother_check.f90 b/mlprec/impl/smoother/amg_s_base_smoother_check.f90 new file mode 100644 index 00000000..8c29b3b8 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_base_smoother_check.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_smoother_check(sm,info) + + use psb_base_mod + use amg_s_base_smoother_mod, amg_protect_name => amg_s_base_smoother_check + Implicit None + + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + Integer(Psb_ipk_) :: err_act + character(len=20) :: name='s_base_smoother_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%check(info) + else + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_smoother_check diff --git a/mlprec/impl/smoother/amg_s_base_smoother_clear_data.f90 b/mlprec/impl/smoother/amg_s_base_smoother_clear_data.f90 new file mode 100644 index 00000000..846b87a9 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_base_smoother_clear_data.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_smoother_clear_data(sm,info) + + use psb_base_mod + use amg_s_base_smoother_mod, amg_protect_name => amg_s_base_smoother_clear_data + Implicit None + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_smoother_clear_data' + + call psb_erractionsave(err_act) + + info = 0 + if (allocated(sm%sv)) then + call sm%sv%clear_data(info) + if (info /= 0) then + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_smoother_clear_data diff --git a/mlprec/impl/smoother/amg_s_base_smoother_clone.f90 b/mlprec/impl/smoother/amg_s_base_smoother_clone.f90 new file mode 100644 index 00000000..82436729 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_base_smoother_clone.f90 @@ -0,0 +1,62 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_smoother_clone(sm,smout,info) + + use psb_base_mod + use amg_s_base_smoother_mod, amg_protect_name => amg_s_base_smoother_clone + Implicit None + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + class(amg_s_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_smoother_clone' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_smoother_clone diff --git a/mlprec/impl/smoother/amg_s_base_smoother_clone_settings.f90 b/mlprec/impl/smoother/amg_s_base_smoother_clone_settings.f90 new file mode 100644 index 00000000..2b23888c --- /dev/null +++ b/mlprec/impl/smoother/amg_s_base_smoother_clone_settings.f90 @@ -0,0 +1,89 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_smoother_clone_settings(sm,smout,info) + + use psb_base_mod + use amg_s_base_smoother_mod, amg_protect_name => amg_s_base_smoother_clone_settings + Implicit None + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + class(amg_s_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_smoother_clone_settings' + + call psb_erractionsave(err_act) + + info=psb_success_ + if (same_type_as(sm,smout)) then + if (allocated(smout%sv)) then + if (.not.same_type_as(sm%sv,smout%sv)) then + call smout%sv%free(info) + if (info == 0) deallocate(smout%sv,stat=info) + end if + end if + if (info /= 0) then + info = psb_err_internal_error_ + else + if (allocated(smout%sv)) then + if (same_type_as(sm%sv,smout%sv)) then + call sm%sv%clone_settings(smout%sv,info) + else + info = psb_err_internal_error_ + end if + else + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == 0) call sm%sv%clone_settings(smout%sv,info) + if (info /= 0) info = psb_err_internal_error_ + end if + end if + else + info = psb_err_internal_error_ + end if + if (info /= 0) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_smoother_clone_settings diff --git a/mlprec/impl/smoother/amg_s_base_smoother_cnv.f90 b/mlprec/impl/smoother/amg_s_base_smoother_cnv.f90 new file mode 100644 index 00000000..7eaa96af --- /dev/null +++ b/mlprec/impl/smoother/amg_s_base_smoother_cnv.f90 @@ -0,0 +1,70 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_smoother_cnv(sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_s_base_smoother_mod, amg_protect_name => amg_s_base_smoother_cnv + Implicit None + + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_smoother_cnv' + + call psb_erractionsave(err_act) + + info = psb_success_ + if (allocated(sm%sv)) then + call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) + else + info = 1121 + call psb_errpush(info,name) + endif + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_smoother_cnv diff --git a/mlprec/impl/smoother/amg_s_base_smoother_csetc.f90 b/mlprec/impl/smoother/amg_s_base_smoother_csetc.f90 new file mode 100644 index 00000000..d184cf43 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_base_smoother_csetc.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_smoother_csetc(sm,what,val,info,idx) + + use psb_base_mod + use amg_s_base_smoother_mod, amg_protect_name => amg_s_base_smoother_csetc + Implicit None + + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='s_base_smoother_csetc' + + call psb_erractionsave(err_act) + + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%set(what,val,info,idx=idx) + end if + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_smoother_csetc diff --git a/mlprec/impl/smoother/amg_s_base_smoother_cseti.f90 b/mlprec/impl/smoother/amg_s_base_smoother_cseti.f90 new file mode 100644 index 00000000..29e1122d --- /dev/null +++ b/mlprec/impl/smoother/amg_s_base_smoother_cseti.f90 @@ -0,0 +1,65 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_smoother_cseti(sm,what,val,info,idx) + + use psb_base_mod + use amg_s_base_smoother_mod, amg_protect_name => amg_s_base_smoother_cseti + Implicit None + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_smoother_cseti' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%set(what,val,info,idx=idx) + end if + if (info /= psb_success_) goto 9999 + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_smoother_cseti diff --git a/mlprec/impl/smoother/amg_s_base_smoother_csetr.f90 b/mlprec/impl/smoother/amg_s_base_smoother_csetr.f90 new file mode 100644 index 00000000..8dcd6156 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_base_smoother_csetr.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_smoother_csetr(sm,what,val,info,idx) + + use psb_base_mod + use amg_s_base_smoother_mod, amg_protect_name => amg_s_base_smoother_csetr + Implicit None + + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_smoother_csetr' + + call psb_erractionsave(err_act) + + + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%set(what,val,info,idx=idx) + end if + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_smoother_csetr diff --git a/mlprec/impl/smoother/amg_s_base_smoother_descr.f90 b/mlprec/impl/smoother/amg_s_base_smoother_descr.f90 new file mode 100644 index 00000000..9496a9b3 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_base_smoother_descr.f90 @@ -0,0 +1,101 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_smoother_descr(sm,info,iout,coarse) + + use psb_base_mod + use amg_s_base_smoother_mod, amg_protect_name => amg_s_base_smoother_descr + use amg_s_id_solver + Implicit None + + ! Arguments + class(amg_s_base_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt, me, np + character(len=20), parameter :: name='amg_s_base_smoother_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse_ + + + call psb_erractionsave(err_act) + info = psb_success_ + + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + + if (coarse_) then + if (allocated(sm%sv)) call sm%sv%descr(info,iout,coarse) + else + if (allocated(sm%sv)) then + select type (sv => sm%sv) + class is (amg_s_id_solver_type) + write(iout_,*) 'No preconditioner/smoother' + class default + write(iout_,*) 'Decoupled preconditioner/smoother with local solver' + call sm%sv%descr(info,iout,coarse) + end select + else + write(iout_,*) 'No preconditioner/smoother' + end if + end if + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='Local solver') + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_smoother_descr diff --git a/mlprec/impl/smoother/amg_s_base_smoother_dmp.f90 b/mlprec/impl/smoother/amg_s_base_smoother_dmp.f90 new file mode 100644 index 00000000..3f84e1f4 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_base_smoother_dmp.f90 @@ -0,0 +1,85 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + + use psb_base_mod + use amg_s_base_smoother_mod, amg_protect_name => amg_s_base_smoother_dmp + implicit none + class(amg_s_base_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: smoother_, global_num_ + ! len of prefix_ + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_smth_s" + end if + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + if (present(smoother)) then + smoother_ = smoother + else + smoother_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + ! At base level do nothing for the smoother + if (allocated(sm%sv)) & + & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) + +end subroutine amg_s_base_smoother_dmp diff --git a/mlprec/impl/smoother/amg_s_base_smoother_free.f90 b/mlprec/impl/smoother/amg_s_base_smoother_free.f90 new file mode 100644 index 00000000..adf8e6c9 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_base_smoother_free.f90 @@ -0,0 +1,68 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_smoother_free(sm,info) + + use psb_base_mod + use amg_s_base_smoother_mod, amg_protect_name => amg_s_base_smoother_free + Implicit None + + ! Arguments + class(amg_s_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_smoother_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%free(info) + if (info == psb_success_) deallocate(sm%sv,stat=info) + end if + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_smoother_free diff --git a/mlprec/impl/smoother/amg_s_jac_smoother_apply.f90 b/mlprec/impl/smoother/amg_s_jac_smoother_apply.f90 new file mode 100644 index 00000000..bb404518 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_jac_smoother_apply.f90 @@ -0,0 +1,273 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_jac_smoother_apply(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,info,init,initu) + use psb_base_mod + use amg_s_jac_smoother, amg_protect_name => amg_s_jac_smoother_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_jac_smoother_type), intent(inout) :: sm + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col + real(psb_spk_), allocatable :: tx(:),ty(:) + real(psb_spk_), pointer :: aux(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='s_jac_smoother_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = desc_data%get_context() + call psb_info(ictxt,me,np) + + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (4*n_col <= size(work)) then + aux => work(:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + endif + + if ((.not.sm%sv%is_iterative()).and.((sweeps == 1).or.(sm%nd_nnz_tot==0))) then + ! if .not.sv%is_iterative, there's no need to pass init + call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + else if (sweeps >= 0) then + if (associated(sm%pa)) then + ! + ! This means we are dealing with a pure Jacobi smoother/solver. + ! + call psb_geasb(tx,desc_data,info) + call psb_geasb(ty,desc_data,info) + select case (init_) + case('Z') + + call sm%sv%apply(sone,x,szero,ty,desc_data,trans_,aux,info,init='Z') + + case('Y') + call psb_geaxpby(sone,x,szero,tx,desc_data,info) + call psb_geaxpby(sone,y,szero,ty,desc_data,info) + call psb_spmm(-sone,sm%pa,ty,sone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(sone,x,szero,tx,desc_data,info) + call psb_geaxpby(sone,initu,szero,ty,desc_data,info) + call psb_spmm(-sone,sm%pa,ty,sone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = Y(j)+ D^(-1)*(X-A*Y(j)), + ! where is the diagonal and A the matrix. + ! + call psb_geaxpby(sone,x,szero,tx,desc_data,info) + call psb_spmm(-sone,sm%pa,ty,sone,tx,desc_data,info,work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(sone,tx,sone,ty,desc_data,trans_,aux,info,init='Y') + + if (info /= psb_success_) exit + end do + + + if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + else + ! + ! + ! Apply multiple sweeps of a block-Jacobi solver + ! to compute an approximate solution of a linear system. + ! + ! + call psb_geasb(tx,desc_data,info) + call psb_geasb(ty,desc_data,info) + + ! + ! Unroll the first iteration and fold it inside SELECT CASE + ! this will save one AXPBY and one SPMM when INIT=Z, and will be + ! significant when sweeps=1 (a common case) + ! + select case (init_) + case('Z') + + call sm%sv%apply(sone,x,szero,ty,desc_data,trans_,aux,info,init='Z') + + case('Y') + call psb_geaxpby(sone,x,szero,tx,desc_data,info) + call psb_geaxpby(sone,y,szero,ty,desc_data,info) + call psb_spmm(-sone,sm%nd,ty,sone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(sone,x,szero,tx,desc_data,info) + call psb_geaxpby(sone,initu,szero,ty,desc_data,info) + call psb_spmm(-sone,sm%nd,ty,sone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the + ! block diagonal part and the remaining part of the local matrix + ! and Y(j) is the approximate solution at sweep j. + ! + call psb_geaxpby(sone,x,szero,tx,desc_data,info) + call psb_spmm(-sone,sm%nd,ty,sone,tx,desc_data,info,work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,info,init='Y') + + if (info /= psb_success_) exit + end do + + if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + end if + + deallocate(tx,ty,stat=info) + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='final cleanup with Jacobi sweeps > 1') + goto 9999 + end if + + else + + info = psb_err_iarg_neg_ + call psb_errpush(info,name,& + & i_err=(/itwo,sweeps,izero,izero,izero/)) + goto 9999 + + endif + + if (.not.(4*n_col <= size(work))) then + deallocate(aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_jac_smoother_apply diff --git a/mlprec/impl/smoother/amg_s_jac_smoother_apply_vect.f90 b/mlprec/impl/smoother/amg_s_jac_smoother_apply_vect.f90 new file mode 100644 index 00000000..7c020b9f --- /dev/null +++ b/mlprec/impl/smoother/amg_s_jac_smoother_apply_vect.f90 @@ -0,0 +1,320 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_jac_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,wv,info,init,initu) + + use psb_base_mod + use amg_s_diag_solver + use psb_base_krylov_conv_mod, only : log_conv + use amg_s_jac_smoother, amg_protect_name => amg_s_jac_smoother_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_jac_smoother_type), intent(inout) :: sm + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + ! + integer(psb_ipk_) :: n_row,n_col + type(psb_s_vect_type) :: tx, ty, r + real(psb_spk_), pointer :: aux(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + real(psb_dpk_) :: res, resdenum + character(len=20) :: name='s_jac_smoother_apply_v' + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = desc_data%get_context() + call psb_info(ictxt,me,np) + + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (4*n_col <= size(work)) then + aux => work(:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + endif + + if(sm%checkres) then + call psb_geall(r,desc_data,info) + call psb_geasb(r,desc_data,info) + resdenum = psb_genrm2(x,desc_data,info) + end if + + if ((.not.sm%sv%is_iterative()).and.((sweeps == 1).or.(sm%nd_nnz_tot==0))) then + ! if .not.sv%is_iterative, there's no need to pass init + call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,wv,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + else if (sweeps >= 0) then + select type (smsv => sm%sv) + class is (amg_s_diag_solver_type) + ! + ! This means we are dealing with a pure Jacobi smoother/solver. + ! + associate(tx => wv(1), ty => wv(2)) + select case (init_) + case('Z') + + call sm%sv%apply(sone,x,szero,ty,desc_data,trans_,aux,wv(3:),info,init='Z') + + case('Y') + call psb_geaxpby(sone,x,szero,tx,desc_data,info) + call psb_geaxpby(sone,y,szero,ty,desc_data,info) + call psb_spmm(-sone,sm%pa,ty,sone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(sone,x,szero,tx,desc_data,info) + call psb_geaxpby(sone,initu,szero,ty,desc_data,info) + call psb_spmm(-sone,sm%pa,ty,sone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = Y(j)+ D^(-1)*(X-A*Y(j)), + ! where is the diagonal and A the matrix. + ! + call psb_geaxpby(sone,x,szero,tx,desc_data,info) + call psb_spmm(-sone,sm%pa,ty,sone,tx,desc_data,info,work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(sone,tx,sone,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + if (info /= psb_success_) exit + + if ( sm%checkres.and.(mod(i,sm%checkiter) == 0) ) then + call psb_geaxpby(sone,x,szero,r,r,desc_data,info) + call psb_spmm(-sone,sm%pa,ty,sone,r,desc_data,info) + res = psb_genrm2(r,desc_data,info) + if( sm%printres ) then + call log_conv("BJAC",me,i,sm%printiter,res,resdenum,sm%tol) + end if + if ( res < sm%tol*resdenum ) then + if( (sm%printres).and.(mod(sm%printiter,sm%checkiter)/=0) ) & + & call log_conv("BJAC",me,i,1,res,resdenum,sm%tol) + exit + end if + end if + + end do + + + if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + + end associate + + class default + ! + ! + ! Apply multiple sweeps of a block-Jacobi solver + ! to compute an approximate solution of a linear system. + ! + ! + if (size(wv) < 2) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size in smoother_apply') + goto 9999 + end if + associate(tx => wv(1), ty => wv(2)) + + ! + ! Unroll the first iteration and fold it inside SELECT CASE + ! this will save one AXPBY and one SPMM when INIT=Z, and will be + ! significant when sweeps=1 (a common case) + ! + select case (init_) + case('Z') + + call sm%sv%apply(sone,x,szero,ty,desc_data,trans_,aux,wv(3:),info,init='Z') + + case('Y') + call psb_geaxpby(sone,x,szero,tx,desc_data,info) + call psb_geaxpby(sone,y,szero,ty,desc_data,info) + call psb_spmm(-sone,sm%nd,ty,sone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(sone,x,szero,tx,desc_data,info) + call psb_geaxpby(sone,initu,szero,ty,desc_data,info) + call psb_spmm(-sone,sm%nd,ty,sone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the + ! block diagonal part and the remaining part of the local matrix + ! and Y(j) is the approximate solution at sweep j. + ! + call psb_geaxpby(sone,x,szero,tx,desc_data,info) + call psb_spmm(-sone,sm%nd,ty,sone,tx,desc_data,info,work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + if (info /= psb_success_) exit + + if ( sm%checkres.and.(mod(i,sm%checkiter) == 0) ) then + call psb_geaxpby(sone,x,szero,r,r,desc_data,info) + call psb_spmm(-sone,sm%pa,ty,sone,r,desc_data,info) + res = psb_genrm2(r,desc_data,info) + if( sm%printres ) then + call log_conv("BJAC",me,i,sm%printiter,res,resdenum,sm%tol) + end if + if (res < sm%tol*resdenum ) then + if( (sm%printres).and.( mod(sm%printiter,sm%checkiter) /=0 ) ) & + & call log_conv("BJAC",me,i,1,res,resdenum,sm%tol) + exit + end if + end if + + end do + + if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + end associate + end select + + else + + info = psb_err_iarg_neg_ + call psb_errpush(info,name,& + & i_err=(/itwo,sweeps,izero,izero,izero/)) + goto 9999 + + endif + + if (.not.(4*n_col <= size(work))) then + deallocate(aux) + endif + + if(sm%checkres) then + call psb_gefree(r,desc_data,info) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_jac_smoother_apply_vect diff --git a/mlprec/impl/smoother/amg_s_jac_smoother_bld.f90 b/mlprec/impl/smoother/amg_s_jac_smoother_bld.f90 new file mode 100644 index 00000000..bbd85cc3 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_jac_smoother_bld.f90 @@ -0,0 +1,127 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_s_diag_solver + use amg_s_jac_smoother, amg_protect_name => amg_s_jac_smoother_bld + Implicit None + + ! Arguments + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + type(psb_sspmat_type) :: tmpa + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota, nzeros + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='s_jac_smoother_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + n_col = desc_a%get_local_cols() + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + + if( sm%checkres ) sm%pa => a + + select type (smsv => sm%sv) + class is (amg_s_diag_solver_type) + call sm%nd%free() + sm%pa => a + sm%nd_nnz_tot = nztota + call psb_sum(ictxt,sm%nd_nnz_tot) + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + + class default + if (smsv%is_global()) then + ! Do not put anything into SM%ND since the solver + ! is acting globally. + call sm%nd%free() + sm%nd_nnz_tot = 0 + call psb_sum(ictxt,sm%nd_nnz_tot) + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + else + call a%csclip(sm%nd,info,& + & jmin=nrow_a+1,rscale=.false.,cscale=.false.) + if (info == psb_success_) then + if (present(amold)) then + call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + else + call sm%nd%cscnv(info,& + & type='csr',dupl=psb_dupl_add_) + endif + end if + sm%nd_nnz_tot = sm%nd%get_nzeros() + call psb_sum(ictxt,sm%nd_nnz_tot) + call a%csclip(tmpa,info,& + & jmax=nrow_a,rscale=.false.,cscale=.false.) + call sm%sv%build(tmpa,desc_a,info,amold=amold,vmold=vmold) + end if + end select + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='clip & psb_spcnv csr 4') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_jac_smoother_bld diff --git a/mlprec/impl/smoother/amg_s_jac_smoother_clear_data.f90 b/mlprec/impl/smoother/amg_s_jac_smoother_clear_data.f90 new file mode 100644 index 00000000..c4b1e3d7 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_jac_smoother_clear_data.f90 @@ -0,0 +1,70 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_jac_smoother_clear_data(sm,info) + + use psb_base_mod + use amg_s_jac_smoother, amg_protect_name => amg_s_jac_smoother_clear_data + Implicit None + ! Arguments + class(amg_s_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_jac_smoother_clear_data' + + call psb_erractionsave(err_act) + + info = 0 + call sm%nd%free() + sm%nd_nnz_tot = 0 + sm%pa => null() + if ((info==0).and.allocated(sm%sv)) then + call sm%sv%clear_data(info) + end if + if (info /= 0) then + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_jac_smoother_clear_data diff --git a/mlprec/impl/smoother/amg_s_jac_smoother_clone.f90 b/mlprec/impl/smoother/amg_s_jac_smoother_clone.f90 new file mode 100644 index 00000000..44646cbb --- /dev/null +++ b/mlprec/impl/smoother/amg_s_jac_smoother_clone.f90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_jac_smoother_clone(sm,smout,info) + + use psb_base_mod + use amg_s_jac_smoother, amg_protect_name => amg_s_jac_smoother_clone + + Implicit None + + ! Arguments + class(amg_s_jac_smoother_type), intent(inout) :: sm + class(amg_s_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(smout)) then + call smout%free(info) + if (info == psb_success_) deallocate(smout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_s_jac_smoother_type :: smout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(smo => smout) + type is (amg_s_jac_smoother_type) + smo%nd_nnz_tot = sm%nd_nnz_tot + smo%checkres = sm%checkres + smo%printres = sm%printres + smo%checkiter = sm%checkiter + smo%printiter = sm%printiter + smo%tol = sm%tol + call sm%nd%clone(smo%nd,info) + if ((info==psb_success_).and.(allocated(sm%sv))) then + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == psb_success_) call sm%sv%clone(smo%sv,info) + end if + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_jac_smoother_clone diff --git a/mlprec/impl/smoother/amg_s_jac_smoother_clone_settings.f90 b/mlprec/impl/smoother/amg_s_jac_smoother_clone_settings.f90 new file mode 100644 index 00000000..03380398 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_jac_smoother_clone_settings.f90 @@ -0,0 +1,101 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! asd on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_jac_smoother_clone_settings(sm,smout,info) + + use psb_base_mod + use amg_s_jac_smoother, amg_protect_name => amg_s_jac_smoother_clone_settings + Implicit None + ! Arguments + class(amg_s_jac_smoother_type), intent(inout) :: sm + class(amg_s_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_jac_smoother_clone_settings' + + call psb_erractionsave(err_act) + + info = psb_success_ + + select type(smout) + class is(amg_s_jac_smoother_type) + + smout%pa => null() + smout%nd_nnz_tot = 0 + smout%checkres = sm%checkres + smout%printres = sm%printres + smout%checkiter = sm%checkiter + smout%printiter = sm%printiter + smout%tol = sm%tol + + if (allocated(smout%sv)) then + if (.not.same_type_as(sm%sv,smout%sv)) then + call smout%sv%free(info) + if (info == 0) deallocate(smout%sv,stat=info) + end if + end if + if (info /= 0) then + info = psb_err_internal_error_ + else + if (allocated(smout%sv)) then + if (same_type_as(sm%sv,smout%sv)) then + call sm%sv%clone_settings(smout%sv,info) + else + info = psb_err_internal_error_ + end if + else + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == 0) call sm%sv%clone_settings(smout%sv,info) + if (info /= 0) info = psb_err_internal_error_ + end if + end if + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_jac_smoother_clone_settings diff --git a/mlprec/impl/smoother/amg_s_jac_smoother_cnv.f90 b/mlprec/impl/smoother/amg_s_jac_smoother_cnv.f90 new file mode 100644 index 00000000..33d53171 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_jac_smoother_cnv.f90 @@ -0,0 +1,90 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_jac_smoother_cnv(sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_s_diag_solver + use amg_s_jac_smoother, amg_protect_name => amg_s_jac_smoother_cnv + Implicit None + + ! Arguments + class(amg_s_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_jac_smoother_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + + if (info == psb_success_) then + if (sm%nd%is_asb()) then + if (present(amold)) then + call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + else + call sm%nd%cscnv(info,& + & type='csr',dupl=psb_dupl_add_) + endif + end if + end if + + if (info == psb_success_) then + if (allocated(sm%sv)) & + & call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='solver cnv') + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_jac_smoother_cnv diff --git a/mlprec/impl/smoother/amg_s_jac_smoother_csetc.f90 b/mlprec/impl/smoother/amg_s_jac_smoother_csetc.f90 new file mode 100644 index 00000000..85e4d3a2 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_jac_smoother_csetc.f90 @@ -0,0 +1,90 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_jac_smoother_csetc(sm,what,val,info,idx) + + use psb_base_mod + use amg_s_jac_smoother, amg_protect_nam => amg_s_jac_smoother_csetc + Implicit None + ! Arguments + class(amg_s_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='s_jac_smoother_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(trim(what))) + case('SMOOTHER_STOP') + select case(psb_toupper(trim(val))) + case('T','TRUE') + sm%checkres = .true. + case('F','FALSE') + sm%checkres = .false. + case default + write(0,*) 'Unknown value for smoother_stop : "',psb_toupper(trim(val)),'"' + end select + case('SMOOTHER_TRACE') + select case(psb_toupper(trim(val))) + case('T','TRUE') + sm%printres = .true. + case('F','FALSE') + sm%printres = .false. + case default + write(0,*) 'Unknown value for smoother_trace : "',psb_toupper(trim(val)),'"' + end select + case default + call sm%amg_s_base_smoother_type%set(what,val,info,idx=idx) + end select + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info, name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_jac_smoother_csetc diff --git a/mlprec/impl/smoother/amg_s_jac_smoother_cseti.f90 b/mlprec/impl/smoother/amg_s_jac_smoother_cseti.f90 new file mode 100644 index 00000000..3f1e307d --- /dev/null +++ b/mlprec/impl/smoother/amg_s_jac_smoother_cseti.f90 @@ -0,0 +1,71 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_jac_smoother_cseti(sm,what,val,info,idx) + + use psb_base_mod + use amg_s_jac_smoother, amg_protect_nam => amg_s_jac_smoother_cseti + Implicit None + + ! Arguments + class(amg_s_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_jac_smoother_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) + case('SMOOTHER_RESIDUAL') + sm%checkiter = val + case('SMOOTHER_ITRACE') + sm%printiter = val + case default + call sm%amg_s_base_smoother_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_jac_smoother_cseti diff --git a/mlprec/impl/smoother/amg_s_jac_smoother_csetr.f90 b/mlprec/impl/smoother/amg_s_jac_smoother_csetr.f90 new file mode 100644 index 00000000..6f954db0 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_jac_smoother_csetr.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_jac_smoother_csetr(sm,what,val,info,idx) + + use psb_base_mod + use amg_s_jac_smoother, amg_protect_nam => amg_s_jac_smoother_csetr + Implicit None + + ! Arguments + class(amg_s_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_jac_smoother_csetr' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) + case('SMOOTHER_STOPTOL') + sm%tol = val + case default + call sm%amg_s_base_smoother_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_jac_smoother_csetr diff --git a/mlprec/impl/smoother/amg_s_jac_smoother_descr.f90 b/mlprec/impl/smoother/amg_s_jac_smoother_descr.f90 new file mode 100644 index 00000000..5c4e1a46 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_jac_smoother_descr.f90 @@ -0,0 +1,103 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_jac_smoother_descr(sm,info,iout,coarse) + + use psb_base_mod + use amg_s_diag_solver + use amg_s_jac_smoother, amg_protect_name => amg_s_jac_smoother_descr + use amg_s_diag_solver + use amg_s_gs_solver + + Implicit None + + ! Arguments + class(amg_s_jac_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_s_jac_smoother_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (.not.coarse_) then + if (allocated(sm%sv)) then + select type(smv=>sm%sv) + class is (amg_s_diag_solver_type) + write(iout_,*) ' Point Jacobi ' + write(iout_,*) ' Local diagonal:' + call smv%descr(info,iout_,coarse=coarse) + class is (amg_s_bwgs_solver_type) + write(iout_,*) ' Hybrid Backward Gauss-Seidel ' + class is (amg_s_gs_solver_type) + write(iout_,*) ' Hybrid Forward Gauss-Seidel ' + class default + write(iout_,*) ' Block Jacobi ' + write(iout_,*) ' Local solver details:' + call smv%descr(info,iout_,coarse=coarse) + end select + + else + write(iout_,*) ' Block Jacobi ' + end if + else + if (allocated(sm%sv)) then + call sm%sv%descr(info,iout_,coarse=coarse) + end if + end if + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return +end subroutine amg_s_jac_smoother_descr diff --git a/mlprec/impl/smoother/amg_s_jac_smoother_dmp.f90 b/mlprec/impl/smoother/amg_s_jac_smoother_dmp.f90 new file mode 100644 index 00000000..a24bddab --- /dev/null +++ b/mlprec/impl/smoother/amg_s_jac_smoother_dmp.f90 @@ -0,0 +1,97 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_jac_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + + use psb_base_mod + use amg_s_jac_smoother, amg_protect_nam => amg_s_jac_smoother_dmp + implicit none + class(amg_s_jac_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + integer(psb_lpk_), allocatable :: iv(:) + logical :: smoother_, global_num_ + ! len of prefix_ + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_smth_s" + end if + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(smoother)) then + smoother_ = smoother + else + smoother_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + if (smoother_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_nd.mtx' + if (global_num_) then + iv = desc%get_global_indices(owned=.false.) + if (sm%nd%is_asb()) & + & call sm%nd%print(fname,head=head,iv=iv) + else + if (sm%nd%is_asb()) & + & call sm%nd%print(fname,head=head) + end if + end if + ! At base level do nothing for the smoother + if (allocated(sm%sv)) & + & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) + +end subroutine amg_s_jac_smoother_dmp diff --git a/mlprec/impl/smoother/amg_s_l1_jac_smoother_bld.f90 b/mlprec/impl/smoother/amg_s_l1_jac_smoother_bld.f90 new file mode 100644 index 00000000..452edad8 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_l1_jac_smoother_bld.f90 @@ -0,0 +1,176 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_l1_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_s_diag_solver + use amg_s_jac_smoother, amg_protect_name => amg_s_l1_jac_smoother_bld + Implicit None + + ! Arguments + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_l1_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota, nzeros + real(psb_spk_), allocatable :: arwsum(:) + type(psb_sspmat_type) :: tmpa + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='s_l1_jac_smoother_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + n_col = desc_a%get_local_cols() + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + + if( sm%checkres ) sm%pa => a + + select type (smsv => sm%sv) + class is (amg_s_diag_solver_type) + call sm%nd%free() + sm%pa => a + sm%nd_nnz_tot = nztota + + call psb_sum(ictxt,sm%nd_nnz_tot) + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + + class default + if (smsv%is_global()) then + ! Do not put anything into SM%ND since the solver + ! is acting globally. + call sm%nd%free() + sm%nd_nnz_tot = 0 + call psb_sum(ictxt,sm%nd_nnz_tot) + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + else + + call a%csclip(tmpa,info,& + & jmax=nrow_a,rscale=.false.,cscale=.false.) + + call a%csclip(sm%nd,info,& + & jmin=nrow_a+1,rscale=.false.,cscale=.false.) + + arwsum = sm%nd%arwsum(info) + + call combine_dl1(-sone,arwsum,sm%nd,info) + call combine_dl1(sone,arwsum,tmpa,info) + + sm%nd_nnz_tot = sm%nd%get_nzeros() + call psb_sum(ictxt,sm%nd_nnz_tot) + + call sm%sv%build(tmpa,desc_a,info,amold=amold,vmold=vmold) + + if (info == psb_success_) then + if (present(amold)) then + call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + else + call sm%nd%cscnv(info,& + & type='csr',dupl=psb_dupl_add_) + endif + end if + end if + end select + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='clip & psb_spcnv csr 4') + goto 9999 + end if + + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='solver build') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + + subroutine combine_dl1(alpha,dl1,mat,info) + implicit none + real(psb_spk_), intent(in) :: alpha, dl1(:) + type(psb_sspmat_type), intent(inout) :: mat + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: k, nz, nrm, dp + type(psb_s_coo_sparse_mat) :: tcoo + + call mat%mv_to(tcoo) + nz = tcoo%get_nzeros() + nrm = min(size(dl1),tcoo%get_nrows(),tcoo%get_ncols()) +!!$ write(0,*) 'Check on combine_dl1: ',nrm, tcoo%get_nrows(),tcoo%get_ncols(), nz + call tcoo%ensure_size(nz+nrm) + call tcoo%set_dupl(psb_dupl_add_) + do k=1,nrm + if (dl1(k) /= szero) then + nz = nz + 1 + tcoo%ia(nz) = k + tcoo%ja(nz) = k + tcoo%val(nz) = alpha*dl1(k) + end if + end do + call tcoo%set_nzeros(nz) + call tcoo%fix(info) + call mat%mv_from(tcoo) + end subroutine combine_dl1 + + +end subroutine amg_s_l1_jac_smoother_bld diff --git a/mlprec/impl/smoother/amg_s_l1_jac_smoother_clone.f90 b/mlprec/impl/smoother/amg_s_l1_jac_smoother_clone.f90 new file mode 100644 index 00000000..5c08c985 --- /dev/null +++ b/mlprec/impl/smoother/amg_s_l1_jac_smoother_clone.f90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_l1_jac_smoother_clone(sm,smout,info) + + use psb_base_mod + use amg_s_jac_smoother, amg_protect_name => amg_s_l1_jac_smoother_clone + + Implicit None + + ! Arguments + class(amg_s_l1_jac_smoother_type), intent(inout) :: sm + class(amg_s_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(smout)) then + call smout%free(info) + if (info == psb_success_) deallocate(smout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_s_l1_jac_smoother_type :: smout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(smo => smout) + type is (amg_s_l1_jac_smoother_type) + smo%nd_nnz_tot = sm%nd_nnz_tot + smo%checkres = sm%checkres + smo%printres = sm%printres + smo%checkiter = sm%checkiter + smo%printiter = sm%printiter + smo%tol = sm%tol + call sm%nd%clone(smo%nd,info) + if ((info==psb_success_).and.(allocated(sm%sv))) then + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == psb_success_) call sm%sv%clone(smo%sv,info) + end if + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_l1_jac_smoother_clone diff --git a/mlprec/impl/smoother/amg_s_l1_jac_smoother_descr.f90 b/mlprec/impl/smoother/amg_s_l1_jac_smoother_descr.f90 new file mode 100644 index 00000000..40b2d3ab --- /dev/null +++ b/mlprec/impl/smoother/amg_s_l1_jac_smoother_descr.f90 @@ -0,0 +1,103 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_l1_jac_smoother_descr(sm,info,iout,coarse) + + use psb_base_mod + use amg_s_diag_solver + use amg_s_jac_smoother, amg_protect_name => amg_s_l1_jac_smoother_descr + use amg_s_diag_solver + use amg_s_gs_solver + + Implicit None + + ! Arguments + class(amg_s_l1_jac_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_s_l1_jac_smoother_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (.not.coarse_) then + if (allocated(sm%sv)) then + select type(smv=>sm%sv) + class is (amg_s_diag_solver_type) + write(iout_,*) ' Point Jacobi ' + write(iout_,*) ' Local diagonal:' + call smv%descr(info,iout_,coarse=coarse) + class is (amg_s_bwgs_solver_type) + write(iout_,*) ' L1-Hybrid Backward Gauss-Seidel ' + class is (amg_s_gs_solver_type) + write(iout_,*) ' L1-Hybrid Forward Gauss-Seidel ' + class default + write(iout_,*) ' L1-Block Jacobi ' + write(iout_,*) ' Local solver details:' + call smv%descr(info,iout_,coarse=coarse) + end select + + else + write(iout_,*) ' L1-Block Jacobi ' + end if + else + if (allocated(sm%sv)) then + call sm%sv%descr(info,iout_,coarse=coarse) + end if + end if + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return +end subroutine amg_s_l1_jac_smoother_descr diff --git a/mlprec/impl/smoother/amg_z_as_smoother_apply.f90 b/mlprec/impl/smoother/amg_z_as_smoother_apply.f90 new file mode 100644 index 00000000..75431423 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_as_smoother_apply.f90 @@ -0,0 +1,235 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_as_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,info,init,initu) + use psb_base_mod + use amg_z_as_smoother, amg_protect_nam => amg_z_as_smoother_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_as_smoother_type), intent(inout) :: sm + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col, nrow_d, i + complex(psb_dpk_), pointer :: aux(:) + complex(psb_dpk_), allocatable :: tx(:),ty(:), ww(:) + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5) + character :: trans_, init_ + character(len=20) :: name='z_as_smoother_apply', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = desc_data%get_context() + call psb_info(ictxt,me,np) + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + n_row = sm%desc_data%get_local_rows() + n_col = sm%desc_data%get_local_cols() + nrow_d = desc_data%get_local_rows() + isz = max(n_row,N_COL) + + if ((4*isz) <= size(work)) then + aux => work(1:) + else + allocate(aux(4*isz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name,& + & i_err=(/4*isz,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + endif + + if ((.not.sm%sv%is_iterative()).and.(sweeps == 1).and.(sm%novr==0)) then + ! + ! Shortcut: in this case there is nothing else to be done. + ! + call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + else if (sweeps >= 0) then + ! + ! + ! Apply multiple sweeps of an AS solver + ! to compute an approximate solution of a linear system. + ! + ! + call psb_geasb(tx,sm%desc_data,info) + call psb_geasb(ty,sm%desc_data,info) + call psb_geasb(ww,sm%desc_data,info) + + ! + ! Unroll the first iteration and fold it inside SELECT CASE + ! this will save one SPMM when INIT=Z, and will be + ! significant when sweeps=1 (a common case) + ! + call psb_geaxpby(zone,x,zzero,tx,desc_data,info) + if (info == 0) call sm%apply_restr(tx,trans_,aux,info) + if (info == 0) call psb_geaxpby(zone,tx,zzero,ww,sm%desc_data,info) + + select case (init_) + case('Z') + call sm%sv%apply(zone,ww,zzero,ty,sm%desc_data,trans_,aux,info,init='Z') + + case('Y') + call psb_geaxpby(zone,y,zzero,ty,desc_data,info) + if (info == 0) call sm%apply_restr(ty,trans_,aux,info) + if (info == 0) call psb_spmm(-zone,sm%nd,ty,zone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + call sm%sv%apply(zone,ww,zzero,ty,desc_data,trans_,aux,info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(zone,initu,zzero,ty,desc_data,info) + if (info == 0) call sm%apply_restr(ty,trans_,aux,info) + if (info == 0) call psb_spmm(-zone,sm%nd,ty,zone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + call sm%sv%apply(zone,ww,zzero,ty,desc_data,trans_,aux,info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + if (info == 0) call sm%apply_prol(ty,trans_,aux,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the + ! block diagonal part and the remaining part of the local matrix + ! and Y(j) is the approximate solution at sweep j. + ! + if (info == 0) call psb_geaxpby(zone,tx,zzero,ww,sm%desc_data,info) + if (info == 0) call psb_spmm(-zone,sm%nd,ty,zone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(zone,ww,zzero,ty,sm%desc_data,trans_,aux,info,init='Y') + + if (info /= psb_success_) exit + if (info == 0) call sm%apply_prol(ty,trans_,aux,info) + + end do + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + ! + ! Compute y = beta*y + alpha*ty (ty == K^(-1)*tx) + ! + call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + + else + + info = psb_err_iarg_neg_ + call psb_errpush(info,name,& + & i_err=(/itwo,sweeps,izero,izero,izero/)) + goto 9999 + + endif + + + if (.not.(4*isz <= size(work))) then + deallocate(aux,stat=info) + endif + if (info ==0) deallocate(ww,tx,ty,stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_as_smoother_apply diff --git a/mlprec/impl/smoother/amg_z_as_smoother_apply_vect.f90 b/mlprec/impl/smoother/amg_z_as_smoother_apply_vect.f90 new file mode 100644 index 00000000..9a70275b --- /dev/null +++ b/mlprec/impl/smoother/amg_z_as_smoother_apply_vect.f90 @@ -0,0 +1,259 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_as_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,wv,info,init,initu) + use psb_base_mod + use amg_z_as_smoother, amg_protect_nam => amg_z_as_smoother_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_as_smoother_type), intent(inout) :: sm + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col, nrow_d, i + complex(psb_dpk_), pointer :: aux(:) + type(psb_z_vect_type) :: tx, ty, ww + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5) + character :: trans_, init_ + logical :: do_realloc_wv + character(len=20) :: name='z_as_smoother_apply_v', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = desc_data%get_context() + call psb_info(ictxt,me,np) + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + n_row = sm%desc_data%get_local_rows() + n_col = sm%desc_data%get_local_cols() + nrow_d = desc_data%get_local_rows() + isz = max(n_row,N_COL) + + if (4*isz <= size(work)) then + aux => work(:) + else + allocate(aux(4*isz),stat=info) + if (info /= psb_success_) then + call psb_errpush(psb_err_alloc_request_,name,& + & i_err=(/4*isz,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + endif + + if ((.not.sm%sv%is_iterative()).and.(sweeps == 1).and.(sm%novr==0)) then + ! + ! Shortcut: in this case there is nothing else to be done. + ! + call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,wv,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + else if (sweeps >= 0) then + ! + ! + ! Apply multiple sweeps of an AS solver + ! to compute an approximate solution of a linear system. + ! + ! + if (size(wv) < 3) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='invalid wv size in smoother_apply') + goto 9999 + end if + + ! + ! This is tricky. This smoother has a descriptor sm%desc_data + ! for an index space potentially different from + ! that of desc_data. Hence the size of the work vectors + ! could be wrong. We need to check and reallocate as needed. + ! + do_realloc_wv = (wv(1)%get_nrows() < sm%desc_data%get_local_cols()).or.& + & (wv(2)%get_nrows() < sm%desc_data%get_local_cols()).or.& + & (wv(3)%get_nrows() < sm%desc_data%get_local_cols()) + + if (do_realloc_wv) then + call psb_geasb(wv(1),sm%desc_data,info,scratch=.true.,mold=wv(2)%v) + call psb_geasb(wv(2),sm%desc_data,info,scratch=.true.,mold=wv(1)%v) + call psb_geasb(wv(3),sm%desc_data,info,scratch=.true.,mold=wv(1)%v) + end if + + associate(tx => wv(1), ty => wv(2), ww => wv(3)) + + ! Need to zero tx because of the apply_restr call. + call tx%zero() + ! + ! Unroll the first iteration and fold it inside SELECT CASE + ! this will save one SPMM when INIT=Z, and will be + ! significant when sweeps=1 (a common case) + ! + call psb_geaxpby(zone,x,zzero,tx,desc_data,info) + if (info == 0) call sm%apply_restr(tx,trans_,aux,info) + if (info == 0) call psb_geaxpby(zone,tx,zzero,ww,sm%desc_data,info) + + select case (init_) + case('Z') + call sm%sv%apply(zone,ww,zzero,ty,sm%desc_data,trans_,aux,wv(4:),info,init='Z') + + case('Y') + call psb_geaxpby(zone,y,zzero,ty,desc_data,info) + if (info == 0) call sm%apply_restr(ty,trans_,aux,info) + if (info == 0) call psb_spmm(-zone,sm%nd,ty,zone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + call sm%sv%apply(zone,ww,zzero,ty,desc_data,trans_,aux,wv(4:),info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(zone,initu,zzero,ty,desc_data,info) + if (info == 0) call sm%apply_restr(ty,trans_,aux,info) + if (info == 0) call psb_spmm(-zone,sm%nd,ty,zone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + call sm%sv%apply(zone,ww,zzero,ty,desc_data,trans_,aux,wv(4:),info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + if (info == 0) call sm%apply_prol(ty,trans_,aux,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the + ! block diagonal part and the remaining part of the local matrix + ! and Y(j) is the approximate solution at sweep j. + ! + if (info == 0) call psb_geaxpby(zone,tx,zzero,ww,sm%desc_data,info) + if (info == 0) call psb_spmm(-zone,sm%nd,ty,zone,ww,sm%desc_data,info,& + & work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(zone,ww,zzero,ty,sm%desc_data,trans_,aux,wv(4:),info,init='Y') + + if (info /= psb_success_) exit + if (info == 0) call sm%apply_prol(ty,trans_,aux,info) + + end do + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + ! + ! Compute y = beta*y + alpha*ty (ty == K^(-1)*tx) + ! + call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + end associate + + else + + info = psb_err_iarg_neg_ + call psb_errpush(info,name,& + & i_err=(/itwo,sweeps,izero,izero,izero/)) + goto 9999 + + endif + + + if (.not.(4*isz <= size(work))) then + deallocate(aux,stat=info) + endif + + if (info /= 0) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_as_smoother_apply_vect diff --git a/mlprec/impl/smoother/amg_z_as_smoother_bld.f90 b/mlprec/impl/smoother/amg_z_as_smoother_bld.f90 new file mode 100644 index 00000000..f06ce41b --- /dev/null +++ b/mlprec/impl/smoother/amg_z_as_smoother_bld.f90 @@ -0,0 +1,183 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_as_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_z_as_smoother, amg_protect_nam => amg_z_as_smoother_bld + Implicit None + + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local variables + type(psb_zspmat_type) :: blck, atmp + integer(psb_ipk_) :: n_row,n_col, nrow_a, nhalo, novr, data_ + complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='z_as_smoother_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + novr = sm%novr + if (novr < 0) then + info=psb_err_invalid_ovr_num_ + call psb_errpush(info,name,& + & i_err=(/novr,izero,izero,izero,izero,izero/)) + goto 9999 + endif + + if ((novr == 0).or.(np == 1)) then + call psb_cdcpy(desc_a,sm%desc_data,info) + If(debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' done cdcpy' + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_cdcpy' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Early return: P>=3 N_OVR=0' + call blck%csall(izero,izero,info,ione) + else + + ! + ! Build the auxiliary descriptor desc_p%matrix_data(psb_n_row_). + ! This is done by psb_cdbldext (interface to psb_cdovr), which is + ! independent of CSR, and has been placed in the tools directory + ! of PSBLAS, instead of the mlprec directory of MLD2P4, because it + ! might be used independently of the AS preconditioner, to build + ! a descriptor for an extended stencil in a PDE solver. + ! + call psb_cdbldext(a,desc_a,novr,sm%desc_data,info,extype=psb_ovt_asov_) + if(debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' From cdbldext _:',sm%desc_data%get_local_rows(),& + & sm%desc_data%get_local_cols() + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_cdbldext' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'Before sphalo ' + + ! + ! Retrieve the remote sparse matrix rows required for the AS extended + ! matrix + data_ = psb_comm_ext_ + Call psb_sphalo(a,sm%desc_data,blck,info,data=data_,rowscale=.true.) + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_sphalo' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + if (debug_level >=psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'After psb_sphalo ',& + & blck%get_nrows(), blck%get_nzeros() + + End if + if (info == psb_success_) & + & call sm%sv%build(a,sm%desc_data,info,& + & blck,amold=amold,vmold=vmold) + + nrow_a = a%get_nrows() + n_row = sm%desc_data%get_local_rows() + n_col = sm%desc_data%get_local_cols() + + if (info == psb_success_) call a%csclip(sm%nd,info,& + & jmin=nrow_a+1,rscale=.false.,cscale=.false.) + if (info == psb_success_) call blck%csclip(atmp,info,& + & jmin=nrow_a+1,rscale=.false.,cscale=.false.) + if (info == psb_success_) call psb_rwextd(n_row,sm%nd,info,b=atmp) + + if (info == psb_success_) then + if (present(amold)) then + call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + else + call sm%nd%cscnv(info,& + & type='csr',dupl=psb_dupl_add_) + end if + end if + if (info == psb_success_) then + if (present(imold)) then + call sm%desc_data%cnv(imold) + end if + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='clip & psb_spcnv csr 4') + goto 9999 + end if + sm%nd_nnz_tot = sm%nd%get_nzeros() + call psb_sum(ictxt,sm%nd_nnz_tot) + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_as_smoother_bld diff --git a/mlprec/impl/smoother/amg_z_as_smoother_check.f90 b/mlprec/impl/smoother/amg_z_as_smoother_check.f90 new file mode 100644 index 00000000..3a2a8bae --- /dev/null +++ b/mlprec/impl/smoother/amg_z_as_smoother_check.f90 @@ -0,0 +1,78 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_as_smoother_check(sm,info) + + use psb_base_mod + use amg_z_as_smoother, amg_protect_nam => amg_z_as_smoother_check + + Implicit None + + ! Arguments + class(amg_z_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + Integer(Psb_ipk_) :: err_act + character(len=20) :: name='z_as_smoother_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + call amg_check_def(sm%restr,& + & 'Restrictor',psb_halo_,is_legal_restrict) + call amg_check_def(sm%prol,& + & 'Prolongator',psb_none_,is_legal_prolong) + call amg_check_def(sm%novr,& + & 'Overlap layers ',izero,is_int_non_negative) + + + if (allocated(sm%sv)) then + call sm%sv%check(info) + else + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_as_smoother_check diff --git a/mlprec/impl/smoother/amg_z_as_smoother_clear_data.f90 b/mlprec/impl/smoother/amg_z_as_smoother_clear_data.f90 new file mode 100644 index 00000000..242d554d --- /dev/null +++ b/mlprec/impl/smoother/amg_z_as_smoother_clear_data.f90 @@ -0,0 +1,70 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_as_smoother_clear_data(sm,info) + + use psb_base_mod + use amg_z_as_smoother, amg_protect_name => amg_z_as_smoother_clear_data + Implicit None + ! Arguments + class(amg_z_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_as_smoother_clear_data' + + call psb_erractionsave(err_act) + + info = 0 + call sm%nd%free() + sm%nd_nnz_tot = 0 + call sm%desc_data%free(info) + if ((info==0).and.allocated(sm%sv)) then + call sm%sv%clear_data(info) + end if + if (info /= 0) then + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_as_smoother_clear_data diff --git a/mlprec/impl/smoother/amg_z_as_smoother_clone.f90 b/mlprec/impl/smoother/amg_z_as_smoother_clone.f90 new file mode 100644 index 00000000..9b9115ee --- /dev/null +++ b/mlprec/impl/smoother/amg_z_as_smoother_clone.f90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_as_smoother_clone(sm,smout,info) + + use psb_base_mod + use amg_z_as_smoother, amg_protect_name => amg_z_as_smoother_clone + + Implicit None + + ! Arguments + class(amg_z_as_smoother_type), intent(inout) :: sm + class(amg_z_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(smout)) then + call smout%free(info) + if (info == psb_success_) deallocate(smout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_z_as_smoother_type :: smout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(smo => smout) + type is (amg_z_as_smoother_type) + smo%novr = sm%novr + smo%restr = sm%restr + smo%prol = sm%prol + smo%nd_nnz_tot = sm%nd_nnz_tot + call sm%nd%clone(smo%nd,info) + if (info == psb_success_) & + & call sm%desc_data%clone(smo%desc_data,info) + if ((info==psb_success_).and.(allocated(sm%sv))) then + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == psb_success_) call sm%sv%clone(smo%sv,info) + end if + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_as_smoother_clone diff --git a/mlprec/impl/smoother/amg_z_as_smoother_clone_settings.f90 b/mlprec/impl/smoother/amg_z_as_smoother_clone_settings.f90 new file mode 100644 index 00000000..a2ef9920 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_as_smoother_clone_settings.f90 @@ -0,0 +1,95 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! asd on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_as_smoother_clone_settings(sm,smout,info) + + use psb_base_mod + use amg_z_as_smoother, amg_protect_name => amg_z_as_smoother_clone_settings + Implicit None + ! Arguments + class(amg_z_as_smoother_type), intent(inout) :: sm + class(amg_z_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_as_smoother_clone_settings' + + call psb_erractionsave(err_act) + + info = psb_success_ + + select type(smout) + class is(amg_z_as_smoother_type) + smout%novr = sm%novr + smout%restr = sm%restr + smout%prol = sm%prol + if (allocated(smout%sv)) then + if (.not.same_type_as(sm%sv,smout%sv)) then + call smout%sv%free(info) + if (info == 0) deallocate(smout%sv,stat=info) + end if + end if + if (info /= 0) then + info = psb_err_internal_error_ + else + if (allocated(smout%sv)) then + if (same_type_as(sm%sv,smout%sv)) then + call sm%sv%clone_settings(smout%sv,info) + else + info = psb_err_internal_error_ + end if + else + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == 0) call sm%sv%clone_settings(smout%sv,info) + if (info /= 0) info = psb_err_internal_error_ + end if + end if + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_as_smoother_clone_settings diff --git a/mlprec/impl/smoother/amg_z_as_smoother_cnv.f90 b/mlprec/impl/smoother/amg_z_as_smoother_cnv.f90 new file mode 100644 index 00000000..6287b17e --- /dev/null +++ b/mlprec/impl/smoother/amg_z_as_smoother_cnv.f90 @@ -0,0 +1,96 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_as_smoother_cnv(sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_z_as_smoother, amg_protect_nam => amg_z_as_smoother_cnv + Implicit None + + ! Arguments + class(amg_z_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + ! Local variables + type(psb_dspmat_type) :: blck, atmp + integer(psb_ipk_) :: n_row,n_col, nrow_a, nhalo, novr, data_, nzeros + real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_as_smoother_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = sm%desc_data%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + if (allocated(sm%sv)) & + & call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) + + if (info == psb_success_) then + if (present(amold)) then + if (sm%nd%is_asb()) call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + end if + end if + if (info == psb_success_) then + if (present(imold)) then + call sm%desc_data%cnv(imold) + end if + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='clip & psb_spcnv csr 4') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_as_smoother_cnv diff --git a/mlprec/impl/smoother/amg_z_as_smoother_csetc.f90 b/mlprec/impl/smoother/amg_z_as_smoother_csetc.f90 new file mode 100644 index 00000000..8dca633a --- /dev/null +++ b/mlprec/impl/smoother/amg_z_as_smoother_csetc.f90 @@ -0,0 +1,78 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_as_smoother_csetc(sm,what,val,info,idx) + + use psb_base_mod + use amg_z_as_smoother, amg_protect_nam => amg_z_as_smoother_csetc + Implicit None + ! Arguments + class(amg_z_as_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='z_as_smoother_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + + + ival = sm%stringval(val) + select case(psb_toupper(what)) + case('SUB_RESTR') + sm%restr = ival + case('SUB_PROL') + sm%prol = ival + case default + call sm%amg_z_base_smoother_type%set(what,val,info,idx=idx) + end select + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info, name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_as_smoother_csetc diff --git a/mlprec/impl/smoother/amg_z_as_smoother_cseti.f90 b/mlprec/impl/smoother/amg_z_as_smoother_cseti.f90 new file mode 100644 index 00000000..36146030 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_as_smoother_cseti.f90 @@ -0,0 +1,73 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_as_smoother_cseti(sm,what,val,info,idx) + + use psb_base_mod + use amg_z_as_smoother, amg_protect_nam => amg_z_as_smoother_cseti + Implicit None + + ! Arguments + class(amg_z_as_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_as_smoother_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) + case('SUB_OVR') + sm%novr = val + case('SUB_RESTR') + sm%restr = val + case('SUB_PROL') + sm%prol = val + case default + call sm%amg_z_base_smoother_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_as_smoother_cseti diff --git a/mlprec/impl/smoother/amg_z_as_smoother_dmp.f90 b/mlprec/impl/smoother/amg_z_as_smoother_dmp.f90 new file mode 100644 index 00000000..d1a668b2 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_as_smoother_dmp.f90 @@ -0,0 +1,92 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_as_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + + use psb_base_mod + use amg_z_as_smoother, amg_protect_nam => amg_z_as_smoother_dmp + implicit none + class(amg_z_as_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: smoother_, global_num_ + ! len of prefix_ + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_smth_z" + end if + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(smoother)) then + smoother_ = smoother + else + smoother_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + if (global_num_) then + write(0,*) iam,' Warning: no global num with AS smoothers dump' + end if + if (smoother_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_nd.mtx' + if (sm%nd%is_asb()) & + & call sm%nd%print(fname,head=head) + end if + ! At base level do nothing for the smoother + if (allocated(sm%sv)) & + & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) + +end subroutine amg_z_as_smoother_dmp diff --git a/mlprec/impl/smoother/amg_z_as_smoother_free.f90 b/mlprec/impl/smoother/amg_z_as_smoother_free.f90 new file mode 100644 index 00000000..35a76b94 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_as_smoother_free.f90 @@ -0,0 +1,71 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_as_smoother_free(sm,info) + + use psb_base_mod + use amg_z_as_smoother, amg_protect_nam => amg_z_as_smoother_free + Implicit None + ! Arguments + class(amg_z_as_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_as_smoother_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + + + if (allocated(sm%sv)) then + call sm%sv%free(info) + if (info == psb_success_) deallocate(sm%sv,stat=info) + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + end if + call sm%nd%free() + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_as_smoother_free diff --git a/mlprec/impl/smoother/amg_z_as_smoother_prol_a.f90 b/mlprec/impl/smoother/amg_z_as_smoother_prol_a.f90 new file mode 100644 index 00000000..afb99581 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_as_smoother_prol_a.f90 @@ -0,0 +1,149 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_as_smoother_prol_a(sm,x,trans,work,info,data) + use psb_base_mod + use amg_z_as_smoother, amg_protect_nam => amg_z_as_smoother_prol_a + implicit none + class(amg_z_as_smoother_type), intent(inout) :: sm + complex(psb_dpk_), intent(inout) :: x(:) + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + !Local + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ + character :: trans_ + character(len=20) :: name='z_as_smther_prol_a', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = sm%desc_data%get_context() + call psb_info(ictxt,me,np) + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + info = psb_err_iarg_invalid_i_ + call psb_errpush(info,name) + goto 9999 + end select + + if (present(data)) then + data_ = data + else + data_ = psb_comm_ext_ + end if + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + + select case(trans_) + case('N') + + select case (sm%prol) + + case(psb_none_) + ! + ! Would work anyway, but since it is supposed to do nothing ... + ! call psb_ovrl(x,sm%desc_data,info,& + ! & update=sm%prol,work=work) + + + case(psb_sum_,psb_avg_) + ! + ! Update the overlap of x + ! + call psb_ovrl(x,sm%desc_data,info,& + & update=sm%prol,work=work) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_prol_') + goto 9999 + end select + + case('T','C') + ! + ! With transpose, we have to do it here + ! + if (sm%restr == psb_halo_) then + call psb_ovrl(x,sm%desc_data,info,& + & update=psb_sum_,work=work) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + else if (sm%restr /= psb_none_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_restr_') + goto 9999 + end if + + case default + info=psb_err_iarg_invalid_i_ + int_err(1)=6 + ch_err(2:2)=trans + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_as_smoother_prol_a + + diff --git a/mlprec/impl/smoother/amg_z_as_smoother_prol_v.f90 b/mlprec/impl/smoother/amg_z_as_smoother_prol_v.f90 new file mode 100644 index 00000000..97b91d53 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_as_smoother_prol_v.f90 @@ -0,0 +1,149 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_as_smoother_prol_v(sm,x,trans,work,info,data) + use psb_base_mod + use amg_z_as_smoother, amg_protect_nam => amg_z_as_smoother_prol_v + implicit none + class(amg_z_as_smoother_type), intent(inout) :: sm + type(psb_z_vect_type),intent(inout) :: x + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + !Local + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ + character :: trans_ + character(len=20) :: name='z_as_smther_prol_v', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = sm%desc_data%get_context() + call psb_info(ictxt,me,np) + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + info = psb_err_iarg_invalid_i_ + call psb_errpush(info,name) + goto 9999 + end select + + if (present(data)) then + data_ = data + else + data_ = psb_comm_ext_ + end if + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + + select case(trans_) + case('N') + + select case (sm%prol) + + case(psb_none_) + ! + ! Would work anyway, but since it is supposed to do nothing ... + ! call psb_ovrl(x,sm%desc_data,info,& + ! & update=sm%prol,work=work) + + + case(psb_sum_,psb_avg_) + ! + ! Update the overlap of x + ! + call psb_ovrl(x,sm%desc_data,info,& + & update=sm%prol,work=work) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_prol_') + goto 9999 + end select + + case('T','C') + ! + ! With transpose, we have to do it here + ! + if (sm%restr == psb_halo_) then + call psb_ovrl(x,sm%desc_data,info,& + & update=psb_sum_,work=work) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + else if (sm%restr /= psb_none_) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_restr_') + goto 9999 + end if + + case default + info=psb_err_iarg_invalid_i_ + int_err(1)=6 + ch_err(2:2)=trans + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_as_smoother_prol_v + + diff --git a/mlprec/impl/smoother/amg_z_as_smoother_restr_a.f90 b/mlprec/impl/smoother/amg_z_as_smoother_restr_a.f90 new file mode 100644 index 00000000..15e536ce --- /dev/null +++ b/mlprec/impl/smoother/amg_z_as_smoother_restr_a.f90 @@ -0,0 +1,168 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_as_smoother_restr_a(sm,x,trans,work,info,data) + use psb_base_mod + use amg_z_as_smoother, amg_protect_nam => amg_z_as_smoother_restr_a + implicit none + class(amg_z_as_smoother_type), intent(inout) :: sm + complex(psb_dpk_), intent(inout) :: x(:) + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + !Local + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ + character :: trans_ + character(len=20) :: name='z_as_smther_restr_a', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = sm%desc_data%get_context() + call psb_info(ictxt,me,np) + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + info = psb_err_iarg_invalid_i_ + call psb_errpush(info,name) + goto 9999 + end select + + if (present(data)) then + data_ = data + else + data_ = psb_comm_ext_ + end if + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + select case(trans_) + case('N') + ! + ! Get the overlap entries x + ! + if (sm%restr == psb_halo_) then + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + else if (sm%restr /= psb_none_) then + call psb_errpush(psb_err_internal_error_,name,& + &a_err='Invalid amg_sub_restr_') + goto 9999 + end if + + + case('T','C') + ! + ! With transpose, we have to do it here + ! + + select case (sm%prol) + + case(psb_none_) + ! + ! Do nothing + + case(psb_sum_) + ! + ! The transpose of sum is halo + ! + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + + case(psb_avg_) + ! + ! Tricky one: first we have to scale the overlap entries, + ! which we can do by assignind mode=0, i.e. no communication + ! (hence only scaling), then we do the halo + ! + call psb_ovrl(x,sm%desc_data,info,& + & update=psb_avg_,work=work,mode=izero) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_prol_') + goto 9999 + end select + + + case default + info=psb_err_iarg_invalid_i_ + int_err(1)=6 + ch_err(2:2)=trans + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_as_smoother_restr_a + + diff --git a/mlprec/impl/smoother/amg_z_as_smoother_restr_v.f90 b/mlprec/impl/smoother/amg_z_as_smoother_restr_v.f90 new file mode 100644 index 00000000..8b37952f --- /dev/null +++ b/mlprec/impl/smoother/amg_z_as_smoother_restr_v.f90 @@ -0,0 +1,168 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_as_smoother_restr_v(sm,x,trans,work,info,data) + use psb_base_mod + use amg_z_as_smoother, amg_protect_nam => amg_z_as_smoother_restr_v + implicit none + class(amg_z_as_smoother_type), intent(inout) :: sm + type(psb_z_vect_type),intent(inout) :: x + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), optional, intent(in) :: data + !Local + integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ + character :: trans_ + character(len=20) :: name='z_as_smther_restr_v', ch_err + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = sm%desc_data%get_context() + call psb_info(ictxt,me,np) + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + info = psb_err_iarg_invalid_i_ + call psb_errpush(info,name) + goto 9999 + end select + + if (present(data)) then + data_ = data + else + data_ = psb_comm_ext_ + end if + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + + select case(trans_) + case('N') + ! + ! Get the overlap entries x + ! + if (sm%restr == psb_halo_) then + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + else if (sm%restr /= psb_none_) then + call psb_errpush(psb_err_internal_error_,name,& + &a_err='Invalid amg_sub_restr_') + goto 9999 + end if + + + case('T','C') + ! + ! With transpose, we have to do it here + ! + + select case (sm%prol) + + case(psb_none_) + ! + ! Do nothing + + case(psb_sum_) + ! + ! The transpose of sum is halo + ! + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + + case(psb_avg_) + ! + ! Tricky one: first we have to scale the overlap entries, + ! which we can do by assignind mode=0, i.e. no communication + ! (hence only scaling), then we do the halo + ! + call psb_ovrl(x,sm%desc_data,info,& + & update=psb_avg_,work=work,mode=izero) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ovrl' + goto 9999 + end if + call psb_halo(x,sm%desc_data,info,work=work,data=data_) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_halo' + goto 9999 + end if + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid amg_sub_prol_') + goto 9999 + end select + + + case default + info=psb_err_iarg_invalid_i_ + int_err(1)=6 + ch_err(2:2)=trans + goto 9999 + end select + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_as_smoother_restr_v + + diff --git a/mlprec/impl/smoother/amg_z_base_smoother_apply.f90 b/mlprec/impl/smoother/amg_z_base_smoother_apply.f90 new file mode 100644 index 00000000..ff9a1e69 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_base_smoother_apply.f90 @@ -0,0 +1,87 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_smoother_apply(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,info,init,initu) + use psb_base_mod + use amg_z_base_smoother_mod, amg_protect_name => amg_z_base_smoother_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_base_smoother_type), intent(inout) :: sm + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_smoother_apply' + + call psb_erractionsave(err_act) + info = psb_success_ + if (sweeps == 0) then + + ! + ! K^0 = I + ! zero sweeps of any smoother is just the identity. + ! + call psb_geaxpby(alpha,x,beta,y,desc_data,info) + + else + if (allocated(sm%sv)) then + call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,info,init=init, initu=initu) + else + info = 1121 + endif + end if + if (info /= psb_success_) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_base_smoother_apply diff --git a/mlprec/impl/smoother/amg_z_base_smoother_apply_vect.f90 b/mlprec/impl/smoother/amg_z_base_smoother_apply_vect.f90 new file mode 100644 index 00000000..cb887e47 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_base_smoother_apply_vect.f90 @@ -0,0 +1,88 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,wv,info,init,initu) + use psb_base_mod + use amg_z_base_smoother_mod, amg_protect_name => amg_z_base_smoother_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_base_smoother_type), intent(inout) :: sm + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + ! + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_smoother_apply' + + call psb_erractionsave(err_act) + info = psb_success_ + if (sweeps == 0) then + + ! + ! K^0 = I + ! zero sweeps of any smoother is just the identity. + ! + call psb_geaxpby(alpha,x,beta,y,desc_data,info) + + else + if (allocated(sm%sv)) then + call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,wv,info,init=init, initu=initu) + else + info = 1121 + endif + end if + if (info /= psb_success_) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_base_smoother_apply_vect diff --git a/mlprec/impl/smoother/amg_z_base_smoother_bld.f90 b/mlprec/impl/smoother/amg_z_base_smoother_bld.f90 new file mode 100644 index 00000000..0125005b --- /dev/null +++ b/mlprec/impl/smoother/amg_z_base_smoother_bld.f90 @@ -0,0 +1,72 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_z_base_smoother_mod, amg_protect_name => amg_z_base_smoother_bld + Implicit None + + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_smoother_bld' + + call psb_erractionsave(err_act) + + info = psb_success_ + if (allocated(sm%sv)) then + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + else + info = 1121 + call psb_errpush(info,name) + endif + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_smoother_bld diff --git a/mlprec/impl/smoother/amg_z_base_smoother_check.f90 b/mlprec/impl/smoother/amg_z_base_smoother_check.f90 new file mode 100644 index 00000000..96da1994 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_base_smoother_check.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_smoother_check(sm,info) + + use psb_base_mod + use amg_z_base_smoother_mod, amg_protect_name => amg_z_base_smoother_check + Implicit None + + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + Integer(Psb_ipk_) :: err_act + character(len=20) :: name='z_base_smoother_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%check(info) + else + info=3111 + call psb_errpush(info,name) + goto 9999 + end if + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_smoother_check diff --git a/mlprec/impl/smoother/amg_z_base_smoother_clear_data.f90 b/mlprec/impl/smoother/amg_z_base_smoother_clear_data.f90 new file mode 100644 index 00000000..fa3181cc --- /dev/null +++ b/mlprec/impl/smoother/amg_z_base_smoother_clear_data.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_smoother_clear_data(sm,info) + + use psb_base_mod + use amg_z_base_smoother_mod, amg_protect_name => amg_z_base_smoother_clear_data + Implicit None + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_smoother_clear_data' + + call psb_erractionsave(err_act) + + info = 0 + if (allocated(sm%sv)) then + call sm%sv%clear_data(info) + if (info /= 0) then + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_smoother_clear_data diff --git a/mlprec/impl/smoother/amg_z_base_smoother_clone.f90 b/mlprec/impl/smoother/amg_z_base_smoother_clone.f90 new file mode 100644 index 00000000..d56ebdb0 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_base_smoother_clone.f90 @@ -0,0 +1,62 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_smoother_clone(sm,smout,info) + + use psb_base_mod + use amg_z_base_smoother_mod, amg_protect_name => amg_z_base_smoother_clone + Implicit None + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + class(amg_z_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_smoother_clone' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_smoother_clone diff --git a/mlprec/impl/smoother/amg_z_base_smoother_clone_settings.f90 b/mlprec/impl/smoother/amg_z_base_smoother_clone_settings.f90 new file mode 100644 index 00000000..621bb3e3 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_base_smoother_clone_settings.f90 @@ -0,0 +1,89 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_smoother_clone_settings(sm,smout,info) + + use psb_base_mod + use amg_z_base_smoother_mod, amg_protect_name => amg_z_base_smoother_clone_settings + Implicit None + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + class(amg_z_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_smoother_clone_settings' + + call psb_erractionsave(err_act) + + info=psb_success_ + if (same_type_as(sm,smout)) then + if (allocated(smout%sv)) then + if (.not.same_type_as(sm%sv,smout%sv)) then + call smout%sv%free(info) + if (info == 0) deallocate(smout%sv,stat=info) + end if + end if + if (info /= 0) then + info = psb_err_internal_error_ + else + if (allocated(smout%sv)) then + if (same_type_as(sm%sv,smout%sv)) then + call sm%sv%clone_settings(smout%sv,info) + else + info = psb_err_internal_error_ + end if + else + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == 0) call sm%sv%clone_settings(smout%sv,info) + if (info /= 0) info = psb_err_internal_error_ + end if + end if + else + info = psb_err_internal_error_ + end if + if (info /= 0) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_smoother_clone_settings diff --git a/mlprec/impl/smoother/amg_z_base_smoother_cnv.f90 b/mlprec/impl/smoother/amg_z_base_smoother_cnv.f90 new file mode 100644 index 00000000..21462624 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_base_smoother_cnv.f90 @@ -0,0 +1,70 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_smoother_cnv(sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_z_base_smoother_mod, amg_protect_name => amg_z_base_smoother_cnv + Implicit None + + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_smoother_cnv' + + call psb_erractionsave(err_act) + + info = psb_success_ + if (allocated(sm%sv)) then + call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) + else + info = 1121 + call psb_errpush(info,name) + endif + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_smoother_cnv diff --git a/mlprec/impl/smoother/amg_z_base_smoother_csetc.f90 b/mlprec/impl/smoother/amg_z_base_smoother_csetc.f90 new file mode 100644 index 00000000..81ddc550 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_base_smoother_csetc.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_smoother_csetc(sm,what,val,info,idx) + + use psb_base_mod + use amg_z_base_smoother_mod, amg_protect_name => amg_z_base_smoother_csetc + Implicit None + + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='z_base_smoother_csetc' + + call psb_erractionsave(err_act) + + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%set(what,val,info,idx=idx) + end if + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_smoother_csetc diff --git a/mlprec/impl/smoother/amg_z_base_smoother_cseti.f90 b/mlprec/impl/smoother/amg_z_base_smoother_cseti.f90 new file mode 100644 index 00000000..5fed13b4 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_base_smoother_cseti.f90 @@ -0,0 +1,65 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_smoother_cseti(sm,what,val,info,idx) + + use psb_base_mod + use amg_z_base_smoother_mod, amg_protect_name => amg_z_base_smoother_cseti + Implicit None + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_smoother_cseti' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%set(what,val,info,idx=idx) + end if + if (info /= psb_success_) goto 9999 + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_smoother_cseti diff --git a/mlprec/impl/smoother/amg_z_base_smoother_csetr.f90 b/mlprec/impl/smoother/amg_z_base_smoother_csetr.f90 new file mode 100644 index 00000000..de37ed1d --- /dev/null +++ b/mlprec/impl/smoother/amg_z_base_smoother_csetr.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_smoother_csetr(sm,what,val,info,idx) + + use psb_base_mod + use amg_z_base_smoother_mod, amg_protect_name => amg_z_base_smoother_csetr + Implicit None + + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_smoother_csetr' + + call psb_erractionsave(err_act) + + + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%set(what,val,info,idx=idx) + end if + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_smoother_csetr diff --git a/mlprec/impl/smoother/amg_z_base_smoother_descr.f90 b/mlprec/impl/smoother/amg_z_base_smoother_descr.f90 new file mode 100644 index 00000000..409f00b2 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_base_smoother_descr.f90 @@ -0,0 +1,101 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_smoother_descr(sm,info,iout,coarse) + + use psb_base_mod + use amg_z_base_smoother_mod, amg_protect_name => amg_z_base_smoother_descr + use amg_z_id_solver + Implicit None + + ! Arguments + class(amg_z_base_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + integer(psb_ipk_) :: ictxt, me, np + character(len=20), parameter :: name='amg_z_base_smoother_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse_ + + + call psb_erractionsave(err_act) + info = psb_success_ + + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + end if + + if (coarse_) then + if (allocated(sm%sv)) call sm%sv%descr(info,iout,coarse) + else + if (allocated(sm%sv)) then + select type (sv => sm%sv) + class is (amg_z_id_solver_type) + write(iout_,*) 'No preconditioner/smoother' + class default + write(iout_,*) 'Decoupled preconditioner/smoother with local solver' + call sm%sv%descr(info,iout,coarse) + end select + else + write(iout_,*) 'No preconditioner/smoother' + end if + end if + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='Local solver') + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_smoother_descr diff --git a/mlprec/impl/smoother/amg_z_base_smoother_dmp.f90 b/mlprec/impl/smoother/amg_z_base_smoother_dmp.f90 new file mode 100644 index 00000000..97afb2f5 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_base_smoother_dmp.f90 @@ -0,0 +1,85 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + + use psb_base_mod + use amg_z_base_smoother_mod, amg_protect_name => amg_z_base_smoother_dmp + implicit none + class(amg_z_base_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: smoother_, global_num_ + ! len of prefix_ + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_smth_z" + end if + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + if (present(smoother)) then + smoother_ = smoother + else + smoother_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + ! At base level do nothing for the smoother + if (allocated(sm%sv)) & + & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) + +end subroutine amg_z_base_smoother_dmp diff --git a/mlprec/impl/smoother/amg_z_base_smoother_free.f90 b/mlprec/impl/smoother/amg_z_base_smoother_free.f90 new file mode 100644 index 00000000..ab2e742f --- /dev/null +++ b/mlprec/impl/smoother/amg_z_base_smoother_free.f90 @@ -0,0 +1,68 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_smoother_free(sm,info) + + use psb_base_mod + use amg_z_base_smoother_mod, amg_protect_name => amg_z_base_smoother_free + Implicit None + + ! Arguments + class(amg_z_base_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_smoother_free' + + call psb_erractionsave(err_act) + info = psb_success_ + + if (allocated(sm%sv)) then + call sm%sv%free(info) + if (info == psb_success_) deallocate(sm%sv,stat=info) + end if + if (info /= psb_success_) then + info = psb_err_alloc_dealloc_ + call psb_errpush(info,name) + goto 9999 + end if + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_smoother_free diff --git a/mlprec/impl/smoother/amg_z_jac_smoother_apply.f90 b/mlprec/impl/smoother/amg_z_jac_smoother_apply.f90 new file mode 100644 index 00000000..4b0ad15e --- /dev/null +++ b/mlprec/impl/smoother/amg_z_jac_smoother_apply.f90 @@ -0,0 +1,273 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_jac_smoother_apply(alpha,sm,x,beta,y,desc_data,& + & trans,sweeps,work,info,init,initu) + use psb_base_mod + use amg_z_jac_smoother, amg_protect_name => amg_z_jac_smoother_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_jac_smoother_type), intent(inout) :: sm + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col + complex(psb_dpk_), allocatable :: tx(:),ty(:) + complex(psb_dpk_), pointer :: aux(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='z_jac_smoother_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = desc_data%get_context() + call psb_info(ictxt,me,np) + + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (4*n_col <= size(work)) then + aux => work(:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + endif + + if ((.not.sm%sv%is_iterative()).and.((sweeps == 1).or.(sm%nd_nnz_tot==0))) then + ! if .not.sv%is_iterative, there's no need to pass init + call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + else if (sweeps >= 0) then + if (associated(sm%pa)) then + ! + ! This means we are dealing with a pure Jacobi smoother/solver. + ! + call psb_geasb(tx,desc_data,info) + call psb_geasb(ty,desc_data,info) + select case (init_) + case('Z') + + call sm%sv%apply(zone,x,zzero,ty,desc_data,trans_,aux,info,init='Z') + + case('Y') + call psb_geaxpby(zone,x,zzero,tx,desc_data,info) + call psb_geaxpby(zone,y,zzero,ty,desc_data,info) + call psb_spmm(-zone,sm%pa,ty,zone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(zone,x,zzero,tx,desc_data,info) + call psb_geaxpby(zone,initu,zzero,ty,desc_data,info) + call psb_spmm(-zone,sm%pa,ty,zone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = Y(j)+ D^(-1)*(X-A*Y(j)), + ! where is the diagonal and A the matrix. + ! + call psb_geaxpby(zone,x,zzero,tx,desc_data,info) + call psb_spmm(-zone,sm%pa,ty,zone,tx,desc_data,info,work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(zone,tx,zone,ty,desc_data,trans_,aux,info,init='Y') + + if (info /= psb_success_) exit + end do + + + if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + else + ! + ! + ! Apply multiple sweeps of a block-Jacobi solver + ! to compute an approximate solution of a linear system. + ! + ! + call psb_geasb(tx,desc_data,info) + call psb_geasb(ty,desc_data,info) + + ! + ! Unroll the first iteration and fold it inside SELECT CASE + ! this will save one AXPBY and one SPMM when INIT=Z, and will be + ! significant when sweeps=1 (a common case) + ! + select case (init_) + case('Z') + + call sm%sv%apply(zone,x,zzero,ty,desc_data,trans_,aux,info,init='Z') + + case('Y') + call psb_geaxpby(zone,x,zzero,tx,desc_data,info) + call psb_geaxpby(zone,y,zzero,ty,desc_data,info) + call psb_spmm(-zone,sm%nd,ty,zone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(zone,x,zzero,tx,desc_data,info) + call psb_geaxpby(zone,initu,zzero,ty,desc_data,info) + call psb_spmm(-zone,sm%nd,ty,zone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the + ! block diagonal part and the remaining part of the local matrix + ! and Y(j) is the approximate solution at sweep j. + ! + call psb_geaxpby(zone,x,zzero,tx,desc_data,info) + call psb_spmm(-zone,sm%nd,ty,zone,tx,desc_data,info,work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,info,init='Y') + + if (info /= psb_success_) exit + end do + + if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + end if + + deallocate(tx,ty,stat=info) + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='final cleanup with Jacobi sweeps > 1') + goto 9999 + end if + + else + + info = psb_err_iarg_neg_ + call psb_errpush(info,name,& + & i_err=(/itwo,sweeps,izero,izero,izero/)) + goto 9999 + + endif + + if (.not.(4*n_col <= size(work))) then + deallocate(aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_jac_smoother_apply diff --git a/mlprec/impl/smoother/amg_z_jac_smoother_apply_vect.f90 b/mlprec/impl/smoother/amg_z_jac_smoother_apply_vect.f90 new file mode 100644 index 00000000..2f56fe58 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_jac_smoother_apply_vect.f90 @@ -0,0 +1,320 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_jac_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& + & sweeps,work,wv,info,init,initu) + + use psb_base_mod + use amg_z_diag_solver + use psb_base_krylov_conv_mod, only : log_conv + use amg_z_jac_smoother, amg_protect_name => amg_z_jac_smoother_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_jac_smoother_type), intent(inout) :: sm + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + integer(psb_ipk_), intent(in) :: sweeps + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + ! + integer(psb_ipk_) :: n_row,n_col + type(psb_z_vect_type) :: tx, ty, r + complex(psb_dpk_), pointer :: aux(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + real(psb_dpk_) :: res, resdenum + character(len=20) :: name='z_jac_smoother_apply_v' + + call psb_erractionsave(err_act) + + info = psb_success_ + ictxt = desc_data%get_context() + call psb_info(ictxt,me,np) + + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (.not.allocated(sm%sv)) then + info = 1121 + call psb_errpush(info,name) + goto 9999 + end if + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (4*n_col <= size(work)) then + aux => work(:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + endif + + if(sm%checkres) then + call psb_geall(r,desc_data,info) + call psb_geasb(r,desc_data,info) + resdenum = psb_genrm2(x,desc_data,info) + end if + + if ((.not.sm%sv%is_iterative()).and.((sweeps == 1).or.(sm%nd_nnz_tot==0))) then + ! if .not.sv%is_iterative, there's no need to pass init + call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,wv,info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in sub_aply Jacobi Sweeps = 1') + goto 9999 + endif + + else if (sweeps >= 0) then + select type (smsv => sm%sv) + class is (amg_z_diag_solver_type) + ! + ! This means we are dealing with a pure Jacobi smoother/solver. + ! + associate(tx => wv(1), ty => wv(2)) + select case (init_) + case('Z') + + call sm%sv%apply(zone,x,zzero,ty,desc_data,trans_,aux,wv(3:),info,init='Z') + + case('Y') + call psb_geaxpby(zone,x,zzero,tx,desc_data,info) + call psb_geaxpby(zone,y,zzero,ty,desc_data,info) + call psb_spmm(-zone,sm%pa,ty,zone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(zone,x,zzero,tx,desc_data,info) + call psb_geaxpby(zone,initu,zzero,ty,desc_data,info) + call psb_spmm(-zone,sm%pa,ty,zone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = Y(j)+ D^(-1)*(X-A*Y(j)), + ! where is the diagonal and A the matrix. + ! + call psb_geaxpby(zone,x,zzero,tx,desc_data,info) + call psb_spmm(-zone,sm%pa,ty,zone,tx,desc_data,info,work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(zone,tx,zone,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + if (info /= psb_success_) exit + + if ( sm%checkres.and.(mod(i,sm%checkiter) == 0) ) then + call psb_geaxpby(zone,x,zzero,r,r,desc_data,info) + call psb_spmm(-zone,sm%pa,ty,zone,r,desc_data,info) + res = psb_genrm2(r,desc_data,info) + if( sm%printres ) then + call log_conv("BJAC",me,i,sm%printiter,res,resdenum,sm%tol) + end if + if ( res < sm%tol*resdenum ) then + if( (sm%printres).and.(mod(sm%printiter,sm%checkiter)/=0) ) & + & call log_conv("BJAC",me,i,1,res,resdenum,sm%tol) + exit + end if + end if + + end do + + + if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + + end associate + + class default + ! + ! + ! Apply multiple sweeps of a block-Jacobi solver + ! to compute an approximate solution of a linear system. + ! + ! + if (size(wv) < 2) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size in smoother_apply') + goto 9999 + end if + associate(tx => wv(1), ty => wv(2)) + + ! + ! Unroll the first iteration and fold it inside SELECT CASE + ! this will save one AXPBY and one SPMM when INIT=Z, and will be + ! significant when sweeps=1 (a common case) + ! + select case (init_) + case('Z') + + call sm%sv%apply(zone,x,zzero,ty,desc_data,trans_,aux,wv(3:),info,init='Z') + + case('Y') + call psb_geaxpby(zone,x,zzero,tx,desc_data,info) + call psb_geaxpby(zone,y,zzero,ty,desc_data,info) + call psb_spmm(-zone,sm%nd,ty,zone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(zone,x,zzero,tx,desc_data,info) + call psb_geaxpby(zone,initu,zzero,ty,desc_data,info) + call psb_spmm(-zone,sm%nd,ty,zone,tx,desc_data,info,work=aux,trans=trans_) + call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + do i=1, sweeps-1 + ! + ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the + ! block diagonal part and the remaining part of the local matrix + ! and Y(j) is the approximate solution at sweep j. + ! + call psb_geaxpby(zone,x,zzero,tx,desc_data,info) + call psb_spmm(-zone,sm%nd,ty,zone,tx,desc_data,info,work=aux,trans=trans_) + + if (info /= psb_success_) exit + + call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') + + if (info /= psb_success_) exit + + if ( sm%checkres.and.(mod(i,sm%checkiter) == 0) ) then + call psb_geaxpby(zone,x,zzero,r,r,desc_data,info) + call psb_spmm(-zone,sm%pa,ty,zone,r,desc_data,info) + res = psb_genrm2(r,desc_data,info) + if( sm%printres ) then + call log_conv("BJAC",me,i,sm%printiter,res,resdenum,sm%tol) + end if + if (res < sm%tol*resdenum ) then + if( (sm%printres).and.( mod(sm%printiter,sm%checkiter) /=0 ) ) & + & call log_conv("BJAC",me,i,1,res,resdenum,sm%tol) + exit + end if + end if + + end do + + if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) + + if (info /= psb_success_) then + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='subsolve with Jacobi sweeps > 1') + goto 9999 + end if + + end associate + end select + + else + + info = psb_err_iarg_neg_ + call psb_errpush(info,name,& + & i_err=(/itwo,sweeps,izero,izero,izero/)) + goto 9999 + + endif + + if (.not.(4*n_col <= size(work))) then + deallocate(aux) + endif + + if(sm%checkres) then + call psb_gefree(r,desc_data,info) + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_jac_smoother_apply_vect diff --git a/mlprec/impl/smoother/amg_z_jac_smoother_bld.f90 b/mlprec/impl/smoother/amg_z_jac_smoother_bld.f90 new file mode 100644 index 00000000..2e902f94 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_jac_smoother_bld.f90 @@ -0,0 +1,127 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_z_diag_solver + use amg_z_jac_smoother, amg_protect_name => amg_z_jac_smoother_bld + Implicit None + + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + type(psb_zspmat_type) :: tmpa + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota, nzeros + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='z_jac_smoother_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + n_col = desc_a%get_local_cols() + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + + if( sm%checkres ) sm%pa => a + + select type (smsv => sm%sv) + class is (amg_z_diag_solver_type) + call sm%nd%free() + sm%pa => a + sm%nd_nnz_tot = nztota + call psb_sum(ictxt,sm%nd_nnz_tot) + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + + class default + if (smsv%is_global()) then + ! Do not put anything into SM%ND since the solver + ! is acting globally. + call sm%nd%free() + sm%nd_nnz_tot = 0 + call psb_sum(ictxt,sm%nd_nnz_tot) + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + else + call a%csclip(sm%nd,info,& + & jmin=nrow_a+1,rscale=.false.,cscale=.false.) + if (info == psb_success_) then + if (present(amold)) then + call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + else + call sm%nd%cscnv(info,& + & type='csr',dupl=psb_dupl_add_) + endif + end if + sm%nd_nnz_tot = sm%nd%get_nzeros() + call psb_sum(ictxt,sm%nd_nnz_tot) + call a%csclip(tmpa,info,& + & jmax=nrow_a,rscale=.false.,cscale=.false.) + call sm%sv%build(tmpa,desc_a,info,amold=amold,vmold=vmold) + end if + end select + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='clip & psb_spcnv csr 4') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_jac_smoother_bld diff --git a/mlprec/impl/smoother/amg_z_jac_smoother_clear_data.f90 b/mlprec/impl/smoother/amg_z_jac_smoother_clear_data.f90 new file mode 100644 index 00000000..657bf2e9 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_jac_smoother_clear_data.f90 @@ -0,0 +1,70 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_jac_smoother_clear_data(sm,info) + + use psb_base_mod + use amg_z_jac_smoother, amg_protect_name => amg_z_jac_smoother_clear_data + Implicit None + ! Arguments + class(amg_z_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_jac_smoother_clear_data' + + call psb_erractionsave(err_act) + + info = 0 + call sm%nd%free() + sm%nd_nnz_tot = 0 + sm%pa => null() + if ((info==0).and.allocated(sm%sv)) then + call sm%sv%clear_data(info) + end if + if (info /= 0) then + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_jac_smoother_clear_data diff --git a/mlprec/impl/smoother/amg_z_jac_smoother_clone.f90 b/mlprec/impl/smoother/amg_z_jac_smoother_clone.f90 new file mode 100644 index 00000000..138a2efd --- /dev/null +++ b/mlprec/impl/smoother/amg_z_jac_smoother_clone.f90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_jac_smoother_clone(sm,smout,info) + + use psb_base_mod + use amg_z_jac_smoother, amg_protect_name => amg_z_jac_smoother_clone + + Implicit None + + ! Arguments + class(amg_z_jac_smoother_type), intent(inout) :: sm + class(amg_z_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(smout)) then + call smout%free(info) + if (info == psb_success_) deallocate(smout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_z_jac_smoother_type :: smout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(smo => smout) + type is (amg_z_jac_smoother_type) + smo%nd_nnz_tot = sm%nd_nnz_tot + smo%checkres = sm%checkres + smo%printres = sm%printres + smo%checkiter = sm%checkiter + smo%printiter = sm%printiter + smo%tol = sm%tol + call sm%nd%clone(smo%nd,info) + if ((info==psb_success_).and.(allocated(sm%sv))) then + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == psb_success_) call sm%sv%clone(smo%sv,info) + end if + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_jac_smoother_clone diff --git a/mlprec/impl/smoother/amg_z_jac_smoother_clone_settings.f90 b/mlprec/impl/smoother/amg_z_jac_smoother_clone_settings.f90 new file mode 100644 index 00000000..cd28ad8a --- /dev/null +++ b/mlprec/impl/smoother/amg_z_jac_smoother_clone_settings.f90 @@ -0,0 +1,101 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! asd on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_jac_smoother_clone_settings(sm,smout,info) + + use psb_base_mod + use amg_z_jac_smoother, amg_protect_name => amg_z_jac_smoother_clone_settings + Implicit None + ! Arguments + class(amg_z_jac_smoother_type), intent(inout) :: sm + class(amg_z_base_smoother_type), intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_jac_smoother_clone_settings' + + call psb_erractionsave(err_act) + + info = psb_success_ + + select type(smout) + class is(amg_z_jac_smoother_type) + + smout%pa => null() + smout%nd_nnz_tot = 0 + smout%checkres = sm%checkres + smout%printres = sm%printres + smout%checkiter = sm%checkiter + smout%printiter = sm%printiter + smout%tol = sm%tol + + if (allocated(smout%sv)) then + if (.not.same_type_as(sm%sv,smout%sv)) then + call smout%sv%free(info) + if (info == 0) deallocate(smout%sv,stat=info) + end if + end if + if (info /= 0) then + info = psb_err_internal_error_ + else + if (allocated(smout%sv)) then + if (same_type_as(sm%sv,smout%sv)) then + call sm%sv%clone_settings(smout%sv,info) + else + info = psb_err_internal_error_ + end if + else + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == 0) call sm%sv%clone_settings(smout%sv,info) + if (info /= 0) info = psb_err_internal_error_ + end if + end if + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) then + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_jac_smoother_clone_settings diff --git a/mlprec/impl/smoother/amg_z_jac_smoother_cnv.f90 b/mlprec/impl/smoother/amg_z_jac_smoother_cnv.f90 new file mode 100644 index 00000000..288c571f --- /dev/null +++ b/mlprec/impl/smoother/amg_z_jac_smoother_cnv.f90 @@ -0,0 +1,90 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_jac_smoother_cnv(sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_z_diag_solver + use amg_z_jac_smoother, amg_protect_name => amg_z_jac_smoother_cnv + Implicit None + + ! Arguments + class(amg_z_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_jac_smoother_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + + if (info == psb_success_) then + if (sm%nd%is_asb()) then + if (present(amold)) then + call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + else + call sm%nd%cscnv(info,& + & type='csr',dupl=psb_dupl_add_) + endif + end if + end if + + if (info == psb_success_) then + if (allocated(sm%sv)) & + & call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='solver cnv') + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_jac_smoother_cnv diff --git a/mlprec/impl/smoother/amg_z_jac_smoother_csetc.f90 b/mlprec/impl/smoother/amg_z_jac_smoother_csetc.f90 new file mode 100644 index 00000000..b12733c4 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_jac_smoother_csetc.f90 @@ -0,0 +1,90 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_jac_smoother_csetc(sm,what,val,info,idx) + + use psb_base_mod + use amg_z_jac_smoother, amg_protect_nam => amg_z_jac_smoother_csetc + Implicit None + ! Arguments + class(amg_z_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act, ival + character(len=20) :: name='z_jac_smoother_csetc' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(trim(what))) + case('SMOOTHER_STOP') + select case(psb_toupper(trim(val))) + case('T','TRUE') + sm%checkres = .true. + case('F','FALSE') + sm%checkres = .false. + case default + write(0,*) 'Unknown value for smoother_stop : "',psb_toupper(trim(val)),'"' + end select + case('SMOOTHER_TRACE') + select case(psb_toupper(trim(val))) + case('T','TRUE') + sm%printres = .true. + case('F','FALSE') + sm%printres = .false. + case default + write(0,*) 'Unknown value for smoother_trace : "',psb_toupper(trim(val)),'"' + end select + case default + call sm%amg_z_base_smoother_type%set(what,val,info,idx=idx) + end select + + if (info /= psb_success_) then + info = psb_err_from_subroutine_ + call psb_errpush(info, name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_jac_smoother_csetc diff --git a/mlprec/impl/smoother/amg_z_jac_smoother_cseti.f90 b/mlprec/impl/smoother/amg_z_jac_smoother_cseti.f90 new file mode 100644 index 00000000..c2eae36a --- /dev/null +++ b/mlprec/impl/smoother/amg_z_jac_smoother_cseti.f90 @@ -0,0 +1,71 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_jac_smoother_cseti(sm,what,val,info,idx) + + use psb_base_mod + use amg_z_jac_smoother, amg_protect_nam => amg_z_jac_smoother_cseti + Implicit None + + ! Arguments + class(amg_z_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_jac_smoother_cseti' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) + case('SMOOTHER_RESIDUAL') + sm%checkiter = val + case('SMOOTHER_ITRACE') + sm%printiter = val + case default + call sm%amg_z_base_smoother_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_jac_smoother_cseti diff --git a/mlprec/impl/smoother/amg_z_jac_smoother_csetr.f90 b/mlprec/impl/smoother/amg_z_jac_smoother_csetr.f90 new file mode 100644 index 00000000..c7fc5d7d --- /dev/null +++ b/mlprec/impl/smoother/amg_z_jac_smoother_csetr.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_jac_smoother_csetr(sm,what,val,info,idx) + + use psb_base_mod + use amg_z_jac_smoother, amg_protect_nam => amg_z_jac_smoother_csetr + Implicit None + + ! Arguments + class(amg_z_jac_smoother_type), intent(inout) :: sm + character(len=*), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_jac_smoother_csetr' + + info = psb_success_ + call psb_erractionsave(err_act) + + select case(psb_toupper(what)) + case('SMOOTHER_STOPTOL') + sm%tol = val + case default + call sm%amg_z_base_smoother_type%set(what,val,info,idx=idx) + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_jac_smoother_csetr diff --git a/mlprec/impl/smoother/amg_z_jac_smoother_descr.f90 b/mlprec/impl/smoother/amg_z_jac_smoother_descr.f90 new file mode 100644 index 00000000..f8f90ec7 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_jac_smoother_descr.f90 @@ -0,0 +1,103 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_jac_smoother_descr(sm,info,iout,coarse) + + use psb_base_mod + use amg_z_diag_solver + use amg_z_jac_smoother, amg_protect_name => amg_z_jac_smoother_descr + use amg_z_diag_solver + use amg_z_gs_solver + + Implicit None + + ! Arguments + class(amg_z_jac_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_z_jac_smoother_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (.not.coarse_) then + if (allocated(sm%sv)) then + select type(smv=>sm%sv) + class is (amg_z_diag_solver_type) + write(iout_,*) ' Point Jacobi ' + write(iout_,*) ' Local diagonal:' + call smv%descr(info,iout_,coarse=coarse) + class is (amg_z_bwgs_solver_type) + write(iout_,*) ' Hybrid Backward Gauss-Seidel ' + class is (amg_z_gs_solver_type) + write(iout_,*) ' Hybrid Forward Gauss-Seidel ' + class default + write(iout_,*) ' Block Jacobi ' + write(iout_,*) ' Local solver details:' + call smv%descr(info,iout_,coarse=coarse) + end select + + else + write(iout_,*) ' Block Jacobi ' + end if + else + if (allocated(sm%sv)) then + call sm%sv%descr(info,iout_,coarse=coarse) + end if + end if + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return +end subroutine amg_z_jac_smoother_descr diff --git a/mlprec/impl/smoother/amg_z_jac_smoother_dmp.f90 b/mlprec/impl/smoother/amg_z_jac_smoother_dmp.f90 new file mode 100644 index 00000000..5d08757a --- /dev/null +++ b/mlprec/impl/smoother/amg_z_jac_smoother_dmp.f90 @@ -0,0 +1,97 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_jac_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) + + use psb_base_mod + use amg_z_jac_smoother, amg_protect_nam => amg_z_jac_smoother_dmp + implicit none + class(amg_z_jac_smoother_type), intent(in) :: sm + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: smoother, solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + integer(psb_lpk_), allocatable :: iv(:) + logical :: smoother_, global_num_ + ! len of prefix_ + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_smth_z" + end if + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(smoother)) then + smoother_ = smoother + else + smoother_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + if (smoother_) then + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_nd.mtx' + if (global_num_) then + iv = desc%get_global_indices(owned=.false.) + if (sm%nd%is_asb()) & + & call sm%nd%print(fname,head=head,iv=iv) + else + if (sm%nd%is_asb()) & + & call sm%nd%print(fname,head=head) + end if + end if + ! At base level do nothing for the smoother + if (allocated(sm%sv)) & + & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) + +end subroutine amg_z_jac_smoother_dmp diff --git a/mlprec/impl/smoother/amg_z_l1_jac_smoother_bld.f90 b/mlprec/impl/smoother/amg_z_l1_jac_smoother_bld.f90 new file mode 100644 index 00000000..18ad62fc --- /dev/null +++ b/mlprec/impl/smoother/amg_z_l1_jac_smoother_bld.f90 @@ -0,0 +1,176 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_l1_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) + + use psb_base_mod + use amg_z_diag_solver + use amg_z_jac_smoother, amg_protect_name => amg_z_l1_jac_smoother_bld + Implicit None + + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_l1_jac_smoother_type), intent(inout) :: sm + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota, nzeros + real(psb_dpk_), allocatable :: arwsum(:) + type(psb_zspmat_type) :: tmpa + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='z_l1_jac_smoother_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + n_col = desc_a%get_local_cols() + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + + if( sm%checkres ) sm%pa => a + + select type (smsv => sm%sv) + class is (amg_z_diag_solver_type) + call sm%nd%free() + sm%pa => a + sm%nd_nnz_tot = nztota + + call psb_sum(ictxt,sm%nd_nnz_tot) + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + + class default + if (smsv%is_global()) then + ! Do not put anything into SM%ND since the solver + ! is acting globally. + call sm%nd%free() + sm%nd_nnz_tot = 0 + call psb_sum(ictxt,sm%nd_nnz_tot) + call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) + else + + call a%csclip(tmpa,info,& + & jmax=nrow_a,rscale=.false.,cscale=.false.) + + call a%csclip(sm%nd,info,& + & jmin=nrow_a+1,rscale=.false.,cscale=.false.) + + arwsum = sm%nd%arwsum(info) + + call combine_dl1(-done,arwsum,sm%nd,info) + call combine_dl1(done,arwsum,tmpa,info) + + sm%nd_nnz_tot = sm%nd%get_nzeros() + call psb_sum(ictxt,sm%nd_nnz_tot) + + call sm%sv%build(tmpa,desc_a,info,amold=amold,vmold=vmold) + + if (info == psb_success_) then + if (present(amold)) then + call sm%nd%cscnv(info,& + & mold=amold,dupl=psb_dupl_add_) + else + call sm%nd%cscnv(info,& + & type='csr',dupl=psb_dupl_add_) + endif + end if + end if + end select + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='clip & psb_spcnv csr 4') + goto 9999 + end if + + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='solver build') + goto 9999 + end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +contains + + subroutine combine_dl1(alpha,dl1,mat,info) + implicit none + real(psb_dpk_), intent(in) :: alpha, dl1(:) + type(psb_zspmat_type), intent(inout) :: mat + integer(psb_ipk_), intent(out) :: info + ! + integer(psb_ipk_) :: k, nz, nrm, dp + type(psb_z_coo_sparse_mat) :: tcoo + + call mat%mv_to(tcoo) + nz = tcoo%get_nzeros() + nrm = min(size(dl1),tcoo%get_nrows(),tcoo%get_ncols()) +!!$ write(0,*) 'Check on combine_dl1: ',nrm, tcoo%get_nrows(),tcoo%get_ncols(), nz + call tcoo%ensure_size(nz+nrm) + call tcoo%set_dupl(psb_dupl_add_) + do k=1,nrm + if (dl1(k) /= dzero) then + nz = nz + 1 + tcoo%ia(nz) = k + tcoo%ja(nz) = k + tcoo%val(nz) = alpha*dl1(k) + end if + end do + call tcoo%set_nzeros(nz) + call tcoo%fix(info) + call mat%mv_from(tcoo) + end subroutine combine_dl1 + + +end subroutine amg_z_l1_jac_smoother_bld diff --git a/mlprec/impl/smoother/amg_z_l1_jac_smoother_clone.f90 b/mlprec/impl/smoother/amg_z_l1_jac_smoother_clone.f90 new file mode 100644 index 00000000..e42f6600 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_l1_jac_smoother_clone.f90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_l1_jac_smoother_clone(sm,smout,info) + + use psb_base_mod + use amg_z_jac_smoother, amg_protect_name => amg_z_l1_jac_smoother_clone + + Implicit None + + ! Arguments + class(amg_z_l1_jac_smoother_type), intent(inout) :: sm + class(amg_z_base_smoother_type), allocatable, intent(inout) :: smout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(smout)) then + call smout%free(info) + if (info == psb_success_) deallocate(smout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_z_l1_jac_smoother_type :: smout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(smo => smout) + type is (amg_z_l1_jac_smoother_type) + smo%nd_nnz_tot = sm%nd_nnz_tot + smo%checkres = sm%checkres + smo%printres = sm%printres + smo%checkiter = sm%checkiter + smo%printiter = sm%printiter + smo%tol = sm%tol + call sm%nd%clone(smo%nd,info) + if ((info==psb_success_).and.(allocated(sm%sv))) then + allocate(smout%sv,mold=sm%sv,stat=info) + if (info == psb_success_) call sm%sv%clone(smo%sv,info) + end if + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_l1_jac_smoother_clone diff --git a/mlprec/impl/smoother/amg_z_l1_jac_smoother_descr.f90 b/mlprec/impl/smoother/amg_z_l1_jac_smoother_descr.f90 new file mode 100644 index 00000000..f290e165 --- /dev/null +++ b/mlprec/impl/smoother/amg_z_l1_jac_smoother_descr.f90 @@ -0,0 +1,103 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_l1_jac_smoother_descr(sm,info,iout,coarse) + + use psb_base_mod + use amg_z_diag_solver + use amg_z_jac_smoother, amg_protect_name => amg_z_l1_jac_smoother_descr + use amg_z_diag_solver + use amg_z_gs_solver + + Implicit None + + ! Arguments + class(amg_z_l1_jac_smoother_type), intent(in) :: sm + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_z_l1_jac_smoother_descr' + integer(psb_ipk_) :: iout_ + logical :: coarse_ + + call psb_erractionsave(err_act) + info = psb_success_ + if (present(coarse)) then + coarse_ = coarse + else + coarse_ = .false. + end if + if (present(iout)) then + iout_ = iout + else + iout_ = psb_out_unit + endif + + if (.not.coarse_) then + if (allocated(sm%sv)) then + select type(smv=>sm%sv) + class is (amg_z_diag_solver_type) + write(iout_,*) ' Point Jacobi ' + write(iout_,*) ' Local diagonal:' + call smv%descr(info,iout_,coarse=coarse) + class is (amg_z_bwgs_solver_type) + write(iout_,*) ' L1-Hybrid Backward Gauss-Seidel ' + class is (amg_z_gs_solver_type) + write(iout_,*) ' L1-Hybrid Forward Gauss-Seidel ' + class default + write(iout_,*) ' L1-Block Jacobi ' + write(iout_,*) ' Local solver details:' + call smv%descr(info,iout_,coarse=coarse) + end select + + else + write(iout_,*) ' L1-Block Jacobi ' + end if + else + if (allocated(sm%sv)) then + call sm%sv%descr(info,iout_,coarse=coarse) + end if + end if + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return +end subroutine amg_z_l1_jac_smoother_descr diff --git a/mlprec/impl/smoother/mld_c_as_smoother_apply.f90 b/mlprec/impl/smoother/mld_c_as_smoother_apply.f90 deleted file mode 100644 index b2687cce..00000000 --- a/mlprec/impl/smoother/mld_c_as_smoother_apply.f90 +++ /dev/null @@ -1,235 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_as_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,info,init,initu) - use psb_base_mod - use mld_c_as_smoother, mld_protect_nam => mld_c_as_smoother_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_as_smoother_type), intent(inout) :: sm - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col, nrow_d, i - complex(psb_spk_), pointer :: aux(:) - complex(psb_spk_), allocatable :: tx(:),ty(:), ww(:) - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5) - character :: trans_, init_ - character(len=20) :: name='c_as_smoother_apply', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = desc_data%get_context() - call psb_info(ictxt,me,np) - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - n_row = sm%desc_data%get_local_rows() - n_col = sm%desc_data%get_local_cols() - nrow_d = desc_data%get_local_rows() - isz = max(n_row,N_COL) - - if ((4*isz) <= size(work)) then - aux => work(1:) - else - allocate(aux(4*isz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name,& - & i_err=(/4*isz,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - endif - - if ((.not.sm%sv%is_iterative()).and.(sweeps == 1).and.(sm%novr==0)) then - ! - ! Shortcut: in this case there is nothing else to be done. - ! - call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - else if (sweeps >= 0) then - ! - ! - ! Apply multiple sweeps of an AS solver - ! to compute an approximate solution of a linear system. - ! - ! - call psb_geasb(tx,sm%desc_data,info) - call psb_geasb(ty,sm%desc_data,info) - call psb_geasb(ww,sm%desc_data,info) - - ! - ! Unroll the first iteration and fold it inside SELECT CASE - ! this will save one SPMM when INIT=Z, and will be - ! significant when sweeps=1 (a common case) - ! - call psb_geaxpby(cone,x,czero,tx,desc_data,info) - if (info == 0) call sm%apply_restr(tx,trans_,aux,info) - if (info == 0) call psb_geaxpby(cone,tx,czero,ww,sm%desc_data,info) - - select case (init_) - case('Z') - call sm%sv%apply(cone,ww,czero,ty,sm%desc_data,trans_,aux,info,init='Z') - - case('Y') - call psb_geaxpby(cone,y,czero,ty,desc_data,info) - if (info == 0) call sm%apply_restr(ty,trans_,aux,info) - if (info == 0) call psb_spmm(-cone,sm%nd,ty,cone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - call sm%sv%apply(cone,ww,czero,ty,desc_data,trans_,aux,info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(cone,initu,czero,ty,desc_data,info) - if (info == 0) call sm%apply_restr(ty,trans_,aux,info) - if (info == 0) call psb_spmm(-cone,sm%nd,ty,cone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - call sm%sv%apply(cone,ww,czero,ty,desc_data,trans_,aux,info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - if (info == 0) call sm%apply_prol(ty,trans_,aux,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the - ! block diagonal part and the remaining part of the local matrix - ! and Y(j) is the approximate solution at sweep j. - ! - if (info == 0) call psb_geaxpby(cone,tx,czero,ww,sm%desc_data,info) - if (info == 0) call psb_spmm(-cone,sm%nd,ty,cone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(cone,ww,czero,ty,sm%desc_data,trans_,aux,info,init='Y') - - if (info /= psb_success_) exit - if (info == 0) call sm%apply_prol(ty,trans_,aux,info) - - end do - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - ! - ! Compute y = beta*y + alpha*ty (ty == K^(-1)*tx) - ! - call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - - else - - info = psb_err_iarg_neg_ - call psb_errpush(info,name,& - & i_err=(/itwo,sweeps,izero,izero,izero/)) - goto 9999 - - endif - - - if (.not.(4*isz <= size(work))) then - deallocate(aux,stat=info) - endif - if (info ==0) deallocate(ww,tx,ty,stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_as_smoother_apply diff --git a/mlprec/impl/smoother/mld_c_as_smoother_apply_vect.f90 b/mlprec/impl/smoother/mld_c_as_smoother_apply_vect.f90 deleted file mode 100644 index 55b0d94a..00000000 --- a/mlprec/impl/smoother/mld_c_as_smoother_apply_vect.f90 +++ /dev/null @@ -1,259 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_as_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,wv,info,init,initu) - use psb_base_mod - use mld_c_as_smoother, mld_protect_nam => mld_c_as_smoother_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_as_smoother_type), intent(inout) :: sm - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col, nrow_d, i - complex(psb_spk_), pointer :: aux(:) - type(psb_c_vect_type) :: tx, ty, ww - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5) - character :: trans_, init_ - logical :: do_realloc_wv - character(len=20) :: name='c_as_smoother_apply_v', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = desc_data%get_context() - call psb_info(ictxt,me,np) - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - n_row = sm%desc_data%get_local_rows() - n_col = sm%desc_data%get_local_cols() - nrow_d = desc_data%get_local_rows() - isz = max(n_row,N_COL) - - if (4*isz <= size(work)) then - aux => work(:) - else - allocate(aux(4*isz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name,& - & i_err=(/4*isz,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - endif - - if ((.not.sm%sv%is_iterative()).and.(sweeps == 1).and.(sm%novr==0)) then - ! - ! Shortcut: in this case there is nothing else to be done. - ! - call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,wv,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - else if (sweeps >= 0) then - ! - ! - ! Apply multiple sweeps of an AS solver - ! to compute an approximate solution of a linear system. - ! - ! - if (size(wv) < 3) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='invalid wv size in smoother_apply') - goto 9999 - end if - - ! - ! This is tricky. This smoother has a descriptor sm%desc_data - ! for an index space potentially different from - ! that of desc_data. Hence the size of the work vectors - ! could be wrong. We need to check and reallocate as needed. - ! - do_realloc_wv = (wv(1)%get_nrows() < sm%desc_data%get_local_cols()).or.& - & (wv(2)%get_nrows() < sm%desc_data%get_local_cols()).or.& - & (wv(3)%get_nrows() < sm%desc_data%get_local_cols()) - - if (do_realloc_wv) then - call psb_geasb(wv(1),sm%desc_data,info,scratch=.true.,mold=wv(2)%v) - call psb_geasb(wv(2),sm%desc_data,info,scratch=.true.,mold=wv(1)%v) - call psb_geasb(wv(3),sm%desc_data,info,scratch=.true.,mold=wv(1)%v) - end if - - associate(tx => wv(1), ty => wv(2), ww => wv(3)) - - ! Need to zero tx because of the apply_restr call. - call tx%zero() - ! - ! Unroll the first iteration and fold it inside SELECT CASE - ! this will save one SPMM when INIT=Z, and will be - ! significant when sweeps=1 (a common case) - ! - call psb_geaxpby(cone,x,czero,tx,desc_data,info) - if (info == 0) call sm%apply_restr(tx,trans_,aux,info) - if (info == 0) call psb_geaxpby(cone,tx,czero,ww,sm%desc_data,info) - - select case (init_) - case('Z') - call sm%sv%apply(cone,ww,czero,ty,sm%desc_data,trans_,aux,wv(4:),info,init='Z') - - case('Y') - call psb_geaxpby(cone,y,czero,ty,desc_data,info) - if (info == 0) call sm%apply_restr(ty,trans_,aux,info) - if (info == 0) call psb_spmm(-cone,sm%nd,ty,cone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - call sm%sv%apply(cone,ww,czero,ty,desc_data,trans_,aux,wv(4:),info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(cone,initu,czero,ty,desc_data,info) - if (info == 0) call sm%apply_restr(ty,trans_,aux,info) - if (info == 0) call psb_spmm(-cone,sm%nd,ty,cone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - call sm%sv%apply(cone,ww,czero,ty,desc_data,trans_,aux,wv(4:),info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - if (info == 0) call sm%apply_prol(ty,trans_,aux,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the - ! block diagonal part and the remaining part of the local matrix - ! and Y(j) is the approximate solution at sweep j. - ! - if (info == 0) call psb_geaxpby(cone,tx,czero,ww,sm%desc_data,info) - if (info == 0) call psb_spmm(-cone,sm%nd,ty,cone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(cone,ww,czero,ty,sm%desc_data,trans_,aux,wv(4:),info,init='Y') - - if (info /= psb_success_) exit - if (info == 0) call sm%apply_prol(ty,trans_,aux,info) - - end do - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - ! - ! Compute y = beta*y + alpha*ty (ty == K^(-1)*tx) - ! - call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - end associate - - else - - info = psb_err_iarg_neg_ - call psb_errpush(info,name,& - & i_err=(/itwo,sweeps,izero,izero,izero/)) - goto 9999 - - endif - - - if (.not.(4*isz <= size(work))) then - deallocate(aux,stat=info) - endif - - if (info /= 0) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_as_smoother_apply_vect diff --git a/mlprec/impl/smoother/mld_c_as_smoother_bld.f90 b/mlprec/impl/smoother/mld_c_as_smoother_bld.f90 deleted file mode 100644 index 19dff29d..00000000 --- a/mlprec/impl/smoother/mld_c_as_smoother_bld.f90 +++ /dev/null @@ -1,183 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_as_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_c_as_smoother, mld_protect_nam => mld_c_as_smoother_bld - Implicit None - - ! Arguments - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local variables - type(psb_cspmat_type) :: blck, atmp - integer(psb_ipk_) :: n_row,n_col, nrow_a, nhalo, novr, data_ - complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='c_as_smoother_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - novr = sm%novr - if (novr < 0) then - info=psb_err_invalid_ovr_num_ - call psb_errpush(info,name,& - & i_err=(/novr,izero,izero,izero,izero,izero/)) - goto 9999 - endif - - if ((novr == 0).or.(np == 1)) then - call psb_cdcpy(desc_a,sm%desc_data,info) - If(debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' done cdcpy' - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_cdcpy' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Early return: P>=3 N_OVR=0' - call blck%csall(izero,izero,info,ione) - else - - ! - ! Build the auxiliary descriptor desc_p%matrix_data(psb_n_row_). - ! This is done by psb_cdbldext (interface to psb_cdovr), which is - ! independent of CSR, and has been placed in the tools directory - ! of PSBLAS, instead of the mlprec directory of MLD2P4, because it - ! might be used independently of the AS preconditioner, to build - ! a descriptor for an extended stencil in a PDE solver. - ! - call psb_cdbldext(a,desc_a,novr,sm%desc_data,info,extype=psb_ovt_asov_) - if(debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' From cdbldext _:',sm%desc_data%get_local_rows(),& - & sm%desc_data%get_local_cols() - - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_cdbldext' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Before sphalo ' - - ! - ! Retrieve the remote sparse matrix rows required for the AS extended - ! matrix - data_ = psb_comm_ext_ - Call psb_sphalo(a,sm%desc_data,blck,info,data=data_,rowscale=.true.) - - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_sphalo' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if (debug_level >=psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'After psb_sphalo ',& - & blck%get_nrows(), blck%get_nzeros() - - End if - if (info == psb_success_) & - & call sm%sv%build(a,sm%desc_data,info,& - & blck,amold=amold,vmold=vmold) - - nrow_a = a%get_nrows() - n_row = sm%desc_data%get_local_rows() - n_col = sm%desc_data%get_local_cols() - - if (info == psb_success_) call a%csclip(sm%nd,info,& - & jmin=nrow_a+1,rscale=.false.,cscale=.false.) - if (info == psb_success_) call blck%csclip(atmp,info,& - & jmin=nrow_a+1,rscale=.false.,cscale=.false.) - if (info == psb_success_) call psb_rwextd(n_row,sm%nd,info,b=atmp) - - if (info == psb_success_) then - if (present(amold)) then - call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - else - call sm%nd%cscnv(info,& - & type='csr',dupl=psb_dupl_add_) - end if - end if - if (info == psb_success_) then - if (present(imold)) then - call sm%desc_data%cnv(imold) - end if - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='clip & psb_spcnv csr 4') - goto 9999 - end if - sm%nd_nnz_tot = sm%nd%get_nzeros() - call psb_sum(ictxt,sm%nd_nnz_tot) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_as_smoother_bld diff --git a/mlprec/impl/smoother/mld_c_as_smoother_check.f90 b/mlprec/impl/smoother/mld_c_as_smoother_check.f90 deleted file mode 100644 index 29172630..00000000 --- a/mlprec/impl/smoother/mld_c_as_smoother_check.f90 +++ /dev/null @@ -1,78 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_as_smoother_check(sm,info) - - use psb_base_mod - use mld_c_as_smoother, mld_protect_nam => mld_c_as_smoother_check - - Implicit None - - ! Arguments - class(mld_c_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - Integer(Psb_ipk_) :: err_act - character(len=20) :: name='c_as_smoother_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - call mld_check_def(sm%restr,& - & 'Restrictor',psb_halo_,is_legal_restrict) - call mld_check_def(sm%prol,& - & 'Prolongator',psb_none_,is_legal_prolong) - call mld_check_def(sm%novr,& - & 'Overlap layers ',izero,is_int_non_negative) - - - if (allocated(sm%sv)) then - call sm%sv%check(info) - else - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_as_smoother_check diff --git a/mlprec/impl/smoother/mld_c_as_smoother_clear_data.f90 b/mlprec/impl/smoother/mld_c_as_smoother_clear_data.f90 deleted file mode 100644 index ec8dfccc..00000000 --- a/mlprec/impl/smoother/mld_c_as_smoother_clear_data.f90 +++ /dev/null @@ -1,70 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_as_smoother_clear_data(sm,info) - - use psb_base_mod - use mld_c_as_smoother, mld_protect_name => mld_c_as_smoother_clear_data - Implicit None - ! Arguments - class(mld_c_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_as_smoother_clear_data' - - call psb_erractionsave(err_act) - - info = 0 - call sm%nd%free() - sm%nd_nnz_tot = 0 - call sm%desc_data%free(info) - if ((info==0).and.allocated(sm%sv)) then - call sm%sv%clear_data(info) - end if - if (info /= 0) then - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_as_smoother_clear_data diff --git a/mlprec/impl/smoother/mld_c_as_smoother_clone.f90 b/mlprec/impl/smoother/mld_c_as_smoother_clone.f90 deleted file mode 100644 index badcf5ca..00000000 --- a/mlprec/impl/smoother/mld_c_as_smoother_clone.f90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_as_smoother_clone(sm,smout,info) - - use psb_base_mod - use mld_c_as_smoother, mld_protect_name => mld_c_as_smoother_clone - - Implicit None - - ! Arguments - class(mld_c_as_smoother_type), intent(inout) :: sm - class(mld_c_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(smout)) then - call smout%free(info) - if (info == psb_success_) deallocate(smout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_c_as_smoother_type :: smout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(smo => smout) - type is (mld_c_as_smoother_type) - smo%novr = sm%novr - smo%restr = sm%restr - smo%prol = sm%prol - smo%nd_nnz_tot = sm%nd_nnz_tot - call sm%nd%clone(smo%nd,info) - if (info == psb_success_) & - & call sm%desc_data%clone(smo%desc_data,info) - if ((info==psb_success_).and.(allocated(sm%sv))) then - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == psb_success_) call sm%sv%clone(smo%sv,info) - end if - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_as_smoother_clone diff --git a/mlprec/impl/smoother/mld_c_as_smoother_clone_settings.f90 b/mlprec/impl/smoother/mld_c_as_smoother_clone_settings.f90 deleted file mode 100644 index 67b3ade9..00000000 --- a/mlprec/impl/smoother/mld_c_as_smoother_clone_settings.f90 +++ /dev/null @@ -1,95 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! asd on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_as_smoother_clone_settings(sm,smout,info) - - use psb_base_mod - use mld_c_as_smoother, mld_protect_name => mld_c_as_smoother_clone_settings - Implicit None - ! Arguments - class(mld_c_as_smoother_type), intent(inout) :: sm - class(mld_c_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_as_smoother_clone_settings' - - call psb_erractionsave(err_act) - - info = psb_success_ - - select type(smout) - class is(mld_c_as_smoother_type) - smout%novr = sm%novr - smout%restr = sm%restr - smout%prol = sm%prol - if (allocated(smout%sv)) then - if (.not.same_type_as(sm%sv,smout%sv)) then - call smout%sv%free(info) - if (info == 0) deallocate(smout%sv,stat=info) - end if - end if - if (info /= 0) then - info = psb_err_internal_error_ - else - if (allocated(smout%sv)) then - if (same_type_as(sm%sv,smout%sv)) then - call sm%sv%clone_settings(smout%sv,info) - else - info = psb_err_internal_error_ - end if - else - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == 0) call sm%sv%clone_settings(smout%sv,info) - if (info /= 0) info = psb_err_internal_error_ - end if - end if - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_as_smoother_clone_settings diff --git a/mlprec/impl/smoother/mld_c_as_smoother_cnv.f90 b/mlprec/impl/smoother/mld_c_as_smoother_cnv.f90 deleted file mode 100644 index 9dfc7af2..00000000 --- a/mlprec/impl/smoother/mld_c_as_smoother_cnv.f90 +++ /dev/null @@ -1,96 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_as_smoother_cnv(sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_c_as_smoother, mld_protect_nam => mld_c_as_smoother_cnv - Implicit None - - ! Arguments - class(mld_c_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local variables - type(psb_dspmat_type) :: blck, atmp - integer(psb_ipk_) :: n_row,n_col, nrow_a, nhalo, novr, data_, nzeros - real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_as_smoother_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = sm%desc_data%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - if (allocated(sm%sv)) & - & call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) - - if (info == psb_success_) then - if (present(amold)) then - if (sm%nd%is_asb()) call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - end if - end if - if (info == psb_success_) then - if (present(imold)) then - call sm%desc_data%cnv(imold) - end if - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='clip & psb_spcnv csr 4') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_as_smoother_cnv diff --git a/mlprec/impl/smoother/mld_c_as_smoother_csetc.f90 b/mlprec/impl/smoother/mld_c_as_smoother_csetc.f90 deleted file mode 100644 index 1d6c14c0..00000000 --- a/mlprec/impl/smoother/mld_c_as_smoother_csetc.f90 +++ /dev/null @@ -1,78 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_as_smoother_csetc(sm,what,val,info,idx) - - use psb_base_mod - use mld_c_as_smoother, mld_protect_nam => mld_c_as_smoother_csetc - Implicit None - ! Arguments - class(mld_c_as_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='c_as_smoother_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - - - ival = sm%stringval(val) - select case(psb_toupper(what)) - case('SUB_RESTR') - sm%restr = ival - case('SUB_PROL') - sm%prol = ival - case default - call sm%mld_c_base_smoother_type%set(what,val,info,idx=idx) - end select - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info, name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_as_smoother_csetc diff --git a/mlprec/impl/smoother/mld_c_as_smoother_cseti.f90 b/mlprec/impl/smoother/mld_c_as_smoother_cseti.f90 deleted file mode 100644 index 5a17adaf..00000000 --- a/mlprec/impl/smoother/mld_c_as_smoother_cseti.f90 +++ /dev/null @@ -1,73 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_as_smoother_cseti(sm,what,val,info,idx) - - use psb_base_mod - use mld_c_as_smoother, mld_protect_nam => mld_c_as_smoother_cseti - Implicit None - - ! Arguments - class(mld_c_as_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_as_smoother_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) - case('SUB_OVR') - sm%novr = val - case('SUB_RESTR') - sm%restr = val - case('SUB_PROL') - sm%prol = val - case default - call sm%mld_c_base_smoother_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_as_smoother_cseti diff --git a/mlprec/impl/smoother/mld_c_as_smoother_dmp.f90 b/mlprec/impl/smoother/mld_c_as_smoother_dmp.f90 deleted file mode 100644 index 4265d486..00000000 --- a/mlprec/impl/smoother/mld_c_as_smoother_dmp.f90 +++ /dev/null @@ -1,92 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_as_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - - use psb_base_mod - use mld_c_as_smoother, mld_protect_nam => mld_c_as_smoother_dmp - implicit none - class(mld_c_as_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: smoother_, global_num_ - ! len of prefix_ - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_smth_c" - end if - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(smoother)) then - smoother_ = smoother - else - smoother_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - if (global_num_) then - write(0,*) iam,' Warning: no global num with AS smoothers dump' - end if - if (smoother_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_nd.mtx' - if (sm%nd%is_asb()) & - & call sm%nd%print(fname,head=head) - end if - ! At base level do nothing for the smoother - if (allocated(sm%sv)) & - & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) - -end subroutine mld_c_as_smoother_dmp diff --git a/mlprec/impl/smoother/mld_c_as_smoother_free.f90 b/mlprec/impl/smoother/mld_c_as_smoother_free.f90 deleted file mode 100644 index 3f299a89..00000000 --- a/mlprec/impl/smoother/mld_c_as_smoother_free.f90 +++ /dev/null @@ -1,71 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_as_smoother_free(sm,info) - - use psb_base_mod - use mld_c_as_smoother, mld_protect_nam => mld_c_as_smoother_free - Implicit None - ! Arguments - class(mld_c_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_as_smoother_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - - - if (allocated(sm%sv)) then - call sm%sv%free(info) - if (info == psb_success_) deallocate(sm%sv,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - end if - call sm%nd%free() - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_as_smoother_free diff --git a/mlprec/impl/smoother/mld_c_as_smoother_prol_a.f90 b/mlprec/impl/smoother/mld_c_as_smoother_prol_a.f90 deleted file mode 100644 index b2b0e775..00000000 --- a/mlprec/impl/smoother/mld_c_as_smoother_prol_a.f90 +++ /dev/null @@ -1,149 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_as_smoother_prol_a(sm,x,trans,work,info,data) - use psb_base_mod - use mld_c_as_smoother, mld_protect_nam => mld_c_as_smoother_prol_a - implicit none - class(mld_c_as_smoother_type), intent(inout) :: sm - complex(psb_spk_), intent(inout) :: x(:) - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - !Local - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ - character :: trans_ - character(len=20) :: name='c_as_smther_prol_a', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = sm%desc_data%get_context() - call psb_info(ictxt,me,np) - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - info = psb_err_iarg_invalid_i_ - call psb_errpush(info,name) - goto 9999 - end select - - if (present(data)) then - data_ = data - else - data_ = psb_comm_ext_ - end if - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - - select case(trans_) - case('N') - - select case (sm%prol) - - case(psb_none_) - ! - ! Would work anyway, but since it is supposed to do nothing ... - ! call psb_ovrl(x,sm%desc_data,info,& - ! & update=sm%prol,work=work) - - - case(psb_sum_,psb_avg_) - ! - ! Update the overlap of x - ! - call psb_ovrl(x,sm%desc_data,info,& - & update=sm%prol,work=work) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_prol_') - goto 9999 - end select - - case('T','C') - ! - ! With transpose, we have to do it here - ! - if (sm%restr == psb_halo_) then - call psb_ovrl(x,sm%desc_data,info,& - & update=psb_sum_,work=work) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - else if (sm%restr /= psb_none_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_restr_') - goto 9999 - end if - - case default - info=psb_err_iarg_invalid_i_ - int_err(1)=6 - ch_err(2:2)=trans - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_as_smoother_prol_a - - diff --git a/mlprec/impl/smoother/mld_c_as_smoother_prol_v.f90 b/mlprec/impl/smoother/mld_c_as_smoother_prol_v.f90 deleted file mode 100644 index 218f519f..00000000 --- a/mlprec/impl/smoother/mld_c_as_smoother_prol_v.f90 +++ /dev/null @@ -1,149 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_as_smoother_prol_v(sm,x,trans,work,info,data) - use psb_base_mod - use mld_c_as_smoother, mld_protect_nam => mld_c_as_smoother_prol_v - implicit none - class(mld_c_as_smoother_type), intent(inout) :: sm - type(psb_c_vect_type),intent(inout) :: x - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - !Local - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ - character :: trans_ - character(len=20) :: name='c_as_smther_prol_v', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = sm%desc_data%get_context() - call psb_info(ictxt,me,np) - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - info = psb_err_iarg_invalid_i_ - call psb_errpush(info,name) - goto 9999 - end select - - if (present(data)) then - data_ = data - else - data_ = psb_comm_ext_ - end if - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - - select case(trans_) - case('N') - - select case (sm%prol) - - case(psb_none_) - ! - ! Would work anyway, but since it is supposed to do nothing ... - ! call psb_ovrl(x,sm%desc_data,info,& - ! & update=sm%prol,work=work) - - - case(psb_sum_,psb_avg_) - ! - ! Update the overlap of x - ! - call psb_ovrl(x,sm%desc_data,info,& - & update=sm%prol,work=work) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_prol_') - goto 9999 - end select - - case('T','C') - ! - ! With transpose, we have to do it here - ! - if (sm%restr == psb_halo_) then - call psb_ovrl(x,sm%desc_data,info,& - & update=psb_sum_,work=work) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - else if (sm%restr /= psb_none_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_restr_') - goto 9999 - end if - - case default - info=psb_err_iarg_invalid_i_ - int_err(1)=6 - ch_err(2:2)=trans - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_as_smoother_prol_v - - diff --git a/mlprec/impl/smoother/mld_c_as_smoother_restr_a.f90 b/mlprec/impl/smoother/mld_c_as_smoother_restr_a.f90 deleted file mode 100644 index bf404987..00000000 --- a/mlprec/impl/smoother/mld_c_as_smoother_restr_a.f90 +++ /dev/null @@ -1,168 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_as_smoother_restr_a(sm,x,trans,work,info,data) - use psb_base_mod - use mld_c_as_smoother, mld_protect_nam => mld_c_as_smoother_restr_a - implicit none - class(mld_c_as_smoother_type), intent(inout) :: sm - complex(psb_spk_), intent(inout) :: x(:) - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - !Local - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ - character :: trans_ - character(len=20) :: name='c_as_smther_restr_a', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = sm%desc_data%get_context() - call psb_info(ictxt,me,np) - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - info = psb_err_iarg_invalid_i_ - call psb_errpush(info,name) - goto 9999 - end select - - if (present(data)) then - data_ = data - else - data_ = psb_comm_ext_ - end if - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - select case(trans_) - case('N') - ! - ! Get the overlap entries x - ! - if (sm%restr == psb_halo_) then - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - else if (sm%restr /= psb_none_) then - call psb_errpush(psb_err_internal_error_,name,& - &a_err='Invalid mld_sub_restr_') - goto 9999 - end if - - - case('T','C') - ! - ! With transpose, we have to do it here - ! - - select case (sm%prol) - - case(psb_none_) - ! - ! Do nothing - - case(psb_sum_) - ! - ! The transpose of sum is halo - ! - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - - case(psb_avg_) - ! - ! Tricky one: first we have to scale the overlap entries, - ! which we can do by assignind mode=0, i.e. no communication - ! (hence only scaling), then we do the halo - ! - call psb_ovrl(x,sm%desc_data,info,& - & update=psb_avg_,work=work,mode=izero) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_prol_') - goto 9999 - end select - - - case default - info=psb_err_iarg_invalid_i_ - int_err(1)=6 - ch_err(2:2)=trans - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_as_smoother_restr_a - - diff --git a/mlprec/impl/smoother/mld_c_as_smoother_restr_v.f90 b/mlprec/impl/smoother/mld_c_as_smoother_restr_v.f90 deleted file mode 100644 index 111d4f89..00000000 --- a/mlprec/impl/smoother/mld_c_as_smoother_restr_v.f90 +++ /dev/null @@ -1,168 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_as_smoother_restr_v(sm,x,trans,work,info,data) - use psb_base_mod - use mld_c_as_smoother, mld_protect_nam => mld_c_as_smoother_restr_v - implicit none - class(mld_c_as_smoother_type), intent(inout) :: sm - type(psb_c_vect_type),intent(inout) :: x - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - !Local - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ - character :: trans_ - character(len=20) :: name='c_as_smther_restr_v', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = sm%desc_data%get_context() - call psb_info(ictxt,me,np) - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - info = psb_err_iarg_invalid_i_ - call psb_errpush(info,name) - goto 9999 - end select - - if (present(data)) then - data_ = data - else - data_ = psb_comm_ext_ - end if - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - select case(trans_) - case('N') - ! - ! Get the overlap entries x - ! - if (sm%restr == psb_halo_) then - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - else if (sm%restr /= psb_none_) then - call psb_errpush(psb_err_internal_error_,name,& - &a_err='Invalid mld_sub_restr_') - goto 9999 - end if - - - case('T','C') - ! - ! With transpose, we have to do it here - ! - - select case (sm%prol) - - case(psb_none_) - ! - ! Do nothing - - case(psb_sum_) - ! - ! The transpose of sum is halo - ! - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - - case(psb_avg_) - ! - ! Tricky one: first we have to scale the overlap entries, - ! which we can do by assignind mode=0, i.e. no communication - ! (hence only scaling), then we do the halo - ! - call psb_ovrl(x,sm%desc_data,info,& - & update=psb_avg_,work=work,mode=izero) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_prol_') - goto 9999 - end select - - - case default - info=psb_err_iarg_invalid_i_ - int_err(1)=6 - ch_err(2:2)=trans - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_as_smoother_restr_v - - diff --git a/mlprec/impl/smoother/mld_c_base_smoother_apply.f90 b/mlprec/impl/smoother/mld_c_base_smoother_apply.f90 deleted file mode 100644 index db1ea5f5..00000000 --- a/mlprec/impl/smoother/mld_c_base_smoother_apply.f90 +++ /dev/null @@ -1,87 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_smoother_apply(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,info,init,initu) - use psb_base_mod - use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_base_smoother_type), intent(inout) :: sm - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_smoother_apply' - - call psb_erractionsave(err_act) - info = psb_success_ - if (sweeps == 0) then - - ! - ! K^0 = I - ! zero sweeps of any smoother is just the identity. - ! - call psb_geaxpby(alpha,x,beta,y,desc_data,info) - - else - if (allocated(sm%sv)) then - call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,info,init=init, initu=initu) - else - info = 1121 - endif - end if - if (info /= psb_success_) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_base_smoother_apply diff --git a/mlprec/impl/smoother/mld_c_base_smoother_apply_vect.f90 b/mlprec/impl/smoother/mld_c_base_smoother_apply_vect.f90 deleted file mode 100644 index 1cf7ad7d..00000000 --- a/mlprec/impl/smoother/mld_c_base_smoother_apply_vect.f90 +++ /dev/null @@ -1,88 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,wv,info,init,initu) - use psb_base_mod - use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_base_smoother_type), intent(inout) :: sm - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - ! - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_smoother_apply' - - call psb_erractionsave(err_act) - info = psb_success_ - if (sweeps == 0) then - - ! - ! K^0 = I - ! zero sweeps of any smoother is just the identity. - ! - call psb_geaxpby(alpha,x,beta,y,desc_data,info) - - else - if (allocated(sm%sv)) then - call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,wv,info,init=init, initu=initu) - else - info = 1121 - endif - end if - if (info /= psb_success_) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_base_smoother_apply_vect diff --git a/mlprec/impl/smoother/mld_c_base_smoother_bld.f90 b/mlprec/impl/smoother/mld_c_base_smoother_bld.f90 deleted file mode 100644 index 29cf9613..00000000 --- a/mlprec/impl/smoother/mld_c_base_smoother_bld.f90 +++ /dev/null @@ -1,72 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_bld - Implicit None - - ! Arguments - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_smoother_bld' - - call psb_erractionsave(err_act) - - info = psb_success_ - if (allocated(sm%sv)) then - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - else - info = 1121 - call psb_errpush(info,name) - endif - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_smoother_bld diff --git a/mlprec/impl/smoother/mld_c_base_smoother_check.f90 b/mlprec/impl/smoother/mld_c_base_smoother_check.f90 deleted file mode 100644 index d88b17fe..00000000 --- a/mlprec/impl/smoother/mld_c_base_smoother_check.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_smoother_check(sm,info) - - use psb_base_mod - use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_check - Implicit None - - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - Integer(Psb_ipk_) :: err_act - character(len=20) :: name='c_base_smoother_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%check(info) - else - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_smoother_check diff --git a/mlprec/impl/smoother/mld_c_base_smoother_clear_data.f90 b/mlprec/impl/smoother/mld_c_base_smoother_clear_data.f90 deleted file mode 100644 index c9371e85..00000000 --- a/mlprec/impl/smoother/mld_c_base_smoother_clear_data.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_smoother_clear_data(sm,info) - - use psb_base_mod - use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_clear_data - Implicit None - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_smoother_clear_data' - - call psb_erractionsave(err_act) - - info = 0 - if (allocated(sm%sv)) then - call sm%sv%clear_data(info) - if (info /= 0) then - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_smoother_clear_data diff --git a/mlprec/impl/smoother/mld_c_base_smoother_clone.f90 b/mlprec/impl/smoother/mld_c_base_smoother_clone.f90 deleted file mode 100644 index 221778b8..00000000 --- a/mlprec/impl/smoother/mld_c_base_smoother_clone.f90 +++ /dev/null @@ -1,62 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_smoother_clone(sm,smout,info) - - use psb_base_mod - use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_clone - Implicit None - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - class(mld_c_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_smoother_clone' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_smoother_clone diff --git a/mlprec/impl/smoother/mld_c_base_smoother_clone_settings.f90 b/mlprec/impl/smoother/mld_c_base_smoother_clone_settings.f90 deleted file mode 100644 index 03ddfe85..00000000 --- a/mlprec/impl/smoother/mld_c_base_smoother_clone_settings.f90 +++ /dev/null @@ -1,89 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_smoother_clone_settings(sm,smout,info) - - use psb_base_mod - use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_clone_settings - Implicit None - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - class(mld_c_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_smoother_clone_settings' - - call psb_erractionsave(err_act) - - info=psb_success_ - if (same_type_as(sm,smout)) then - if (allocated(smout%sv)) then - if (.not.same_type_as(sm%sv,smout%sv)) then - call smout%sv%free(info) - if (info == 0) deallocate(smout%sv,stat=info) - end if - end if - if (info /= 0) then - info = psb_err_internal_error_ - else - if (allocated(smout%sv)) then - if (same_type_as(sm%sv,smout%sv)) then - call sm%sv%clone_settings(smout%sv,info) - else - info = psb_err_internal_error_ - end if - else - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == 0) call sm%sv%clone_settings(smout%sv,info) - if (info /= 0) info = psb_err_internal_error_ - end if - end if - else - info = psb_err_internal_error_ - end if - if (info /= 0) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_smoother_clone_settings diff --git a/mlprec/impl/smoother/mld_c_base_smoother_cnv.f90 b/mlprec/impl/smoother/mld_c_base_smoother_cnv.f90 deleted file mode 100644 index a1743e86..00000000 --- a/mlprec/impl/smoother/mld_c_base_smoother_cnv.f90 +++ /dev/null @@ -1,70 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_smoother_cnv(sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_cnv - Implicit None - - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_smoother_cnv' - - call psb_erractionsave(err_act) - - info = psb_success_ - if (allocated(sm%sv)) then - call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) - else - info = 1121 - call psb_errpush(info,name) - endif - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_smoother_cnv diff --git a/mlprec/impl/smoother/mld_c_base_smoother_csetc.f90 b/mlprec/impl/smoother/mld_c_base_smoother_csetc.f90 deleted file mode 100644 index 54bf1f8a..00000000 --- a/mlprec/impl/smoother/mld_c_base_smoother_csetc.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_smoother_csetc(sm,what,val,info,idx) - - use psb_base_mod - use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_csetc - Implicit None - - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='c_base_smoother_csetc' - - call psb_erractionsave(err_act) - - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%set(what,val,info,idx=idx) - end if - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_smoother_csetc diff --git a/mlprec/impl/smoother/mld_c_base_smoother_cseti.f90 b/mlprec/impl/smoother/mld_c_base_smoother_cseti.f90 deleted file mode 100644 index 41ac305d..00000000 --- a/mlprec/impl/smoother/mld_c_base_smoother_cseti.f90 +++ /dev/null @@ -1,65 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_smoother_cseti(sm,what,val,info,idx) - - use psb_base_mod - use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_cseti - Implicit None - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_smoother_cseti' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%set(what,val,info,idx=idx) - end if - if (info /= psb_success_) goto 9999 - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_smoother_cseti diff --git a/mlprec/impl/smoother/mld_c_base_smoother_csetr.f90 b/mlprec/impl/smoother/mld_c_base_smoother_csetr.f90 deleted file mode 100644 index 5cd3ad34..00000000 --- a/mlprec/impl/smoother/mld_c_base_smoother_csetr.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_smoother_csetr(sm,what,val,info,idx) - - use psb_base_mod - use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_csetr - Implicit None - - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_smoother_csetr' - - call psb_erractionsave(err_act) - - - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%set(what,val,info,idx=idx) - end if - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_smoother_csetr diff --git a/mlprec/impl/smoother/mld_c_base_smoother_descr.f90 b/mlprec/impl/smoother/mld_c_base_smoother_descr.f90 deleted file mode 100644 index d2710d1d..00000000 --- a/mlprec/impl/smoother/mld_c_base_smoother_descr.f90 +++ /dev/null @@ -1,101 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_smoother_descr(sm,info,iout,coarse) - - use psb_base_mod - use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_descr - use mld_c_id_solver - Implicit None - - ! Arguments - class(mld_c_base_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt, me, np - character(len=20), parameter :: name='mld_c_base_smoother_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse_ - - - call psb_erractionsave(err_act) - info = psb_success_ - - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - end if - - if (coarse_) then - if (allocated(sm%sv)) call sm%sv%descr(info,iout,coarse) - else - if (allocated(sm%sv)) then - select type (sv => sm%sv) - class is (mld_c_id_solver_type) - write(iout_,*) 'No preconditioner/smoother' - class default - write(iout_,*) 'Decoupled preconditioner/smoother with local solver' - call sm%sv%descr(info,iout,coarse) - end select - else - write(iout_,*) 'No preconditioner/smoother' - end if - end if - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='Local solver') - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_smoother_descr diff --git a/mlprec/impl/smoother/mld_c_base_smoother_dmp.f90 b/mlprec/impl/smoother/mld_c_base_smoother_dmp.f90 deleted file mode 100644 index ffb008bb..00000000 --- a/mlprec/impl/smoother/mld_c_base_smoother_dmp.f90 +++ /dev/null @@ -1,85 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - - use psb_base_mod - use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_dmp - implicit none - class(mld_c_base_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: smoother_, global_num_ - ! len of prefix_ - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_smth_c" - end if - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - if (present(smoother)) then - smoother_ = smoother - else - smoother_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - ! At base level do nothing for the smoother - if (allocated(sm%sv)) & - & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) - -end subroutine mld_c_base_smoother_dmp diff --git a/mlprec/impl/smoother/mld_c_base_smoother_free.f90 b/mlprec/impl/smoother/mld_c_base_smoother_free.f90 deleted file mode 100644 index 73e2a9fc..00000000 --- a/mlprec/impl/smoother/mld_c_base_smoother_free.f90 +++ /dev/null @@ -1,68 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_smoother_free(sm,info) - - use psb_base_mod - use mld_c_base_smoother_mod, mld_protect_name => mld_c_base_smoother_free - Implicit None - - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_smoother_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%free(info) - if (info == psb_success_) deallocate(sm%sv,stat=info) - end if - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_smoother_free diff --git a/mlprec/impl/smoother/mld_c_jac_smoother_apply.f90 b/mlprec/impl/smoother/mld_c_jac_smoother_apply.f90 deleted file mode 100644 index e76c6707..00000000 --- a/mlprec/impl/smoother/mld_c_jac_smoother_apply.f90 +++ /dev/null @@ -1,273 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_jac_smoother_apply(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,info,init,initu) - use psb_base_mod - use mld_c_jac_smoother, mld_protect_name => mld_c_jac_smoother_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_jac_smoother_type), intent(inout) :: sm - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col - complex(psb_spk_), allocatable :: tx(:),ty(:) - complex(psb_spk_), pointer :: aux(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='c_jac_smoother_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = desc_data%get_context() - call psb_info(ictxt,me,np) - - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (4*n_col <= size(work)) then - aux => work(:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - endif - - if ((.not.sm%sv%is_iterative()).and.((sweeps == 1).or.(sm%nd_nnz_tot==0))) then - ! if .not.sv%is_iterative, there's no need to pass init - call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - else if (sweeps >= 0) then - if (associated(sm%pa)) then - ! - ! This means we are dealing with a pure Jacobi smoother/solver. - ! - call psb_geasb(tx,desc_data,info) - call psb_geasb(ty,desc_data,info) - select case (init_) - case('Z') - - call sm%sv%apply(cone,x,czero,ty,desc_data,trans_,aux,info,init='Z') - - case('Y') - call psb_geaxpby(cone,x,czero,tx,desc_data,info) - call psb_geaxpby(cone,y,czero,ty,desc_data,info) - call psb_spmm(-cone,sm%pa,ty,cone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(cone,x,czero,tx,desc_data,info) - call psb_geaxpby(cone,initu,czero,ty,desc_data,info) - call psb_spmm(-cone,sm%pa,ty,cone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = Y(j)+ D^(-1)*(X-A*Y(j)), - ! where is the diagonal and A the matrix. - ! - call psb_geaxpby(cone,x,czero,tx,desc_data,info) - call psb_spmm(-cone,sm%pa,ty,cone,tx,desc_data,info,work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(cone,tx,cone,ty,desc_data,trans_,aux,info,init='Y') - - if (info /= psb_success_) exit - end do - - - if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - else - ! - ! - ! Apply multiple sweeps of a block-Jacobi solver - ! to compute an approximate solution of a linear system. - ! - ! - call psb_geasb(tx,desc_data,info) - call psb_geasb(ty,desc_data,info) - - ! - ! Unroll the first iteration and fold it inside SELECT CASE - ! this will save one AXPBY and one SPMM when INIT=Z, and will be - ! significant when sweeps=1 (a common case) - ! - select case (init_) - case('Z') - - call sm%sv%apply(cone,x,czero,ty,desc_data,trans_,aux,info,init='Z') - - case('Y') - call psb_geaxpby(cone,x,czero,tx,desc_data,info) - call psb_geaxpby(cone,y,czero,ty,desc_data,info) - call psb_spmm(-cone,sm%nd,ty,cone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(cone,x,czero,tx,desc_data,info) - call psb_geaxpby(cone,initu,czero,ty,desc_data,info) - call psb_spmm(-cone,sm%nd,ty,cone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the - ! block diagonal part and the remaining part of the local matrix - ! and Y(j) is the approximate solution at sweep j. - ! - call psb_geaxpby(cone,x,czero,tx,desc_data,info) - call psb_spmm(-cone,sm%nd,ty,cone,tx,desc_data,info,work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,info,init='Y') - - if (info /= psb_success_) exit - end do - - if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - end if - - deallocate(tx,ty,stat=info) - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='final cleanup with Jacobi sweeps > 1') - goto 9999 - end if - - else - - info = psb_err_iarg_neg_ - call psb_errpush(info,name,& - & i_err=(/itwo,sweeps,izero,izero,izero/)) - goto 9999 - - endif - - if (.not.(4*n_col <= size(work))) then - deallocate(aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_jac_smoother_apply diff --git a/mlprec/impl/smoother/mld_c_jac_smoother_apply_vect.f90 b/mlprec/impl/smoother/mld_c_jac_smoother_apply_vect.f90 deleted file mode 100644 index 2b55f98d..00000000 --- a/mlprec/impl/smoother/mld_c_jac_smoother_apply_vect.f90 +++ /dev/null @@ -1,320 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_jac_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,wv,info,init,initu) - - use psb_base_mod - use mld_c_diag_solver - use psb_base_krylov_conv_mod, only : log_conv - use mld_c_jac_smoother, mld_protect_name => mld_c_jac_smoother_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_jac_smoother_type), intent(inout) :: sm - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - ! - integer(psb_ipk_) :: n_row,n_col - type(psb_c_vect_type) :: tx, ty, r - complex(psb_spk_), pointer :: aux(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - real(psb_dpk_) :: res, resdenum - character(len=20) :: name='c_jac_smoother_apply_v' - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = desc_data%get_context() - call psb_info(ictxt,me,np) - - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (4*n_col <= size(work)) then - aux => work(:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - endif - - if(sm%checkres) then - call psb_geall(r,desc_data,info) - call psb_geasb(r,desc_data,info) - resdenum = psb_genrm2(x,desc_data,info) - end if - - if ((.not.sm%sv%is_iterative()).and.((sweeps == 1).or.(sm%nd_nnz_tot==0))) then - ! if .not.sv%is_iterative, there's no need to pass init - call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,wv,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - else if (sweeps >= 0) then - select type (smsv => sm%sv) - class is (mld_c_diag_solver_type) - ! - ! This means we are dealing with a pure Jacobi smoother/solver. - ! - associate(tx => wv(1), ty => wv(2)) - select case (init_) - case('Z') - - call sm%sv%apply(cone,x,czero,ty,desc_data,trans_,aux,wv(3:),info,init='Z') - - case('Y') - call psb_geaxpby(cone,x,czero,tx,desc_data,info) - call psb_geaxpby(cone,y,czero,ty,desc_data,info) - call psb_spmm(-cone,sm%pa,ty,cone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(cone,x,czero,tx,desc_data,info) - call psb_geaxpby(cone,initu,czero,ty,desc_data,info) - call psb_spmm(-cone,sm%pa,ty,cone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = Y(j)+ D^(-1)*(X-A*Y(j)), - ! where is the diagonal and A the matrix. - ! - call psb_geaxpby(cone,x,czero,tx,desc_data,info) - call psb_spmm(-cone,sm%pa,ty,cone,tx,desc_data,info,work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(cone,tx,cone,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - if (info /= psb_success_) exit - - if ( sm%checkres.and.(mod(i,sm%checkiter) == 0) ) then - call psb_geaxpby(cone,x,czero,r,r,desc_data,info) - call psb_spmm(-cone,sm%pa,ty,cone,r,desc_data,info) - res = psb_genrm2(r,desc_data,info) - if( sm%printres ) then - call log_conv("BJAC",me,i,sm%printiter,res,resdenum,sm%tol) - end if - if ( res < sm%tol*resdenum ) then - if( (sm%printres).and.(mod(sm%printiter,sm%checkiter)/=0) ) & - & call log_conv("BJAC",me,i,1,res,resdenum,sm%tol) - exit - end if - end if - - end do - - - if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - - end associate - - class default - ! - ! - ! Apply multiple sweeps of a block-Jacobi solver - ! to compute an approximate solution of a linear system. - ! - ! - if (size(wv) < 2) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size in smoother_apply') - goto 9999 - end if - associate(tx => wv(1), ty => wv(2)) - - ! - ! Unroll the first iteration and fold it inside SELECT CASE - ! this will save one AXPBY and one SPMM when INIT=Z, and will be - ! significant when sweeps=1 (a common case) - ! - select case (init_) - case('Z') - - call sm%sv%apply(cone,x,czero,ty,desc_data,trans_,aux,wv(3:),info,init='Z') - - case('Y') - call psb_geaxpby(cone,x,czero,tx,desc_data,info) - call psb_geaxpby(cone,y,czero,ty,desc_data,info) - call psb_spmm(-cone,sm%nd,ty,cone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(cone,x,czero,tx,desc_data,info) - call psb_geaxpby(cone,initu,czero,ty,desc_data,info) - call psb_spmm(-cone,sm%nd,ty,cone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the - ! block diagonal part and the remaining part of the local matrix - ! and Y(j) is the approximate solution at sweep j. - ! - call psb_geaxpby(cone,x,czero,tx,desc_data,info) - call psb_spmm(-cone,sm%nd,ty,cone,tx,desc_data,info,work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(cone,tx,czero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - if (info /= psb_success_) exit - - if ( sm%checkres.and.(mod(i,sm%checkiter) == 0) ) then - call psb_geaxpby(cone,x,czero,r,r,desc_data,info) - call psb_spmm(-cone,sm%pa,ty,cone,r,desc_data,info) - res = psb_genrm2(r,desc_data,info) - if( sm%printres ) then - call log_conv("BJAC",me,i,sm%printiter,res,resdenum,sm%tol) - end if - if (res < sm%tol*resdenum ) then - if( (sm%printres).and.( mod(sm%printiter,sm%checkiter) /=0 ) ) & - & call log_conv("BJAC",me,i,1,res,resdenum,sm%tol) - exit - end if - end if - - end do - - if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - end associate - end select - - else - - info = psb_err_iarg_neg_ - call psb_errpush(info,name,& - & i_err=(/itwo,sweeps,izero,izero,izero/)) - goto 9999 - - endif - - if (.not.(4*n_col <= size(work))) then - deallocate(aux) - endif - - if(sm%checkres) then - call psb_gefree(r,desc_data,info) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_jac_smoother_apply_vect diff --git a/mlprec/impl/smoother/mld_c_jac_smoother_bld.f90 b/mlprec/impl/smoother/mld_c_jac_smoother_bld.f90 deleted file mode 100644 index c443886a..00000000 --- a/mlprec/impl/smoother/mld_c_jac_smoother_bld.f90 +++ /dev/null @@ -1,127 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_c_diag_solver - use mld_c_jac_smoother, mld_protect_name => mld_c_jac_smoother_bld - Implicit None - - ! Arguments - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - type(psb_cspmat_type) :: tmpa - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota, nzeros - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='c_jac_smoother_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - n_col = desc_a%get_local_cols() - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - - if( sm%checkres ) sm%pa => a - - select type (smsv => sm%sv) - class is (mld_c_diag_solver_type) - call sm%nd%free() - sm%pa => a - sm%nd_nnz_tot = nztota - call psb_sum(ictxt,sm%nd_nnz_tot) - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - - class default - if (smsv%is_global()) then - ! Do not put anything into SM%ND since the solver - ! is acting globally. - call sm%nd%free() - sm%nd_nnz_tot = 0 - call psb_sum(ictxt,sm%nd_nnz_tot) - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - else - call a%csclip(sm%nd,info,& - & jmin=nrow_a+1,rscale=.false.,cscale=.false.) - if (info == psb_success_) then - if (present(amold)) then - call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - else - call sm%nd%cscnv(info,& - & type='csr',dupl=psb_dupl_add_) - endif - end if - sm%nd_nnz_tot = sm%nd%get_nzeros() - call psb_sum(ictxt,sm%nd_nnz_tot) - call a%csclip(tmpa,info,& - & jmax=nrow_a,rscale=.false.,cscale=.false.) - call sm%sv%build(tmpa,desc_a,info,amold=amold,vmold=vmold) - end if - end select - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='clip & psb_spcnv csr 4') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_jac_smoother_bld diff --git a/mlprec/impl/smoother/mld_c_jac_smoother_clear_data.f90 b/mlprec/impl/smoother/mld_c_jac_smoother_clear_data.f90 deleted file mode 100644 index 0dbf3d9e..00000000 --- a/mlprec/impl/smoother/mld_c_jac_smoother_clear_data.f90 +++ /dev/null @@ -1,70 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_jac_smoother_clear_data(sm,info) - - use psb_base_mod - use mld_c_jac_smoother, mld_protect_name => mld_c_jac_smoother_clear_data - Implicit None - ! Arguments - class(mld_c_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_jac_smoother_clear_data' - - call psb_erractionsave(err_act) - - info = 0 - call sm%nd%free() - sm%nd_nnz_tot = 0 - sm%pa => null() - if ((info==0).and.allocated(sm%sv)) then - call sm%sv%clear_data(info) - end if - if (info /= 0) then - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_jac_smoother_clear_data diff --git a/mlprec/impl/smoother/mld_c_jac_smoother_clone.f90 b/mlprec/impl/smoother/mld_c_jac_smoother_clone.f90 deleted file mode 100644 index f17f50a6..00000000 --- a/mlprec/impl/smoother/mld_c_jac_smoother_clone.f90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_jac_smoother_clone(sm,smout,info) - - use psb_base_mod - use mld_c_jac_smoother, mld_protect_name => mld_c_jac_smoother_clone - - Implicit None - - ! Arguments - class(mld_c_jac_smoother_type), intent(inout) :: sm - class(mld_c_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(smout)) then - call smout%free(info) - if (info == psb_success_) deallocate(smout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_c_jac_smoother_type :: smout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(smo => smout) - type is (mld_c_jac_smoother_type) - smo%nd_nnz_tot = sm%nd_nnz_tot - smo%checkres = sm%checkres - smo%printres = sm%printres - smo%checkiter = sm%checkiter - smo%printiter = sm%printiter - smo%tol = sm%tol - call sm%nd%clone(smo%nd,info) - if ((info==psb_success_).and.(allocated(sm%sv))) then - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == psb_success_) call sm%sv%clone(smo%sv,info) - end if - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_jac_smoother_clone diff --git a/mlprec/impl/smoother/mld_c_jac_smoother_clone_settings.f90 b/mlprec/impl/smoother/mld_c_jac_smoother_clone_settings.f90 deleted file mode 100644 index fb8c4567..00000000 --- a/mlprec/impl/smoother/mld_c_jac_smoother_clone_settings.f90 +++ /dev/null @@ -1,101 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! asd on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_jac_smoother_clone_settings(sm,smout,info) - - use psb_base_mod - use mld_c_jac_smoother, mld_protect_name => mld_c_jac_smoother_clone_settings - Implicit None - ! Arguments - class(mld_c_jac_smoother_type), intent(inout) :: sm - class(mld_c_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_jac_smoother_clone_settings' - - call psb_erractionsave(err_act) - - info = psb_success_ - - select type(smout) - class is(mld_c_jac_smoother_type) - - smout%pa => null() - smout%nd_nnz_tot = 0 - smout%checkres = sm%checkres - smout%printres = sm%printres - smout%checkiter = sm%checkiter - smout%printiter = sm%printiter - smout%tol = sm%tol - - if (allocated(smout%sv)) then - if (.not.same_type_as(sm%sv,smout%sv)) then - call smout%sv%free(info) - if (info == 0) deallocate(smout%sv,stat=info) - end if - end if - if (info /= 0) then - info = psb_err_internal_error_ - else - if (allocated(smout%sv)) then - if (same_type_as(sm%sv,smout%sv)) then - call sm%sv%clone_settings(smout%sv,info) - else - info = psb_err_internal_error_ - end if - else - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == 0) call sm%sv%clone_settings(smout%sv,info) - if (info /= 0) info = psb_err_internal_error_ - end if - end if - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_jac_smoother_clone_settings diff --git a/mlprec/impl/smoother/mld_c_jac_smoother_cnv.f90 b/mlprec/impl/smoother/mld_c_jac_smoother_cnv.f90 deleted file mode 100644 index 576c461e..00000000 --- a/mlprec/impl/smoother/mld_c_jac_smoother_cnv.f90 +++ /dev/null @@ -1,90 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_jac_smoother_cnv(sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_c_diag_solver - use mld_c_jac_smoother, mld_protect_name => mld_c_jac_smoother_cnv - Implicit None - - ! Arguments - class(mld_c_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_jac_smoother_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - - if (info == psb_success_) then - if (sm%nd%is_asb()) then - if (present(amold)) then - call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - else - call sm%nd%cscnv(info,& - & type='csr',dupl=psb_dupl_add_) - endif - end if - end if - - if (info == psb_success_) then - if (allocated(sm%sv)) & - & call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='solver cnv') - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_jac_smoother_cnv diff --git a/mlprec/impl/smoother/mld_c_jac_smoother_csetc.f90 b/mlprec/impl/smoother/mld_c_jac_smoother_csetc.f90 deleted file mode 100644 index b021e074..00000000 --- a/mlprec/impl/smoother/mld_c_jac_smoother_csetc.f90 +++ /dev/null @@ -1,90 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_jac_smoother_csetc(sm,what,val,info,idx) - - use psb_base_mod - use mld_c_jac_smoother, mld_protect_nam => mld_c_jac_smoother_csetc - Implicit None - ! Arguments - class(mld_c_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='c_jac_smoother_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(trim(what))) - case('SMOOTHER_STOP') - select case(psb_toupper(trim(val))) - case('T','TRUE') - sm%checkres = .true. - case('F','FALSE') - sm%checkres = .false. - case default - write(0,*) 'Unknown value for smoother_stop : "',psb_toupper(trim(val)),'"' - end select - case('SMOOTHER_TRACE') - select case(psb_toupper(trim(val))) - case('T','TRUE') - sm%printres = .true. - case('F','FALSE') - sm%printres = .false. - case default - write(0,*) 'Unknown value for smoother_trace : "',psb_toupper(trim(val)),'"' - end select - case default - call sm%mld_c_base_smoother_type%set(what,val,info,idx=idx) - end select - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info, name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_jac_smoother_csetc diff --git a/mlprec/impl/smoother/mld_c_jac_smoother_cseti.f90 b/mlprec/impl/smoother/mld_c_jac_smoother_cseti.f90 deleted file mode 100644 index 294abf53..00000000 --- a/mlprec/impl/smoother/mld_c_jac_smoother_cseti.f90 +++ /dev/null @@ -1,71 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_jac_smoother_cseti(sm,what,val,info,idx) - - use psb_base_mod - use mld_c_jac_smoother, mld_protect_nam => mld_c_jac_smoother_cseti - Implicit None - - ! Arguments - class(mld_c_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_jac_smoother_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) - case('SMOOTHER_RESIDUAL') - sm%checkiter = val - case('SMOOTHER_ITRACE') - sm%printiter = val - case default - call sm%mld_c_base_smoother_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_jac_smoother_cseti diff --git a/mlprec/impl/smoother/mld_c_jac_smoother_csetr.f90 b/mlprec/impl/smoother/mld_c_jac_smoother_csetr.f90 deleted file mode 100644 index 154b2b28..00000000 --- a/mlprec/impl/smoother/mld_c_jac_smoother_csetr.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_jac_smoother_csetr(sm,what,val,info,idx) - - use psb_base_mod - use mld_c_jac_smoother, mld_protect_nam => mld_c_jac_smoother_csetr - Implicit None - - ! Arguments - class(mld_c_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_jac_smoother_csetr' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) - case('SMOOTHER_STOPTOL') - sm%tol = val - case default - call sm%mld_c_base_smoother_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_jac_smoother_csetr diff --git a/mlprec/impl/smoother/mld_c_jac_smoother_descr.f90 b/mlprec/impl/smoother/mld_c_jac_smoother_descr.f90 deleted file mode 100644 index 1ef69c46..00000000 --- a/mlprec/impl/smoother/mld_c_jac_smoother_descr.f90 +++ /dev/null @@ -1,103 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_jac_smoother_descr(sm,info,iout,coarse) - - use psb_base_mod - use mld_c_diag_solver - use mld_c_jac_smoother, mld_protect_name => mld_c_jac_smoother_descr - use mld_c_diag_solver - use mld_c_gs_solver - - Implicit None - - ! Arguments - class(mld_c_jac_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_c_jac_smoother_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (.not.coarse_) then - if (allocated(sm%sv)) then - select type(smv=>sm%sv) - class is (mld_c_diag_solver_type) - write(iout_,*) ' Point Jacobi ' - write(iout_,*) ' Local diagonal:' - call smv%descr(info,iout_,coarse=coarse) - class is (mld_c_bwgs_solver_type) - write(iout_,*) ' Hybrid Backward Gauss-Seidel ' - class is (mld_c_gs_solver_type) - write(iout_,*) ' Hybrid Forward Gauss-Seidel ' - class default - write(iout_,*) ' Block Jacobi ' - write(iout_,*) ' Local solver details:' - call smv%descr(info,iout_,coarse=coarse) - end select - - else - write(iout_,*) ' Block Jacobi ' - end if - else - if (allocated(sm%sv)) then - call sm%sv%descr(info,iout_,coarse=coarse) - end if - end if - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return -end subroutine mld_c_jac_smoother_descr diff --git a/mlprec/impl/smoother/mld_c_jac_smoother_dmp.f90 b/mlprec/impl/smoother/mld_c_jac_smoother_dmp.f90 deleted file mode 100644 index 79540aee..00000000 --- a/mlprec/impl/smoother/mld_c_jac_smoother_dmp.f90 +++ /dev/null @@ -1,97 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_jac_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - - use psb_base_mod - use mld_c_jac_smoother, mld_protect_nam => mld_c_jac_smoother_dmp - implicit none - class(mld_c_jac_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - integer(psb_lpk_), allocatable :: iv(:) - logical :: smoother_, global_num_ - ! len of prefix_ - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_smth_c" - end if - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(smoother)) then - smoother_ = smoother - else - smoother_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - if (smoother_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_nd.mtx' - if (global_num_) then - iv = desc%get_global_indices(owned=.false.) - if (sm%nd%is_asb()) & - & call sm%nd%print(fname,head=head,iv=iv) - else - if (sm%nd%is_asb()) & - & call sm%nd%print(fname,head=head) - end if - end if - ! At base level do nothing for the smoother - if (allocated(sm%sv)) & - & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) - -end subroutine mld_c_jac_smoother_dmp diff --git a/mlprec/impl/smoother/mld_c_l1_jac_smoother_bld.f90 b/mlprec/impl/smoother/mld_c_l1_jac_smoother_bld.f90 deleted file mode 100644 index 2c27b0e7..00000000 --- a/mlprec/impl/smoother/mld_c_l1_jac_smoother_bld.f90 +++ /dev/null @@ -1,176 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_l1_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_c_diag_solver - use mld_c_jac_smoother, mld_protect_name => mld_c_l1_jac_smoother_bld - Implicit None - - ! Arguments - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_l1_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota, nzeros - real(psb_spk_), allocatable :: arwsum(:) - type(psb_cspmat_type) :: tmpa - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='c_l1_jac_smoother_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - n_col = desc_a%get_local_cols() - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - - if( sm%checkres ) sm%pa => a - - select type (smsv => sm%sv) - class is (mld_c_diag_solver_type) - call sm%nd%free() - sm%pa => a - sm%nd_nnz_tot = nztota - - call psb_sum(ictxt,sm%nd_nnz_tot) - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - - class default - if (smsv%is_global()) then - ! Do not put anything into SM%ND since the solver - ! is acting globally. - call sm%nd%free() - sm%nd_nnz_tot = 0 - call psb_sum(ictxt,sm%nd_nnz_tot) - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - else - - call a%csclip(tmpa,info,& - & jmax=nrow_a,rscale=.false.,cscale=.false.) - - call a%csclip(sm%nd,info,& - & jmin=nrow_a+1,rscale=.false.,cscale=.false.) - - arwsum = sm%nd%arwsum(info) - - call combine_dl1(-sone,arwsum,sm%nd,info) - call combine_dl1(sone,arwsum,tmpa,info) - - sm%nd_nnz_tot = sm%nd%get_nzeros() - call psb_sum(ictxt,sm%nd_nnz_tot) - - call sm%sv%build(tmpa,desc_a,info,amold=amold,vmold=vmold) - - if (info == psb_success_) then - if (present(amold)) then - call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - else - call sm%nd%cscnv(info,& - & type='csr',dupl=psb_dupl_add_) - endif - end if - end if - end select - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='clip & psb_spcnv csr 4') - goto 9999 - end if - - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='solver build') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - - subroutine combine_dl1(alpha,dl1,mat,info) - implicit none - real(psb_spk_), intent(in) :: alpha, dl1(:) - type(psb_cspmat_type), intent(inout) :: mat - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: k, nz, nrm, dp - type(psb_c_coo_sparse_mat) :: tcoo - - call mat%mv_to(tcoo) - nz = tcoo%get_nzeros() - nrm = min(size(dl1),tcoo%get_nrows(),tcoo%get_ncols()) -!!$ write(0,*) 'Check on combine_dl1: ',nrm, tcoo%get_nrows(),tcoo%get_ncols(), nz - call tcoo%ensure_size(nz+nrm) - call tcoo%set_dupl(psb_dupl_add_) - do k=1,nrm - if (dl1(k) /= szero) then - nz = nz + 1 - tcoo%ia(nz) = k - tcoo%ja(nz) = k - tcoo%val(nz) = alpha*dl1(k) - end if - end do - call tcoo%set_nzeros(nz) - call tcoo%fix(info) - call mat%mv_from(tcoo) - end subroutine combine_dl1 - - -end subroutine mld_c_l1_jac_smoother_bld diff --git a/mlprec/impl/smoother/mld_c_l1_jac_smoother_clone.f90 b/mlprec/impl/smoother/mld_c_l1_jac_smoother_clone.f90 deleted file mode 100644 index 3e6d38b0..00000000 --- a/mlprec/impl/smoother/mld_c_l1_jac_smoother_clone.f90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_l1_jac_smoother_clone(sm,smout,info) - - use psb_base_mod - use mld_c_jac_smoother, mld_protect_name => mld_c_l1_jac_smoother_clone - - Implicit None - - ! Arguments - class(mld_c_l1_jac_smoother_type), intent(inout) :: sm - class(mld_c_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(smout)) then - call smout%free(info) - if (info == psb_success_) deallocate(smout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_c_l1_jac_smoother_type :: smout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(smo => smout) - type is (mld_c_l1_jac_smoother_type) - smo%nd_nnz_tot = sm%nd_nnz_tot - smo%checkres = sm%checkres - smo%printres = sm%printres - smo%checkiter = sm%checkiter - smo%printiter = sm%printiter - smo%tol = sm%tol - call sm%nd%clone(smo%nd,info) - if ((info==psb_success_).and.(allocated(sm%sv))) then - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == psb_success_) call sm%sv%clone(smo%sv,info) - end if - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_l1_jac_smoother_clone diff --git a/mlprec/impl/smoother/mld_c_l1_jac_smoother_descr.f90 b/mlprec/impl/smoother/mld_c_l1_jac_smoother_descr.f90 deleted file mode 100644 index 82fd358a..00000000 --- a/mlprec/impl/smoother/mld_c_l1_jac_smoother_descr.f90 +++ /dev/null @@ -1,103 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_l1_jac_smoother_descr(sm,info,iout,coarse) - - use psb_base_mod - use mld_c_diag_solver - use mld_c_jac_smoother, mld_protect_name => mld_c_l1_jac_smoother_descr - use mld_c_diag_solver - use mld_c_gs_solver - - Implicit None - - ! Arguments - class(mld_c_l1_jac_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_c_l1_jac_smoother_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (.not.coarse_) then - if (allocated(sm%sv)) then - select type(smv=>sm%sv) - class is (mld_c_diag_solver_type) - write(iout_,*) ' Point Jacobi ' - write(iout_,*) ' Local diagonal:' - call smv%descr(info,iout_,coarse=coarse) - class is (mld_c_bwgs_solver_type) - write(iout_,*) ' L1-Hybrid Backward Gauss-Seidel ' - class is (mld_c_gs_solver_type) - write(iout_,*) ' L1-Hybrid Forward Gauss-Seidel ' - class default - write(iout_,*) ' L1-Block Jacobi ' - write(iout_,*) ' Local solver details:' - call smv%descr(info,iout_,coarse=coarse) - end select - - else - write(iout_,*) ' L1-Block Jacobi ' - end if - else - if (allocated(sm%sv)) then - call sm%sv%descr(info,iout_,coarse=coarse) - end if - end if - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return -end subroutine mld_c_l1_jac_smoother_descr diff --git a/mlprec/impl/smoother/mld_d_as_smoother_apply.f90 b/mlprec/impl/smoother/mld_d_as_smoother_apply.f90 deleted file mode 100644 index 4a8835d9..00000000 --- a/mlprec/impl/smoother/mld_d_as_smoother_apply.f90 +++ /dev/null @@ -1,235 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_as_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,info,init,initu) - use psb_base_mod - use mld_d_as_smoother, mld_protect_nam => mld_d_as_smoother_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_as_smoother_type), intent(inout) :: sm - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col, nrow_d, i - real(psb_dpk_), pointer :: aux(:) - real(psb_dpk_), allocatable :: tx(:),ty(:), ww(:) - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5) - character :: trans_, init_ - character(len=20) :: name='d_as_smoother_apply', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = desc_data%get_context() - call psb_info(ictxt,me,np) - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - n_row = sm%desc_data%get_local_rows() - n_col = sm%desc_data%get_local_cols() - nrow_d = desc_data%get_local_rows() - isz = max(n_row,N_COL) - - if ((4*isz) <= size(work)) then - aux => work(1:) - else - allocate(aux(4*isz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name,& - & i_err=(/4*isz,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - endif - - if ((.not.sm%sv%is_iterative()).and.(sweeps == 1).and.(sm%novr==0)) then - ! - ! Shortcut: in this case there is nothing else to be done. - ! - call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - else if (sweeps >= 0) then - ! - ! - ! Apply multiple sweeps of an AS solver - ! to compute an approximate solution of a linear system. - ! - ! - call psb_geasb(tx,sm%desc_data,info) - call psb_geasb(ty,sm%desc_data,info) - call psb_geasb(ww,sm%desc_data,info) - - ! - ! Unroll the first iteration and fold it inside SELECT CASE - ! this will save one SPMM when INIT=Z, and will be - ! significant when sweeps=1 (a common case) - ! - call psb_geaxpby(done,x,dzero,tx,desc_data,info) - if (info == 0) call sm%apply_restr(tx,trans_,aux,info) - if (info == 0) call psb_geaxpby(done,tx,dzero,ww,sm%desc_data,info) - - select case (init_) - case('Z') - call sm%sv%apply(done,ww,dzero,ty,sm%desc_data,trans_,aux,info,init='Z') - - case('Y') - call psb_geaxpby(done,y,dzero,ty,desc_data,info) - if (info == 0) call sm%apply_restr(ty,trans_,aux,info) - if (info == 0) call psb_spmm(-done,sm%nd,ty,done,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - call sm%sv%apply(done,ww,dzero,ty,desc_data,trans_,aux,info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(done,initu,dzero,ty,desc_data,info) - if (info == 0) call sm%apply_restr(ty,trans_,aux,info) - if (info == 0) call psb_spmm(-done,sm%nd,ty,done,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - call sm%sv%apply(done,ww,dzero,ty,desc_data,trans_,aux,info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - if (info == 0) call sm%apply_prol(ty,trans_,aux,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the - ! block diagonal part and the remaining part of the local matrix - ! and Y(j) is the approximate solution at sweep j. - ! - if (info == 0) call psb_geaxpby(done,tx,dzero,ww,sm%desc_data,info) - if (info == 0) call psb_spmm(-done,sm%nd,ty,done,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(done,ww,dzero,ty,sm%desc_data,trans_,aux,info,init='Y') - - if (info /= psb_success_) exit - if (info == 0) call sm%apply_prol(ty,trans_,aux,info) - - end do - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - ! - ! Compute y = beta*y + alpha*ty (ty == K^(-1)*tx) - ! - call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - - else - - info = psb_err_iarg_neg_ - call psb_errpush(info,name,& - & i_err=(/itwo,sweeps,izero,izero,izero/)) - goto 9999 - - endif - - - if (.not.(4*isz <= size(work))) then - deallocate(aux,stat=info) - endif - if (info ==0) deallocate(ww,tx,ty,stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_as_smoother_apply diff --git a/mlprec/impl/smoother/mld_d_as_smoother_apply_vect.f90 b/mlprec/impl/smoother/mld_d_as_smoother_apply_vect.f90 deleted file mode 100644 index 7ae8e8bf..00000000 --- a/mlprec/impl/smoother/mld_d_as_smoother_apply_vect.f90 +++ /dev/null @@ -1,259 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_as_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,wv,info,init,initu) - use psb_base_mod - use mld_d_as_smoother, mld_protect_nam => mld_d_as_smoother_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_as_smoother_type), intent(inout) :: sm - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col, nrow_d, i - real(psb_dpk_), pointer :: aux(:) - type(psb_d_vect_type) :: tx, ty, ww - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5) - character :: trans_, init_ - logical :: do_realloc_wv - character(len=20) :: name='d_as_smoother_apply_v', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = desc_data%get_context() - call psb_info(ictxt,me,np) - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - n_row = sm%desc_data%get_local_rows() - n_col = sm%desc_data%get_local_cols() - nrow_d = desc_data%get_local_rows() - isz = max(n_row,N_COL) - - if (4*isz <= size(work)) then - aux => work(:) - else - allocate(aux(4*isz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name,& - & i_err=(/4*isz,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - endif - - if ((.not.sm%sv%is_iterative()).and.(sweeps == 1).and.(sm%novr==0)) then - ! - ! Shortcut: in this case there is nothing else to be done. - ! - call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,wv,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - else if (sweeps >= 0) then - ! - ! - ! Apply multiple sweeps of an AS solver - ! to compute an approximate solution of a linear system. - ! - ! - if (size(wv) < 3) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='invalid wv size in smoother_apply') - goto 9999 - end if - - ! - ! This is tricky. This smoother has a descriptor sm%desc_data - ! for an index space potentially different from - ! that of desc_data. Hence the size of the work vectors - ! could be wrong. We need to check and reallocate as needed. - ! - do_realloc_wv = (wv(1)%get_nrows() < sm%desc_data%get_local_cols()).or.& - & (wv(2)%get_nrows() < sm%desc_data%get_local_cols()).or.& - & (wv(3)%get_nrows() < sm%desc_data%get_local_cols()) - - if (do_realloc_wv) then - call psb_geasb(wv(1),sm%desc_data,info,scratch=.true.,mold=wv(2)%v) - call psb_geasb(wv(2),sm%desc_data,info,scratch=.true.,mold=wv(1)%v) - call psb_geasb(wv(3),sm%desc_data,info,scratch=.true.,mold=wv(1)%v) - end if - - associate(tx => wv(1), ty => wv(2), ww => wv(3)) - - ! Need to zero tx because of the apply_restr call. - call tx%zero() - ! - ! Unroll the first iteration and fold it inside SELECT CASE - ! this will save one SPMM when INIT=Z, and will be - ! significant when sweeps=1 (a common case) - ! - call psb_geaxpby(done,x,dzero,tx,desc_data,info) - if (info == 0) call sm%apply_restr(tx,trans_,aux,info) - if (info == 0) call psb_geaxpby(done,tx,dzero,ww,sm%desc_data,info) - - select case (init_) - case('Z') - call sm%sv%apply(done,ww,dzero,ty,sm%desc_data,trans_,aux,wv(4:),info,init='Z') - - case('Y') - call psb_geaxpby(done,y,dzero,ty,desc_data,info) - if (info == 0) call sm%apply_restr(ty,trans_,aux,info) - if (info == 0) call psb_spmm(-done,sm%nd,ty,done,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - call sm%sv%apply(done,ww,dzero,ty,desc_data,trans_,aux,wv(4:),info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(done,initu,dzero,ty,desc_data,info) - if (info == 0) call sm%apply_restr(ty,trans_,aux,info) - if (info == 0) call psb_spmm(-done,sm%nd,ty,done,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - call sm%sv%apply(done,ww,dzero,ty,desc_data,trans_,aux,wv(4:),info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - if (info == 0) call sm%apply_prol(ty,trans_,aux,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the - ! block diagonal part and the remaining part of the local matrix - ! and Y(j) is the approximate solution at sweep j. - ! - if (info == 0) call psb_geaxpby(done,tx,dzero,ww,sm%desc_data,info) - if (info == 0) call psb_spmm(-done,sm%nd,ty,done,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(done,ww,dzero,ty,sm%desc_data,trans_,aux,wv(4:),info,init='Y') - - if (info /= psb_success_) exit - if (info == 0) call sm%apply_prol(ty,trans_,aux,info) - - end do - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - ! - ! Compute y = beta*y + alpha*ty (ty == K^(-1)*tx) - ! - call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - end associate - - else - - info = psb_err_iarg_neg_ - call psb_errpush(info,name,& - & i_err=(/itwo,sweeps,izero,izero,izero/)) - goto 9999 - - endif - - - if (.not.(4*isz <= size(work))) then - deallocate(aux,stat=info) - endif - - if (info /= 0) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_as_smoother_apply_vect diff --git a/mlprec/impl/smoother/mld_d_as_smoother_bld.f90 b/mlprec/impl/smoother/mld_d_as_smoother_bld.f90 deleted file mode 100644 index 6cc55934..00000000 --- a/mlprec/impl/smoother/mld_d_as_smoother_bld.f90 +++ /dev/null @@ -1,183 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_as_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_d_as_smoother, mld_protect_nam => mld_d_as_smoother_bld - Implicit None - - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local variables - type(psb_dspmat_type) :: blck, atmp - integer(psb_ipk_) :: n_row,n_col, nrow_a, nhalo, novr, data_ - real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_as_smoother_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - novr = sm%novr - if (novr < 0) then - info=psb_err_invalid_ovr_num_ - call psb_errpush(info,name,& - & i_err=(/novr,izero,izero,izero,izero,izero/)) - goto 9999 - endif - - if ((novr == 0).or.(np == 1)) then - call psb_cdcpy(desc_a,sm%desc_data,info) - If(debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' done cdcpy' - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_cdcpy' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Early return: P>=3 N_OVR=0' - call blck%csall(izero,izero,info,ione) - else - - ! - ! Build the auxiliary descriptor desc_p%matrix_data(psb_n_row_). - ! This is done by psb_cdbldext (interface to psb_cdovr), which is - ! independent of CSR, and has been placed in the tools directory - ! of PSBLAS, instead of the mlprec directory of MLD2P4, because it - ! might be used independently of the AS preconditioner, to build - ! a descriptor for an extended stencil in a PDE solver. - ! - call psb_cdbldext(a,desc_a,novr,sm%desc_data,info,extype=psb_ovt_asov_) - if(debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' From cdbldext _:',sm%desc_data%get_local_rows(),& - & sm%desc_data%get_local_cols() - - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_cdbldext' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Before sphalo ' - - ! - ! Retrieve the remote sparse matrix rows required for the AS extended - ! matrix - data_ = psb_comm_ext_ - Call psb_sphalo(a,sm%desc_data,blck,info,data=data_,rowscale=.true.) - - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_sphalo' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if (debug_level >=psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'After psb_sphalo ',& - & blck%get_nrows(), blck%get_nzeros() - - End if - if (info == psb_success_) & - & call sm%sv%build(a,sm%desc_data,info,& - & blck,amold=amold,vmold=vmold) - - nrow_a = a%get_nrows() - n_row = sm%desc_data%get_local_rows() - n_col = sm%desc_data%get_local_cols() - - if (info == psb_success_) call a%csclip(sm%nd,info,& - & jmin=nrow_a+1,rscale=.false.,cscale=.false.) - if (info == psb_success_) call blck%csclip(atmp,info,& - & jmin=nrow_a+1,rscale=.false.,cscale=.false.) - if (info == psb_success_) call psb_rwextd(n_row,sm%nd,info,b=atmp) - - if (info == psb_success_) then - if (present(amold)) then - call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - else - call sm%nd%cscnv(info,& - & type='csr',dupl=psb_dupl_add_) - end if - end if - if (info == psb_success_) then - if (present(imold)) then - call sm%desc_data%cnv(imold) - end if - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='clip & psb_spcnv csr 4') - goto 9999 - end if - sm%nd_nnz_tot = sm%nd%get_nzeros() - call psb_sum(ictxt,sm%nd_nnz_tot) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_as_smoother_bld diff --git a/mlprec/impl/smoother/mld_d_as_smoother_check.f90 b/mlprec/impl/smoother/mld_d_as_smoother_check.f90 deleted file mode 100644 index ef4be4e7..00000000 --- a/mlprec/impl/smoother/mld_d_as_smoother_check.f90 +++ /dev/null @@ -1,78 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_as_smoother_check(sm,info) - - use psb_base_mod - use mld_d_as_smoother, mld_protect_nam => mld_d_as_smoother_check - - Implicit None - - ! Arguments - class(mld_d_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - Integer(Psb_ipk_) :: err_act - character(len=20) :: name='d_as_smoother_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - call mld_check_def(sm%restr,& - & 'Restrictor',psb_halo_,is_legal_restrict) - call mld_check_def(sm%prol,& - & 'Prolongator',psb_none_,is_legal_prolong) - call mld_check_def(sm%novr,& - & 'Overlap layers ',izero,is_int_non_negative) - - - if (allocated(sm%sv)) then - call sm%sv%check(info) - else - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_as_smoother_check diff --git a/mlprec/impl/smoother/mld_d_as_smoother_clear_data.f90 b/mlprec/impl/smoother/mld_d_as_smoother_clear_data.f90 deleted file mode 100644 index 898e6f8f..00000000 --- a/mlprec/impl/smoother/mld_d_as_smoother_clear_data.f90 +++ /dev/null @@ -1,70 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_as_smoother_clear_data(sm,info) - - use psb_base_mod - use mld_d_as_smoother, mld_protect_name => mld_d_as_smoother_clear_data - Implicit None - ! Arguments - class(mld_d_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_as_smoother_clear_data' - - call psb_erractionsave(err_act) - - info = 0 - call sm%nd%free() - sm%nd_nnz_tot = 0 - call sm%desc_data%free(info) - if ((info==0).and.allocated(sm%sv)) then - call sm%sv%clear_data(info) - end if - if (info /= 0) then - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_as_smoother_clear_data diff --git a/mlprec/impl/smoother/mld_d_as_smoother_clone.f90 b/mlprec/impl/smoother/mld_d_as_smoother_clone.f90 deleted file mode 100644 index e84e670c..00000000 --- a/mlprec/impl/smoother/mld_d_as_smoother_clone.f90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_as_smoother_clone(sm,smout,info) - - use psb_base_mod - use mld_d_as_smoother, mld_protect_name => mld_d_as_smoother_clone - - Implicit None - - ! Arguments - class(mld_d_as_smoother_type), intent(inout) :: sm - class(mld_d_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(smout)) then - call smout%free(info) - if (info == psb_success_) deallocate(smout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_d_as_smoother_type :: smout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(smo => smout) - type is (mld_d_as_smoother_type) - smo%novr = sm%novr - smo%restr = sm%restr - smo%prol = sm%prol - smo%nd_nnz_tot = sm%nd_nnz_tot - call sm%nd%clone(smo%nd,info) - if (info == psb_success_) & - & call sm%desc_data%clone(smo%desc_data,info) - if ((info==psb_success_).and.(allocated(sm%sv))) then - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == psb_success_) call sm%sv%clone(smo%sv,info) - end if - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_as_smoother_clone diff --git a/mlprec/impl/smoother/mld_d_as_smoother_clone_settings.f90 b/mlprec/impl/smoother/mld_d_as_smoother_clone_settings.f90 deleted file mode 100644 index 1f713a38..00000000 --- a/mlprec/impl/smoother/mld_d_as_smoother_clone_settings.f90 +++ /dev/null @@ -1,95 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! asd on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_as_smoother_clone_settings(sm,smout,info) - - use psb_base_mod - use mld_d_as_smoother, mld_protect_name => mld_d_as_smoother_clone_settings - Implicit None - ! Arguments - class(mld_d_as_smoother_type), intent(inout) :: sm - class(mld_d_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_as_smoother_clone_settings' - - call psb_erractionsave(err_act) - - info = psb_success_ - - select type(smout) - class is(mld_d_as_smoother_type) - smout%novr = sm%novr - smout%restr = sm%restr - smout%prol = sm%prol - if (allocated(smout%sv)) then - if (.not.same_type_as(sm%sv,smout%sv)) then - call smout%sv%free(info) - if (info == 0) deallocate(smout%sv,stat=info) - end if - end if - if (info /= 0) then - info = psb_err_internal_error_ - else - if (allocated(smout%sv)) then - if (same_type_as(sm%sv,smout%sv)) then - call sm%sv%clone_settings(smout%sv,info) - else - info = psb_err_internal_error_ - end if - else - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == 0) call sm%sv%clone_settings(smout%sv,info) - if (info /= 0) info = psb_err_internal_error_ - end if - end if - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_as_smoother_clone_settings diff --git a/mlprec/impl/smoother/mld_d_as_smoother_cnv.f90 b/mlprec/impl/smoother/mld_d_as_smoother_cnv.f90 deleted file mode 100644 index d1c5f5df..00000000 --- a/mlprec/impl/smoother/mld_d_as_smoother_cnv.f90 +++ /dev/null @@ -1,96 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_as_smoother_cnv(sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_d_as_smoother, mld_protect_nam => mld_d_as_smoother_cnv - Implicit None - - ! Arguments - class(mld_d_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local variables - type(psb_dspmat_type) :: blck, atmp - integer(psb_ipk_) :: n_row,n_col, nrow_a, nhalo, novr, data_, nzeros - real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_as_smoother_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = sm%desc_data%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - if (allocated(sm%sv)) & - & call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) - - if (info == psb_success_) then - if (present(amold)) then - if (sm%nd%is_asb()) call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - end if - end if - if (info == psb_success_) then - if (present(imold)) then - call sm%desc_data%cnv(imold) - end if - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='clip & psb_spcnv csr 4') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_as_smoother_cnv diff --git a/mlprec/impl/smoother/mld_d_as_smoother_csetc.f90 b/mlprec/impl/smoother/mld_d_as_smoother_csetc.f90 deleted file mode 100644 index 331ccf85..00000000 --- a/mlprec/impl/smoother/mld_d_as_smoother_csetc.f90 +++ /dev/null @@ -1,78 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_as_smoother_csetc(sm,what,val,info,idx) - - use psb_base_mod - use mld_d_as_smoother, mld_protect_nam => mld_d_as_smoother_csetc - Implicit None - ! Arguments - class(mld_d_as_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='d_as_smoother_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - - - ival = sm%stringval(val) - select case(psb_toupper(what)) - case('SUB_RESTR') - sm%restr = ival - case('SUB_PROL') - sm%prol = ival - case default - call sm%mld_d_base_smoother_type%set(what,val,info,idx=idx) - end select - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info, name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_as_smoother_csetc diff --git a/mlprec/impl/smoother/mld_d_as_smoother_cseti.f90 b/mlprec/impl/smoother/mld_d_as_smoother_cseti.f90 deleted file mode 100644 index 0e51c2c7..00000000 --- a/mlprec/impl/smoother/mld_d_as_smoother_cseti.f90 +++ /dev/null @@ -1,73 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_as_smoother_cseti(sm,what,val,info,idx) - - use psb_base_mod - use mld_d_as_smoother, mld_protect_nam => mld_d_as_smoother_cseti - Implicit None - - ! Arguments - class(mld_d_as_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_as_smoother_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) - case('SUB_OVR') - sm%novr = val - case('SUB_RESTR') - sm%restr = val - case('SUB_PROL') - sm%prol = val - case default - call sm%mld_d_base_smoother_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_as_smoother_cseti diff --git a/mlprec/impl/smoother/mld_d_as_smoother_dmp.f90 b/mlprec/impl/smoother/mld_d_as_smoother_dmp.f90 deleted file mode 100644 index 566fde76..00000000 --- a/mlprec/impl/smoother/mld_d_as_smoother_dmp.f90 +++ /dev/null @@ -1,92 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_as_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - - use psb_base_mod - use mld_d_as_smoother, mld_protect_nam => mld_d_as_smoother_dmp - implicit none - class(mld_d_as_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: smoother_, global_num_ - ! len of prefix_ - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_smth_d" - end if - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(smoother)) then - smoother_ = smoother - else - smoother_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - if (global_num_) then - write(0,*) iam,' Warning: no global num with AS smoothers dump' - end if - if (smoother_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_nd.mtx' - if (sm%nd%is_asb()) & - & call sm%nd%print(fname,head=head) - end if - ! At base level do nothing for the smoother - if (allocated(sm%sv)) & - & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) - -end subroutine mld_d_as_smoother_dmp diff --git a/mlprec/impl/smoother/mld_d_as_smoother_free.f90 b/mlprec/impl/smoother/mld_d_as_smoother_free.f90 deleted file mode 100644 index 2b446d9d..00000000 --- a/mlprec/impl/smoother/mld_d_as_smoother_free.f90 +++ /dev/null @@ -1,71 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_as_smoother_free(sm,info) - - use psb_base_mod - use mld_d_as_smoother, mld_protect_nam => mld_d_as_smoother_free - Implicit None - ! Arguments - class(mld_d_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_as_smoother_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - - - if (allocated(sm%sv)) then - call sm%sv%free(info) - if (info == psb_success_) deallocate(sm%sv,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - end if - call sm%nd%free() - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_as_smoother_free diff --git a/mlprec/impl/smoother/mld_d_as_smoother_prol_a.f90 b/mlprec/impl/smoother/mld_d_as_smoother_prol_a.f90 deleted file mode 100644 index 97b1025e..00000000 --- a/mlprec/impl/smoother/mld_d_as_smoother_prol_a.f90 +++ /dev/null @@ -1,149 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_as_smoother_prol_a(sm,x,trans,work,info,data) - use psb_base_mod - use mld_d_as_smoother, mld_protect_nam => mld_d_as_smoother_prol_a - implicit none - class(mld_d_as_smoother_type), intent(inout) :: sm - real(psb_dpk_), intent(inout) :: x(:) - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - !Local - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ - character :: trans_ - character(len=20) :: name='d_as_smther_prol_a', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = sm%desc_data%get_context() - call psb_info(ictxt,me,np) - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - info = psb_err_iarg_invalid_i_ - call psb_errpush(info,name) - goto 9999 - end select - - if (present(data)) then - data_ = data - else - data_ = psb_comm_ext_ - end if - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - - select case(trans_) - case('N') - - select case (sm%prol) - - case(psb_none_) - ! - ! Would work anyway, but since it is supposed to do nothing ... - ! call psb_ovrl(x,sm%desc_data,info,& - ! & update=sm%prol,work=work) - - - case(psb_sum_,psb_avg_) - ! - ! Update the overlap of x - ! - call psb_ovrl(x,sm%desc_data,info,& - & update=sm%prol,work=work) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_prol_') - goto 9999 - end select - - case('T','C') - ! - ! With transpose, we have to do it here - ! - if (sm%restr == psb_halo_) then - call psb_ovrl(x,sm%desc_data,info,& - & update=psb_sum_,work=work) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - else if (sm%restr /= psb_none_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_restr_') - goto 9999 - end if - - case default - info=psb_err_iarg_invalid_i_ - int_err(1)=6 - ch_err(2:2)=trans - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_as_smoother_prol_a - - diff --git a/mlprec/impl/smoother/mld_d_as_smoother_prol_v.f90 b/mlprec/impl/smoother/mld_d_as_smoother_prol_v.f90 deleted file mode 100644 index d616a16f..00000000 --- a/mlprec/impl/smoother/mld_d_as_smoother_prol_v.f90 +++ /dev/null @@ -1,149 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_as_smoother_prol_v(sm,x,trans,work,info,data) - use psb_base_mod - use mld_d_as_smoother, mld_protect_nam => mld_d_as_smoother_prol_v - implicit none - class(mld_d_as_smoother_type), intent(inout) :: sm - type(psb_d_vect_type),intent(inout) :: x - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - !Local - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ - character :: trans_ - character(len=20) :: name='d_as_smther_prol_v', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = sm%desc_data%get_context() - call psb_info(ictxt,me,np) - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - info = psb_err_iarg_invalid_i_ - call psb_errpush(info,name) - goto 9999 - end select - - if (present(data)) then - data_ = data - else - data_ = psb_comm_ext_ - end if - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - - select case(trans_) - case('N') - - select case (sm%prol) - - case(psb_none_) - ! - ! Would work anyway, but since it is supposed to do nothing ... - ! call psb_ovrl(x,sm%desc_data,info,& - ! & update=sm%prol,work=work) - - - case(psb_sum_,psb_avg_) - ! - ! Update the overlap of x - ! - call psb_ovrl(x,sm%desc_data,info,& - & update=sm%prol,work=work) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_prol_') - goto 9999 - end select - - case('T','C') - ! - ! With transpose, we have to do it here - ! - if (sm%restr == psb_halo_) then - call psb_ovrl(x,sm%desc_data,info,& - & update=psb_sum_,work=work) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - else if (sm%restr /= psb_none_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_restr_') - goto 9999 - end if - - case default - info=psb_err_iarg_invalid_i_ - int_err(1)=6 - ch_err(2:2)=trans - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_as_smoother_prol_v - - diff --git a/mlprec/impl/smoother/mld_d_as_smoother_restr_a.f90 b/mlprec/impl/smoother/mld_d_as_smoother_restr_a.f90 deleted file mode 100644 index f469ae6e..00000000 --- a/mlprec/impl/smoother/mld_d_as_smoother_restr_a.f90 +++ /dev/null @@ -1,168 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_as_smoother_restr_a(sm,x,trans,work,info,data) - use psb_base_mod - use mld_d_as_smoother, mld_protect_nam => mld_d_as_smoother_restr_a - implicit none - class(mld_d_as_smoother_type), intent(inout) :: sm - real(psb_dpk_), intent(inout) :: x(:) - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - !Local - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ - character :: trans_ - character(len=20) :: name='d_as_smther_restr_a', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = sm%desc_data%get_context() - call psb_info(ictxt,me,np) - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - info = psb_err_iarg_invalid_i_ - call psb_errpush(info,name) - goto 9999 - end select - - if (present(data)) then - data_ = data - else - data_ = psb_comm_ext_ - end if - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - select case(trans_) - case('N') - ! - ! Get the overlap entries x - ! - if (sm%restr == psb_halo_) then - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - else if (sm%restr /= psb_none_) then - call psb_errpush(psb_err_internal_error_,name,& - &a_err='Invalid mld_sub_restr_') - goto 9999 - end if - - - case('T','C') - ! - ! With transpose, we have to do it here - ! - - select case (sm%prol) - - case(psb_none_) - ! - ! Do nothing - - case(psb_sum_) - ! - ! The transpose of sum is halo - ! - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - - case(psb_avg_) - ! - ! Tricky one: first we have to scale the overlap entries, - ! which we can do by assignind mode=0, i.e. no communication - ! (hence only scaling), then we do the halo - ! - call psb_ovrl(x,sm%desc_data,info,& - & update=psb_avg_,work=work,mode=izero) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_prol_') - goto 9999 - end select - - - case default - info=psb_err_iarg_invalid_i_ - int_err(1)=6 - ch_err(2:2)=trans - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_as_smoother_restr_a - - diff --git a/mlprec/impl/smoother/mld_d_as_smoother_restr_v.f90 b/mlprec/impl/smoother/mld_d_as_smoother_restr_v.f90 deleted file mode 100644 index 7c4eca48..00000000 --- a/mlprec/impl/smoother/mld_d_as_smoother_restr_v.f90 +++ /dev/null @@ -1,168 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_as_smoother_restr_v(sm,x,trans,work,info,data) - use psb_base_mod - use mld_d_as_smoother, mld_protect_nam => mld_d_as_smoother_restr_v - implicit none - class(mld_d_as_smoother_type), intent(inout) :: sm - type(psb_d_vect_type),intent(inout) :: x - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - !Local - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ - character :: trans_ - character(len=20) :: name='d_as_smther_restr_v', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = sm%desc_data%get_context() - call psb_info(ictxt,me,np) - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - info = psb_err_iarg_invalid_i_ - call psb_errpush(info,name) - goto 9999 - end select - - if (present(data)) then - data_ = data - else - data_ = psb_comm_ext_ - end if - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - select case(trans_) - case('N') - ! - ! Get the overlap entries x - ! - if (sm%restr == psb_halo_) then - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - else if (sm%restr /= psb_none_) then - call psb_errpush(psb_err_internal_error_,name,& - &a_err='Invalid mld_sub_restr_') - goto 9999 - end if - - - case('T','C') - ! - ! With transpose, we have to do it here - ! - - select case (sm%prol) - - case(psb_none_) - ! - ! Do nothing - - case(psb_sum_) - ! - ! The transpose of sum is halo - ! - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - - case(psb_avg_) - ! - ! Tricky one: first we have to scale the overlap entries, - ! which we can do by assignind mode=0, i.e. no communication - ! (hence only scaling), then we do the halo - ! - call psb_ovrl(x,sm%desc_data,info,& - & update=psb_avg_,work=work,mode=izero) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_prol_') - goto 9999 - end select - - - case default - info=psb_err_iarg_invalid_i_ - int_err(1)=6 - ch_err(2:2)=trans - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_as_smoother_restr_v - - diff --git a/mlprec/impl/smoother/mld_d_base_smoother_apply.f90 b/mlprec/impl/smoother/mld_d_base_smoother_apply.f90 deleted file mode 100644 index 00b841c3..00000000 --- a/mlprec/impl/smoother/mld_d_base_smoother_apply.f90 +++ /dev/null @@ -1,87 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_smoother_apply(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,info,init,initu) - use psb_base_mod - use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_base_smoother_type), intent(inout) :: sm - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_smoother_apply' - - call psb_erractionsave(err_act) - info = psb_success_ - if (sweeps == 0) then - - ! - ! K^0 = I - ! zero sweeps of any smoother is just the identity. - ! - call psb_geaxpby(alpha,x,beta,y,desc_data,info) - - else - if (allocated(sm%sv)) then - call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,info,init=init, initu=initu) - else - info = 1121 - endif - end if - if (info /= psb_success_) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_base_smoother_apply diff --git a/mlprec/impl/smoother/mld_d_base_smoother_apply_vect.f90 b/mlprec/impl/smoother/mld_d_base_smoother_apply_vect.f90 deleted file mode 100644 index 4a7dda3e..00000000 --- a/mlprec/impl/smoother/mld_d_base_smoother_apply_vect.f90 +++ /dev/null @@ -1,88 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,wv,info,init,initu) - use psb_base_mod - use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_base_smoother_type), intent(inout) :: sm - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - ! - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_smoother_apply' - - call psb_erractionsave(err_act) - info = psb_success_ - if (sweeps == 0) then - - ! - ! K^0 = I - ! zero sweeps of any smoother is just the identity. - ! - call psb_geaxpby(alpha,x,beta,y,desc_data,info) - - else - if (allocated(sm%sv)) then - call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,wv,info,init=init, initu=initu) - else - info = 1121 - endif - end if - if (info /= psb_success_) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_base_smoother_apply_vect diff --git a/mlprec/impl/smoother/mld_d_base_smoother_bld.f90 b/mlprec/impl/smoother/mld_d_base_smoother_bld.f90 deleted file mode 100644 index 737c4a95..00000000 --- a/mlprec/impl/smoother/mld_d_base_smoother_bld.f90 +++ /dev/null @@ -1,72 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_bld - Implicit None - - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_smoother_bld' - - call psb_erractionsave(err_act) - - info = psb_success_ - if (allocated(sm%sv)) then - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - else - info = 1121 - call psb_errpush(info,name) - endif - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_smoother_bld diff --git a/mlprec/impl/smoother/mld_d_base_smoother_check.f90 b/mlprec/impl/smoother/mld_d_base_smoother_check.f90 deleted file mode 100644 index 339f2f3d..00000000 --- a/mlprec/impl/smoother/mld_d_base_smoother_check.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_smoother_check(sm,info) - - use psb_base_mod - use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_check - Implicit None - - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - Integer(Psb_ipk_) :: err_act - character(len=20) :: name='d_base_smoother_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%check(info) - else - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_smoother_check diff --git a/mlprec/impl/smoother/mld_d_base_smoother_clear_data.f90 b/mlprec/impl/smoother/mld_d_base_smoother_clear_data.f90 deleted file mode 100644 index 055c328a..00000000 --- a/mlprec/impl/smoother/mld_d_base_smoother_clear_data.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_smoother_clear_data(sm,info) - - use psb_base_mod - use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_clear_data - Implicit None - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_smoother_clear_data' - - call psb_erractionsave(err_act) - - info = 0 - if (allocated(sm%sv)) then - call sm%sv%clear_data(info) - if (info /= 0) then - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_smoother_clear_data diff --git a/mlprec/impl/smoother/mld_d_base_smoother_clone.f90 b/mlprec/impl/smoother/mld_d_base_smoother_clone.f90 deleted file mode 100644 index a596335a..00000000 --- a/mlprec/impl/smoother/mld_d_base_smoother_clone.f90 +++ /dev/null @@ -1,62 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_smoother_clone(sm,smout,info) - - use psb_base_mod - use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_clone - Implicit None - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - class(mld_d_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_smoother_clone' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_smoother_clone diff --git a/mlprec/impl/smoother/mld_d_base_smoother_clone_settings.f90 b/mlprec/impl/smoother/mld_d_base_smoother_clone_settings.f90 deleted file mode 100644 index 32960db8..00000000 --- a/mlprec/impl/smoother/mld_d_base_smoother_clone_settings.f90 +++ /dev/null @@ -1,89 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_smoother_clone_settings(sm,smout,info) - - use psb_base_mod - use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_clone_settings - Implicit None - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - class(mld_d_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_smoother_clone_settings' - - call psb_erractionsave(err_act) - - info=psb_success_ - if (same_type_as(sm,smout)) then - if (allocated(smout%sv)) then - if (.not.same_type_as(sm%sv,smout%sv)) then - call smout%sv%free(info) - if (info == 0) deallocate(smout%sv,stat=info) - end if - end if - if (info /= 0) then - info = psb_err_internal_error_ - else - if (allocated(smout%sv)) then - if (same_type_as(sm%sv,smout%sv)) then - call sm%sv%clone_settings(smout%sv,info) - else - info = psb_err_internal_error_ - end if - else - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == 0) call sm%sv%clone_settings(smout%sv,info) - if (info /= 0) info = psb_err_internal_error_ - end if - end if - else - info = psb_err_internal_error_ - end if - if (info /= 0) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_smoother_clone_settings diff --git a/mlprec/impl/smoother/mld_d_base_smoother_cnv.f90 b/mlprec/impl/smoother/mld_d_base_smoother_cnv.f90 deleted file mode 100644 index 5518ac9b..00000000 --- a/mlprec/impl/smoother/mld_d_base_smoother_cnv.f90 +++ /dev/null @@ -1,70 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_smoother_cnv(sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_cnv - Implicit None - - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_smoother_cnv' - - call psb_erractionsave(err_act) - - info = psb_success_ - if (allocated(sm%sv)) then - call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) - else - info = 1121 - call psb_errpush(info,name) - endif - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_smoother_cnv diff --git a/mlprec/impl/smoother/mld_d_base_smoother_csetc.f90 b/mlprec/impl/smoother/mld_d_base_smoother_csetc.f90 deleted file mode 100644 index f8a7c236..00000000 --- a/mlprec/impl/smoother/mld_d_base_smoother_csetc.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_smoother_csetc(sm,what,val,info,idx) - - use psb_base_mod - use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_csetc - Implicit None - - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='d_base_smoother_csetc' - - call psb_erractionsave(err_act) - - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%set(what,val,info,idx=idx) - end if - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_smoother_csetc diff --git a/mlprec/impl/smoother/mld_d_base_smoother_cseti.f90 b/mlprec/impl/smoother/mld_d_base_smoother_cseti.f90 deleted file mode 100644 index 20175edc..00000000 --- a/mlprec/impl/smoother/mld_d_base_smoother_cseti.f90 +++ /dev/null @@ -1,65 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_smoother_cseti(sm,what,val,info,idx) - - use psb_base_mod - use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_cseti - Implicit None - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_smoother_cseti' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%set(what,val,info,idx=idx) - end if - if (info /= psb_success_) goto 9999 - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_smoother_cseti diff --git a/mlprec/impl/smoother/mld_d_base_smoother_csetr.f90 b/mlprec/impl/smoother/mld_d_base_smoother_csetr.f90 deleted file mode 100644 index bdae241d..00000000 --- a/mlprec/impl/smoother/mld_d_base_smoother_csetr.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_smoother_csetr(sm,what,val,info,idx) - - use psb_base_mod - use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_csetr - Implicit None - - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_smoother_csetr' - - call psb_erractionsave(err_act) - - - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%set(what,val,info,idx=idx) - end if - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_smoother_csetr diff --git a/mlprec/impl/smoother/mld_d_base_smoother_descr.f90 b/mlprec/impl/smoother/mld_d_base_smoother_descr.f90 deleted file mode 100644 index da0a8bf1..00000000 --- a/mlprec/impl/smoother/mld_d_base_smoother_descr.f90 +++ /dev/null @@ -1,101 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_smoother_descr(sm,info,iout,coarse) - - use psb_base_mod - use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_descr - use mld_d_id_solver - Implicit None - - ! Arguments - class(mld_d_base_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt, me, np - character(len=20), parameter :: name='mld_d_base_smoother_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse_ - - - call psb_erractionsave(err_act) - info = psb_success_ - - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - end if - - if (coarse_) then - if (allocated(sm%sv)) call sm%sv%descr(info,iout,coarse) - else - if (allocated(sm%sv)) then - select type (sv => sm%sv) - class is (mld_d_id_solver_type) - write(iout_,*) 'No preconditioner/smoother' - class default - write(iout_,*) 'Decoupled preconditioner/smoother with local solver' - call sm%sv%descr(info,iout,coarse) - end select - else - write(iout_,*) 'No preconditioner/smoother' - end if - end if - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='Local solver') - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_smoother_descr diff --git a/mlprec/impl/smoother/mld_d_base_smoother_dmp.f90 b/mlprec/impl/smoother/mld_d_base_smoother_dmp.f90 deleted file mode 100644 index bc836eff..00000000 --- a/mlprec/impl/smoother/mld_d_base_smoother_dmp.f90 +++ /dev/null @@ -1,85 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - - use psb_base_mod - use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_dmp - implicit none - class(mld_d_base_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: smoother_, global_num_ - ! len of prefix_ - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_smth_d" - end if - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - if (present(smoother)) then - smoother_ = smoother - else - smoother_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - ! At base level do nothing for the smoother - if (allocated(sm%sv)) & - & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) - -end subroutine mld_d_base_smoother_dmp diff --git a/mlprec/impl/smoother/mld_d_base_smoother_free.f90 b/mlprec/impl/smoother/mld_d_base_smoother_free.f90 deleted file mode 100644 index 624fd718..00000000 --- a/mlprec/impl/smoother/mld_d_base_smoother_free.f90 +++ /dev/null @@ -1,68 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_smoother_free(sm,info) - - use psb_base_mod - use mld_d_base_smoother_mod, mld_protect_name => mld_d_base_smoother_free - Implicit None - - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_smoother_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%free(info) - if (info == psb_success_) deallocate(sm%sv,stat=info) - end if - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_smoother_free diff --git a/mlprec/impl/smoother/mld_d_jac_smoother_apply.f90 b/mlprec/impl/smoother/mld_d_jac_smoother_apply.f90 deleted file mode 100644 index a2512551..00000000 --- a/mlprec/impl/smoother/mld_d_jac_smoother_apply.f90 +++ /dev/null @@ -1,273 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_jac_smoother_apply(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,info,init,initu) - use psb_base_mod - use mld_d_jac_smoother, mld_protect_name => mld_d_jac_smoother_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_jac_smoother_type), intent(inout) :: sm - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col - real(psb_dpk_), allocatable :: tx(:),ty(:) - real(psb_dpk_), pointer :: aux(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='d_jac_smoother_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = desc_data%get_context() - call psb_info(ictxt,me,np) - - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (4*n_col <= size(work)) then - aux => work(:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - endif - - if ((.not.sm%sv%is_iterative()).and.((sweeps == 1).or.(sm%nd_nnz_tot==0))) then - ! if .not.sv%is_iterative, there's no need to pass init - call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - else if (sweeps >= 0) then - if (associated(sm%pa)) then - ! - ! This means we are dealing with a pure Jacobi smoother/solver. - ! - call psb_geasb(tx,desc_data,info) - call psb_geasb(ty,desc_data,info) - select case (init_) - case('Z') - - call sm%sv%apply(done,x,dzero,ty,desc_data,trans_,aux,info,init='Z') - - case('Y') - call psb_geaxpby(done,x,dzero,tx,desc_data,info) - call psb_geaxpby(done,y,dzero,ty,desc_data,info) - call psb_spmm(-done,sm%pa,ty,done,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(done,x,dzero,tx,desc_data,info) - call psb_geaxpby(done,initu,dzero,ty,desc_data,info) - call psb_spmm(-done,sm%pa,ty,done,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = Y(j)+ D^(-1)*(X-A*Y(j)), - ! where is the diagonal and A the matrix. - ! - call psb_geaxpby(done,x,dzero,tx,desc_data,info) - call psb_spmm(-done,sm%pa,ty,done,tx,desc_data,info,work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(done,tx,done,ty,desc_data,trans_,aux,info,init='Y') - - if (info /= psb_success_) exit - end do - - - if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - else - ! - ! - ! Apply multiple sweeps of a block-Jacobi solver - ! to compute an approximate solution of a linear system. - ! - ! - call psb_geasb(tx,desc_data,info) - call psb_geasb(ty,desc_data,info) - - ! - ! Unroll the first iteration and fold it inside SELECT CASE - ! this will save one AXPBY and one SPMM when INIT=Z, and will be - ! significant when sweeps=1 (a common case) - ! - select case (init_) - case('Z') - - call sm%sv%apply(done,x,dzero,ty,desc_data,trans_,aux,info,init='Z') - - case('Y') - call psb_geaxpby(done,x,dzero,tx,desc_data,info) - call psb_geaxpby(done,y,dzero,ty,desc_data,info) - call psb_spmm(-done,sm%nd,ty,done,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(done,x,dzero,tx,desc_data,info) - call psb_geaxpby(done,initu,dzero,ty,desc_data,info) - call psb_spmm(-done,sm%nd,ty,done,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the - ! block diagonal part and the remaining part of the local matrix - ! and Y(j) is the approximate solution at sweep j. - ! - call psb_geaxpby(done,x,dzero,tx,desc_data,info) - call psb_spmm(-done,sm%nd,ty,done,tx,desc_data,info,work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,info,init='Y') - - if (info /= psb_success_) exit - end do - - if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - end if - - deallocate(tx,ty,stat=info) - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='final cleanup with Jacobi sweeps > 1') - goto 9999 - end if - - else - - info = psb_err_iarg_neg_ - call psb_errpush(info,name,& - & i_err=(/itwo,sweeps,izero,izero,izero/)) - goto 9999 - - endif - - if (.not.(4*n_col <= size(work))) then - deallocate(aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_jac_smoother_apply diff --git a/mlprec/impl/smoother/mld_d_jac_smoother_apply_vect.f90 b/mlprec/impl/smoother/mld_d_jac_smoother_apply_vect.f90 deleted file mode 100644 index 2e95454d..00000000 --- a/mlprec/impl/smoother/mld_d_jac_smoother_apply_vect.f90 +++ /dev/null @@ -1,320 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_jac_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,wv,info,init,initu) - - use psb_base_mod - use mld_d_diag_solver - use psb_base_krylov_conv_mod, only : log_conv - use mld_d_jac_smoother, mld_protect_name => mld_d_jac_smoother_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_jac_smoother_type), intent(inout) :: sm - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - ! - integer(psb_ipk_) :: n_row,n_col - type(psb_d_vect_type) :: tx, ty, r - real(psb_dpk_), pointer :: aux(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - real(psb_dpk_) :: res, resdenum - character(len=20) :: name='d_jac_smoother_apply_v' - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = desc_data%get_context() - call psb_info(ictxt,me,np) - - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (4*n_col <= size(work)) then - aux => work(:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - endif - - if(sm%checkres) then - call psb_geall(r,desc_data,info) - call psb_geasb(r,desc_data,info) - resdenum = psb_genrm2(x,desc_data,info) - end if - - if ((.not.sm%sv%is_iterative()).and.((sweeps == 1).or.(sm%nd_nnz_tot==0))) then - ! if .not.sv%is_iterative, there's no need to pass init - call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,wv,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - else if (sweeps >= 0) then - select type (smsv => sm%sv) - class is (mld_d_diag_solver_type) - ! - ! This means we are dealing with a pure Jacobi smoother/solver. - ! - associate(tx => wv(1), ty => wv(2)) - select case (init_) - case('Z') - - call sm%sv%apply(done,x,dzero,ty,desc_data,trans_,aux,wv(3:),info,init='Z') - - case('Y') - call psb_geaxpby(done,x,dzero,tx,desc_data,info) - call psb_geaxpby(done,y,dzero,ty,desc_data,info) - call psb_spmm(-done,sm%pa,ty,done,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(done,x,dzero,tx,desc_data,info) - call psb_geaxpby(done,initu,dzero,ty,desc_data,info) - call psb_spmm(-done,sm%pa,ty,done,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = Y(j)+ D^(-1)*(X-A*Y(j)), - ! where is the diagonal and A the matrix. - ! - call psb_geaxpby(done,x,dzero,tx,desc_data,info) - call psb_spmm(-done,sm%pa,ty,done,tx,desc_data,info,work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(done,tx,done,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - if (info /= psb_success_) exit - - if ( sm%checkres.and.(mod(i,sm%checkiter) == 0) ) then - call psb_geaxpby(done,x,dzero,r,r,desc_data,info) - call psb_spmm(-done,sm%pa,ty,done,r,desc_data,info) - res = psb_genrm2(r,desc_data,info) - if( sm%printres ) then - call log_conv("BJAC",me,i,sm%printiter,res,resdenum,sm%tol) - end if - if ( res < sm%tol*resdenum ) then - if( (sm%printres).and.(mod(sm%printiter,sm%checkiter)/=0) ) & - & call log_conv("BJAC",me,i,1,res,resdenum,sm%tol) - exit - end if - end if - - end do - - - if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - - end associate - - class default - ! - ! - ! Apply multiple sweeps of a block-Jacobi solver - ! to compute an approximate solution of a linear system. - ! - ! - if (size(wv) < 2) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size in smoother_apply') - goto 9999 - end if - associate(tx => wv(1), ty => wv(2)) - - ! - ! Unroll the first iteration and fold it inside SELECT CASE - ! this will save one AXPBY and one SPMM when INIT=Z, and will be - ! significant when sweeps=1 (a common case) - ! - select case (init_) - case('Z') - - call sm%sv%apply(done,x,dzero,ty,desc_data,trans_,aux,wv(3:),info,init='Z') - - case('Y') - call psb_geaxpby(done,x,dzero,tx,desc_data,info) - call psb_geaxpby(done,y,dzero,ty,desc_data,info) - call psb_spmm(-done,sm%nd,ty,done,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(done,x,dzero,tx,desc_data,info) - call psb_geaxpby(done,initu,dzero,ty,desc_data,info) - call psb_spmm(-done,sm%nd,ty,done,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the - ! block diagonal part and the remaining part of the local matrix - ! and Y(j) is the approximate solution at sweep j. - ! - call psb_geaxpby(done,x,dzero,tx,desc_data,info) - call psb_spmm(-done,sm%nd,ty,done,tx,desc_data,info,work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(done,tx,dzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - if (info /= psb_success_) exit - - if ( sm%checkres.and.(mod(i,sm%checkiter) == 0) ) then - call psb_geaxpby(done,x,dzero,r,r,desc_data,info) - call psb_spmm(-done,sm%pa,ty,done,r,desc_data,info) - res = psb_genrm2(r,desc_data,info) - if( sm%printres ) then - call log_conv("BJAC",me,i,sm%printiter,res,resdenum,sm%tol) - end if - if (res < sm%tol*resdenum ) then - if( (sm%printres).and.( mod(sm%printiter,sm%checkiter) /=0 ) ) & - & call log_conv("BJAC",me,i,1,res,resdenum,sm%tol) - exit - end if - end if - - end do - - if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - end associate - end select - - else - - info = psb_err_iarg_neg_ - call psb_errpush(info,name,& - & i_err=(/itwo,sweeps,izero,izero,izero/)) - goto 9999 - - endif - - if (.not.(4*n_col <= size(work))) then - deallocate(aux) - endif - - if(sm%checkres) then - call psb_gefree(r,desc_data,info) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_jac_smoother_apply_vect diff --git a/mlprec/impl/smoother/mld_d_jac_smoother_bld.f90 b/mlprec/impl/smoother/mld_d_jac_smoother_bld.f90 deleted file mode 100644 index b008957a..00000000 --- a/mlprec/impl/smoother/mld_d_jac_smoother_bld.f90 +++ /dev/null @@ -1,127 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_d_diag_solver - use mld_d_jac_smoother, mld_protect_name => mld_d_jac_smoother_bld - Implicit None - - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - type(psb_dspmat_type) :: tmpa - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota, nzeros - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_jac_smoother_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - n_col = desc_a%get_local_cols() - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - - if( sm%checkres ) sm%pa => a - - select type (smsv => sm%sv) - class is (mld_d_diag_solver_type) - call sm%nd%free() - sm%pa => a - sm%nd_nnz_tot = nztota - call psb_sum(ictxt,sm%nd_nnz_tot) - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - - class default - if (smsv%is_global()) then - ! Do not put anything into SM%ND since the solver - ! is acting globally. - call sm%nd%free() - sm%nd_nnz_tot = 0 - call psb_sum(ictxt,sm%nd_nnz_tot) - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - else - call a%csclip(sm%nd,info,& - & jmin=nrow_a+1,rscale=.false.,cscale=.false.) - if (info == psb_success_) then - if (present(amold)) then - call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - else - call sm%nd%cscnv(info,& - & type='csr',dupl=psb_dupl_add_) - endif - end if - sm%nd_nnz_tot = sm%nd%get_nzeros() - call psb_sum(ictxt,sm%nd_nnz_tot) - call a%csclip(tmpa,info,& - & jmax=nrow_a,rscale=.false.,cscale=.false.) - call sm%sv%build(tmpa,desc_a,info,amold=amold,vmold=vmold) - end if - end select - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='clip & psb_spcnv csr 4') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_jac_smoother_bld diff --git a/mlprec/impl/smoother/mld_d_jac_smoother_clear_data.f90 b/mlprec/impl/smoother/mld_d_jac_smoother_clear_data.f90 deleted file mode 100644 index 83e0dcc5..00000000 --- a/mlprec/impl/smoother/mld_d_jac_smoother_clear_data.f90 +++ /dev/null @@ -1,70 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_jac_smoother_clear_data(sm,info) - - use psb_base_mod - use mld_d_jac_smoother, mld_protect_name => mld_d_jac_smoother_clear_data - Implicit None - ! Arguments - class(mld_d_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_jac_smoother_clear_data' - - call psb_erractionsave(err_act) - - info = 0 - call sm%nd%free() - sm%nd_nnz_tot = 0 - sm%pa => null() - if ((info==0).and.allocated(sm%sv)) then - call sm%sv%clear_data(info) - end if - if (info /= 0) then - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_jac_smoother_clear_data diff --git a/mlprec/impl/smoother/mld_d_jac_smoother_clone.f90 b/mlprec/impl/smoother/mld_d_jac_smoother_clone.f90 deleted file mode 100644 index caa88534..00000000 --- a/mlprec/impl/smoother/mld_d_jac_smoother_clone.f90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_jac_smoother_clone(sm,smout,info) - - use psb_base_mod - use mld_d_jac_smoother, mld_protect_name => mld_d_jac_smoother_clone - - Implicit None - - ! Arguments - class(mld_d_jac_smoother_type), intent(inout) :: sm - class(mld_d_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(smout)) then - call smout%free(info) - if (info == psb_success_) deallocate(smout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_d_jac_smoother_type :: smout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(smo => smout) - type is (mld_d_jac_smoother_type) - smo%nd_nnz_tot = sm%nd_nnz_tot - smo%checkres = sm%checkres - smo%printres = sm%printres - smo%checkiter = sm%checkiter - smo%printiter = sm%printiter - smo%tol = sm%tol - call sm%nd%clone(smo%nd,info) - if ((info==psb_success_).and.(allocated(sm%sv))) then - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == psb_success_) call sm%sv%clone(smo%sv,info) - end if - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_jac_smoother_clone diff --git a/mlprec/impl/smoother/mld_d_jac_smoother_clone_settings.f90 b/mlprec/impl/smoother/mld_d_jac_smoother_clone_settings.f90 deleted file mode 100644 index 5591b832..00000000 --- a/mlprec/impl/smoother/mld_d_jac_smoother_clone_settings.f90 +++ /dev/null @@ -1,101 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! asd on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_jac_smoother_clone_settings(sm,smout,info) - - use psb_base_mod - use mld_d_jac_smoother, mld_protect_name => mld_d_jac_smoother_clone_settings - Implicit None - ! Arguments - class(mld_d_jac_smoother_type), intent(inout) :: sm - class(mld_d_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_jac_smoother_clone_settings' - - call psb_erractionsave(err_act) - - info = psb_success_ - - select type(smout) - class is(mld_d_jac_smoother_type) - - smout%pa => null() - smout%nd_nnz_tot = 0 - smout%checkres = sm%checkres - smout%printres = sm%printres - smout%checkiter = sm%checkiter - smout%printiter = sm%printiter - smout%tol = sm%tol - - if (allocated(smout%sv)) then - if (.not.same_type_as(sm%sv,smout%sv)) then - call smout%sv%free(info) - if (info == 0) deallocate(smout%sv,stat=info) - end if - end if - if (info /= 0) then - info = psb_err_internal_error_ - else - if (allocated(smout%sv)) then - if (same_type_as(sm%sv,smout%sv)) then - call sm%sv%clone_settings(smout%sv,info) - else - info = psb_err_internal_error_ - end if - else - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == 0) call sm%sv%clone_settings(smout%sv,info) - if (info /= 0) info = psb_err_internal_error_ - end if - end if - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_jac_smoother_clone_settings diff --git a/mlprec/impl/smoother/mld_d_jac_smoother_cnv.f90 b/mlprec/impl/smoother/mld_d_jac_smoother_cnv.f90 deleted file mode 100644 index b35c3bef..00000000 --- a/mlprec/impl/smoother/mld_d_jac_smoother_cnv.f90 +++ /dev/null @@ -1,90 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_jac_smoother_cnv(sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_d_diag_solver - use mld_d_jac_smoother, mld_protect_name => mld_d_jac_smoother_cnv - Implicit None - - ! Arguments - class(mld_d_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_jac_smoother_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - - if (info == psb_success_) then - if (sm%nd%is_asb()) then - if (present(amold)) then - call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - else - call sm%nd%cscnv(info,& - & type='csr',dupl=psb_dupl_add_) - endif - end if - end if - - if (info == psb_success_) then - if (allocated(sm%sv)) & - & call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='solver cnv') - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_jac_smoother_cnv diff --git a/mlprec/impl/smoother/mld_d_jac_smoother_csetc.f90 b/mlprec/impl/smoother/mld_d_jac_smoother_csetc.f90 deleted file mode 100644 index aba40147..00000000 --- a/mlprec/impl/smoother/mld_d_jac_smoother_csetc.f90 +++ /dev/null @@ -1,90 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_jac_smoother_csetc(sm,what,val,info,idx) - - use psb_base_mod - use mld_d_jac_smoother, mld_protect_nam => mld_d_jac_smoother_csetc - Implicit None - ! Arguments - class(mld_d_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='d_jac_smoother_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(trim(what))) - case('SMOOTHER_STOP') - select case(psb_toupper(trim(val))) - case('T','TRUE') - sm%checkres = .true. - case('F','FALSE') - sm%checkres = .false. - case default - write(0,*) 'Unknown value for smoother_stop : "',psb_toupper(trim(val)),'"' - end select - case('SMOOTHER_TRACE') - select case(psb_toupper(trim(val))) - case('T','TRUE') - sm%printres = .true. - case('F','FALSE') - sm%printres = .false. - case default - write(0,*) 'Unknown value for smoother_trace : "',psb_toupper(trim(val)),'"' - end select - case default - call sm%mld_d_base_smoother_type%set(what,val,info,idx=idx) - end select - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info, name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_jac_smoother_csetc diff --git a/mlprec/impl/smoother/mld_d_jac_smoother_cseti.f90 b/mlprec/impl/smoother/mld_d_jac_smoother_cseti.f90 deleted file mode 100644 index 43ea0cd4..00000000 --- a/mlprec/impl/smoother/mld_d_jac_smoother_cseti.f90 +++ /dev/null @@ -1,71 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_jac_smoother_cseti(sm,what,val,info,idx) - - use psb_base_mod - use mld_d_jac_smoother, mld_protect_nam => mld_d_jac_smoother_cseti - Implicit None - - ! Arguments - class(mld_d_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_jac_smoother_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) - case('SMOOTHER_RESIDUAL') - sm%checkiter = val - case('SMOOTHER_ITRACE') - sm%printiter = val - case default - call sm%mld_d_base_smoother_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_jac_smoother_cseti diff --git a/mlprec/impl/smoother/mld_d_jac_smoother_csetr.f90 b/mlprec/impl/smoother/mld_d_jac_smoother_csetr.f90 deleted file mode 100644 index 03cba588..00000000 --- a/mlprec/impl/smoother/mld_d_jac_smoother_csetr.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_jac_smoother_csetr(sm,what,val,info,idx) - - use psb_base_mod - use mld_d_jac_smoother, mld_protect_nam => mld_d_jac_smoother_csetr - Implicit None - - ! Arguments - class(mld_d_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_jac_smoother_csetr' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) - case('SMOOTHER_STOPTOL') - sm%tol = val - case default - call sm%mld_d_base_smoother_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_jac_smoother_csetr diff --git a/mlprec/impl/smoother/mld_d_jac_smoother_descr.f90 b/mlprec/impl/smoother/mld_d_jac_smoother_descr.f90 deleted file mode 100644 index d9940a5c..00000000 --- a/mlprec/impl/smoother/mld_d_jac_smoother_descr.f90 +++ /dev/null @@ -1,103 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_jac_smoother_descr(sm,info,iout,coarse) - - use psb_base_mod - use mld_d_diag_solver - use mld_d_jac_smoother, mld_protect_name => mld_d_jac_smoother_descr - use mld_d_diag_solver - use mld_d_gs_solver - - Implicit None - - ! Arguments - class(mld_d_jac_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_d_jac_smoother_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (.not.coarse_) then - if (allocated(sm%sv)) then - select type(smv=>sm%sv) - class is (mld_d_diag_solver_type) - write(iout_,*) ' Point Jacobi ' - write(iout_,*) ' Local diagonal:' - call smv%descr(info,iout_,coarse=coarse) - class is (mld_d_bwgs_solver_type) - write(iout_,*) ' Hybrid Backward Gauss-Seidel ' - class is (mld_d_gs_solver_type) - write(iout_,*) ' Hybrid Forward Gauss-Seidel ' - class default - write(iout_,*) ' Block Jacobi ' - write(iout_,*) ' Local solver details:' - call smv%descr(info,iout_,coarse=coarse) - end select - - else - write(iout_,*) ' Block Jacobi ' - end if - else - if (allocated(sm%sv)) then - call sm%sv%descr(info,iout_,coarse=coarse) - end if - end if - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return -end subroutine mld_d_jac_smoother_descr diff --git a/mlprec/impl/smoother/mld_d_jac_smoother_dmp.f90 b/mlprec/impl/smoother/mld_d_jac_smoother_dmp.f90 deleted file mode 100644 index 72f20bbd..00000000 --- a/mlprec/impl/smoother/mld_d_jac_smoother_dmp.f90 +++ /dev/null @@ -1,97 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_jac_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - - use psb_base_mod - use mld_d_jac_smoother, mld_protect_nam => mld_d_jac_smoother_dmp - implicit none - class(mld_d_jac_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - integer(psb_lpk_), allocatable :: iv(:) - logical :: smoother_, global_num_ - ! len of prefix_ - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_smth_d" - end if - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(smoother)) then - smoother_ = smoother - else - smoother_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - if (smoother_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_nd.mtx' - if (global_num_) then - iv = desc%get_global_indices(owned=.false.) - if (sm%nd%is_asb()) & - & call sm%nd%print(fname,head=head,iv=iv) - else - if (sm%nd%is_asb()) & - & call sm%nd%print(fname,head=head) - end if - end if - ! At base level do nothing for the smoother - if (allocated(sm%sv)) & - & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) - -end subroutine mld_d_jac_smoother_dmp diff --git a/mlprec/impl/smoother/mld_d_l1_jac_smoother_bld.f90 b/mlprec/impl/smoother/mld_d_l1_jac_smoother_bld.f90 deleted file mode 100644 index efa5932c..00000000 --- a/mlprec/impl/smoother/mld_d_l1_jac_smoother_bld.f90 +++ /dev/null @@ -1,176 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_l1_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_d_diag_solver - use mld_d_jac_smoother, mld_protect_name => mld_d_l1_jac_smoother_bld - Implicit None - - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_l1_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota, nzeros - real(psb_dpk_), allocatable :: arwsum(:) - type(psb_dspmat_type) :: tmpa - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_l1_jac_smoother_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - n_col = desc_a%get_local_cols() - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - - if( sm%checkres ) sm%pa => a - - select type (smsv => sm%sv) - class is (mld_d_diag_solver_type) - call sm%nd%free() - sm%pa => a - sm%nd_nnz_tot = nztota - - call psb_sum(ictxt,sm%nd_nnz_tot) - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - - class default - if (smsv%is_global()) then - ! Do not put anything into SM%ND since the solver - ! is acting globally. - call sm%nd%free() - sm%nd_nnz_tot = 0 - call psb_sum(ictxt,sm%nd_nnz_tot) - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - else - - call a%csclip(tmpa,info,& - & jmax=nrow_a,rscale=.false.,cscale=.false.) - - call a%csclip(sm%nd,info,& - & jmin=nrow_a+1,rscale=.false.,cscale=.false.) - - arwsum = sm%nd%arwsum(info) - - call combine_dl1(-done,arwsum,sm%nd,info) - call combine_dl1(done,arwsum,tmpa,info) - - sm%nd_nnz_tot = sm%nd%get_nzeros() - call psb_sum(ictxt,sm%nd_nnz_tot) - - call sm%sv%build(tmpa,desc_a,info,amold=amold,vmold=vmold) - - if (info == psb_success_) then - if (present(amold)) then - call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - else - call sm%nd%cscnv(info,& - & type='csr',dupl=psb_dupl_add_) - endif - end if - end if - end select - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='clip & psb_spcnv csr 4') - goto 9999 - end if - - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='solver build') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - - subroutine combine_dl1(alpha,dl1,mat,info) - implicit none - real(psb_dpk_), intent(in) :: alpha, dl1(:) - type(psb_dspmat_type), intent(inout) :: mat - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: k, nz, nrm, dp - type(psb_d_coo_sparse_mat) :: tcoo - - call mat%mv_to(tcoo) - nz = tcoo%get_nzeros() - nrm = min(size(dl1),tcoo%get_nrows(),tcoo%get_ncols()) -!!$ write(0,*) 'Check on combine_dl1: ',nrm, tcoo%get_nrows(),tcoo%get_ncols(), nz - call tcoo%ensure_size(nz+nrm) - call tcoo%set_dupl(psb_dupl_add_) - do k=1,nrm - if (dl1(k) /= dzero) then - nz = nz + 1 - tcoo%ia(nz) = k - tcoo%ja(nz) = k - tcoo%val(nz) = alpha*dl1(k) - end if - end do - call tcoo%set_nzeros(nz) - call tcoo%fix(info) - call mat%mv_from(tcoo) - end subroutine combine_dl1 - - -end subroutine mld_d_l1_jac_smoother_bld diff --git a/mlprec/impl/smoother/mld_d_l1_jac_smoother_clone.f90 b/mlprec/impl/smoother/mld_d_l1_jac_smoother_clone.f90 deleted file mode 100644 index b2237d5c..00000000 --- a/mlprec/impl/smoother/mld_d_l1_jac_smoother_clone.f90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_l1_jac_smoother_clone(sm,smout,info) - - use psb_base_mod - use mld_d_jac_smoother, mld_protect_name => mld_d_l1_jac_smoother_clone - - Implicit None - - ! Arguments - class(mld_d_l1_jac_smoother_type), intent(inout) :: sm - class(mld_d_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(smout)) then - call smout%free(info) - if (info == psb_success_) deallocate(smout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_d_l1_jac_smoother_type :: smout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(smo => smout) - type is (mld_d_l1_jac_smoother_type) - smo%nd_nnz_tot = sm%nd_nnz_tot - smo%checkres = sm%checkres - smo%printres = sm%printres - smo%checkiter = sm%checkiter - smo%printiter = sm%printiter - smo%tol = sm%tol - call sm%nd%clone(smo%nd,info) - if ((info==psb_success_).and.(allocated(sm%sv))) then - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == psb_success_) call sm%sv%clone(smo%sv,info) - end if - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_l1_jac_smoother_clone diff --git a/mlprec/impl/smoother/mld_d_l1_jac_smoother_descr.f90 b/mlprec/impl/smoother/mld_d_l1_jac_smoother_descr.f90 deleted file mode 100644 index 8c6a9479..00000000 --- a/mlprec/impl/smoother/mld_d_l1_jac_smoother_descr.f90 +++ /dev/null @@ -1,103 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_l1_jac_smoother_descr(sm,info,iout,coarse) - - use psb_base_mod - use mld_d_diag_solver - use mld_d_jac_smoother, mld_protect_name => mld_d_l1_jac_smoother_descr - use mld_d_diag_solver - use mld_d_gs_solver - - Implicit None - - ! Arguments - class(mld_d_l1_jac_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_d_l1_jac_smoother_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (.not.coarse_) then - if (allocated(sm%sv)) then - select type(smv=>sm%sv) - class is (mld_d_diag_solver_type) - write(iout_,*) ' Point Jacobi ' - write(iout_,*) ' Local diagonal:' - call smv%descr(info,iout_,coarse=coarse) - class is (mld_d_bwgs_solver_type) - write(iout_,*) ' L1-Hybrid Backward Gauss-Seidel ' - class is (mld_d_gs_solver_type) - write(iout_,*) ' L1-Hybrid Forward Gauss-Seidel ' - class default - write(iout_,*) ' L1-Block Jacobi ' - write(iout_,*) ' Local solver details:' - call smv%descr(info,iout_,coarse=coarse) - end select - - else - write(iout_,*) ' L1-Block Jacobi ' - end if - else - if (allocated(sm%sv)) then - call sm%sv%descr(info,iout_,coarse=coarse) - end if - end if - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return -end subroutine mld_d_l1_jac_smoother_descr diff --git a/mlprec/impl/smoother/mld_s_as_smoother_apply.f90 b/mlprec/impl/smoother/mld_s_as_smoother_apply.f90 deleted file mode 100644 index 0dbb467e..00000000 --- a/mlprec/impl/smoother/mld_s_as_smoother_apply.f90 +++ /dev/null @@ -1,235 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_as_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,info,init,initu) - use psb_base_mod - use mld_s_as_smoother, mld_protect_nam => mld_s_as_smoother_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_as_smoother_type), intent(inout) :: sm - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col, nrow_d, i - real(psb_spk_), pointer :: aux(:) - real(psb_spk_), allocatable :: tx(:),ty(:), ww(:) - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5) - character :: trans_, init_ - character(len=20) :: name='s_as_smoother_apply', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = desc_data%get_context() - call psb_info(ictxt,me,np) - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - n_row = sm%desc_data%get_local_rows() - n_col = sm%desc_data%get_local_cols() - nrow_d = desc_data%get_local_rows() - isz = max(n_row,N_COL) - - if ((4*isz) <= size(work)) then - aux => work(1:) - else - allocate(aux(4*isz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name,& - & i_err=(/4*isz,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - endif - - if ((.not.sm%sv%is_iterative()).and.(sweeps == 1).and.(sm%novr==0)) then - ! - ! Shortcut: in this case there is nothing else to be done. - ! - call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - else if (sweeps >= 0) then - ! - ! - ! Apply multiple sweeps of an AS solver - ! to compute an approximate solution of a linear system. - ! - ! - call psb_geasb(tx,sm%desc_data,info) - call psb_geasb(ty,sm%desc_data,info) - call psb_geasb(ww,sm%desc_data,info) - - ! - ! Unroll the first iteration and fold it inside SELECT CASE - ! this will save one SPMM when INIT=Z, and will be - ! significant when sweeps=1 (a common case) - ! - call psb_geaxpby(sone,x,szero,tx,desc_data,info) - if (info == 0) call sm%apply_restr(tx,trans_,aux,info) - if (info == 0) call psb_geaxpby(sone,tx,szero,ww,sm%desc_data,info) - - select case (init_) - case('Z') - call sm%sv%apply(sone,ww,szero,ty,sm%desc_data,trans_,aux,info,init='Z') - - case('Y') - call psb_geaxpby(sone,y,szero,ty,desc_data,info) - if (info == 0) call sm%apply_restr(ty,trans_,aux,info) - if (info == 0) call psb_spmm(-sone,sm%nd,ty,sone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - call sm%sv%apply(sone,ww,szero,ty,desc_data,trans_,aux,info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(sone,initu,szero,ty,desc_data,info) - if (info == 0) call sm%apply_restr(ty,trans_,aux,info) - if (info == 0) call psb_spmm(-sone,sm%nd,ty,sone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - call sm%sv%apply(sone,ww,szero,ty,desc_data,trans_,aux,info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - if (info == 0) call sm%apply_prol(ty,trans_,aux,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the - ! block diagonal part and the remaining part of the local matrix - ! and Y(j) is the approximate solution at sweep j. - ! - if (info == 0) call psb_geaxpby(sone,tx,szero,ww,sm%desc_data,info) - if (info == 0) call psb_spmm(-sone,sm%nd,ty,sone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(sone,ww,szero,ty,sm%desc_data,trans_,aux,info,init='Y') - - if (info /= psb_success_) exit - if (info == 0) call sm%apply_prol(ty,trans_,aux,info) - - end do - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - ! - ! Compute y = beta*y + alpha*ty (ty == K^(-1)*tx) - ! - call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - - else - - info = psb_err_iarg_neg_ - call psb_errpush(info,name,& - & i_err=(/itwo,sweeps,izero,izero,izero/)) - goto 9999 - - endif - - - if (.not.(4*isz <= size(work))) then - deallocate(aux,stat=info) - endif - if (info ==0) deallocate(ww,tx,ty,stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_as_smoother_apply diff --git a/mlprec/impl/smoother/mld_s_as_smoother_apply_vect.f90 b/mlprec/impl/smoother/mld_s_as_smoother_apply_vect.f90 deleted file mode 100644 index e20643ba..00000000 --- a/mlprec/impl/smoother/mld_s_as_smoother_apply_vect.f90 +++ /dev/null @@ -1,259 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_as_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,wv,info,init,initu) - use psb_base_mod - use mld_s_as_smoother, mld_protect_nam => mld_s_as_smoother_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_as_smoother_type), intent(inout) :: sm - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col, nrow_d, i - real(psb_spk_), pointer :: aux(:) - type(psb_s_vect_type) :: tx, ty, ww - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5) - character :: trans_, init_ - logical :: do_realloc_wv - character(len=20) :: name='s_as_smoother_apply_v', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = desc_data%get_context() - call psb_info(ictxt,me,np) - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - n_row = sm%desc_data%get_local_rows() - n_col = sm%desc_data%get_local_cols() - nrow_d = desc_data%get_local_rows() - isz = max(n_row,N_COL) - - if (4*isz <= size(work)) then - aux => work(:) - else - allocate(aux(4*isz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name,& - & i_err=(/4*isz,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - endif - - if ((.not.sm%sv%is_iterative()).and.(sweeps == 1).and.(sm%novr==0)) then - ! - ! Shortcut: in this case there is nothing else to be done. - ! - call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,wv,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - else if (sweeps >= 0) then - ! - ! - ! Apply multiple sweeps of an AS solver - ! to compute an approximate solution of a linear system. - ! - ! - if (size(wv) < 3) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='invalid wv size in smoother_apply') - goto 9999 - end if - - ! - ! This is tricky. This smoother has a descriptor sm%desc_data - ! for an index space potentially different from - ! that of desc_data. Hence the size of the work vectors - ! could be wrong. We need to check and reallocate as needed. - ! - do_realloc_wv = (wv(1)%get_nrows() < sm%desc_data%get_local_cols()).or.& - & (wv(2)%get_nrows() < sm%desc_data%get_local_cols()).or.& - & (wv(3)%get_nrows() < sm%desc_data%get_local_cols()) - - if (do_realloc_wv) then - call psb_geasb(wv(1),sm%desc_data,info,scratch=.true.,mold=wv(2)%v) - call psb_geasb(wv(2),sm%desc_data,info,scratch=.true.,mold=wv(1)%v) - call psb_geasb(wv(3),sm%desc_data,info,scratch=.true.,mold=wv(1)%v) - end if - - associate(tx => wv(1), ty => wv(2), ww => wv(3)) - - ! Need to zero tx because of the apply_restr call. - call tx%zero() - ! - ! Unroll the first iteration and fold it inside SELECT CASE - ! this will save one SPMM when INIT=Z, and will be - ! significant when sweeps=1 (a common case) - ! - call psb_geaxpby(sone,x,szero,tx,desc_data,info) - if (info == 0) call sm%apply_restr(tx,trans_,aux,info) - if (info == 0) call psb_geaxpby(sone,tx,szero,ww,sm%desc_data,info) - - select case (init_) - case('Z') - call sm%sv%apply(sone,ww,szero,ty,sm%desc_data,trans_,aux,wv(4:),info,init='Z') - - case('Y') - call psb_geaxpby(sone,y,szero,ty,desc_data,info) - if (info == 0) call sm%apply_restr(ty,trans_,aux,info) - if (info == 0) call psb_spmm(-sone,sm%nd,ty,sone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - call sm%sv%apply(sone,ww,szero,ty,desc_data,trans_,aux,wv(4:),info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(sone,initu,szero,ty,desc_data,info) - if (info == 0) call sm%apply_restr(ty,trans_,aux,info) - if (info == 0) call psb_spmm(-sone,sm%nd,ty,sone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - call sm%sv%apply(sone,ww,szero,ty,desc_data,trans_,aux,wv(4:),info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - if (info == 0) call sm%apply_prol(ty,trans_,aux,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the - ! block diagonal part and the remaining part of the local matrix - ! and Y(j) is the approximate solution at sweep j. - ! - if (info == 0) call psb_geaxpby(sone,tx,szero,ww,sm%desc_data,info) - if (info == 0) call psb_spmm(-sone,sm%nd,ty,sone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(sone,ww,szero,ty,sm%desc_data,trans_,aux,wv(4:),info,init='Y') - - if (info /= psb_success_) exit - if (info == 0) call sm%apply_prol(ty,trans_,aux,info) - - end do - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - ! - ! Compute y = beta*y + alpha*ty (ty == K^(-1)*tx) - ! - call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - end associate - - else - - info = psb_err_iarg_neg_ - call psb_errpush(info,name,& - & i_err=(/itwo,sweeps,izero,izero,izero/)) - goto 9999 - - endif - - - if (.not.(4*isz <= size(work))) then - deallocate(aux,stat=info) - endif - - if (info /= 0) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_as_smoother_apply_vect diff --git a/mlprec/impl/smoother/mld_s_as_smoother_bld.f90 b/mlprec/impl/smoother/mld_s_as_smoother_bld.f90 deleted file mode 100644 index f5f70455..00000000 --- a/mlprec/impl/smoother/mld_s_as_smoother_bld.f90 +++ /dev/null @@ -1,183 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_as_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_s_as_smoother, mld_protect_nam => mld_s_as_smoother_bld - Implicit None - - ! Arguments - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local variables - type(psb_sspmat_type) :: blck, atmp - integer(psb_ipk_) :: n_row,n_col, nrow_a, nhalo, novr, data_ - real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='s_as_smoother_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - novr = sm%novr - if (novr < 0) then - info=psb_err_invalid_ovr_num_ - call psb_errpush(info,name,& - & i_err=(/novr,izero,izero,izero,izero,izero/)) - goto 9999 - endif - - if ((novr == 0).or.(np == 1)) then - call psb_cdcpy(desc_a,sm%desc_data,info) - If(debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' done cdcpy' - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_cdcpy' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Early return: P>=3 N_OVR=0' - call blck%csall(izero,izero,info,ione) - else - - ! - ! Build the auxiliary descriptor desc_p%matrix_data(psb_n_row_). - ! This is done by psb_cdbldext (interface to psb_cdovr), which is - ! independent of CSR, and has been placed in the tools directory - ! of PSBLAS, instead of the mlprec directory of MLD2P4, because it - ! might be used independently of the AS preconditioner, to build - ! a descriptor for an extended stencil in a PDE solver. - ! - call psb_cdbldext(a,desc_a,novr,sm%desc_data,info,extype=psb_ovt_asov_) - if(debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' From cdbldext _:',sm%desc_data%get_local_rows(),& - & sm%desc_data%get_local_cols() - - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_cdbldext' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Before sphalo ' - - ! - ! Retrieve the remote sparse matrix rows required for the AS extended - ! matrix - data_ = psb_comm_ext_ - Call psb_sphalo(a,sm%desc_data,blck,info,data=data_,rowscale=.true.) - - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_sphalo' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if (debug_level >=psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'After psb_sphalo ',& - & blck%get_nrows(), blck%get_nzeros() - - End if - if (info == psb_success_) & - & call sm%sv%build(a,sm%desc_data,info,& - & blck,amold=amold,vmold=vmold) - - nrow_a = a%get_nrows() - n_row = sm%desc_data%get_local_rows() - n_col = sm%desc_data%get_local_cols() - - if (info == psb_success_) call a%csclip(sm%nd,info,& - & jmin=nrow_a+1,rscale=.false.,cscale=.false.) - if (info == psb_success_) call blck%csclip(atmp,info,& - & jmin=nrow_a+1,rscale=.false.,cscale=.false.) - if (info == psb_success_) call psb_rwextd(n_row,sm%nd,info,b=atmp) - - if (info == psb_success_) then - if (present(amold)) then - call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - else - call sm%nd%cscnv(info,& - & type='csr',dupl=psb_dupl_add_) - end if - end if - if (info == psb_success_) then - if (present(imold)) then - call sm%desc_data%cnv(imold) - end if - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='clip & psb_spcnv csr 4') - goto 9999 - end if - sm%nd_nnz_tot = sm%nd%get_nzeros() - call psb_sum(ictxt,sm%nd_nnz_tot) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_as_smoother_bld diff --git a/mlprec/impl/smoother/mld_s_as_smoother_check.f90 b/mlprec/impl/smoother/mld_s_as_smoother_check.f90 deleted file mode 100644 index 06cbaf7f..00000000 --- a/mlprec/impl/smoother/mld_s_as_smoother_check.f90 +++ /dev/null @@ -1,78 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_as_smoother_check(sm,info) - - use psb_base_mod - use mld_s_as_smoother, mld_protect_nam => mld_s_as_smoother_check - - Implicit None - - ! Arguments - class(mld_s_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - Integer(Psb_ipk_) :: err_act - character(len=20) :: name='s_as_smoother_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - call mld_check_def(sm%restr,& - & 'Restrictor',psb_halo_,is_legal_restrict) - call mld_check_def(sm%prol,& - & 'Prolongator',psb_none_,is_legal_prolong) - call mld_check_def(sm%novr,& - & 'Overlap layers ',izero,is_int_non_negative) - - - if (allocated(sm%sv)) then - call sm%sv%check(info) - else - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_as_smoother_check diff --git a/mlprec/impl/smoother/mld_s_as_smoother_clear_data.f90 b/mlprec/impl/smoother/mld_s_as_smoother_clear_data.f90 deleted file mode 100644 index fa16c549..00000000 --- a/mlprec/impl/smoother/mld_s_as_smoother_clear_data.f90 +++ /dev/null @@ -1,70 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_as_smoother_clear_data(sm,info) - - use psb_base_mod - use mld_s_as_smoother, mld_protect_name => mld_s_as_smoother_clear_data - Implicit None - ! Arguments - class(mld_s_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_as_smoother_clear_data' - - call psb_erractionsave(err_act) - - info = 0 - call sm%nd%free() - sm%nd_nnz_tot = 0 - call sm%desc_data%free(info) - if ((info==0).and.allocated(sm%sv)) then - call sm%sv%clear_data(info) - end if - if (info /= 0) then - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_as_smoother_clear_data diff --git a/mlprec/impl/smoother/mld_s_as_smoother_clone.f90 b/mlprec/impl/smoother/mld_s_as_smoother_clone.f90 deleted file mode 100644 index 6076c287..00000000 --- a/mlprec/impl/smoother/mld_s_as_smoother_clone.f90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_as_smoother_clone(sm,smout,info) - - use psb_base_mod - use mld_s_as_smoother, mld_protect_name => mld_s_as_smoother_clone - - Implicit None - - ! Arguments - class(mld_s_as_smoother_type), intent(inout) :: sm - class(mld_s_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(smout)) then - call smout%free(info) - if (info == psb_success_) deallocate(smout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_s_as_smoother_type :: smout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(smo => smout) - type is (mld_s_as_smoother_type) - smo%novr = sm%novr - smo%restr = sm%restr - smo%prol = sm%prol - smo%nd_nnz_tot = sm%nd_nnz_tot - call sm%nd%clone(smo%nd,info) - if (info == psb_success_) & - & call sm%desc_data%clone(smo%desc_data,info) - if ((info==psb_success_).and.(allocated(sm%sv))) then - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == psb_success_) call sm%sv%clone(smo%sv,info) - end if - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_as_smoother_clone diff --git a/mlprec/impl/smoother/mld_s_as_smoother_clone_settings.f90 b/mlprec/impl/smoother/mld_s_as_smoother_clone_settings.f90 deleted file mode 100644 index e65ca290..00000000 --- a/mlprec/impl/smoother/mld_s_as_smoother_clone_settings.f90 +++ /dev/null @@ -1,95 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! asd on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_as_smoother_clone_settings(sm,smout,info) - - use psb_base_mod - use mld_s_as_smoother, mld_protect_name => mld_s_as_smoother_clone_settings - Implicit None - ! Arguments - class(mld_s_as_smoother_type), intent(inout) :: sm - class(mld_s_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_as_smoother_clone_settings' - - call psb_erractionsave(err_act) - - info = psb_success_ - - select type(smout) - class is(mld_s_as_smoother_type) - smout%novr = sm%novr - smout%restr = sm%restr - smout%prol = sm%prol - if (allocated(smout%sv)) then - if (.not.same_type_as(sm%sv,smout%sv)) then - call smout%sv%free(info) - if (info == 0) deallocate(smout%sv,stat=info) - end if - end if - if (info /= 0) then - info = psb_err_internal_error_ - else - if (allocated(smout%sv)) then - if (same_type_as(sm%sv,smout%sv)) then - call sm%sv%clone_settings(smout%sv,info) - else - info = psb_err_internal_error_ - end if - else - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == 0) call sm%sv%clone_settings(smout%sv,info) - if (info /= 0) info = psb_err_internal_error_ - end if - end if - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_as_smoother_clone_settings diff --git a/mlprec/impl/smoother/mld_s_as_smoother_cnv.f90 b/mlprec/impl/smoother/mld_s_as_smoother_cnv.f90 deleted file mode 100644 index 80ac089b..00000000 --- a/mlprec/impl/smoother/mld_s_as_smoother_cnv.f90 +++ /dev/null @@ -1,96 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_as_smoother_cnv(sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_s_as_smoother, mld_protect_nam => mld_s_as_smoother_cnv - Implicit None - - ! Arguments - class(mld_s_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local variables - type(psb_dspmat_type) :: blck, atmp - integer(psb_ipk_) :: n_row,n_col, nrow_a, nhalo, novr, data_, nzeros - real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_as_smoother_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = sm%desc_data%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - if (allocated(sm%sv)) & - & call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) - - if (info == psb_success_) then - if (present(amold)) then - if (sm%nd%is_asb()) call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - end if - end if - if (info == psb_success_) then - if (present(imold)) then - call sm%desc_data%cnv(imold) - end if - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='clip & psb_spcnv csr 4') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_as_smoother_cnv diff --git a/mlprec/impl/smoother/mld_s_as_smoother_csetc.f90 b/mlprec/impl/smoother/mld_s_as_smoother_csetc.f90 deleted file mode 100644 index e14f316c..00000000 --- a/mlprec/impl/smoother/mld_s_as_smoother_csetc.f90 +++ /dev/null @@ -1,78 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_as_smoother_csetc(sm,what,val,info,idx) - - use psb_base_mod - use mld_s_as_smoother, mld_protect_nam => mld_s_as_smoother_csetc - Implicit None - ! Arguments - class(mld_s_as_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='s_as_smoother_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - - - ival = sm%stringval(val) - select case(psb_toupper(what)) - case('SUB_RESTR') - sm%restr = ival - case('SUB_PROL') - sm%prol = ival - case default - call sm%mld_s_base_smoother_type%set(what,val,info,idx=idx) - end select - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info, name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_as_smoother_csetc diff --git a/mlprec/impl/smoother/mld_s_as_smoother_cseti.f90 b/mlprec/impl/smoother/mld_s_as_smoother_cseti.f90 deleted file mode 100644 index 4f0c2f9a..00000000 --- a/mlprec/impl/smoother/mld_s_as_smoother_cseti.f90 +++ /dev/null @@ -1,73 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_as_smoother_cseti(sm,what,val,info,idx) - - use psb_base_mod - use mld_s_as_smoother, mld_protect_nam => mld_s_as_smoother_cseti - Implicit None - - ! Arguments - class(mld_s_as_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_as_smoother_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) - case('SUB_OVR') - sm%novr = val - case('SUB_RESTR') - sm%restr = val - case('SUB_PROL') - sm%prol = val - case default - call sm%mld_s_base_smoother_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_as_smoother_cseti diff --git a/mlprec/impl/smoother/mld_s_as_smoother_dmp.f90 b/mlprec/impl/smoother/mld_s_as_smoother_dmp.f90 deleted file mode 100644 index 00a6dd77..00000000 --- a/mlprec/impl/smoother/mld_s_as_smoother_dmp.f90 +++ /dev/null @@ -1,92 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_as_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - - use psb_base_mod - use mld_s_as_smoother, mld_protect_nam => mld_s_as_smoother_dmp - implicit none - class(mld_s_as_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: smoother_, global_num_ - ! len of prefix_ - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_smth_s" - end if - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(smoother)) then - smoother_ = smoother - else - smoother_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - if (global_num_) then - write(0,*) iam,' Warning: no global num with AS smoothers dump' - end if - if (smoother_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_nd.mtx' - if (sm%nd%is_asb()) & - & call sm%nd%print(fname,head=head) - end if - ! At base level do nothing for the smoother - if (allocated(sm%sv)) & - & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) - -end subroutine mld_s_as_smoother_dmp diff --git a/mlprec/impl/smoother/mld_s_as_smoother_free.f90 b/mlprec/impl/smoother/mld_s_as_smoother_free.f90 deleted file mode 100644 index 5a632a42..00000000 --- a/mlprec/impl/smoother/mld_s_as_smoother_free.f90 +++ /dev/null @@ -1,71 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_as_smoother_free(sm,info) - - use psb_base_mod - use mld_s_as_smoother, mld_protect_nam => mld_s_as_smoother_free - Implicit None - ! Arguments - class(mld_s_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_as_smoother_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - - - if (allocated(sm%sv)) then - call sm%sv%free(info) - if (info == psb_success_) deallocate(sm%sv,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - end if - call sm%nd%free() - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_as_smoother_free diff --git a/mlprec/impl/smoother/mld_s_as_smoother_prol_a.f90 b/mlprec/impl/smoother/mld_s_as_smoother_prol_a.f90 deleted file mode 100644 index caba1267..00000000 --- a/mlprec/impl/smoother/mld_s_as_smoother_prol_a.f90 +++ /dev/null @@ -1,149 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_as_smoother_prol_a(sm,x,trans,work,info,data) - use psb_base_mod - use mld_s_as_smoother, mld_protect_nam => mld_s_as_smoother_prol_a - implicit none - class(mld_s_as_smoother_type), intent(inout) :: sm - real(psb_spk_), intent(inout) :: x(:) - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - !Local - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ - character :: trans_ - character(len=20) :: name='s_as_smther_prol_a', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = sm%desc_data%get_context() - call psb_info(ictxt,me,np) - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - info = psb_err_iarg_invalid_i_ - call psb_errpush(info,name) - goto 9999 - end select - - if (present(data)) then - data_ = data - else - data_ = psb_comm_ext_ - end if - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - - select case(trans_) - case('N') - - select case (sm%prol) - - case(psb_none_) - ! - ! Would work anyway, but since it is supposed to do nothing ... - ! call psb_ovrl(x,sm%desc_data,info,& - ! & update=sm%prol,work=work) - - - case(psb_sum_,psb_avg_) - ! - ! Update the overlap of x - ! - call psb_ovrl(x,sm%desc_data,info,& - & update=sm%prol,work=work) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_prol_') - goto 9999 - end select - - case('T','C') - ! - ! With transpose, we have to do it here - ! - if (sm%restr == psb_halo_) then - call psb_ovrl(x,sm%desc_data,info,& - & update=psb_sum_,work=work) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - else if (sm%restr /= psb_none_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_restr_') - goto 9999 - end if - - case default - info=psb_err_iarg_invalid_i_ - int_err(1)=6 - ch_err(2:2)=trans - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_as_smoother_prol_a - - diff --git a/mlprec/impl/smoother/mld_s_as_smoother_prol_v.f90 b/mlprec/impl/smoother/mld_s_as_smoother_prol_v.f90 deleted file mode 100644 index f5516309..00000000 --- a/mlprec/impl/smoother/mld_s_as_smoother_prol_v.f90 +++ /dev/null @@ -1,149 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_as_smoother_prol_v(sm,x,trans,work,info,data) - use psb_base_mod - use mld_s_as_smoother, mld_protect_nam => mld_s_as_smoother_prol_v - implicit none - class(mld_s_as_smoother_type), intent(inout) :: sm - type(psb_s_vect_type),intent(inout) :: x - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - !Local - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ - character :: trans_ - character(len=20) :: name='s_as_smther_prol_v', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = sm%desc_data%get_context() - call psb_info(ictxt,me,np) - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - info = psb_err_iarg_invalid_i_ - call psb_errpush(info,name) - goto 9999 - end select - - if (present(data)) then - data_ = data - else - data_ = psb_comm_ext_ - end if - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - - select case(trans_) - case('N') - - select case (sm%prol) - - case(psb_none_) - ! - ! Would work anyway, but since it is supposed to do nothing ... - ! call psb_ovrl(x,sm%desc_data,info,& - ! & update=sm%prol,work=work) - - - case(psb_sum_,psb_avg_) - ! - ! Update the overlap of x - ! - call psb_ovrl(x,sm%desc_data,info,& - & update=sm%prol,work=work) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_prol_') - goto 9999 - end select - - case('T','C') - ! - ! With transpose, we have to do it here - ! - if (sm%restr == psb_halo_) then - call psb_ovrl(x,sm%desc_data,info,& - & update=psb_sum_,work=work) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - else if (sm%restr /= psb_none_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_restr_') - goto 9999 - end if - - case default - info=psb_err_iarg_invalid_i_ - int_err(1)=6 - ch_err(2:2)=trans - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_as_smoother_prol_v - - diff --git a/mlprec/impl/smoother/mld_s_as_smoother_restr_a.f90 b/mlprec/impl/smoother/mld_s_as_smoother_restr_a.f90 deleted file mode 100644 index 3055e987..00000000 --- a/mlprec/impl/smoother/mld_s_as_smoother_restr_a.f90 +++ /dev/null @@ -1,168 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_as_smoother_restr_a(sm,x,trans,work,info,data) - use psb_base_mod - use mld_s_as_smoother, mld_protect_nam => mld_s_as_smoother_restr_a - implicit none - class(mld_s_as_smoother_type), intent(inout) :: sm - real(psb_spk_), intent(inout) :: x(:) - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - !Local - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ - character :: trans_ - character(len=20) :: name='s_as_smther_restr_a', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = sm%desc_data%get_context() - call psb_info(ictxt,me,np) - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - info = psb_err_iarg_invalid_i_ - call psb_errpush(info,name) - goto 9999 - end select - - if (present(data)) then - data_ = data - else - data_ = psb_comm_ext_ - end if - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - select case(trans_) - case('N') - ! - ! Get the overlap entries x - ! - if (sm%restr == psb_halo_) then - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - else if (sm%restr /= psb_none_) then - call psb_errpush(psb_err_internal_error_,name,& - &a_err='Invalid mld_sub_restr_') - goto 9999 - end if - - - case('T','C') - ! - ! With transpose, we have to do it here - ! - - select case (sm%prol) - - case(psb_none_) - ! - ! Do nothing - - case(psb_sum_) - ! - ! The transpose of sum is halo - ! - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - - case(psb_avg_) - ! - ! Tricky one: first we have to scale the overlap entries, - ! which we can do by assignind mode=0, i.e. no communication - ! (hence only scaling), then we do the halo - ! - call psb_ovrl(x,sm%desc_data,info,& - & update=psb_avg_,work=work,mode=izero) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_prol_') - goto 9999 - end select - - - case default - info=psb_err_iarg_invalid_i_ - int_err(1)=6 - ch_err(2:2)=trans - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_as_smoother_restr_a - - diff --git a/mlprec/impl/smoother/mld_s_as_smoother_restr_v.f90 b/mlprec/impl/smoother/mld_s_as_smoother_restr_v.f90 deleted file mode 100644 index f6a82d9d..00000000 --- a/mlprec/impl/smoother/mld_s_as_smoother_restr_v.f90 +++ /dev/null @@ -1,168 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_as_smoother_restr_v(sm,x,trans,work,info,data) - use psb_base_mod - use mld_s_as_smoother, mld_protect_nam => mld_s_as_smoother_restr_v - implicit none - class(mld_s_as_smoother_type), intent(inout) :: sm - type(psb_s_vect_type),intent(inout) :: x - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - !Local - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ - character :: trans_ - character(len=20) :: name='s_as_smther_restr_v', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = sm%desc_data%get_context() - call psb_info(ictxt,me,np) - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - info = psb_err_iarg_invalid_i_ - call psb_errpush(info,name) - goto 9999 - end select - - if (present(data)) then - data_ = data - else - data_ = psb_comm_ext_ - end if - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - select case(trans_) - case('N') - ! - ! Get the overlap entries x - ! - if (sm%restr == psb_halo_) then - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - else if (sm%restr /= psb_none_) then - call psb_errpush(psb_err_internal_error_,name,& - &a_err='Invalid mld_sub_restr_') - goto 9999 - end if - - - case('T','C') - ! - ! With transpose, we have to do it here - ! - - select case (sm%prol) - - case(psb_none_) - ! - ! Do nothing - - case(psb_sum_) - ! - ! The transpose of sum is halo - ! - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - - case(psb_avg_) - ! - ! Tricky one: first we have to scale the overlap entries, - ! which we can do by assignind mode=0, i.e. no communication - ! (hence only scaling), then we do the halo - ! - call psb_ovrl(x,sm%desc_data,info,& - & update=psb_avg_,work=work,mode=izero) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_prol_') - goto 9999 - end select - - - case default - info=psb_err_iarg_invalid_i_ - int_err(1)=6 - ch_err(2:2)=trans - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_as_smoother_restr_v - - diff --git a/mlprec/impl/smoother/mld_s_base_smoother_apply.f90 b/mlprec/impl/smoother/mld_s_base_smoother_apply.f90 deleted file mode 100644 index e74a4d96..00000000 --- a/mlprec/impl/smoother/mld_s_base_smoother_apply.f90 +++ /dev/null @@ -1,87 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_smoother_apply(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,info,init,initu) - use psb_base_mod - use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_base_smoother_type), intent(inout) :: sm - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_smoother_apply' - - call psb_erractionsave(err_act) - info = psb_success_ - if (sweeps == 0) then - - ! - ! K^0 = I - ! zero sweeps of any smoother is just the identity. - ! - call psb_geaxpby(alpha,x,beta,y,desc_data,info) - - else - if (allocated(sm%sv)) then - call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,info,init=init, initu=initu) - else - info = 1121 - endif - end if - if (info /= psb_success_) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_base_smoother_apply diff --git a/mlprec/impl/smoother/mld_s_base_smoother_apply_vect.f90 b/mlprec/impl/smoother/mld_s_base_smoother_apply_vect.f90 deleted file mode 100644 index ab2fd275..00000000 --- a/mlprec/impl/smoother/mld_s_base_smoother_apply_vect.f90 +++ /dev/null @@ -1,88 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,wv,info,init,initu) - use psb_base_mod - use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_base_smoother_type), intent(inout) :: sm - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - ! - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_smoother_apply' - - call psb_erractionsave(err_act) - info = psb_success_ - if (sweeps == 0) then - - ! - ! K^0 = I - ! zero sweeps of any smoother is just the identity. - ! - call psb_geaxpby(alpha,x,beta,y,desc_data,info) - - else - if (allocated(sm%sv)) then - call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,wv,info,init=init, initu=initu) - else - info = 1121 - endif - end if - if (info /= psb_success_) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_base_smoother_apply_vect diff --git a/mlprec/impl/smoother/mld_s_base_smoother_bld.f90 b/mlprec/impl/smoother/mld_s_base_smoother_bld.f90 deleted file mode 100644 index 99e6ea78..00000000 --- a/mlprec/impl/smoother/mld_s_base_smoother_bld.f90 +++ /dev/null @@ -1,72 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_bld - Implicit None - - ! Arguments - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_smoother_bld' - - call psb_erractionsave(err_act) - - info = psb_success_ - if (allocated(sm%sv)) then - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - else - info = 1121 - call psb_errpush(info,name) - endif - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_smoother_bld diff --git a/mlprec/impl/smoother/mld_s_base_smoother_check.f90 b/mlprec/impl/smoother/mld_s_base_smoother_check.f90 deleted file mode 100644 index 06a34223..00000000 --- a/mlprec/impl/smoother/mld_s_base_smoother_check.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_smoother_check(sm,info) - - use psb_base_mod - use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_check - Implicit None - - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - Integer(Psb_ipk_) :: err_act - character(len=20) :: name='s_base_smoother_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%check(info) - else - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_smoother_check diff --git a/mlprec/impl/smoother/mld_s_base_smoother_clear_data.f90 b/mlprec/impl/smoother/mld_s_base_smoother_clear_data.f90 deleted file mode 100644 index d92afd4f..00000000 --- a/mlprec/impl/smoother/mld_s_base_smoother_clear_data.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_smoother_clear_data(sm,info) - - use psb_base_mod - use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_clear_data - Implicit None - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_smoother_clear_data' - - call psb_erractionsave(err_act) - - info = 0 - if (allocated(sm%sv)) then - call sm%sv%clear_data(info) - if (info /= 0) then - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_smoother_clear_data diff --git a/mlprec/impl/smoother/mld_s_base_smoother_clone.f90 b/mlprec/impl/smoother/mld_s_base_smoother_clone.f90 deleted file mode 100644 index 0efc0c67..00000000 --- a/mlprec/impl/smoother/mld_s_base_smoother_clone.f90 +++ /dev/null @@ -1,62 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_smoother_clone(sm,smout,info) - - use psb_base_mod - use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_clone - Implicit None - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - class(mld_s_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_smoother_clone' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_smoother_clone diff --git a/mlprec/impl/smoother/mld_s_base_smoother_clone_settings.f90 b/mlprec/impl/smoother/mld_s_base_smoother_clone_settings.f90 deleted file mode 100644 index ff32a8d3..00000000 --- a/mlprec/impl/smoother/mld_s_base_smoother_clone_settings.f90 +++ /dev/null @@ -1,89 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_smoother_clone_settings(sm,smout,info) - - use psb_base_mod - use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_clone_settings - Implicit None - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - class(mld_s_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_smoother_clone_settings' - - call psb_erractionsave(err_act) - - info=psb_success_ - if (same_type_as(sm,smout)) then - if (allocated(smout%sv)) then - if (.not.same_type_as(sm%sv,smout%sv)) then - call smout%sv%free(info) - if (info == 0) deallocate(smout%sv,stat=info) - end if - end if - if (info /= 0) then - info = psb_err_internal_error_ - else - if (allocated(smout%sv)) then - if (same_type_as(sm%sv,smout%sv)) then - call sm%sv%clone_settings(smout%sv,info) - else - info = psb_err_internal_error_ - end if - else - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == 0) call sm%sv%clone_settings(smout%sv,info) - if (info /= 0) info = psb_err_internal_error_ - end if - end if - else - info = psb_err_internal_error_ - end if - if (info /= 0) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_smoother_clone_settings diff --git a/mlprec/impl/smoother/mld_s_base_smoother_cnv.f90 b/mlprec/impl/smoother/mld_s_base_smoother_cnv.f90 deleted file mode 100644 index 971abe38..00000000 --- a/mlprec/impl/smoother/mld_s_base_smoother_cnv.f90 +++ /dev/null @@ -1,70 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_smoother_cnv(sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_cnv - Implicit None - - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_smoother_cnv' - - call psb_erractionsave(err_act) - - info = psb_success_ - if (allocated(sm%sv)) then - call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) - else - info = 1121 - call psb_errpush(info,name) - endif - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_smoother_cnv diff --git a/mlprec/impl/smoother/mld_s_base_smoother_csetc.f90 b/mlprec/impl/smoother/mld_s_base_smoother_csetc.f90 deleted file mode 100644 index d056c217..00000000 --- a/mlprec/impl/smoother/mld_s_base_smoother_csetc.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_smoother_csetc(sm,what,val,info,idx) - - use psb_base_mod - use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_csetc - Implicit None - - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='s_base_smoother_csetc' - - call psb_erractionsave(err_act) - - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%set(what,val,info,idx=idx) - end if - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_smoother_csetc diff --git a/mlprec/impl/smoother/mld_s_base_smoother_cseti.f90 b/mlprec/impl/smoother/mld_s_base_smoother_cseti.f90 deleted file mode 100644 index 8600372a..00000000 --- a/mlprec/impl/smoother/mld_s_base_smoother_cseti.f90 +++ /dev/null @@ -1,65 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_smoother_cseti(sm,what,val,info,idx) - - use psb_base_mod - use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_cseti - Implicit None - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_smoother_cseti' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%set(what,val,info,idx=idx) - end if - if (info /= psb_success_) goto 9999 - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_smoother_cseti diff --git a/mlprec/impl/smoother/mld_s_base_smoother_csetr.f90 b/mlprec/impl/smoother/mld_s_base_smoother_csetr.f90 deleted file mode 100644 index 31a99c91..00000000 --- a/mlprec/impl/smoother/mld_s_base_smoother_csetr.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_smoother_csetr(sm,what,val,info,idx) - - use psb_base_mod - use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_csetr - Implicit None - - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_smoother_csetr' - - call psb_erractionsave(err_act) - - - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%set(what,val,info,idx=idx) - end if - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_smoother_csetr diff --git a/mlprec/impl/smoother/mld_s_base_smoother_descr.f90 b/mlprec/impl/smoother/mld_s_base_smoother_descr.f90 deleted file mode 100644 index 404e3829..00000000 --- a/mlprec/impl/smoother/mld_s_base_smoother_descr.f90 +++ /dev/null @@ -1,101 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_smoother_descr(sm,info,iout,coarse) - - use psb_base_mod - use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_descr - use mld_s_id_solver - Implicit None - - ! Arguments - class(mld_s_base_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt, me, np - character(len=20), parameter :: name='mld_s_base_smoother_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse_ - - - call psb_erractionsave(err_act) - info = psb_success_ - - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - end if - - if (coarse_) then - if (allocated(sm%sv)) call sm%sv%descr(info,iout,coarse) - else - if (allocated(sm%sv)) then - select type (sv => sm%sv) - class is (mld_s_id_solver_type) - write(iout_,*) 'No preconditioner/smoother' - class default - write(iout_,*) 'Decoupled preconditioner/smoother with local solver' - call sm%sv%descr(info,iout,coarse) - end select - else - write(iout_,*) 'No preconditioner/smoother' - end if - end if - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='Local solver') - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_smoother_descr diff --git a/mlprec/impl/smoother/mld_s_base_smoother_dmp.f90 b/mlprec/impl/smoother/mld_s_base_smoother_dmp.f90 deleted file mode 100644 index 14f2ac9e..00000000 --- a/mlprec/impl/smoother/mld_s_base_smoother_dmp.f90 +++ /dev/null @@ -1,85 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - - use psb_base_mod - use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_dmp - implicit none - class(mld_s_base_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: smoother_, global_num_ - ! len of prefix_ - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_smth_s" - end if - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - if (present(smoother)) then - smoother_ = smoother - else - smoother_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - ! At base level do nothing for the smoother - if (allocated(sm%sv)) & - & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) - -end subroutine mld_s_base_smoother_dmp diff --git a/mlprec/impl/smoother/mld_s_base_smoother_free.f90 b/mlprec/impl/smoother/mld_s_base_smoother_free.f90 deleted file mode 100644 index 048bec71..00000000 --- a/mlprec/impl/smoother/mld_s_base_smoother_free.f90 +++ /dev/null @@ -1,68 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_smoother_free(sm,info) - - use psb_base_mod - use mld_s_base_smoother_mod, mld_protect_name => mld_s_base_smoother_free - Implicit None - - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_smoother_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%free(info) - if (info == psb_success_) deallocate(sm%sv,stat=info) - end if - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_smoother_free diff --git a/mlprec/impl/smoother/mld_s_jac_smoother_apply.f90 b/mlprec/impl/smoother/mld_s_jac_smoother_apply.f90 deleted file mode 100644 index a7b28c29..00000000 --- a/mlprec/impl/smoother/mld_s_jac_smoother_apply.f90 +++ /dev/null @@ -1,273 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_jac_smoother_apply(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,info,init,initu) - use psb_base_mod - use mld_s_jac_smoother, mld_protect_name => mld_s_jac_smoother_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_jac_smoother_type), intent(inout) :: sm - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col - real(psb_spk_), allocatable :: tx(:),ty(:) - real(psb_spk_), pointer :: aux(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='s_jac_smoother_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = desc_data%get_context() - call psb_info(ictxt,me,np) - - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (4*n_col <= size(work)) then - aux => work(:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - endif - - if ((.not.sm%sv%is_iterative()).and.((sweeps == 1).or.(sm%nd_nnz_tot==0))) then - ! if .not.sv%is_iterative, there's no need to pass init - call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - else if (sweeps >= 0) then - if (associated(sm%pa)) then - ! - ! This means we are dealing with a pure Jacobi smoother/solver. - ! - call psb_geasb(tx,desc_data,info) - call psb_geasb(ty,desc_data,info) - select case (init_) - case('Z') - - call sm%sv%apply(sone,x,szero,ty,desc_data,trans_,aux,info,init='Z') - - case('Y') - call psb_geaxpby(sone,x,szero,tx,desc_data,info) - call psb_geaxpby(sone,y,szero,ty,desc_data,info) - call psb_spmm(-sone,sm%pa,ty,sone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(sone,x,szero,tx,desc_data,info) - call psb_geaxpby(sone,initu,szero,ty,desc_data,info) - call psb_spmm(-sone,sm%pa,ty,sone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = Y(j)+ D^(-1)*(X-A*Y(j)), - ! where is the diagonal and A the matrix. - ! - call psb_geaxpby(sone,x,szero,tx,desc_data,info) - call psb_spmm(-sone,sm%pa,ty,sone,tx,desc_data,info,work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(sone,tx,sone,ty,desc_data,trans_,aux,info,init='Y') - - if (info /= psb_success_) exit - end do - - - if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - else - ! - ! - ! Apply multiple sweeps of a block-Jacobi solver - ! to compute an approximate solution of a linear system. - ! - ! - call psb_geasb(tx,desc_data,info) - call psb_geasb(ty,desc_data,info) - - ! - ! Unroll the first iteration and fold it inside SELECT CASE - ! this will save one AXPBY and one SPMM when INIT=Z, and will be - ! significant when sweeps=1 (a common case) - ! - select case (init_) - case('Z') - - call sm%sv%apply(sone,x,szero,ty,desc_data,trans_,aux,info,init='Z') - - case('Y') - call psb_geaxpby(sone,x,szero,tx,desc_data,info) - call psb_geaxpby(sone,y,szero,ty,desc_data,info) - call psb_spmm(-sone,sm%nd,ty,sone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(sone,x,szero,tx,desc_data,info) - call psb_geaxpby(sone,initu,szero,ty,desc_data,info) - call psb_spmm(-sone,sm%nd,ty,sone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the - ! block diagonal part and the remaining part of the local matrix - ! and Y(j) is the approximate solution at sweep j. - ! - call psb_geaxpby(sone,x,szero,tx,desc_data,info) - call psb_spmm(-sone,sm%nd,ty,sone,tx,desc_data,info,work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,info,init='Y') - - if (info /= psb_success_) exit - end do - - if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - end if - - deallocate(tx,ty,stat=info) - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='final cleanup with Jacobi sweeps > 1') - goto 9999 - end if - - else - - info = psb_err_iarg_neg_ - call psb_errpush(info,name,& - & i_err=(/itwo,sweeps,izero,izero,izero/)) - goto 9999 - - endif - - if (.not.(4*n_col <= size(work))) then - deallocate(aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_jac_smoother_apply diff --git a/mlprec/impl/smoother/mld_s_jac_smoother_apply_vect.f90 b/mlprec/impl/smoother/mld_s_jac_smoother_apply_vect.f90 deleted file mode 100644 index 5ed28511..00000000 --- a/mlprec/impl/smoother/mld_s_jac_smoother_apply_vect.f90 +++ /dev/null @@ -1,320 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_jac_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,wv,info,init,initu) - - use psb_base_mod - use mld_s_diag_solver - use psb_base_krylov_conv_mod, only : log_conv - use mld_s_jac_smoother, mld_protect_name => mld_s_jac_smoother_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_jac_smoother_type), intent(inout) :: sm - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - ! - integer(psb_ipk_) :: n_row,n_col - type(psb_s_vect_type) :: tx, ty, r - real(psb_spk_), pointer :: aux(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - real(psb_dpk_) :: res, resdenum - character(len=20) :: name='s_jac_smoother_apply_v' - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = desc_data%get_context() - call psb_info(ictxt,me,np) - - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (4*n_col <= size(work)) then - aux => work(:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - endif - - if(sm%checkres) then - call psb_geall(r,desc_data,info) - call psb_geasb(r,desc_data,info) - resdenum = psb_genrm2(x,desc_data,info) - end if - - if ((.not.sm%sv%is_iterative()).and.((sweeps == 1).or.(sm%nd_nnz_tot==0))) then - ! if .not.sv%is_iterative, there's no need to pass init - call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,wv,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - else if (sweeps >= 0) then - select type (smsv => sm%sv) - class is (mld_s_diag_solver_type) - ! - ! This means we are dealing with a pure Jacobi smoother/solver. - ! - associate(tx => wv(1), ty => wv(2)) - select case (init_) - case('Z') - - call sm%sv%apply(sone,x,szero,ty,desc_data,trans_,aux,wv(3:),info,init='Z') - - case('Y') - call psb_geaxpby(sone,x,szero,tx,desc_data,info) - call psb_geaxpby(sone,y,szero,ty,desc_data,info) - call psb_spmm(-sone,sm%pa,ty,sone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(sone,x,szero,tx,desc_data,info) - call psb_geaxpby(sone,initu,szero,ty,desc_data,info) - call psb_spmm(-sone,sm%pa,ty,sone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = Y(j)+ D^(-1)*(X-A*Y(j)), - ! where is the diagonal and A the matrix. - ! - call psb_geaxpby(sone,x,szero,tx,desc_data,info) - call psb_spmm(-sone,sm%pa,ty,sone,tx,desc_data,info,work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(sone,tx,sone,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - if (info /= psb_success_) exit - - if ( sm%checkres.and.(mod(i,sm%checkiter) == 0) ) then - call psb_geaxpby(sone,x,szero,r,r,desc_data,info) - call psb_spmm(-sone,sm%pa,ty,sone,r,desc_data,info) - res = psb_genrm2(r,desc_data,info) - if( sm%printres ) then - call log_conv("BJAC",me,i,sm%printiter,res,resdenum,sm%tol) - end if - if ( res < sm%tol*resdenum ) then - if( (sm%printres).and.(mod(sm%printiter,sm%checkiter)/=0) ) & - & call log_conv("BJAC",me,i,1,res,resdenum,sm%tol) - exit - end if - end if - - end do - - - if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - - end associate - - class default - ! - ! - ! Apply multiple sweeps of a block-Jacobi solver - ! to compute an approximate solution of a linear system. - ! - ! - if (size(wv) < 2) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size in smoother_apply') - goto 9999 - end if - associate(tx => wv(1), ty => wv(2)) - - ! - ! Unroll the first iteration and fold it inside SELECT CASE - ! this will save one AXPBY and one SPMM when INIT=Z, and will be - ! significant when sweeps=1 (a common case) - ! - select case (init_) - case('Z') - - call sm%sv%apply(sone,x,szero,ty,desc_data,trans_,aux,wv(3:),info,init='Z') - - case('Y') - call psb_geaxpby(sone,x,szero,tx,desc_data,info) - call psb_geaxpby(sone,y,szero,ty,desc_data,info) - call psb_spmm(-sone,sm%nd,ty,sone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(sone,x,szero,tx,desc_data,info) - call psb_geaxpby(sone,initu,szero,ty,desc_data,info) - call psb_spmm(-sone,sm%nd,ty,sone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the - ! block diagonal part and the remaining part of the local matrix - ! and Y(j) is the approximate solution at sweep j. - ! - call psb_geaxpby(sone,x,szero,tx,desc_data,info) - call psb_spmm(-sone,sm%nd,ty,sone,tx,desc_data,info,work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(sone,tx,szero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - if (info /= psb_success_) exit - - if ( sm%checkres.and.(mod(i,sm%checkiter) == 0) ) then - call psb_geaxpby(sone,x,szero,r,r,desc_data,info) - call psb_spmm(-sone,sm%pa,ty,sone,r,desc_data,info) - res = psb_genrm2(r,desc_data,info) - if( sm%printres ) then - call log_conv("BJAC",me,i,sm%printiter,res,resdenum,sm%tol) - end if - if (res < sm%tol*resdenum ) then - if( (sm%printres).and.( mod(sm%printiter,sm%checkiter) /=0 ) ) & - & call log_conv("BJAC",me,i,1,res,resdenum,sm%tol) - exit - end if - end if - - end do - - if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - end associate - end select - - else - - info = psb_err_iarg_neg_ - call psb_errpush(info,name,& - & i_err=(/itwo,sweeps,izero,izero,izero/)) - goto 9999 - - endif - - if (.not.(4*n_col <= size(work))) then - deallocate(aux) - endif - - if(sm%checkres) then - call psb_gefree(r,desc_data,info) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_jac_smoother_apply_vect diff --git a/mlprec/impl/smoother/mld_s_jac_smoother_bld.f90 b/mlprec/impl/smoother/mld_s_jac_smoother_bld.f90 deleted file mode 100644 index deb7acae..00000000 --- a/mlprec/impl/smoother/mld_s_jac_smoother_bld.f90 +++ /dev/null @@ -1,127 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_s_diag_solver - use mld_s_jac_smoother, mld_protect_name => mld_s_jac_smoother_bld - Implicit None - - ! Arguments - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - type(psb_sspmat_type) :: tmpa - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota, nzeros - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='s_jac_smoother_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - n_col = desc_a%get_local_cols() - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - - if( sm%checkres ) sm%pa => a - - select type (smsv => sm%sv) - class is (mld_s_diag_solver_type) - call sm%nd%free() - sm%pa => a - sm%nd_nnz_tot = nztota - call psb_sum(ictxt,sm%nd_nnz_tot) - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - - class default - if (smsv%is_global()) then - ! Do not put anything into SM%ND since the solver - ! is acting globally. - call sm%nd%free() - sm%nd_nnz_tot = 0 - call psb_sum(ictxt,sm%nd_nnz_tot) - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - else - call a%csclip(sm%nd,info,& - & jmin=nrow_a+1,rscale=.false.,cscale=.false.) - if (info == psb_success_) then - if (present(amold)) then - call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - else - call sm%nd%cscnv(info,& - & type='csr',dupl=psb_dupl_add_) - endif - end if - sm%nd_nnz_tot = sm%nd%get_nzeros() - call psb_sum(ictxt,sm%nd_nnz_tot) - call a%csclip(tmpa,info,& - & jmax=nrow_a,rscale=.false.,cscale=.false.) - call sm%sv%build(tmpa,desc_a,info,amold=amold,vmold=vmold) - end if - end select - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='clip & psb_spcnv csr 4') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_jac_smoother_bld diff --git a/mlprec/impl/smoother/mld_s_jac_smoother_clear_data.f90 b/mlprec/impl/smoother/mld_s_jac_smoother_clear_data.f90 deleted file mode 100644 index 3838ef64..00000000 --- a/mlprec/impl/smoother/mld_s_jac_smoother_clear_data.f90 +++ /dev/null @@ -1,70 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_jac_smoother_clear_data(sm,info) - - use psb_base_mod - use mld_s_jac_smoother, mld_protect_name => mld_s_jac_smoother_clear_data - Implicit None - ! Arguments - class(mld_s_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_jac_smoother_clear_data' - - call psb_erractionsave(err_act) - - info = 0 - call sm%nd%free() - sm%nd_nnz_tot = 0 - sm%pa => null() - if ((info==0).and.allocated(sm%sv)) then - call sm%sv%clear_data(info) - end if - if (info /= 0) then - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_jac_smoother_clear_data diff --git a/mlprec/impl/smoother/mld_s_jac_smoother_clone.f90 b/mlprec/impl/smoother/mld_s_jac_smoother_clone.f90 deleted file mode 100644 index a0b6c349..00000000 --- a/mlprec/impl/smoother/mld_s_jac_smoother_clone.f90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_jac_smoother_clone(sm,smout,info) - - use psb_base_mod - use mld_s_jac_smoother, mld_protect_name => mld_s_jac_smoother_clone - - Implicit None - - ! Arguments - class(mld_s_jac_smoother_type), intent(inout) :: sm - class(mld_s_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(smout)) then - call smout%free(info) - if (info == psb_success_) deallocate(smout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_s_jac_smoother_type :: smout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(smo => smout) - type is (mld_s_jac_smoother_type) - smo%nd_nnz_tot = sm%nd_nnz_tot - smo%checkres = sm%checkres - smo%printres = sm%printres - smo%checkiter = sm%checkiter - smo%printiter = sm%printiter - smo%tol = sm%tol - call sm%nd%clone(smo%nd,info) - if ((info==psb_success_).and.(allocated(sm%sv))) then - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == psb_success_) call sm%sv%clone(smo%sv,info) - end if - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_jac_smoother_clone diff --git a/mlprec/impl/smoother/mld_s_jac_smoother_clone_settings.f90 b/mlprec/impl/smoother/mld_s_jac_smoother_clone_settings.f90 deleted file mode 100644 index c16d6d6d..00000000 --- a/mlprec/impl/smoother/mld_s_jac_smoother_clone_settings.f90 +++ /dev/null @@ -1,101 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! asd on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_jac_smoother_clone_settings(sm,smout,info) - - use psb_base_mod - use mld_s_jac_smoother, mld_protect_name => mld_s_jac_smoother_clone_settings - Implicit None - ! Arguments - class(mld_s_jac_smoother_type), intent(inout) :: sm - class(mld_s_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_jac_smoother_clone_settings' - - call psb_erractionsave(err_act) - - info = psb_success_ - - select type(smout) - class is(mld_s_jac_smoother_type) - - smout%pa => null() - smout%nd_nnz_tot = 0 - smout%checkres = sm%checkres - smout%printres = sm%printres - smout%checkiter = sm%checkiter - smout%printiter = sm%printiter - smout%tol = sm%tol - - if (allocated(smout%sv)) then - if (.not.same_type_as(sm%sv,smout%sv)) then - call smout%sv%free(info) - if (info == 0) deallocate(smout%sv,stat=info) - end if - end if - if (info /= 0) then - info = psb_err_internal_error_ - else - if (allocated(smout%sv)) then - if (same_type_as(sm%sv,smout%sv)) then - call sm%sv%clone_settings(smout%sv,info) - else - info = psb_err_internal_error_ - end if - else - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == 0) call sm%sv%clone_settings(smout%sv,info) - if (info /= 0) info = psb_err_internal_error_ - end if - end if - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_jac_smoother_clone_settings diff --git a/mlprec/impl/smoother/mld_s_jac_smoother_cnv.f90 b/mlprec/impl/smoother/mld_s_jac_smoother_cnv.f90 deleted file mode 100644 index b57eb4a9..00000000 --- a/mlprec/impl/smoother/mld_s_jac_smoother_cnv.f90 +++ /dev/null @@ -1,90 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_jac_smoother_cnv(sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_s_diag_solver - use mld_s_jac_smoother, mld_protect_name => mld_s_jac_smoother_cnv - Implicit None - - ! Arguments - class(mld_s_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_jac_smoother_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - - if (info == psb_success_) then - if (sm%nd%is_asb()) then - if (present(amold)) then - call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - else - call sm%nd%cscnv(info,& - & type='csr',dupl=psb_dupl_add_) - endif - end if - end if - - if (info == psb_success_) then - if (allocated(sm%sv)) & - & call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='solver cnv') - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_jac_smoother_cnv diff --git a/mlprec/impl/smoother/mld_s_jac_smoother_csetc.f90 b/mlprec/impl/smoother/mld_s_jac_smoother_csetc.f90 deleted file mode 100644 index 4f88efbd..00000000 --- a/mlprec/impl/smoother/mld_s_jac_smoother_csetc.f90 +++ /dev/null @@ -1,90 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_jac_smoother_csetc(sm,what,val,info,idx) - - use psb_base_mod - use mld_s_jac_smoother, mld_protect_nam => mld_s_jac_smoother_csetc - Implicit None - ! Arguments - class(mld_s_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='s_jac_smoother_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(trim(what))) - case('SMOOTHER_STOP') - select case(psb_toupper(trim(val))) - case('T','TRUE') - sm%checkres = .true. - case('F','FALSE') - sm%checkres = .false. - case default - write(0,*) 'Unknown value for smoother_stop : "',psb_toupper(trim(val)),'"' - end select - case('SMOOTHER_TRACE') - select case(psb_toupper(trim(val))) - case('T','TRUE') - sm%printres = .true. - case('F','FALSE') - sm%printres = .false. - case default - write(0,*) 'Unknown value for smoother_trace : "',psb_toupper(trim(val)),'"' - end select - case default - call sm%mld_s_base_smoother_type%set(what,val,info,idx=idx) - end select - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info, name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_jac_smoother_csetc diff --git a/mlprec/impl/smoother/mld_s_jac_smoother_cseti.f90 b/mlprec/impl/smoother/mld_s_jac_smoother_cseti.f90 deleted file mode 100644 index 8a60c193..00000000 --- a/mlprec/impl/smoother/mld_s_jac_smoother_cseti.f90 +++ /dev/null @@ -1,71 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_jac_smoother_cseti(sm,what,val,info,idx) - - use psb_base_mod - use mld_s_jac_smoother, mld_protect_nam => mld_s_jac_smoother_cseti - Implicit None - - ! Arguments - class(mld_s_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_jac_smoother_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) - case('SMOOTHER_RESIDUAL') - sm%checkiter = val - case('SMOOTHER_ITRACE') - sm%printiter = val - case default - call sm%mld_s_base_smoother_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_jac_smoother_cseti diff --git a/mlprec/impl/smoother/mld_s_jac_smoother_csetr.f90 b/mlprec/impl/smoother/mld_s_jac_smoother_csetr.f90 deleted file mode 100644 index 8438b353..00000000 --- a/mlprec/impl/smoother/mld_s_jac_smoother_csetr.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_jac_smoother_csetr(sm,what,val,info,idx) - - use psb_base_mod - use mld_s_jac_smoother, mld_protect_nam => mld_s_jac_smoother_csetr - Implicit None - - ! Arguments - class(mld_s_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_jac_smoother_csetr' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) - case('SMOOTHER_STOPTOL') - sm%tol = val - case default - call sm%mld_s_base_smoother_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_jac_smoother_csetr diff --git a/mlprec/impl/smoother/mld_s_jac_smoother_descr.f90 b/mlprec/impl/smoother/mld_s_jac_smoother_descr.f90 deleted file mode 100644 index 9525e4b3..00000000 --- a/mlprec/impl/smoother/mld_s_jac_smoother_descr.f90 +++ /dev/null @@ -1,103 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_jac_smoother_descr(sm,info,iout,coarse) - - use psb_base_mod - use mld_s_diag_solver - use mld_s_jac_smoother, mld_protect_name => mld_s_jac_smoother_descr - use mld_s_diag_solver - use mld_s_gs_solver - - Implicit None - - ! Arguments - class(mld_s_jac_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_s_jac_smoother_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (.not.coarse_) then - if (allocated(sm%sv)) then - select type(smv=>sm%sv) - class is (mld_s_diag_solver_type) - write(iout_,*) ' Point Jacobi ' - write(iout_,*) ' Local diagonal:' - call smv%descr(info,iout_,coarse=coarse) - class is (mld_s_bwgs_solver_type) - write(iout_,*) ' Hybrid Backward Gauss-Seidel ' - class is (mld_s_gs_solver_type) - write(iout_,*) ' Hybrid Forward Gauss-Seidel ' - class default - write(iout_,*) ' Block Jacobi ' - write(iout_,*) ' Local solver details:' - call smv%descr(info,iout_,coarse=coarse) - end select - - else - write(iout_,*) ' Block Jacobi ' - end if - else - if (allocated(sm%sv)) then - call sm%sv%descr(info,iout_,coarse=coarse) - end if - end if - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return -end subroutine mld_s_jac_smoother_descr diff --git a/mlprec/impl/smoother/mld_s_jac_smoother_dmp.f90 b/mlprec/impl/smoother/mld_s_jac_smoother_dmp.f90 deleted file mode 100644 index c58c7074..00000000 --- a/mlprec/impl/smoother/mld_s_jac_smoother_dmp.f90 +++ /dev/null @@ -1,97 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_jac_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - - use psb_base_mod - use mld_s_jac_smoother, mld_protect_nam => mld_s_jac_smoother_dmp - implicit none - class(mld_s_jac_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - integer(psb_lpk_), allocatable :: iv(:) - logical :: smoother_, global_num_ - ! len of prefix_ - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_smth_s" - end if - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(smoother)) then - smoother_ = smoother - else - smoother_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - if (smoother_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_nd.mtx' - if (global_num_) then - iv = desc%get_global_indices(owned=.false.) - if (sm%nd%is_asb()) & - & call sm%nd%print(fname,head=head,iv=iv) - else - if (sm%nd%is_asb()) & - & call sm%nd%print(fname,head=head) - end if - end if - ! At base level do nothing for the smoother - if (allocated(sm%sv)) & - & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) - -end subroutine mld_s_jac_smoother_dmp diff --git a/mlprec/impl/smoother/mld_s_l1_jac_smoother_bld.f90 b/mlprec/impl/smoother/mld_s_l1_jac_smoother_bld.f90 deleted file mode 100644 index 116a01e1..00000000 --- a/mlprec/impl/smoother/mld_s_l1_jac_smoother_bld.f90 +++ /dev/null @@ -1,176 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_l1_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_s_diag_solver - use mld_s_jac_smoother, mld_protect_name => mld_s_l1_jac_smoother_bld - Implicit None - - ! Arguments - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_l1_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota, nzeros - real(psb_spk_), allocatable :: arwsum(:) - type(psb_sspmat_type) :: tmpa - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='s_l1_jac_smoother_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - n_col = desc_a%get_local_cols() - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - - if( sm%checkres ) sm%pa => a - - select type (smsv => sm%sv) - class is (mld_s_diag_solver_type) - call sm%nd%free() - sm%pa => a - sm%nd_nnz_tot = nztota - - call psb_sum(ictxt,sm%nd_nnz_tot) - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - - class default - if (smsv%is_global()) then - ! Do not put anything into SM%ND since the solver - ! is acting globally. - call sm%nd%free() - sm%nd_nnz_tot = 0 - call psb_sum(ictxt,sm%nd_nnz_tot) - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - else - - call a%csclip(tmpa,info,& - & jmax=nrow_a,rscale=.false.,cscale=.false.) - - call a%csclip(sm%nd,info,& - & jmin=nrow_a+1,rscale=.false.,cscale=.false.) - - arwsum = sm%nd%arwsum(info) - - call combine_dl1(-sone,arwsum,sm%nd,info) - call combine_dl1(sone,arwsum,tmpa,info) - - sm%nd_nnz_tot = sm%nd%get_nzeros() - call psb_sum(ictxt,sm%nd_nnz_tot) - - call sm%sv%build(tmpa,desc_a,info,amold=amold,vmold=vmold) - - if (info == psb_success_) then - if (present(amold)) then - call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - else - call sm%nd%cscnv(info,& - & type='csr',dupl=psb_dupl_add_) - endif - end if - end if - end select - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='clip & psb_spcnv csr 4') - goto 9999 - end if - - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='solver build') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - - subroutine combine_dl1(alpha,dl1,mat,info) - implicit none - real(psb_spk_), intent(in) :: alpha, dl1(:) - type(psb_sspmat_type), intent(inout) :: mat - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: k, nz, nrm, dp - type(psb_s_coo_sparse_mat) :: tcoo - - call mat%mv_to(tcoo) - nz = tcoo%get_nzeros() - nrm = min(size(dl1),tcoo%get_nrows(),tcoo%get_ncols()) -!!$ write(0,*) 'Check on combine_dl1: ',nrm, tcoo%get_nrows(),tcoo%get_ncols(), nz - call tcoo%ensure_size(nz+nrm) - call tcoo%set_dupl(psb_dupl_add_) - do k=1,nrm - if (dl1(k) /= szero) then - nz = nz + 1 - tcoo%ia(nz) = k - tcoo%ja(nz) = k - tcoo%val(nz) = alpha*dl1(k) - end if - end do - call tcoo%set_nzeros(nz) - call tcoo%fix(info) - call mat%mv_from(tcoo) - end subroutine combine_dl1 - - -end subroutine mld_s_l1_jac_smoother_bld diff --git a/mlprec/impl/smoother/mld_s_l1_jac_smoother_clone.f90 b/mlprec/impl/smoother/mld_s_l1_jac_smoother_clone.f90 deleted file mode 100644 index fefcbaaf..00000000 --- a/mlprec/impl/smoother/mld_s_l1_jac_smoother_clone.f90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_l1_jac_smoother_clone(sm,smout,info) - - use psb_base_mod - use mld_s_jac_smoother, mld_protect_name => mld_s_l1_jac_smoother_clone - - Implicit None - - ! Arguments - class(mld_s_l1_jac_smoother_type), intent(inout) :: sm - class(mld_s_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(smout)) then - call smout%free(info) - if (info == psb_success_) deallocate(smout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_s_l1_jac_smoother_type :: smout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(smo => smout) - type is (mld_s_l1_jac_smoother_type) - smo%nd_nnz_tot = sm%nd_nnz_tot - smo%checkres = sm%checkres - smo%printres = sm%printres - smo%checkiter = sm%checkiter - smo%printiter = sm%printiter - smo%tol = sm%tol - call sm%nd%clone(smo%nd,info) - if ((info==psb_success_).and.(allocated(sm%sv))) then - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == psb_success_) call sm%sv%clone(smo%sv,info) - end if - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_l1_jac_smoother_clone diff --git a/mlprec/impl/smoother/mld_s_l1_jac_smoother_descr.f90 b/mlprec/impl/smoother/mld_s_l1_jac_smoother_descr.f90 deleted file mode 100644 index 9dc14726..00000000 --- a/mlprec/impl/smoother/mld_s_l1_jac_smoother_descr.f90 +++ /dev/null @@ -1,103 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_l1_jac_smoother_descr(sm,info,iout,coarse) - - use psb_base_mod - use mld_s_diag_solver - use mld_s_jac_smoother, mld_protect_name => mld_s_l1_jac_smoother_descr - use mld_s_diag_solver - use mld_s_gs_solver - - Implicit None - - ! Arguments - class(mld_s_l1_jac_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_s_l1_jac_smoother_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (.not.coarse_) then - if (allocated(sm%sv)) then - select type(smv=>sm%sv) - class is (mld_s_diag_solver_type) - write(iout_,*) ' Point Jacobi ' - write(iout_,*) ' Local diagonal:' - call smv%descr(info,iout_,coarse=coarse) - class is (mld_s_bwgs_solver_type) - write(iout_,*) ' L1-Hybrid Backward Gauss-Seidel ' - class is (mld_s_gs_solver_type) - write(iout_,*) ' L1-Hybrid Forward Gauss-Seidel ' - class default - write(iout_,*) ' L1-Block Jacobi ' - write(iout_,*) ' Local solver details:' - call smv%descr(info,iout_,coarse=coarse) - end select - - else - write(iout_,*) ' L1-Block Jacobi ' - end if - else - if (allocated(sm%sv)) then - call sm%sv%descr(info,iout_,coarse=coarse) - end if - end if - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return -end subroutine mld_s_l1_jac_smoother_descr diff --git a/mlprec/impl/smoother/mld_z_as_smoother_apply.f90 b/mlprec/impl/smoother/mld_z_as_smoother_apply.f90 deleted file mode 100644 index a0e18c1a..00000000 --- a/mlprec/impl/smoother/mld_z_as_smoother_apply.f90 +++ /dev/null @@ -1,235 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_as_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,info,init,initu) - use psb_base_mod - use mld_z_as_smoother, mld_protect_nam => mld_z_as_smoother_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_as_smoother_type), intent(inout) :: sm - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col, nrow_d, i - complex(psb_dpk_), pointer :: aux(:) - complex(psb_dpk_), allocatable :: tx(:),ty(:), ww(:) - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5) - character :: trans_, init_ - character(len=20) :: name='z_as_smoother_apply', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = desc_data%get_context() - call psb_info(ictxt,me,np) - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - n_row = sm%desc_data%get_local_rows() - n_col = sm%desc_data%get_local_cols() - nrow_d = desc_data%get_local_rows() - isz = max(n_row,N_COL) - - if ((4*isz) <= size(work)) then - aux => work(1:) - else - allocate(aux(4*isz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name,& - & i_err=(/4*isz,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - endif - - if ((.not.sm%sv%is_iterative()).and.(sweeps == 1).and.(sm%novr==0)) then - ! - ! Shortcut: in this case there is nothing else to be done. - ! - call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - else if (sweeps >= 0) then - ! - ! - ! Apply multiple sweeps of an AS solver - ! to compute an approximate solution of a linear system. - ! - ! - call psb_geasb(tx,sm%desc_data,info) - call psb_geasb(ty,sm%desc_data,info) - call psb_geasb(ww,sm%desc_data,info) - - ! - ! Unroll the first iteration and fold it inside SELECT CASE - ! this will save one SPMM when INIT=Z, and will be - ! significant when sweeps=1 (a common case) - ! - call psb_geaxpby(zone,x,zzero,tx,desc_data,info) - if (info == 0) call sm%apply_restr(tx,trans_,aux,info) - if (info == 0) call psb_geaxpby(zone,tx,zzero,ww,sm%desc_data,info) - - select case (init_) - case('Z') - call sm%sv%apply(zone,ww,zzero,ty,sm%desc_data,trans_,aux,info,init='Z') - - case('Y') - call psb_geaxpby(zone,y,zzero,ty,desc_data,info) - if (info == 0) call sm%apply_restr(ty,trans_,aux,info) - if (info == 0) call psb_spmm(-zone,sm%nd,ty,zone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - call sm%sv%apply(zone,ww,zzero,ty,desc_data,trans_,aux,info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(zone,initu,zzero,ty,desc_data,info) - if (info == 0) call sm%apply_restr(ty,trans_,aux,info) - if (info == 0) call psb_spmm(-zone,sm%nd,ty,zone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - call sm%sv%apply(zone,ww,zzero,ty,desc_data,trans_,aux,info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - if (info == 0) call sm%apply_prol(ty,trans_,aux,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the - ! block diagonal part and the remaining part of the local matrix - ! and Y(j) is the approximate solution at sweep j. - ! - if (info == 0) call psb_geaxpby(zone,tx,zzero,ww,sm%desc_data,info) - if (info == 0) call psb_spmm(-zone,sm%nd,ty,zone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(zone,ww,zzero,ty,sm%desc_data,trans_,aux,info,init='Y') - - if (info /= psb_success_) exit - if (info == 0) call sm%apply_prol(ty,trans_,aux,info) - - end do - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - ! - ! Compute y = beta*y + alpha*ty (ty == K^(-1)*tx) - ! - call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - - else - - info = psb_err_iarg_neg_ - call psb_errpush(info,name,& - & i_err=(/itwo,sweeps,izero,izero,izero/)) - goto 9999 - - endif - - - if (.not.(4*isz <= size(work))) then - deallocate(aux,stat=info) - endif - if (info ==0) deallocate(ww,tx,ty,stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_as_smoother_apply diff --git a/mlprec/impl/smoother/mld_z_as_smoother_apply_vect.f90 b/mlprec/impl/smoother/mld_z_as_smoother_apply_vect.f90 deleted file mode 100644 index 53bf90f6..00000000 --- a/mlprec/impl/smoother/mld_z_as_smoother_apply_vect.f90 +++ /dev/null @@ -1,259 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_as_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,wv,info,init,initu) - use psb_base_mod - use mld_z_as_smoother, mld_protect_nam => mld_z_as_smoother_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_as_smoother_type), intent(inout) :: sm - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col, nrow_d, i - complex(psb_dpk_), pointer :: aux(:) - type(psb_z_vect_type) :: tx, ty, ww - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5) - character :: trans_, init_ - logical :: do_realloc_wv - character(len=20) :: name='z_as_smoother_apply_v', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = desc_data%get_context() - call psb_info(ictxt,me,np) - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - n_row = sm%desc_data%get_local_rows() - n_col = sm%desc_data%get_local_cols() - nrow_d = desc_data%get_local_rows() - isz = max(n_row,N_COL) - - if (4*isz <= size(work)) then - aux => work(:) - else - allocate(aux(4*isz),stat=info) - if (info /= psb_success_) then - call psb_errpush(psb_err_alloc_request_,name,& - & i_err=(/4*isz,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - endif - - if ((.not.sm%sv%is_iterative()).and.(sweeps == 1).and.(sm%novr==0)) then - ! - ! Shortcut: in this case there is nothing else to be done. - ! - call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,wv,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - else if (sweeps >= 0) then - ! - ! - ! Apply multiple sweeps of an AS solver - ! to compute an approximate solution of a linear system. - ! - ! - if (size(wv) < 3) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='invalid wv size in smoother_apply') - goto 9999 - end if - - ! - ! This is tricky. This smoother has a descriptor sm%desc_data - ! for an index space potentially different from - ! that of desc_data. Hence the size of the work vectors - ! could be wrong. We need to check and reallocate as needed. - ! - do_realloc_wv = (wv(1)%get_nrows() < sm%desc_data%get_local_cols()).or.& - & (wv(2)%get_nrows() < sm%desc_data%get_local_cols()).or.& - & (wv(3)%get_nrows() < sm%desc_data%get_local_cols()) - - if (do_realloc_wv) then - call psb_geasb(wv(1),sm%desc_data,info,scratch=.true.,mold=wv(2)%v) - call psb_geasb(wv(2),sm%desc_data,info,scratch=.true.,mold=wv(1)%v) - call psb_geasb(wv(3),sm%desc_data,info,scratch=.true.,mold=wv(1)%v) - end if - - associate(tx => wv(1), ty => wv(2), ww => wv(3)) - - ! Need to zero tx because of the apply_restr call. - call tx%zero() - ! - ! Unroll the first iteration and fold it inside SELECT CASE - ! this will save one SPMM when INIT=Z, and will be - ! significant when sweeps=1 (a common case) - ! - call psb_geaxpby(zone,x,zzero,tx,desc_data,info) - if (info == 0) call sm%apply_restr(tx,trans_,aux,info) - if (info == 0) call psb_geaxpby(zone,tx,zzero,ww,sm%desc_data,info) - - select case (init_) - case('Z') - call sm%sv%apply(zone,ww,zzero,ty,sm%desc_data,trans_,aux,wv(4:),info,init='Z') - - case('Y') - call psb_geaxpby(zone,y,zzero,ty,desc_data,info) - if (info == 0) call sm%apply_restr(ty,trans_,aux,info) - if (info == 0) call psb_spmm(-zone,sm%nd,ty,zone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - call sm%sv%apply(zone,ww,zzero,ty,desc_data,trans_,aux,wv(4:),info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(zone,initu,zzero,ty,desc_data,info) - if (info == 0) call sm%apply_restr(ty,trans_,aux,info) - if (info == 0) call psb_spmm(-zone,sm%nd,ty,zone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - call sm%sv%apply(zone,ww,zzero,ty,desc_data,trans_,aux,wv(4:),info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - if (info == 0) call sm%apply_prol(ty,trans_,aux,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the - ! block diagonal part and the remaining part of the local matrix - ! and Y(j) is the approximate solution at sweep j. - ! - if (info == 0) call psb_geaxpby(zone,tx,zzero,ww,sm%desc_data,info) - if (info == 0) call psb_spmm(-zone,sm%nd,ty,zone,ww,sm%desc_data,info,& - & work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(zone,ww,zzero,ty,sm%desc_data,trans_,aux,wv(4:),info,init='Y') - - if (info /= psb_success_) exit - if (info == 0) call sm%apply_prol(ty,trans_,aux,info) - - end do - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - ! - ! Compute y = beta*y + alpha*ty (ty == K^(-1)*tx) - ! - call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - end associate - - else - - info = psb_err_iarg_neg_ - call psb_errpush(info,name,& - & i_err=(/itwo,sweeps,izero,izero,izero/)) - goto 9999 - - endif - - - if (.not.(4*isz <= size(work))) then - deallocate(aux,stat=info) - endif - - if (info /= 0) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_as_smoother_apply_vect diff --git a/mlprec/impl/smoother/mld_z_as_smoother_bld.f90 b/mlprec/impl/smoother/mld_z_as_smoother_bld.f90 deleted file mode 100644 index b002c1af..00000000 --- a/mlprec/impl/smoother/mld_z_as_smoother_bld.f90 +++ /dev/null @@ -1,183 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_as_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_z_as_smoother, mld_protect_nam => mld_z_as_smoother_bld - Implicit None - - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local variables - type(psb_zspmat_type) :: blck, atmp - integer(psb_ipk_) :: n_row,n_col, nrow_a, nhalo, novr, data_ - complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='z_as_smoother_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - novr = sm%novr - if (novr < 0) then - info=psb_err_invalid_ovr_num_ - call psb_errpush(info,name,& - & i_err=(/novr,izero,izero,izero,izero,izero/)) - goto 9999 - endif - - if ((novr == 0).or.(np == 1)) then - call psb_cdcpy(desc_a,sm%desc_data,info) - If(debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' done cdcpy' - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_cdcpy' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Early return: P>=3 N_OVR=0' - call blck%csall(izero,izero,info,ione) - else - - ! - ! Build the auxiliary descriptor desc_p%matrix_data(psb_n_row_). - ! This is done by psb_cdbldext (interface to psb_cdovr), which is - ! independent of CSR, and has been placed in the tools directory - ! of PSBLAS, instead of the mlprec directory of MLD2P4, because it - ! might be used independently of the AS preconditioner, to build - ! a descriptor for an extended stencil in a PDE solver. - ! - call psb_cdbldext(a,desc_a,novr,sm%desc_data,info,extype=psb_ovt_asov_) - if(debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & ' From cdbldext _:',sm%desc_data%get_local_rows(),& - & sm%desc_data%get_local_cols() - - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_cdbldext' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'Before sphalo ' - - ! - ! Retrieve the remote sparse matrix rows required for the AS extended - ! matrix - data_ = psb_comm_ext_ - Call psb_sphalo(a,sm%desc_data,blck,info,data=data_,rowscale=.true.) - - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_sphalo' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if (debug_level >=psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),& - & 'After psb_sphalo ',& - & blck%get_nrows(), blck%get_nzeros() - - End if - if (info == psb_success_) & - & call sm%sv%build(a,sm%desc_data,info,& - & blck,amold=amold,vmold=vmold) - - nrow_a = a%get_nrows() - n_row = sm%desc_data%get_local_rows() - n_col = sm%desc_data%get_local_cols() - - if (info == psb_success_) call a%csclip(sm%nd,info,& - & jmin=nrow_a+1,rscale=.false.,cscale=.false.) - if (info == psb_success_) call blck%csclip(atmp,info,& - & jmin=nrow_a+1,rscale=.false.,cscale=.false.) - if (info == psb_success_) call psb_rwextd(n_row,sm%nd,info,b=atmp) - - if (info == psb_success_) then - if (present(amold)) then - call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - else - call sm%nd%cscnv(info,& - & type='csr',dupl=psb_dupl_add_) - end if - end if - if (info == psb_success_) then - if (present(imold)) then - call sm%desc_data%cnv(imold) - end if - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='clip & psb_spcnv csr 4') - goto 9999 - end if - sm%nd_nnz_tot = sm%nd%get_nzeros() - call psb_sum(ictxt,sm%nd_nnz_tot) - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_as_smoother_bld diff --git a/mlprec/impl/smoother/mld_z_as_smoother_check.f90 b/mlprec/impl/smoother/mld_z_as_smoother_check.f90 deleted file mode 100644 index 4fe4d6fe..00000000 --- a/mlprec/impl/smoother/mld_z_as_smoother_check.f90 +++ /dev/null @@ -1,78 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_as_smoother_check(sm,info) - - use psb_base_mod - use mld_z_as_smoother, mld_protect_nam => mld_z_as_smoother_check - - Implicit None - - ! Arguments - class(mld_z_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - Integer(Psb_ipk_) :: err_act - character(len=20) :: name='z_as_smoother_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - call mld_check_def(sm%restr,& - & 'Restrictor',psb_halo_,is_legal_restrict) - call mld_check_def(sm%prol,& - & 'Prolongator',psb_none_,is_legal_prolong) - call mld_check_def(sm%novr,& - & 'Overlap layers ',izero,is_int_non_negative) - - - if (allocated(sm%sv)) then - call sm%sv%check(info) - else - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_as_smoother_check diff --git a/mlprec/impl/smoother/mld_z_as_smoother_clear_data.f90 b/mlprec/impl/smoother/mld_z_as_smoother_clear_data.f90 deleted file mode 100644 index f5055e9b..00000000 --- a/mlprec/impl/smoother/mld_z_as_smoother_clear_data.f90 +++ /dev/null @@ -1,70 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_as_smoother_clear_data(sm,info) - - use psb_base_mod - use mld_z_as_smoother, mld_protect_name => mld_z_as_smoother_clear_data - Implicit None - ! Arguments - class(mld_z_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_as_smoother_clear_data' - - call psb_erractionsave(err_act) - - info = 0 - call sm%nd%free() - sm%nd_nnz_tot = 0 - call sm%desc_data%free(info) - if ((info==0).and.allocated(sm%sv)) then - call sm%sv%clear_data(info) - end if - if (info /= 0) then - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_as_smoother_clear_data diff --git a/mlprec/impl/smoother/mld_z_as_smoother_clone.f90 b/mlprec/impl/smoother/mld_z_as_smoother_clone.f90 deleted file mode 100644 index c192cdc6..00000000 --- a/mlprec/impl/smoother/mld_z_as_smoother_clone.f90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_as_smoother_clone(sm,smout,info) - - use psb_base_mod - use mld_z_as_smoother, mld_protect_name => mld_z_as_smoother_clone - - Implicit None - - ! Arguments - class(mld_z_as_smoother_type), intent(inout) :: sm - class(mld_z_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(smout)) then - call smout%free(info) - if (info == psb_success_) deallocate(smout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_z_as_smoother_type :: smout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(smo => smout) - type is (mld_z_as_smoother_type) - smo%novr = sm%novr - smo%restr = sm%restr - smo%prol = sm%prol - smo%nd_nnz_tot = sm%nd_nnz_tot - call sm%nd%clone(smo%nd,info) - if (info == psb_success_) & - & call sm%desc_data%clone(smo%desc_data,info) - if ((info==psb_success_).and.(allocated(sm%sv))) then - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == psb_success_) call sm%sv%clone(smo%sv,info) - end if - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_as_smoother_clone diff --git a/mlprec/impl/smoother/mld_z_as_smoother_clone_settings.f90 b/mlprec/impl/smoother/mld_z_as_smoother_clone_settings.f90 deleted file mode 100644 index 9a239b17..00000000 --- a/mlprec/impl/smoother/mld_z_as_smoother_clone_settings.f90 +++ /dev/null @@ -1,95 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! asd on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_as_smoother_clone_settings(sm,smout,info) - - use psb_base_mod - use mld_z_as_smoother, mld_protect_name => mld_z_as_smoother_clone_settings - Implicit None - ! Arguments - class(mld_z_as_smoother_type), intent(inout) :: sm - class(mld_z_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_as_smoother_clone_settings' - - call psb_erractionsave(err_act) - - info = psb_success_ - - select type(smout) - class is(mld_z_as_smoother_type) - smout%novr = sm%novr - smout%restr = sm%restr - smout%prol = sm%prol - if (allocated(smout%sv)) then - if (.not.same_type_as(sm%sv,smout%sv)) then - call smout%sv%free(info) - if (info == 0) deallocate(smout%sv,stat=info) - end if - end if - if (info /= 0) then - info = psb_err_internal_error_ - else - if (allocated(smout%sv)) then - if (same_type_as(sm%sv,smout%sv)) then - call sm%sv%clone_settings(smout%sv,info) - else - info = psb_err_internal_error_ - end if - else - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == 0) call sm%sv%clone_settings(smout%sv,info) - if (info /= 0) info = psb_err_internal_error_ - end if - end if - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_as_smoother_clone_settings diff --git a/mlprec/impl/smoother/mld_z_as_smoother_cnv.f90 b/mlprec/impl/smoother/mld_z_as_smoother_cnv.f90 deleted file mode 100644 index 21a7d4aa..00000000 --- a/mlprec/impl/smoother/mld_z_as_smoother_cnv.f90 +++ /dev/null @@ -1,96 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_as_smoother_cnv(sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_z_as_smoother, mld_protect_nam => mld_z_as_smoother_cnv - Implicit None - - ! Arguments - class(mld_z_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - ! Local variables - type(psb_dspmat_type) :: blck, atmp - integer(psb_ipk_) :: n_row,n_col, nrow_a, nhalo, novr, data_, nzeros - real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_as_smoother_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = sm%desc_data%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - if (allocated(sm%sv)) & - & call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) - - if (info == psb_success_) then - if (present(amold)) then - if (sm%nd%is_asb()) call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - end if - end if - if (info == psb_success_) then - if (present(imold)) then - call sm%desc_data%cnv(imold) - end if - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='clip & psb_spcnv csr 4') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_as_smoother_cnv diff --git a/mlprec/impl/smoother/mld_z_as_smoother_csetc.f90 b/mlprec/impl/smoother/mld_z_as_smoother_csetc.f90 deleted file mode 100644 index c1ae925e..00000000 --- a/mlprec/impl/smoother/mld_z_as_smoother_csetc.f90 +++ /dev/null @@ -1,78 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_as_smoother_csetc(sm,what,val,info,idx) - - use psb_base_mod - use mld_z_as_smoother, mld_protect_nam => mld_z_as_smoother_csetc - Implicit None - ! Arguments - class(mld_z_as_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='z_as_smoother_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - - - ival = sm%stringval(val) - select case(psb_toupper(what)) - case('SUB_RESTR') - sm%restr = ival - case('SUB_PROL') - sm%prol = ival - case default - call sm%mld_z_base_smoother_type%set(what,val,info,idx=idx) - end select - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info, name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_as_smoother_csetc diff --git a/mlprec/impl/smoother/mld_z_as_smoother_cseti.f90 b/mlprec/impl/smoother/mld_z_as_smoother_cseti.f90 deleted file mode 100644 index 03b47764..00000000 --- a/mlprec/impl/smoother/mld_z_as_smoother_cseti.f90 +++ /dev/null @@ -1,73 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_as_smoother_cseti(sm,what,val,info,idx) - - use psb_base_mod - use mld_z_as_smoother, mld_protect_nam => mld_z_as_smoother_cseti - Implicit None - - ! Arguments - class(mld_z_as_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_as_smoother_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) - case('SUB_OVR') - sm%novr = val - case('SUB_RESTR') - sm%restr = val - case('SUB_PROL') - sm%prol = val - case default - call sm%mld_z_base_smoother_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_as_smoother_cseti diff --git a/mlprec/impl/smoother/mld_z_as_smoother_dmp.f90 b/mlprec/impl/smoother/mld_z_as_smoother_dmp.f90 deleted file mode 100644 index 42ed5828..00000000 --- a/mlprec/impl/smoother/mld_z_as_smoother_dmp.f90 +++ /dev/null @@ -1,92 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_as_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - - use psb_base_mod - use mld_z_as_smoother, mld_protect_nam => mld_z_as_smoother_dmp - implicit none - class(mld_z_as_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: smoother_, global_num_ - ! len of prefix_ - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_smth_z" - end if - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(smoother)) then - smoother_ = smoother - else - smoother_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - if (global_num_) then - write(0,*) iam,' Warning: no global num with AS smoothers dump' - end if - if (smoother_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_nd.mtx' - if (sm%nd%is_asb()) & - & call sm%nd%print(fname,head=head) - end if - ! At base level do nothing for the smoother - if (allocated(sm%sv)) & - & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) - -end subroutine mld_z_as_smoother_dmp diff --git a/mlprec/impl/smoother/mld_z_as_smoother_free.f90 b/mlprec/impl/smoother/mld_z_as_smoother_free.f90 deleted file mode 100644 index 6745ff10..00000000 --- a/mlprec/impl/smoother/mld_z_as_smoother_free.f90 +++ /dev/null @@ -1,71 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_as_smoother_free(sm,info) - - use psb_base_mod - use mld_z_as_smoother, mld_protect_nam => mld_z_as_smoother_free - Implicit None - ! Arguments - class(mld_z_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_as_smoother_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - - - if (allocated(sm%sv)) then - call sm%sv%free(info) - if (info == psb_success_) deallocate(sm%sv,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - end if - call sm%nd%free() - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_as_smoother_free diff --git a/mlprec/impl/smoother/mld_z_as_smoother_prol_a.f90 b/mlprec/impl/smoother/mld_z_as_smoother_prol_a.f90 deleted file mode 100644 index f320b923..00000000 --- a/mlprec/impl/smoother/mld_z_as_smoother_prol_a.f90 +++ /dev/null @@ -1,149 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_as_smoother_prol_a(sm,x,trans,work,info,data) - use psb_base_mod - use mld_z_as_smoother, mld_protect_nam => mld_z_as_smoother_prol_a - implicit none - class(mld_z_as_smoother_type), intent(inout) :: sm - complex(psb_dpk_), intent(inout) :: x(:) - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - !Local - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ - character :: trans_ - character(len=20) :: name='z_as_smther_prol_a', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = sm%desc_data%get_context() - call psb_info(ictxt,me,np) - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - info = psb_err_iarg_invalid_i_ - call psb_errpush(info,name) - goto 9999 - end select - - if (present(data)) then - data_ = data - else - data_ = psb_comm_ext_ - end if - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - - select case(trans_) - case('N') - - select case (sm%prol) - - case(psb_none_) - ! - ! Would work anyway, but since it is supposed to do nothing ... - ! call psb_ovrl(x,sm%desc_data,info,& - ! & update=sm%prol,work=work) - - - case(psb_sum_,psb_avg_) - ! - ! Update the overlap of x - ! - call psb_ovrl(x,sm%desc_data,info,& - & update=sm%prol,work=work) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_prol_') - goto 9999 - end select - - case('T','C') - ! - ! With transpose, we have to do it here - ! - if (sm%restr == psb_halo_) then - call psb_ovrl(x,sm%desc_data,info,& - & update=psb_sum_,work=work) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - else if (sm%restr /= psb_none_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_restr_') - goto 9999 - end if - - case default - info=psb_err_iarg_invalid_i_ - int_err(1)=6 - ch_err(2:2)=trans - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_as_smoother_prol_a - - diff --git a/mlprec/impl/smoother/mld_z_as_smoother_prol_v.f90 b/mlprec/impl/smoother/mld_z_as_smoother_prol_v.f90 deleted file mode 100644 index 613c2005..00000000 --- a/mlprec/impl/smoother/mld_z_as_smoother_prol_v.f90 +++ /dev/null @@ -1,149 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_as_smoother_prol_v(sm,x,trans,work,info,data) - use psb_base_mod - use mld_z_as_smoother, mld_protect_nam => mld_z_as_smoother_prol_v - implicit none - class(mld_z_as_smoother_type), intent(inout) :: sm - type(psb_z_vect_type),intent(inout) :: x - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - !Local - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ - character :: trans_ - character(len=20) :: name='z_as_smther_prol_v', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = sm%desc_data%get_context() - call psb_info(ictxt,me,np) - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - info = psb_err_iarg_invalid_i_ - call psb_errpush(info,name) - goto 9999 - end select - - if (present(data)) then - data_ = data - else - data_ = psb_comm_ext_ - end if - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - - select case(trans_) - case('N') - - select case (sm%prol) - - case(psb_none_) - ! - ! Would work anyway, but since it is supposed to do nothing ... - ! call psb_ovrl(x,sm%desc_data,info,& - ! & update=sm%prol,work=work) - - - case(psb_sum_,psb_avg_) - ! - ! Update the overlap of x - ! - call psb_ovrl(x,sm%desc_data,info,& - & update=sm%prol,work=work) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_prol_') - goto 9999 - end select - - case('T','C') - ! - ! With transpose, we have to do it here - ! - if (sm%restr == psb_halo_) then - call psb_ovrl(x,sm%desc_data,info,& - & update=psb_sum_,work=work) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - else if (sm%restr /= psb_none_) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_restr_') - goto 9999 - end if - - case default - info=psb_err_iarg_invalid_i_ - int_err(1)=6 - ch_err(2:2)=trans - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_as_smoother_prol_v - - diff --git a/mlprec/impl/smoother/mld_z_as_smoother_restr_a.f90 b/mlprec/impl/smoother/mld_z_as_smoother_restr_a.f90 deleted file mode 100644 index c56d72a5..00000000 --- a/mlprec/impl/smoother/mld_z_as_smoother_restr_a.f90 +++ /dev/null @@ -1,168 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_as_smoother_restr_a(sm,x,trans,work,info,data) - use psb_base_mod - use mld_z_as_smoother, mld_protect_nam => mld_z_as_smoother_restr_a - implicit none - class(mld_z_as_smoother_type), intent(inout) :: sm - complex(psb_dpk_), intent(inout) :: x(:) - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - !Local - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ - character :: trans_ - character(len=20) :: name='z_as_smther_restr_a', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = sm%desc_data%get_context() - call psb_info(ictxt,me,np) - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - info = psb_err_iarg_invalid_i_ - call psb_errpush(info,name) - goto 9999 - end select - - if (present(data)) then - data_ = data - else - data_ = psb_comm_ext_ - end if - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - select case(trans_) - case('N') - ! - ! Get the overlap entries x - ! - if (sm%restr == psb_halo_) then - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - else if (sm%restr /= psb_none_) then - call psb_errpush(psb_err_internal_error_,name,& - &a_err='Invalid mld_sub_restr_') - goto 9999 - end if - - - case('T','C') - ! - ! With transpose, we have to do it here - ! - - select case (sm%prol) - - case(psb_none_) - ! - ! Do nothing - - case(psb_sum_) - ! - ! The transpose of sum is halo - ! - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - - case(psb_avg_) - ! - ! Tricky one: first we have to scale the overlap entries, - ! which we can do by assignind mode=0, i.e. no communication - ! (hence only scaling), then we do the halo - ! - call psb_ovrl(x,sm%desc_data,info,& - & update=psb_avg_,work=work,mode=izero) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_prol_') - goto 9999 - end select - - - case default - info=psb_err_iarg_invalid_i_ - int_err(1)=6 - ch_err(2:2)=trans - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_as_smoother_restr_a - - diff --git a/mlprec/impl/smoother/mld_z_as_smoother_restr_v.f90 b/mlprec/impl/smoother/mld_z_as_smoother_restr_v.f90 deleted file mode 100644 index 154c0572..00000000 --- a/mlprec/impl/smoother/mld_z_as_smoother_restr_v.f90 +++ /dev/null @@ -1,168 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_as_smoother_restr_v(sm,x,trans,work,info,data) - use psb_base_mod - use mld_z_as_smoother, mld_protect_nam => mld_z_as_smoother_restr_v - implicit none - class(mld_z_as_smoother_type), intent(inout) :: sm - type(psb_z_vect_type),intent(inout) :: x - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - !Local - integer(psb_ipk_) :: ictxt,np,me, err_act,isz,int_err(5), data_ - character :: trans_ - character(len=20) :: name='z_as_smther_restr_v', ch_err - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = sm%desc_data%get_context() - call psb_info(ictxt,me,np) - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - info = psb_err_iarg_invalid_i_ - call psb_errpush(info,name) - goto 9999 - end select - - if (present(data)) then - data_ = data - else - data_ = psb_comm_ext_ - end if - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - - select case(trans_) - case('N') - ! - ! Get the overlap entries x - ! - if (sm%restr == psb_halo_) then - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - else if (sm%restr /= psb_none_) then - call psb_errpush(psb_err_internal_error_,name,& - &a_err='Invalid mld_sub_restr_') - goto 9999 - end if - - - case('T','C') - ! - ! With transpose, we have to do it here - ! - - select case (sm%prol) - - case(psb_none_) - ! - ! Do nothing - - case(psb_sum_) - ! - ! The transpose of sum is halo - ! - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - - case(psb_avg_) - ! - ! Tricky one: first we have to scale the overlap entries, - ! which we can do by assignind mode=0, i.e. no communication - ! (hence only scaling), then we do the halo - ! - call psb_ovrl(x,sm%desc_data,info,& - & update=psb_avg_,work=work,mode=izero) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ovrl' - goto 9999 - end if - call psb_halo(x,sm%desc_data,info,work=work,data=data_) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_halo' - goto 9999 - end if - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid mld_sub_prol_') - goto 9999 - end select - - - case default - info=psb_err_iarg_invalid_i_ - int_err(1)=6 - ch_err(2:2)=trans - goto 9999 - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_as_smoother_restr_v - - diff --git a/mlprec/impl/smoother/mld_z_base_smoother_apply.f90 b/mlprec/impl/smoother/mld_z_base_smoother_apply.f90 deleted file mode 100644 index b0013a85..00000000 --- a/mlprec/impl/smoother/mld_z_base_smoother_apply.f90 +++ /dev/null @@ -1,87 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_smoother_apply(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,info,init,initu) - use psb_base_mod - use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_base_smoother_type), intent(inout) :: sm - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_smoother_apply' - - call psb_erractionsave(err_act) - info = psb_success_ - if (sweeps == 0) then - - ! - ! K^0 = I - ! zero sweeps of any smoother is just the identity. - ! - call psb_geaxpby(alpha,x,beta,y,desc_data,info) - - else - if (allocated(sm%sv)) then - call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,info,init=init, initu=initu) - else - info = 1121 - endif - end if - if (info /= psb_success_) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_base_smoother_apply diff --git a/mlprec/impl/smoother/mld_z_base_smoother_apply_vect.f90 b/mlprec/impl/smoother/mld_z_base_smoother_apply_vect.f90 deleted file mode 100644 index dc8c7578..00000000 --- a/mlprec/impl/smoother/mld_z_base_smoother_apply_vect.f90 +++ /dev/null @@ -1,88 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,wv,info,init,initu) - use psb_base_mod - use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_base_smoother_type), intent(inout) :: sm - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - ! - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_smoother_apply' - - call psb_erractionsave(err_act) - info = psb_success_ - if (sweeps == 0) then - - ! - ! K^0 = I - ! zero sweeps of any smoother is just the identity. - ! - call psb_geaxpby(alpha,x,beta,y,desc_data,info) - - else - if (allocated(sm%sv)) then - call sm%sv%apply(alpha,x,beta,y,desc_data,trans,work,wv,info,init=init, initu=initu) - else - info = 1121 - endif - end if - if (info /= psb_success_) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_base_smoother_apply_vect diff --git a/mlprec/impl/smoother/mld_z_base_smoother_bld.f90 b/mlprec/impl/smoother/mld_z_base_smoother_bld.f90 deleted file mode 100644 index 52f061aa..00000000 --- a/mlprec/impl/smoother/mld_z_base_smoother_bld.f90 +++ /dev/null @@ -1,72 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_bld - Implicit None - - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_smoother_bld' - - call psb_erractionsave(err_act) - - info = psb_success_ - if (allocated(sm%sv)) then - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - else - info = 1121 - call psb_errpush(info,name) - endif - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_smoother_bld diff --git a/mlprec/impl/smoother/mld_z_base_smoother_check.f90 b/mlprec/impl/smoother/mld_z_base_smoother_check.f90 deleted file mode 100644 index ceb2fe37..00000000 --- a/mlprec/impl/smoother/mld_z_base_smoother_check.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_smoother_check(sm,info) - - use psb_base_mod - use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_check - Implicit None - - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - Integer(Psb_ipk_) :: err_act - character(len=20) :: name='z_base_smoother_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%check(info) - else - info=3111 - call psb_errpush(info,name) - goto 9999 - end if - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_smoother_check diff --git a/mlprec/impl/smoother/mld_z_base_smoother_clear_data.f90 b/mlprec/impl/smoother/mld_z_base_smoother_clear_data.f90 deleted file mode 100644 index 0a9b36b7..00000000 --- a/mlprec/impl/smoother/mld_z_base_smoother_clear_data.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_smoother_clear_data(sm,info) - - use psb_base_mod - use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_clear_data - Implicit None - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_smoother_clear_data' - - call psb_erractionsave(err_act) - - info = 0 - if (allocated(sm%sv)) then - call sm%sv%clear_data(info) - if (info /= 0) then - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_smoother_clear_data diff --git a/mlprec/impl/smoother/mld_z_base_smoother_clone.f90 b/mlprec/impl/smoother/mld_z_base_smoother_clone.f90 deleted file mode 100644 index cd7f16a2..00000000 --- a/mlprec/impl/smoother/mld_z_base_smoother_clone.f90 +++ /dev/null @@ -1,62 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_smoother_clone(sm,smout,info) - - use psb_base_mod - use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_clone - Implicit None - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - class(mld_z_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_smoother_clone' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_smoother_clone diff --git a/mlprec/impl/smoother/mld_z_base_smoother_clone_settings.f90 b/mlprec/impl/smoother/mld_z_base_smoother_clone_settings.f90 deleted file mode 100644 index 7accab8e..00000000 --- a/mlprec/impl/smoother/mld_z_base_smoother_clone_settings.f90 +++ /dev/null @@ -1,89 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_smoother_clone_settings(sm,smout,info) - - use psb_base_mod - use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_clone_settings - Implicit None - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - class(mld_z_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_smoother_clone_settings' - - call psb_erractionsave(err_act) - - info=psb_success_ - if (same_type_as(sm,smout)) then - if (allocated(smout%sv)) then - if (.not.same_type_as(sm%sv,smout%sv)) then - call smout%sv%free(info) - if (info == 0) deallocate(smout%sv,stat=info) - end if - end if - if (info /= 0) then - info = psb_err_internal_error_ - else - if (allocated(smout%sv)) then - if (same_type_as(sm%sv,smout%sv)) then - call sm%sv%clone_settings(smout%sv,info) - else - info = psb_err_internal_error_ - end if - else - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == 0) call sm%sv%clone_settings(smout%sv,info) - if (info /= 0) info = psb_err_internal_error_ - end if - end if - else - info = psb_err_internal_error_ - end if - if (info /= 0) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_smoother_clone_settings diff --git a/mlprec/impl/smoother/mld_z_base_smoother_cnv.f90 b/mlprec/impl/smoother/mld_z_base_smoother_cnv.f90 deleted file mode 100644 index b0a006bf..00000000 --- a/mlprec/impl/smoother/mld_z_base_smoother_cnv.f90 +++ /dev/null @@ -1,70 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_smoother_cnv(sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_cnv - Implicit None - - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_smoother_cnv' - - call psb_erractionsave(err_act) - - info = psb_success_ - if (allocated(sm%sv)) then - call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) - else - info = 1121 - call psb_errpush(info,name) - endif - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_smoother_cnv diff --git a/mlprec/impl/smoother/mld_z_base_smoother_csetc.f90 b/mlprec/impl/smoother/mld_z_base_smoother_csetc.f90 deleted file mode 100644 index 460d4023..00000000 --- a/mlprec/impl/smoother/mld_z_base_smoother_csetc.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_smoother_csetc(sm,what,val,info,idx) - - use psb_base_mod - use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_csetc - Implicit None - - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='z_base_smoother_csetc' - - call psb_erractionsave(err_act) - - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%set(what,val,info,idx=idx) - end if - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_smoother_csetc diff --git a/mlprec/impl/smoother/mld_z_base_smoother_cseti.f90 b/mlprec/impl/smoother/mld_z_base_smoother_cseti.f90 deleted file mode 100644 index f431efd6..00000000 --- a/mlprec/impl/smoother/mld_z_base_smoother_cseti.f90 +++ /dev/null @@ -1,65 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_smoother_cseti(sm,what,val,info,idx) - - use psb_base_mod - use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_cseti - Implicit None - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_smoother_cseti' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%set(what,val,info,idx=idx) - end if - if (info /= psb_success_) goto 9999 - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_smoother_cseti diff --git a/mlprec/impl/smoother/mld_z_base_smoother_csetr.f90 b/mlprec/impl/smoother/mld_z_base_smoother_csetr.f90 deleted file mode 100644 index 07be9ab8..00000000 --- a/mlprec/impl/smoother/mld_z_base_smoother_csetr.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_smoother_csetr(sm,what,val,info,idx) - - use psb_base_mod - use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_csetr - Implicit None - - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_smoother_csetr' - - call psb_erractionsave(err_act) - - - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%set(what,val,info,idx=idx) - end if - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_smoother_csetr diff --git a/mlprec/impl/smoother/mld_z_base_smoother_descr.f90 b/mlprec/impl/smoother/mld_z_base_smoother_descr.f90 deleted file mode 100644 index 589485db..00000000 --- a/mlprec/impl/smoother/mld_z_base_smoother_descr.f90 +++ /dev/null @@ -1,101 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_smoother_descr(sm,info,iout,coarse) - - use psb_base_mod - use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_descr - use mld_z_id_solver - Implicit None - - ! Arguments - class(mld_z_base_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt, me, np - character(len=20), parameter :: name='mld_z_base_smoother_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse_ - - - call psb_erractionsave(err_act) - info = psb_success_ - - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - end if - - if (coarse_) then - if (allocated(sm%sv)) call sm%sv%descr(info,iout,coarse) - else - if (allocated(sm%sv)) then - select type (sv => sm%sv) - class is (mld_z_id_solver_type) - write(iout_,*) 'No preconditioner/smoother' - class default - write(iout_,*) 'Decoupled preconditioner/smoother with local solver' - call sm%sv%descr(info,iout,coarse) - end select - else - write(iout_,*) 'No preconditioner/smoother' - end if - end if - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info,name,a_err='Local solver') - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_smoother_descr diff --git a/mlprec/impl/smoother/mld_z_base_smoother_dmp.f90 b/mlprec/impl/smoother/mld_z_base_smoother_dmp.f90 deleted file mode 100644 index e17246d5..00000000 --- a/mlprec/impl/smoother/mld_z_base_smoother_dmp.f90 +++ /dev/null @@ -1,85 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - - use psb_base_mod - use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_dmp - implicit none - class(mld_z_base_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: smoother_, global_num_ - ! len of prefix_ - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_smth_z" - end if - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - if (present(smoother)) then - smoother_ = smoother - else - smoother_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - ! At base level do nothing for the smoother - if (allocated(sm%sv)) & - & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) - -end subroutine mld_z_base_smoother_dmp diff --git a/mlprec/impl/smoother/mld_z_base_smoother_free.f90 b/mlprec/impl/smoother/mld_z_base_smoother_free.f90 deleted file mode 100644 index 4e0bc66b..00000000 --- a/mlprec/impl/smoother/mld_z_base_smoother_free.f90 +++ /dev/null @@ -1,68 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_smoother_free(sm,info) - - use psb_base_mod - use mld_z_base_smoother_mod, mld_protect_name => mld_z_base_smoother_free - Implicit None - - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_smoother_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sm%sv)) then - call sm%sv%free(info) - if (info == psb_success_) deallocate(sm%sv,stat=info) - end if - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_smoother_free diff --git a/mlprec/impl/smoother/mld_z_jac_smoother_apply.f90 b/mlprec/impl/smoother/mld_z_jac_smoother_apply.f90 deleted file mode 100644 index 3b507f5f..00000000 --- a/mlprec/impl/smoother/mld_z_jac_smoother_apply.f90 +++ /dev/null @@ -1,273 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_jac_smoother_apply(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,info,init,initu) - use psb_base_mod - use mld_z_jac_smoother, mld_protect_name => mld_z_jac_smoother_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_jac_smoother_type), intent(inout) :: sm - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col - complex(psb_dpk_), allocatable :: tx(:),ty(:) - complex(psb_dpk_), pointer :: aux(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='z_jac_smoother_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = desc_data%get_context() - call psb_info(ictxt,me,np) - - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (4*n_col <= size(work)) then - aux => work(:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - endif - - if ((.not.sm%sv%is_iterative()).and.((sweeps == 1).or.(sm%nd_nnz_tot==0))) then - ! if .not.sv%is_iterative, there's no need to pass init - call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - else if (sweeps >= 0) then - if (associated(sm%pa)) then - ! - ! This means we are dealing with a pure Jacobi smoother/solver. - ! - call psb_geasb(tx,desc_data,info) - call psb_geasb(ty,desc_data,info) - select case (init_) - case('Z') - - call sm%sv%apply(zone,x,zzero,ty,desc_data,trans_,aux,info,init='Z') - - case('Y') - call psb_geaxpby(zone,x,zzero,tx,desc_data,info) - call psb_geaxpby(zone,y,zzero,ty,desc_data,info) - call psb_spmm(-zone,sm%pa,ty,zone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(zone,x,zzero,tx,desc_data,info) - call psb_geaxpby(zone,initu,zzero,ty,desc_data,info) - call psb_spmm(-zone,sm%pa,ty,zone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = Y(j)+ D^(-1)*(X-A*Y(j)), - ! where is the diagonal and A the matrix. - ! - call psb_geaxpby(zone,x,zzero,tx,desc_data,info) - call psb_spmm(-zone,sm%pa,ty,zone,tx,desc_data,info,work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(zone,tx,zone,ty,desc_data,trans_,aux,info,init='Y') - - if (info /= psb_success_) exit - end do - - - if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - else - ! - ! - ! Apply multiple sweeps of a block-Jacobi solver - ! to compute an approximate solution of a linear system. - ! - ! - call psb_geasb(tx,desc_data,info) - call psb_geasb(ty,desc_data,info) - - ! - ! Unroll the first iteration and fold it inside SELECT CASE - ! this will save one AXPBY and one SPMM when INIT=Z, and will be - ! significant when sweeps=1 (a common case) - ! - select case (init_) - case('Z') - - call sm%sv%apply(zone,x,zzero,ty,desc_data,trans_,aux,info,init='Z') - - case('Y') - call psb_geaxpby(zone,x,zzero,tx,desc_data,info) - call psb_geaxpby(zone,y,zzero,ty,desc_data,info) - call psb_spmm(-zone,sm%nd,ty,zone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(zone,x,zzero,tx,desc_data,info) - call psb_geaxpby(zone,initu,zzero,ty,desc_data,info) - call psb_spmm(-zone,sm%nd,ty,zone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the - ! block diagonal part and the remaining part of the local matrix - ! and Y(j) is the approximate solution at sweep j. - ! - call psb_geaxpby(zone,x,zzero,tx,desc_data,info) - call psb_spmm(-zone,sm%nd,ty,zone,tx,desc_data,info,work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,info,init='Y') - - if (info /= psb_success_) exit - end do - - if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - end if - - deallocate(tx,ty,stat=info) - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='final cleanup with Jacobi sweeps > 1') - goto 9999 - end if - - else - - info = psb_err_iarg_neg_ - call psb_errpush(info,name,& - & i_err=(/itwo,sweeps,izero,izero,izero/)) - goto 9999 - - endif - - if (.not.(4*n_col <= size(work))) then - deallocate(aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_jac_smoother_apply diff --git a/mlprec/impl/smoother/mld_z_jac_smoother_apply_vect.f90 b/mlprec/impl/smoother/mld_z_jac_smoother_apply_vect.f90 deleted file mode 100644 index 2da1aa53..00000000 --- a/mlprec/impl/smoother/mld_z_jac_smoother_apply_vect.f90 +++ /dev/null @@ -1,320 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_jac_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,wv,info,init,initu) - - use psb_base_mod - use mld_z_diag_solver - use psb_base_krylov_conv_mod, only : log_conv - use mld_z_jac_smoother, mld_protect_name => mld_z_jac_smoother_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_jac_smoother_type), intent(inout) :: sm - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - ! - integer(psb_ipk_) :: n_row,n_col - type(psb_z_vect_type) :: tx, ty, r - complex(psb_dpk_), pointer :: aux(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - real(psb_dpk_) :: res, resdenum - character(len=20) :: name='z_jac_smoother_apply_v' - - call psb_erractionsave(err_act) - - info = psb_success_ - ictxt = desc_data%get_context() - call psb_info(ictxt,me,np) - - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (.not.allocated(sm%sv)) then - info = 1121 - call psb_errpush(info,name) - goto 9999 - end if - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (4*n_col <= size(work)) then - aux => work(:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - endif - - if(sm%checkres) then - call psb_geall(r,desc_data,info) - call psb_geasb(r,desc_data,info) - resdenum = psb_genrm2(x,desc_data,info) - end if - - if ((.not.sm%sv%is_iterative()).and.((sweeps == 1).or.(sm%nd_nnz_tot==0))) then - ! if .not.sv%is_iterative, there's no need to pass init - call sm%sv%apply(alpha,x,beta,y,desc_data,trans_,aux,wv,info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in sub_aply Jacobi Sweeps = 1') - goto 9999 - endif - - else if (sweeps >= 0) then - select type (smsv => sm%sv) - class is (mld_z_diag_solver_type) - ! - ! This means we are dealing with a pure Jacobi smoother/solver. - ! - associate(tx => wv(1), ty => wv(2)) - select case (init_) - case('Z') - - call sm%sv%apply(zone,x,zzero,ty,desc_data,trans_,aux,wv(3:),info,init='Z') - - case('Y') - call psb_geaxpby(zone,x,zzero,tx,desc_data,info) - call psb_geaxpby(zone,y,zzero,ty,desc_data,info) - call psb_spmm(-zone,sm%pa,ty,zone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(zone,x,zzero,tx,desc_data,info) - call psb_geaxpby(zone,initu,zzero,ty,desc_data,info) - call psb_spmm(-zone,sm%pa,ty,zone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = Y(j)+ D^(-1)*(X-A*Y(j)), - ! where is the diagonal and A the matrix. - ! - call psb_geaxpby(zone,x,zzero,tx,desc_data,info) - call psb_spmm(-zone,sm%pa,ty,zone,tx,desc_data,info,work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(zone,tx,zone,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - if (info /= psb_success_) exit - - if ( sm%checkres.and.(mod(i,sm%checkiter) == 0) ) then - call psb_geaxpby(zone,x,zzero,r,r,desc_data,info) - call psb_spmm(-zone,sm%pa,ty,zone,r,desc_data,info) - res = psb_genrm2(r,desc_data,info) - if( sm%printres ) then - call log_conv("BJAC",me,i,sm%printiter,res,resdenum,sm%tol) - end if - if ( res < sm%tol*resdenum ) then - if( (sm%printres).and.(mod(sm%printiter,sm%checkiter)/=0) ) & - & call log_conv("BJAC",me,i,1,res,resdenum,sm%tol) - exit - end if - end if - - end do - - - if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - - end associate - - class default - ! - ! - ! Apply multiple sweeps of a block-Jacobi solver - ! to compute an approximate solution of a linear system. - ! - ! - if (size(wv) < 2) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size in smoother_apply') - goto 9999 - end if - associate(tx => wv(1), ty => wv(2)) - - ! - ! Unroll the first iteration and fold it inside SELECT CASE - ! this will save one AXPBY and one SPMM when INIT=Z, and will be - ! significant when sweeps=1 (a common case) - ! - select case (init_) - case('Z') - - call sm%sv%apply(zone,x,zzero,ty,desc_data,trans_,aux,wv(3:),info,init='Z') - - case('Y') - call psb_geaxpby(zone,x,zzero,tx,desc_data,info) - call psb_geaxpby(zone,y,zzero,ty,desc_data,info) - call psb_spmm(-zone,sm%nd,ty,zone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(zone,x,zzero,tx,desc_data,info) - call psb_geaxpby(zone,initu,zzero,ty,desc_data,info) - call psb_spmm(-zone,sm%nd,ty,zone,tx,desc_data,info,work=aux,trans=trans_) - call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - do i=1, sweeps-1 - ! - ! Compute Y(j+1) = D^(-1)*(X-ND*Y(j)), where D and ND are the - ! block diagonal part and the remaining part of the local matrix - ! and Y(j) is the approximate solution at sweep j. - ! - call psb_geaxpby(zone,x,zzero,tx,desc_data,info) - call psb_spmm(-zone,sm%nd,ty,zone,tx,desc_data,info,work=aux,trans=trans_) - - if (info /= psb_success_) exit - - call sm%sv%apply(zone,tx,zzero,ty,desc_data,trans_,aux,wv(3:),info,init='Y') - - if (info /= psb_success_) exit - - if ( sm%checkres.and.(mod(i,sm%checkiter) == 0) ) then - call psb_geaxpby(zone,x,zzero,r,r,desc_data,info) - call psb_spmm(-zone,sm%pa,ty,zone,r,desc_data,info) - res = psb_genrm2(r,desc_data,info) - if( sm%printres ) then - call log_conv("BJAC",me,i,sm%printiter,res,resdenum,sm%tol) - end if - if (res < sm%tol*resdenum ) then - if( (sm%printres).and.( mod(sm%printiter,sm%checkiter) /=0 ) ) & - & call log_conv("BJAC",me,i,1,res,resdenum,sm%tol) - exit - end if - end if - - end do - - if (info == psb_success_) call psb_geaxpby(alpha,ty,beta,y,desc_data,info) - - if (info /= psb_success_) then - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='subsolve with Jacobi sweeps > 1') - goto 9999 - end if - - end associate - end select - - else - - info = psb_err_iarg_neg_ - call psb_errpush(info,name,& - & i_err=(/itwo,sweeps,izero,izero,izero/)) - goto 9999 - - endif - - if (.not.(4*n_col <= size(work))) then - deallocate(aux) - endif - - if(sm%checkres) then - call psb_gefree(r,desc_data,info) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_jac_smoother_apply_vect diff --git a/mlprec/impl/smoother/mld_z_jac_smoother_bld.f90 b/mlprec/impl/smoother/mld_z_jac_smoother_bld.f90 deleted file mode 100644 index 3852f032..00000000 --- a/mlprec/impl/smoother/mld_z_jac_smoother_bld.f90 +++ /dev/null @@ -1,127 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_z_diag_solver - use mld_z_jac_smoother, mld_protect_name => mld_z_jac_smoother_bld - Implicit None - - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - type(psb_zspmat_type) :: tmpa - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota, nzeros - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='z_jac_smoother_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - n_col = desc_a%get_local_cols() - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - - if( sm%checkres ) sm%pa => a - - select type (smsv => sm%sv) - class is (mld_z_diag_solver_type) - call sm%nd%free() - sm%pa => a - sm%nd_nnz_tot = nztota - call psb_sum(ictxt,sm%nd_nnz_tot) - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - - class default - if (smsv%is_global()) then - ! Do not put anything into SM%ND since the solver - ! is acting globally. - call sm%nd%free() - sm%nd_nnz_tot = 0 - call psb_sum(ictxt,sm%nd_nnz_tot) - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - else - call a%csclip(sm%nd,info,& - & jmin=nrow_a+1,rscale=.false.,cscale=.false.) - if (info == psb_success_) then - if (present(amold)) then - call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - else - call sm%nd%cscnv(info,& - & type='csr',dupl=psb_dupl_add_) - endif - end if - sm%nd_nnz_tot = sm%nd%get_nzeros() - call psb_sum(ictxt,sm%nd_nnz_tot) - call a%csclip(tmpa,info,& - & jmax=nrow_a,rscale=.false.,cscale=.false.) - call sm%sv%build(tmpa,desc_a,info,amold=amold,vmold=vmold) - end if - end select - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='clip & psb_spcnv csr 4') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_jac_smoother_bld diff --git a/mlprec/impl/smoother/mld_z_jac_smoother_clear_data.f90 b/mlprec/impl/smoother/mld_z_jac_smoother_clear_data.f90 deleted file mode 100644 index 9ce9e070..00000000 --- a/mlprec/impl/smoother/mld_z_jac_smoother_clear_data.f90 +++ /dev/null @@ -1,70 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_jac_smoother_clear_data(sm,info) - - use psb_base_mod - use mld_z_jac_smoother, mld_protect_name => mld_z_jac_smoother_clear_data - Implicit None - ! Arguments - class(mld_z_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_jac_smoother_clear_data' - - call psb_erractionsave(err_act) - - info = 0 - call sm%nd%free() - sm%nd_nnz_tot = 0 - sm%pa => null() - if ((info==0).and.allocated(sm%sv)) then - call sm%sv%clear_data(info) - end if - if (info /= 0) then - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_jac_smoother_clear_data diff --git a/mlprec/impl/smoother/mld_z_jac_smoother_clone.f90 b/mlprec/impl/smoother/mld_z_jac_smoother_clone.f90 deleted file mode 100644 index 5e2b54f8..00000000 --- a/mlprec/impl/smoother/mld_z_jac_smoother_clone.f90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_jac_smoother_clone(sm,smout,info) - - use psb_base_mod - use mld_z_jac_smoother, mld_protect_name => mld_z_jac_smoother_clone - - Implicit None - - ! Arguments - class(mld_z_jac_smoother_type), intent(inout) :: sm - class(mld_z_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(smout)) then - call smout%free(info) - if (info == psb_success_) deallocate(smout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_z_jac_smoother_type :: smout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(smo => smout) - type is (mld_z_jac_smoother_type) - smo%nd_nnz_tot = sm%nd_nnz_tot - smo%checkres = sm%checkres - smo%printres = sm%printres - smo%checkiter = sm%checkiter - smo%printiter = sm%printiter - smo%tol = sm%tol - call sm%nd%clone(smo%nd,info) - if ((info==psb_success_).and.(allocated(sm%sv))) then - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == psb_success_) call sm%sv%clone(smo%sv,info) - end if - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_jac_smoother_clone diff --git a/mlprec/impl/smoother/mld_z_jac_smoother_clone_settings.f90 b/mlprec/impl/smoother/mld_z_jac_smoother_clone_settings.f90 deleted file mode 100644 index 416676a6..00000000 --- a/mlprec/impl/smoother/mld_z_jac_smoother_clone_settings.f90 +++ /dev/null @@ -1,101 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! asd on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_jac_smoother_clone_settings(sm,smout,info) - - use psb_base_mod - use mld_z_jac_smoother, mld_protect_name => mld_z_jac_smoother_clone_settings - Implicit None - ! Arguments - class(mld_z_jac_smoother_type), intent(inout) :: sm - class(mld_z_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_jac_smoother_clone_settings' - - call psb_erractionsave(err_act) - - info = psb_success_ - - select type(smout) - class is(mld_z_jac_smoother_type) - - smout%pa => null() - smout%nd_nnz_tot = 0 - smout%checkres = sm%checkres - smout%printres = sm%printres - smout%checkiter = sm%checkiter - smout%printiter = sm%printiter - smout%tol = sm%tol - - if (allocated(smout%sv)) then - if (.not.same_type_as(sm%sv,smout%sv)) then - call smout%sv%free(info) - if (info == 0) deallocate(smout%sv,stat=info) - end if - end if - if (info /= 0) then - info = psb_err_internal_error_ - else - if (allocated(smout%sv)) then - if (same_type_as(sm%sv,smout%sv)) then - call sm%sv%clone_settings(smout%sv,info) - else - info = psb_err_internal_error_ - end if - else - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == 0) call sm%sv%clone_settings(smout%sv,info) - if (info /= 0) info = psb_err_internal_error_ - end if - end if - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) then - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_jac_smoother_clone_settings diff --git a/mlprec/impl/smoother/mld_z_jac_smoother_cnv.f90 b/mlprec/impl/smoother/mld_z_jac_smoother_cnv.f90 deleted file mode 100644 index f5a5c60b..00000000 --- a/mlprec/impl/smoother/mld_z_jac_smoother_cnv.f90 +++ /dev/null @@ -1,90 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_jac_smoother_cnv(sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_z_diag_solver - use mld_z_jac_smoother, mld_protect_name => mld_z_jac_smoother_cnv - Implicit None - - ! Arguments - class(mld_z_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_jac_smoother_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - - if (info == psb_success_) then - if (sm%nd%is_asb()) then - if (present(amold)) then - call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - else - call sm%nd%cscnv(info,& - & type='csr',dupl=psb_dupl_add_) - endif - end if - end if - - if (info == psb_success_) then - if (allocated(sm%sv)) & - & call sm%sv%cnv(info,amold=amold,vmold=vmold,imold=imold) - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='solver cnv') - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_jac_smoother_cnv diff --git a/mlprec/impl/smoother/mld_z_jac_smoother_csetc.f90 b/mlprec/impl/smoother/mld_z_jac_smoother_csetc.f90 deleted file mode 100644 index 9e9cc0f9..00000000 --- a/mlprec/impl/smoother/mld_z_jac_smoother_csetc.f90 +++ /dev/null @@ -1,90 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_jac_smoother_csetc(sm,what,val,info,idx) - - use psb_base_mod - use mld_z_jac_smoother, mld_protect_nam => mld_z_jac_smoother_csetc - Implicit None - ! Arguments - class(mld_z_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='z_jac_smoother_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(trim(what))) - case('SMOOTHER_STOP') - select case(psb_toupper(trim(val))) - case('T','TRUE') - sm%checkres = .true. - case('F','FALSE') - sm%checkres = .false. - case default - write(0,*) 'Unknown value for smoother_stop : "',psb_toupper(trim(val)),'"' - end select - case('SMOOTHER_TRACE') - select case(psb_toupper(trim(val))) - case('T','TRUE') - sm%printres = .true. - case('F','FALSE') - sm%printres = .false. - case default - write(0,*) 'Unknown value for smoother_trace : "',psb_toupper(trim(val)),'"' - end select - case default - call sm%mld_z_base_smoother_type%set(what,val,info,idx=idx) - end select - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info, name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_jac_smoother_csetc diff --git a/mlprec/impl/smoother/mld_z_jac_smoother_cseti.f90 b/mlprec/impl/smoother/mld_z_jac_smoother_cseti.f90 deleted file mode 100644 index c0b12e8b..00000000 --- a/mlprec/impl/smoother/mld_z_jac_smoother_cseti.f90 +++ /dev/null @@ -1,71 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_jac_smoother_cseti(sm,what,val,info,idx) - - use psb_base_mod - use mld_z_jac_smoother, mld_protect_nam => mld_z_jac_smoother_cseti - Implicit None - - ! Arguments - class(mld_z_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_jac_smoother_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) - case('SMOOTHER_RESIDUAL') - sm%checkiter = val - case('SMOOTHER_ITRACE') - sm%printiter = val - case default - call sm%mld_z_base_smoother_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_jac_smoother_cseti diff --git a/mlprec/impl/smoother/mld_z_jac_smoother_csetr.f90 b/mlprec/impl/smoother/mld_z_jac_smoother_csetr.f90 deleted file mode 100644 index 5131f61c..00000000 --- a/mlprec/impl/smoother/mld_z_jac_smoother_csetr.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_jac_smoother_csetr(sm,what,val,info,idx) - - use psb_base_mod - use mld_z_jac_smoother, mld_protect_nam => mld_z_jac_smoother_csetr - Implicit None - - ! Arguments - class(mld_z_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_jac_smoother_csetr' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) - case('SMOOTHER_STOPTOL') - sm%tol = val - case default - call sm%mld_z_base_smoother_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_jac_smoother_csetr diff --git a/mlprec/impl/smoother/mld_z_jac_smoother_descr.f90 b/mlprec/impl/smoother/mld_z_jac_smoother_descr.f90 deleted file mode 100644 index bb549d0f..00000000 --- a/mlprec/impl/smoother/mld_z_jac_smoother_descr.f90 +++ /dev/null @@ -1,103 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_jac_smoother_descr(sm,info,iout,coarse) - - use psb_base_mod - use mld_z_diag_solver - use mld_z_jac_smoother, mld_protect_name => mld_z_jac_smoother_descr - use mld_z_diag_solver - use mld_z_gs_solver - - Implicit None - - ! Arguments - class(mld_z_jac_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_z_jac_smoother_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (.not.coarse_) then - if (allocated(sm%sv)) then - select type(smv=>sm%sv) - class is (mld_z_diag_solver_type) - write(iout_,*) ' Point Jacobi ' - write(iout_,*) ' Local diagonal:' - call smv%descr(info,iout_,coarse=coarse) - class is (mld_z_bwgs_solver_type) - write(iout_,*) ' Hybrid Backward Gauss-Seidel ' - class is (mld_z_gs_solver_type) - write(iout_,*) ' Hybrid Forward Gauss-Seidel ' - class default - write(iout_,*) ' Block Jacobi ' - write(iout_,*) ' Local solver details:' - call smv%descr(info,iout_,coarse=coarse) - end select - - else - write(iout_,*) ' Block Jacobi ' - end if - else - if (allocated(sm%sv)) then - call sm%sv%descr(info,iout_,coarse=coarse) - end if - end if - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return -end subroutine mld_z_jac_smoother_descr diff --git a/mlprec/impl/smoother/mld_z_jac_smoother_dmp.f90 b/mlprec/impl/smoother/mld_z_jac_smoother_dmp.f90 deleted file mode 100644 index dec5aed5..00000000 --- a/mlprec/impl/smoother/mld_z_jac_smoother_dmp.f90 +++ /dev/null @@ -1,97 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_jac_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - - use psb_base_mod - use mld_z_jac_smoother, mld_protect_nam => mld_z_jac_smoother_dmp - implicit none - class(mld_z_jac_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - integer(psb_lpk_), allocatable :: iv(:) - logical :: smoother_, global_num_ - ! len of prefix_ - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_smth_z" - end if - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(smoother)) then - smoother_ = smoother - else - smoother_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - if (smoother_) then - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_nd.mtx' - if (global_num_) then - iv = desc%get_global_indices(owned=.false.) - if (sm%nd%is_asb()) & - & call sm%nd%print(fname,head=head,iv=iv) - else - if (sm%nd%is_asb()) & - & call sm%nd%print(fname,head=head) - end if - end if - ! At base level do nothing for the smoother - if (allocated(sm%sv)) & - & call sm%sv%dump(desc,level,info,solver=solver,prefix=prefix,global_num=global_num) - -end subroutine mld_z_jac_smoother_dmp diff --git a/mlprec/impl/smoother/mld_z_l1_jac_smoother_bld.f90 b/mlprec/impl/smoother/mld_z_l1_jac_smoother_bld.f90 deleted file mode 100644 index 9a467f9e..00000000 --- a/mlprec/impl/smoother/mld_z_l1_jac_smoother_bld.f90 +++ /dev/null @@ -1,176 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_l1_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - - use psb_base_mod - use mld_z_diag_solver - use mld_z_jac_smoother, mld_protect_name => mld_z_l1_jac_smoother_bld - Implicit None - - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_l1_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota, nzeros - real(psb_dpk_), allocatable :: arwsum(:) - type(psb_zspmat_type) :: tmpa - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='z_l1_jac_smoother_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - n_col = desc_a%get_local_cols() - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - - if( sm%checkres ) sm%pa => a - - select type (smsv => sm%sv) - class is (mld_z_diag_solver_type) - call sm%nd%free() - sm%pa => a - sm%nd_nnz_tot = nztota - - call psb_sum(ictxt,sm%nd_nnz_tot) - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - - class default - if (smsv%is_global()) then - ! Do not put anything into SM%ND since the solver - ! is acting globally. - call sm%nd%free() - sm%nd_nnz_tot = 0 - call psb_sum(ictxt,sm%nd_nnz_tot) - call sm%sv%build(a,desc_a,info,amold=amold,vmold=vmold) - else - - call a%csclip(tmpa,info,& - & jmax=nrow_a,rscale=.false.,cscale=.false.) - - call a%csclip(sm%nd,info,& - & jmin=nrow_a+1,rscale=.false.,cscale=.false.) - - arwsum = sm%nd%arwsum(info) - - call combine_dl1(-done,arwsum,sm%nd,info) - call combine_dl1(done,arwsum,tmpa,info) - - sm%nd_nnz_tot = sm%nd%get_nzeros() - call psb_sum(ictxt,sm%nd_nnz_tot) - - call sm%sv%build(tmpa,desc_a,info,amold=amold,vmold=vmold) - - if (info == psb_success_) then - if (present(amold)) then - call sm%nd%cscnv(info,& - & mold=amold,dupl=psb_dupl_add_) - else - call sm%nd%cscnv(info,& - & type='csr',dupl=psb_dupl_add_) - endif - end if - end if - end select - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='clip & psb_spcnv csr 4') - goto 9999 - end if - - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='solver build') - goto 9999 - end if - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -contains - - subroutine combine_dl1(alpha,dl1,mat,info) - implicit none - real(psb_dpk_), intent(in) :: alpha, dl1(:) - type(psb_zspmat_type), intent(inout) :: mat - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: k, nz, nrm, dp - type(psb_z_coo_sparse_mat) :: tcoo - - call mat%mv_to(tcoo) - nz = tcoo%get_nzeros() - nrm = min(size(dl1),tcoo%get_nrows(),tcoo%get_ncols()) -!!$ write(0,*) 'Check on combine_dl1: ',nrm, tcoo%get_nrows(),tcoo%get_ncols(), nz - call tcoo%ensure_size(nz+nrm) - call tcoo%set_dupl(psb_dupl_add_) - do k=1,nrm - if (dl1(k) /= dzero) then - nz = nz + 1 - tcoo%ia(nz) = k - tcoo%ja(nz) = k - tcoo%val(nz) = alpha*dl1(k) - end if - end do - call tcoo%set_nzeros(nz) - call tcoo%fix(info) - call mat%mv_from(tcoo) - end subroutine combine_dl1 - - -end subroutine mld_z_l1_jac_smoother_bld diff --git a/mlprec/impl/smoother/mld_z_l1_jac_smoother_clone.f90 b/mlprec/impl/smoother/mld_z_l1_jac_smoother_clone.f90 deleted file mode 100644 index c83a8a5f..00000000 --- a/mlprec/impl/smoother/mld_z_l1_jac_smoother_clone.f90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_l1_jac_smoother_clone(sm,smout,info) - - use psb_base_mod - use mld_z_jac_smoother, mld_protect_name => mld_z_l1_jac_smoother_clone - - Implicit None - - ! Arguments - class(mld_z_l1_jac_smoother_type), intent(inout) :: sm - class(mld_z_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(smout)) then - call smout%free(info) - if (info == psb_success_) deallocate(smout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_z_l1_jac_smoother_type :: smout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(smo => smout) - type is (mld_z_l1_jac_smoother_type) - smo%nd_nnz_tot = sm%nd_nnz_tot - smo%checkres = sm%checkres - smo%printres = sm%printres - smo%checkiter = sm%checkiter - smo%printiter = sm%printiter - smo%tol = sm%tol - call sm%nd%clone(smo%nd,info) - if ((info==psb_success_).and.(allocated(sm%sv))) then - allocate(smout%sv,mold=sm%sv,stat=info) - if (info == psb_success_) call sm%sv%clone(smo%sv,info) - end if - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_l1_jac_smoother_clone diff --git a/mlprec/impl/smoother/mld_z_l1_jac_smoother_descr.f90 b/mlprec/impl/smoother/mld_z_l1_jac_smoother_descr.f90 deleted file mode 100644 index b72a1503..00000000 --- a/mlprec/impl/smoother/mld_z_l1_jac_smoother_descr.f90 +++ /dev/null @@ -1,103 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_l1_jac_smoother_descr(sm,info,iout,coarse) - - use psb_base_mod - use mld_z_diag_solver - use mld_z_jac_smoother, mld_protect_name => mld_z_l1_jac_smoother_descr - use mld_z_diag_solver - use mld_z_gs_solver - - Implicit None - - ! Arguments - class(mld_z_l1_jac_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_z_l1_jac_smoother_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (.not.coarse_) then - if (allocated(sm%sv)) then - select type(smv=>sm%sv) - class is (mld_z_diag_solver_type) - write(iout_,*) ' Point Jacobi ' - write(iout_,*) ' Local diagonal:' - call smv%descr(info,iout_,coarse=coarse) - class is (mld_z_bwgs_solver_type) - write(iout_,*) ' L1-Hybrid Backward Gauss-Seidel ' - class is (mld_z_gs_solver_type) - write(iout_,*) ' L1-Hybrid Forward Gauss-Seidel ' - class default - write(iout_,*) ' L1-Block Jacobi ' - write(iout_,*) ' Local solver details:' - call smv%descr(info,iout_,coarse=coarse) - end select - - else - write(iout_,*) ' L1-Block Jacobi ' - end if - else - if (allocated(sm%sv)) then - call sm%sv%descr(info,iout_,coarse=coarse) - end if - end if - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return -end subroutine mld_z_l1_jac_smoother_descr diff --git a/mlprec/impl/solver/Makefile b/mlprec/impl/solver/Makefile index ad698c54..c9cd0452 100644 --- a/mlprec/impl/solver/Makefile +++ b/mlprec/impl/solver/Makefile @@ -7,193 +7,193 @@ FINCLUDES=$(FMFLAG)$(HERE) $(FMFLAG)$(MODDIR) $(FMFLAG)$(INCDIR) $(PSBLAS_INCLUD -OBJS=mld_c_base_solver_apply.o \ -mld_c_base_solver_apply_vect.o \ -mld_c_base_solver_bld.o \ -mld_c_base_solver_check.o \ -mld_c_base_solver_clone.o \ -mld_c_base_solver_clone_settings.o \ -mld_c_base_solver_clear_data.o \ -mld_c_base_solver_cnv.o \ -mld_c_base_solver_csetc.o \ -mld_c_base_solver_cseti.o \ -mld_c_base_solver_csetr.o \ -mld_c_base_solver_descr.o \ -mld_c_base_solver_dmp.o \ -mld_c_base_solver_free.o \ -mld_c_diag_solver_apply.o \ -mld_c_diag_solver_apply_vect.o \ -mld_c_diag_solver_bld.o \ -mld_c_diag_solver_dmp.o \ -mld_c_diag_solver_clone.o \ -mld_c_diag_solver_clear_data.o \ -mld_c_diag_solver_cnv.o \ -mld_c_gs_solver_bld.o \ -mld_c_gs_solver_clone.o \ -mld_c_gs_solver_cnv.o \ -mld_c_gs_solver_dmp.o \ -mld_c_gs_solver_apply.o \ -mld_c_gs_solver_apply_vect.o \ -mld_c_gs_solver_clear_data.o \ -mld_c_gs_solver_clone_settings.o \ -mld_c_bwgs_solver_bld.o \ -mld_c_bwgs_solver_apply.o \ -mld_c_bwgs_solver_apply_vect.o \ -mld_c_id_solver_apply.o \ -mld_c_id_solver_apply_vect.o \ -mld_c_id_solver_clone.o \ -mld_c_ilu_solver_apply.o \ -mld_c_ilu_solver_apply_vect.o \ -mld_c_ilu_solver_bld.o \ -mld_c_ilu_solver_clone.o \ -mld_c_ilu_solver_clear_data.o \ -mld_c_ilu_solver_clone_settings.o \ -mld_c_ilu_solver_cnv.o \ -mld_c_ilu_solver_dmp.o \ -mld_c_mumps_solver_apply.o \ -mld_c_mumps_solver_apply_vect.o \ -mld_c_mumps_solver_bld.o \ -mld_d_base_solver_apply.o \ -mld_d_base_solver_apply_vect.o \ -mld_d_base_solver_bld.o \ -mld_d_base_solver_check.o \ -mld_d_base_solver_clone.o \ -mld_d_base_solver_clone_settings.o \ -mld_d_base_solver_clear_data.o \ -mld_d_base_solver_cnv.o \ -mld_d_base_solver_csetc.o \ -mld_d_base_solver_cseti.o \ -mld_d_base_solver_csetr.o \ -mld_d_base_solver_descr.o \ -mld_d_base_solver_dmp.o \ -mld_d_base_solver_free.o \ -mld_d_diag_solver_apply.o \ -mld_d_diag_solver_apply_vect.o \ -mld_d_diag_solver_bld.o \ -mld_d_diag_solver_dmp.o \ -mld_d_diag_solver_clone.o \ -mld_d_diag_solver_clear_data.o \ -mld_d_diag_solver_cnv.o \ -mld_d_bwgs_solver_bld.o \ -mld_d_bwgs_solver_apply.o \ -mld_d_bwgs_solver_apply_vect.o \ -mld_d_gs_solver_bld.o \ -mld_d_gs_solver_clone.o \ -mld_d_gs_solver_cnv.o \ -mld_d_gs_solver_dmp.o \ -mld_d_gs_solver_apply.o \ -mld_d_gs_solver_apply_vect.o \ -mld_d_gs_solver_clear_data.o \ -mld_d_gs_solver_clone_settings.o \ -mld_d_id_solver_apply.o \ -mld_d_id_solver_apply_vect.o \ -mld_d_id_solver_clone.o \ -mld_d_ilu_solver_apply.o \ -mld_d_ilu_solver_apply_vect.o \ -mld_d_ilu_solver_bld.o \ -mld_d_ilu_solver_clone.o \ -mld_d_ilu_solver_clear_data.o \ -mld_d_ilu_solver_clone_settings.o \ -mld_d_ilu_solver_cnv.o \ -mld_d_ilu_solver_dmp.o \ -mld_d_mumps_solver_apply.o \ -mld_d_mumps_solver_apply_vect.o \ -mld_d_mumps_solver_bld.o \ -mld_s_base_solver_apply.o \ -mld_s_base_solver_apply_vect.o \ -mld_s_base_solver_bld.o \ -mld_s_base_solver_check.o \ -mld_s_base_solver_clone.o \ -mld_s_base_solver_clone_settings.o \ -mld_s_base_solver_clear_data.o \ -mld_s_base_solver_cnv.o \ -mld_s_base_solver_csetc.o \ -mld_s_base_solver_cseti.o \ -mld_s_base_solver_csetr.o \ -mld_s_base_solver_descr.o \ -mld_s_base_solver_dmp.o \ -mld_s_base_solver_free.o \ -mld_s_diag_solver_apply.o \ -mld_s_diag_solver_apply_vect.o \ -mld_s_diag_solver_bld.o \ -mld_s_diag_solver_dmp.o \ -mld_s_diag_solver_clone.o \ -mld_s_diag_solver_clear_data.o \ -mld_s_diag_solver_cnv.o \ -mld_s_gs_solver_bld.o \ -mld_s_gs_solver_clone.o \ -mld_s_gs_solver_cnv.o \ -mld_s_gs_solver_dmp.o \ -mld_s_gs_solver_apply.o \ -mld_s_gs_solver_apply_vect.o \ -mld_s_gs_solver_clear_data.o \ -mld_s_gs_solver_clone_settings.o \ -mld_s_bwgs_solver_bld.o \ -mld_s_bwgs_solver_apply.o \ -mld_s_bwgs_solver_apply_vect.o \ -mld_s_id_solver_apply.o \ -mld_s_id_solver_apply_vect.o \ -mld_s_id_solver_clone.o \ -mld_s_ilu_solver_apply.o \ -mld_s_ilu_solver_apply_vect.o \ -mld_s_ilu_solver_bld.o \ -mld_s_ilu_solver_clone.o \ -mld_s_ilu_solver_clear_data.o \ -mld_s_ilu_solver_clone_settings.o \ -mld_s_ilu_solver_cnv.o \ -mld_s_ilu_solver_dmp.o \ -mld_s_mumps_solver_apply.o \ -mld_s_mumps_solver_apply_vect.o \ -mld_s_mumps_solver_bld.o \ -mld_z_base_solver_apply.o \ -mld_z_base_solver_apply_vect.o \ -mld_z_base_solver_bld.o \ -mld_z_base_solver_check.o \ -mld_z_base_solver_clone.o \ -mld_z_base_solver_clone_settings.o \ -mld_z_base_solver_clear_data.o \ -mld_z_base_solver_cnv.o \ -mld_z_base_solver_csetc.o \ -mld_z_base_solver_cseti.o \ -mld_z_base_solver_csetr.o \ -mld_z_base_solver_descr.o \ -mld_z_base_solver_dmp.o \ -mld_z_base_solver_free.o \ -mld_z_diag_solver_apply.o \ -mld_z_diag_solver_apply_vect.o \ -mld_z_diag_solver_bld.o \ -mld_z_diag_solver_dmp.o \ -mld_z_diag_solver_clone.o \ -mld_z_diag_solver_clear_data.o \ -mld_z_diag_solver_cnv.o \ -mld_z_gs_solver_bld.o \ -mld_z_gs_solver_clone.o \ -mld_z_gs_solver_cnv.o \ -mld_z_gs_solver_dmp.o \ -mld_z_gs_solver_apply.o \ -mld_z_gs_solver_apply_vect.o \ -mld_z_gs_solver_clear_data.o \ -mld_z_gs_solver_clone_settings.o \ -mld_z_bwgs_solver_bld.o \ -mld_z_bwgs_solver_apply.o \ -mld_z_bwgs_solver_apply_vect.o \ -mld_z_id_solver_apply.o \ -mld_z_id_solver_apply_vect.o \ -mld_z_id_solver_clone.o \ -mld_z_ilu_solver_clear_data.o \ -mld_z_ilu_solver_clone_settings.o \ -mld_z_ilu_solver_apply.o \ -mld_z_ilu_solver_apply_vect.o \ -mld_z_ilu_solver_bld.o \ -mld_z_ilu_solver_clone.o \ -mld_z_ilu_solver_cnv.o \ -mld_z_ilu_solver_dmp.o \ -mld_z_mumps_solver_apply.o \ -mld_z_mumps_solver_apply_vect.o \ -mld_z_mumps_solver_bld.o \ +OBJS=amg_c_base_solver_apply.o \ +amg_c_base_solver_apply_vect.o \ +amg_c_base_solver_bld.o \ +amg_c_base_solver_check.o \ +amg_c_base_solver_clone.o \ +amg_c_base_solver_clone_settings.o \ +amg_c_base_solver_clear_data.o \ +amg_c_base_solver_cnv.o \ +amg_c_base_solver_csetc.o \ +amg_c_base_solver_cseti.o \ +amg_c_base_solver_csetr.o \ +amg_c_base_solver_descr.o \ +amg_c_base_solver_dmp.o \ +amg_c_base_solver_free.o \ +amg_c_diag_solver_apply.o \ +amg_c_diag_solver_apply_vect.o \ +amg_c_diag_solver_bld.o \ +amg_c_diag_solver_dmp.o \ +amg_c_diag_solver_clone.o \ +amg_c_diag_solver_clear_data.o \ +amg_c_diag_solver_cnv.o \ +amg_c_gs_solver_bld.o \ +amg_c_gs_solver_clone.o \ +amg_c_gs_solver_cnv.o \ +amg_c_gs_solver_dmp.o \ +amg_c_gs_solver_apply.o \ +amg_c_gs_solver_apply_vect.o \ +amg_c_gs_solver_clear_data.o \ +amg_c_gs_solver_clone_settings.o \ +amg_c_bwgs_solver_bld.o \ +amg_c_bwgs_solver_apply.o \ +amg_c_bwgs_solver_apply_vect.o \ +amg_c_id_solver_apply.o \ +amg_c_id_solver_apply_vect.o \ +amg_c_id_solver_clone.o \ +amg_c_ilu_solver_apply.o \ +amg_c_ilu_solver_apply_vect.o \ +amg_c_ilu_solver_bld.o \ +amg_c_ilu_solver_clone.o \ +amg_c_ilu_solver_clear_data.o \ +amg_c_ilu_solver_clone_settings.o \ +amg_c_ilu_solver_cnv.o \ +amg_c_ilu_solver_dmp.o \ +amg_c_mumps_solver_apply.o \ +amg_c_mumps_solver_apply_vect.o \ +amg_c_mumps_solver_bld.o \ +amg_d_base_solver_apply.o \ +amg_d_base_solver_apply_vect.o \ +amg_d_base_solver_bld.o \ +amg_d_base_solver_check.o \ +amg_d_base_solver_clone.o \ +amg_d_base_solver_clone_settings.o \ +amg_d_base_solver_clear_data.o \ +amg_d_base_solver_cnv.o \ +amg_d_base_solver_csetc.o \ +amg_d_base_solver_cseti.o \ +amg_d_base_solver_csetr.o \ +amg_d_base_solver_descr.o \ +amg_d_base_solver_dmp.o \ +amg_d_base_solver_free.o \ +amg_d_diag_solver_apply.o \ +amg_d_diag_solver_apply_vect.o \ +amg_d_diag_solver_bld.o \ +amg_d_diag_solver_dmp.o \ +amg_d_diag_solver_clone.o \ +amg_d_diag_solver_clear_data.o \ +amg_d_diag_solver_cnv.o \ +amg_d_bwgs_solver_bld.o \ +amg_d_bwgs_solver_apply.o \ +amg_d_bwgs_solver_apply_vect.o \ +amg_d_gs_solver_bld.o \ +amg_d_gs_solver_clone.o \ +amg_d_gs_solver_cnv.o \ +amg_d_gs_solver_dmp.o \ +amg_d_gs_solver_apply.o \ +amg_d_gs_solver_apply_vect.o \ +amg_d_gs_solver_clear_data.o \ +amg_d_gs_solver_clone_settings.o \ +amg_d_id_solver_apply.o \ +amg_d_id_solver_apply_vect.o \ +amg_d_id_solver_clone.o \ +amg_d_ilu_solver_apply.o \ +amg_d_ilu_solver_apply_vect.o \ +amg_d_ilu_solver_bld.o \ +amg_d_ilu_solver_clone.o \ +amg_d_ilu_solver_clear_data.o \ +amg_d_ilu_solver_clone_settings.o \ +amg_d_ilu_solver_cnv.o \ +amg_d_ilu_solver_dmp.o \ +amg_d_mumps_solver_apply.o \ +amg_d_mumps_solver_apply_vect.o \ +amg_d_mumps_solver_bld.o \ +amg_s_base_solver_apply.o \ +amg_s_base_solver_apply_vect.o \ +amg_s_base_solver_bld.o \ +amg_s_base_solver_check.o \ +amg_s_base_solver_clone.o \ +amg_s_base_solver_clone_settings.o \ +amg_s_base_solver_clear_data.o \ +amg_s_base_solver_cnv.o \ +amg_s_base_solver_csetc.o \ +amg_s_base_solver_cseti.o \ +amg_s_base_solver_csetr.o \ +amg_s_base_solver_descr.o \ +amg_s_base_solver_dmp.o \ +amg_s_base_solver_free.o \ +amg_s_diag_solver_apply.o \ +amg_s_diag_solver_apply_vect.o \ +amg_s_diag_solver_bld.o \ +amg_s_diag_solver_dmp.o \ +amg_s_diag_solver_clone.o \ +amg_s_diag_solver_clear_data.o \ +amg_s_diag_solver_cnv.o \ +amg_s_gs_solver_bld.o \ +amg_s_gs_solver_clone.o \ +amg_s_gs_solver_cnv.o \ +amg_s_gs_solver_dmp.o \ +amg_s_gs_solver_apply.o \ +amg_s_gs_solver_apply_vect.o \ +amg_s_gs_solver_clear_data.o \ +amg_s_gs_solver_clone_settings.o \ +amg_s_bwgs_solver_bld.o \ +amg_s_bwgs_solver_apply.o \ +amg_s_bwgs_solver_apply_vect.o \ +amg_s_id_solver_apply.o \ +amg_s_id_solver_apply_vect.o \ +amg_s_id_solver_clone.o \ +amg_s_ilu_solver_apply.o \ +amg_s_ilu_solver_apply_vect.o \ +amg_s_ilu_solver_bld.o \ +amg_s_ilu_solver_clone.o \ +amg_s_ilu_solver_clear_data.o \ +amg_s_ilu_solver_clone_settings.o \ +amg_s_ilu_solver_cnv.o \ +amg_s_ilu_solver_dmp.o \ +amg_s_mumps_solver_apply.o \ +amg_s_mumps_solver_apply_vect.o \ +amg_s_mumps_solver_bld.o \ +amg_z_base_solver_apply.o \ +amg_z_base_solver_apply_vect.o \ +amg_z_base_solver_bld.o \ +amg_z_base_solver_check.o \ +amg_z_base_solver_clone.o \ +amg_z_base_solver_clone_settings.o \ +amg_z_base_solver_clear_data.o \ +amg_z_base_solver_cnv.o \ +amg_z_base_solver_csetc.o \ +amg_z_base_solver_cseti.o \ +amg_z_base_solver_csetr.o \ +amg_z_base_solver_descr.o \ +amg_z_base_solver_dmp.o \ +amg_z_base_solver_free.o \ +amg_z_diag_solver_apply.o \ +amg_z_diag_solver_apply_vect.o \ +amg_z_diag_solver_bld.o \ +amg_z_diag_solver_dmp.o \ +amg_z_diag_solver_clone.o \ +amg_z_diag_solver_clear_data.o \ +amg_z_diag_solver_cnv.o \ +amg_z_gs_solver_bld.o \ +amg_z_gs_solver_clone.o \ +amg_z_gs_solver_cnv.o \ +amg_z_gs_solver_dmp.o \ +amg_z_gs_solver_apply.o \ +amg_z_gs_solver_apply_vect.o \ +amg_z_gs_solver_clear_data.o \ +amg_z_gs_solver_clone_settings.o \ +amg_z_bwgs_solver_bld.o \ +amg_z_bwgs_solver_apply.o \ +amg_z_bwgs_solver_apply_vect.o \ +amg_z_id_solver_apply.o \ +amg_z_id_solver_apply_vect.o \ +amg_z_id_solver_clone.o \ +amg_z_ilu_solver_clear_data.o \ +amg_z_ilu_solver_clone_settings.o \ +amg_z_ilu_solver_apply.o \ +amg_z_ilu_solver_apply_vect.o \ +amg_z_ilu_solver_bld.o \ +amg_z_ilu_solver_clone.o \ +amg_z_ilu_solver_cnv.o \ +amg_z_ilu_solver_dmp.o \ +amg_z_mumps_solver_apply.o \ +amg_z_mumps_solver_apply_vect.o \ +amg_z_mumps_solver_bld.o \ -LIBNAME=libmld_prec.a +LIBNAME=libamg_prec.a lib: $(OBJS) $(AR) $(HERE)/$(LIBNAME) $(OBJS) diff --git a/mlprec/impl/solver/amg_c_base_solver_apply.f90 b/mlprec/impl/solver/amg_c_base_solver_apply.f90 new file mode 100644 index 00000000..cccabda7 --- /dev/null +++ b/mlprec/impl/solver/amg_c_base_solver_apply.f90 @@ -0,0 +1,71 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + + use psb_base_mod + use amg_c_base_solver_mod, amg_protect_name => amg_c_base_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_base_solver_type), intent(inout) :: sv + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_base_solver_apply diff --git a/mlprec/impl/solver/amg_c_base_solver_apply_vect.f90 b/mlprec/impl/solver/amg_c_base_solver_apply_vect.f90 new file mode 100644 index 00000000..1889ee18 --- /dev/null +++ b/mlprec/impl/solver/amg_c_base_solver_apply_vect.f90 @@ -0,0 +1,72 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_c_base_solver_mod, amg_protect_name => amg_c_base_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_base_solver_type), intent(inout) :: sv + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_solver_apply_vect' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_base_solver_apply_vect diff --git a/mlprec/impl/solver/amg_c_base_solver_bld.f90 b/mlprec/impl/solver/amg_c_base_solver_bld.f90 new file mode 100644 index 00000000..f3d50b8f --- /dev/null +++ b/mlprec/impl/solver/amg_c_base_solver_bld.f90 @@ -0,0 +1,68 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_c_base_solver_mod, amg_protect_name => amg_c_base_solver_bld + Implicit None + ! Arguments + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type), intent(in), target, optional :: b + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_bld' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_solver_bld diff --git a/mlprec/impl/solver/amg_c_base_solver_check.f90 b/mlprec/impl/solver/amg_c_base_solver_check.f90 new file mode 100644 index 00000000..3bfb61cb --- /dev/null +++ b/mlprec/impl/solver/amg_c_base_solver_check.f90 @@ -0,0 +1,61 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_solver_check(sv,info) + + use psb_base_mod + use amg_c_base_solver_mod, amg_protect_name => amg_c_base_solver_check + Implicit None + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_solver_check diff --git a/mlprec/impl/solver/amg_c_base_solver_clear_data.f90 b/mlprec/impl/solver/amg_c_base_solver_clear_data.f90 new file mode 100644 index 00000000..36562b3c --- /dev/null +++ b/mlprec/impl/solver/amg_c_base_solver_clear_data.f90 @@ -0,0 +1,60 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_solver_clear_data(sv,info) + + use psb_base_mod + use amg_c_base_solver_mod, amg_protect_name => amg_c_base_solver_clear_data + Implicit None + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_solver_clear_data' + + call psb_erractionsave(err_act) + info = 0 + + ! Do nothing + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_solver_clear_data diff --git a/mlprec/impl/solver/amg_c_base_solver_clone.f90 b/mlprec/impl/solver/amg_c_base_solver_clone.f90 new file mode 100644 index 00000000..3c73a5a8 --- /dev/null +++ b/mlprec/impl/solver/amg_c_base_solver_clone.f90 @@ -0,0 +1,62 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_c_base_solver_mod, amg_protect_name => amg_c_base_solver_clone + Implicit None + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_solver_clone' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_solver_clone diff --git a/mlprec/impl/solver/amg_c_base_solver_clone_settings.f90 b/mlprec/impl/solver/amg_c_base_solver_clone_settings.f90 new file mode 100644 index 00000000..89ec4772 --- /dev/null +++ b/mlprec/impl/solver/amg_c_base_solver_clone_settings.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_solver_clone_settings(sv,svout,info) + + use psb_base_mod + use amg_c_base_solver_mod, amg_protect_name => amg_c_base_solver_clone_settings + Implicit None + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_base_solver_clone_settings' + + call psb_erractionsave(err_act) + + if (same_type_as(sv,svout)) then + ! Do nothing + else + + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_solver_clone_settings diff --git a/mlprec/impl/solver/amg_c_base_solver_cnv.f90 b/mlprec/impl/solver/amg_c_base_solver_cnv.f90 new file mode 100644 index 00000000..690c34c9 --- /dev/null +++ b/mlprec/impl/solver/amg_c_base_solver_cnv.f90 @@ -0,0 +1,63 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_solver_cnv(sv,info,amold,vmold,imold) + + use psb_base_mod + use amg_c_base_solver_mod, amg_protect_name => amg_c_base_solver_cnv + Implicit None + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_cnv' + + call psb_erractionsave(err_act) + + info = psb_success_ + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_solver_cnv diff --git a/mlprec/impl/solver/amg_c_base_solver_csetc.f90 b/mlprec/impl/solver/amg_c_base_solver_csetc.f90 new file mode 100644 index 00000000..bdbae627 --- /dev/null +++ b/mlprec/impl/solver/amg_c_base_solver_csetc.f90 @@ -0,0 +1,63 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_solver_csetc(sv,what,val,info,idx) + + use psb_base_mod + use amg_c_base_solver_mod, amg_protect_name => amg_c_base_solver_csetc + Implicit None + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + Integer(Psb_ipk_) :: err_act, ival + character(len=20) :: name='d_base_solver_csetc' + + call psb_erractionsave(err_act) + + info = psb_success_ + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_solver_csetc diff --git a/mlprec/impl/solver/amg_c_base_solver_cseti.f90 b/mlprec/impl/solver/amg_c_base_solver_cseti.f90 new file mode 100644 index 00000000..96674a4d --- /dev/null +++ b/mlprec/impl/solver/amg_c_base_solver_cseti.f90 @@ -0,0 +1,56 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_solver_cseti(sv,what,val,info,idx) + + use psb_base_mod + use amg_c_base_solver_mod, amg_protect_name => amg_c_base_solver_cseti + Implicit None + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_cseti' + + ! Correct action here is doing nothing. + info = 0 + + return +end subroutine amg_c_base_solver_cseti diff --git a/mlprec/impl/solver/amg_c_base_solver_csetr.f90 b/mlprec/impl/solver/amg_c_base_solver_csetr.f90 new file mode 100644 index 00000000..4ffaf2d5 --- /dev/null +++ b/mlprec/impl/solver/amg_c_base_solver_csetr.f90 @@ -0,0 +1,57 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_solver_csetr(sv,what,val,info,idx) + + use psb_base_mod + use amg_c_base_solver_mod, amg_protect_name => amg_c_base_solver_csetr + Implicit None + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_csetr' + + + ! Correct action here is doing nothing. + info = 0 + + return +end subroutine amg_c_base_solver_csetr diff --git a/mlprec/impl/solver/amg_c_base_solver_descr.f90 b/mlprec/impl/solver/amg_c_base_solver_descr.f90 new file mode 100644 index 00000000..3edfcbc6 --- /dev/null +++ b/mlprec/impl/solver/amg_c_base_solver_descr.f90 @@ -0,0 +1,66 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_solver_descr(sv,info,iout,coarse) + + use psb_base_mod + use amg_c_base_solver_mod, amg_protect_name => amg_c_base_solver_descr + Implicit None + ! Arguments + class(amg_c_base_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_c_base_solver_descr' + + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_solver_descr diff --git a/mlprec/impl/solver/amg_c_base_solver_dmp.f90 b/mlprec/impl/solver/amg_c_base_solver_dmp.f90 new file mode 100644 index 00000000..607ff319 --- /dev/null +++ b/mlprec/impl/solver/amg_c_base_solver_dmp.f90 @@ -0,0 +1,78 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_c_base_solver_mod, amg_protect_name => amg_c_base_solver_dmp + implicit none + class(amg_c_base_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: solver_ + ! len of prefix_ + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_c" + end if + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + ! At base level do nothing for the solver + +end subroutine amg_c_base_solver_dmp diff --git a/mlprec/impl/solver/amg_c_base_solver_free.f90 b/mlprec/impl/solver/amg_c_base_solver_free.f90 new file mode 100644 index 00000000..c961d72d --- /dev/null +++ b/mlprec/impl/solver/amg_c_base_solver_free.f90 @@ -0,0 +1,60 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_base_solver_free(sv,info) + + use psb_base_mod + use amg_c_base_solver_mod, amg_protect_name => amg_c_base_solver_free + Implicit None + ! Arguments + class(amg_c_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_free' + + call psb_erractionsave(err_act) + + ! Do nothing + info = psb_success_ + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_base_solver_free diff --git a/mlprec/impl/solver/amg_c_bwgs_solver_apply.f90 b/mlprec/impl/solver/amg_c_bwgs_solver_apply.f90 new file mode 100644 index 00000000..83c008ed --- /dev/null +++ b/mlprec/impl/solver/amg_c_bwgs_solver_apply.f90 @@ -0,0 +1,216 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_bwgs_solver_apply(alpha,sv,x,beta,y,desc_data,& + &trans,work,info,init,initu) + + use psb_base_mod + use amg_c_gs_solver, amg_protect_name => amg_c_bwgs_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_bwgs_solver_type), intent(inout) :: sv + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col, itx, itxst + complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + complex(psb_spk_), allocatable :: temp(:),wv(:),xit(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='c_bwgs_solver_apply' + + call psb_erractionsave(err_act) + ictxt = desc_data%get_ctxt() + call psb_info(ictxt,me,np) + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') +!!$ case('T') +!!$ case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + + call psb_geasb(wv,desc_data,info) + call psb_geasb(xit,desc_data,info) + itxst = 1 + select case (init_) + case('Z') + call psb_geaxpby(cone,x,czero,wv,desc_data,info) + call psb_spsm(cone,sv%u,wv,czero,xit,desc_data,info) + itxst = 2 + case('Y') + call psb_geaxpby(cone,y,czero,xit,desc_data,info) + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(cone,initu,czero,xit,desc_data,info) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + select case(trans_) + case('N') + if (sv%eps <=szero) then + ! + ! Fixed number of iterations + ! + ! + do itx=itxst, sv%sweeps + call psb_geaxpby(cone,x,czero,wv,desc_data,info) + ! Update with L. The off-diagonal block is taken care + ! from the Jacobi smoother, hence this is purely local. + call psb_spmm(-cone,sv%l,xit,cone,wv,desc_data,info,doswap=.false.) + call psb_spsm(cone,sv%u,wv,czero,xit,desc_data,info) + end do + + call psb_geaxpby(alpha,xit,beta,y,desc_data,info) + + else + ! + ! Iterations to convergence, not implemented right now. + ! + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') + goto 9999 + + end if +!!$ case('T') +!!$ call psb_spsm(cone,sv%u,x,czero,wv,desc_data,info,& +!!$ & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) +!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) +!!$ +!!$ case('C') +!!$ +!!$ call psb_spsm(cone,sv%u,x,czero,wv,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) +!!$ +!!$ call wv1%mlt(cone,sv%dv,wv,czero,info,conjgx=trans_) +!!$ +!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv1,beta,y,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid TRANS in GS subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_bwgs_solver_apply diff --git a/mlprec/impl/solver/amg_c_bwgs_solver_apply_vect.f90 b/mlprec/impl/solver/amg_c_bwgs_solver_apply_vect.f90 new file mode 100644 index 00000000..a87346fa --- /dev/null +++ b/mlprec/impl/solver/amg_c_bwgs_solver_apply_vect.f90 @@ -0,0 +1,211 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_bwgs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_c_gs_solver, amg_protect_name => amg_c_bwgs_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_bwgs_solver_type), intent(inout) :: sv + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col, itx, itxst + complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + complex(psb_spk_), allocatable :: temp(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='c_bwgs_solver_apply' + + call psb_erractionsave(err_act) + ictxt = desc_data%get_ctxt() + call psb_info(ictxt,me,np) + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') +!!$ case('T') +!!$ case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + + if (x%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/itwo,n_row,izero,izero,izero/)) + goto 9999 + end if + if (y%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/ithree,n_row,izero,izero,izero/)) + goto 9999 + end if + + + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + + if (size(wv) < 2) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size') + goto 9999 + end if + + associate(tw => wv(1), xit => wv(2)) + itxst = 1 + select case (init_) + case('Z') + call psb_geaxpby(cone,x,czero,tw,desc_data,info) + call psb_spsm(cone,sv%u,tw,czero,xit,desc_data,info) + itxst = 2 + case('Y') + call psb_geaxpby(cone,y,czero,xit,desc_data,info) + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(cone,initu,czero,xit,desc_data,info) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + select case(trans_) + case('N') + if (sv%eps <=szero) then + ! + ! Fixed number of iterations + ! + ! + do itx=itxst,sv%sweeps + call psb_geaxpby(cone,x,czero,tw,desc_data,info) + ! Update with L. The off-diagonal block is taken care + ! from the Jacobi smoother, hence this is purely local. + call psb_spmm(-cone,sv%l,xit,cone,tw,desc_data,info,doswap=.false.) + call psb_spsm(cone,sv%u,tw,czero,xit,desc_data,info) + end do + + call psb_geaxpby(alpha,xit,beta,y,desc_data,info) + + else + ! + ! Iterations to convergence, not implemented right now. + ! + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') + goto 9999 + + end if + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid TRANS in GS subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + end associate + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_bwgs_solver_apply_vect diff --git a/mlprec/impl/solver/amg_c_bwgs_solver_bld.f90 b/mlprec/impl/solver/amg_c_bwgs_solver_bld.f90 new file mode 100644 index 00000000..27d9bda5 --- /dev/null +++ b/mlprec/impl/solver/amg_c_bwgs_solver_bld.f90 @@ -0,0 +1,110 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_bwgs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_c_gs_solver, amg_protect_name => amg_c_bwgs_solver_bld + + Implicit None + + ! Arguments + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(in) :: desc_a + class(amg_c_bwgs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type), intent(in), target, optional :: b + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_bwgs_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + + if (sv%eps <= dzero) then + ! + ! This cuts out the off-diagonal part, because it's supposed to + ! be handled by the outer Jacobi smoother. + ! + call a%tril(sv%l,info,diag=-ione,jmax=nrow_a,u=sv%u) + + else + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end if + + + + call sv%l%set_asb() + call sv%l%trim() + call sv%u%set_asb() + call sv%u%trim() + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_bwgs_solver_bld diff --git a/mlprec/impl/solver/amg_c_diag_solver_apply.f90 b/mlprec/impl/solver/amg_c_diag_solver_apply.f90 new file mode 100644 index 00000000..de4cd4c8 --- /dev/null +++ b/mlprec/impl/solver/amg_c_diag_solver_apply.f90 @@ -0,0 +1,240 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_diag_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + + use psb_base_mod + use amg_c_diag_solver, amg_protect_name => amg_c_diag_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_diag_solver_type), intent(inout) :: sv + complex(psb_spk_), intent(inout) :: x(:) + complex(psb_spk_), intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col + complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='c_diag_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (trans_ == 'C') then + if (beta == czero) then + + if (alpha == czero) then + y(1:n_row) = czero + else if (alpha == cone) then + do i=1, n_row + y(i) = conjg(sv%d(i)) * x(i) + end do + else if (alpha == -cone) then + do i=1, n_row + y(i) = -conjg(sv%d(i)) * x(i) + end do + else + do i=1, n_row + y(i) = alpha * conjg(sv%d(i)) * x(i) + end do + end if + + else if (beta == cone) then + + if (alpha == czero) then + !y(1:n_row) = czero + else if (alpha == cone) then + do i=1, n_row + y(i) = conjg(sv%d(i)) * x(i) + y(i) + end do + else if (alpha == -cone) then + do i=1, n_row + y(i) = -conjg(sv%d(i)) * x(i) + y(i) + end do + else + do i=1, n_row + y(i) = alpha * conjg(sv%d(i)) * x(i) + y(i) + end do + end if + + else if (beta == -cone) then + + if (alpha == czero) then + y(1:n_row) = -y(1:n_row) + else if (alpha == cone) then + do i=1, n_row + y(i) = conjg(sv%d(i)) * x(i) - y(i) + end do + else if (alpha == -cone) then + do i=1, n_row + y(i) = -conjg(sv%d(i)) * x(i) - y(i) + end do + else + do i=1, n_row + y(i) = alpha * conjg(sv%d(i)) * x(i) - y(i) + end do + end if + + else + + if (alpha == czero) then + y(1:n_row) = beta *y(1:n_row) + else if (alpha == cone) then + do i=1, n_row + y(i) = conjg(sv%d(i)) * x(i) + beta*y(i) + end do + else if (alpha == -cone) then + do i=1, n_row + y(i) = -conjg(sv%d(i)) * x(i) + beta*y(i) + end do + else + do i=1, n_row + y(i) = alpha * conjg(sv%d(i)) * x(i) + beta*y(i) + end do + end if + + end if + + else if (trans_ /= 'C') then + + if (beta == czero) then + + if (alpha == czero) then + y(1:n_row) = czero + else if (alpha == cone) then + do i=1, n_row + y(i) = sv%d(i) * x(i) + end do + else if (alpha == -cone) then + do i=1, n_row + y(i) = -sv%d(i) * x(i) + end do + else + do i=1, n_row + y(i) = alpha * sv%d(i) * x(i) + end do + end if + + else if (beta == cone) then + + if (alpha == czero) then + !y(1:n_row) = czero + else if (alpha == cone) then + do i=1, n_row + y(i) = sv%d(i) * x(i) + y(i) + end do + else if (alpha == -cone) then + do i=1, n_row + y(i) = -sv%d(i) * x(i) + y(i) + end do + else + do i=1, n_row + y(i) = alpha * sv%d(i) * x(i) + y(i) + end do + end if + + else if (beta == -cone) then + + if (alpha == czero) then + y(1:n_row) = -y(1:n_row) + else if (alpha == cone) then + do i=1, n_row + y(i) = sv%d(i) * x(i) - y(i) + end do + else if (alpha == -cone) then + do i=1, n_row + y(i) = -sv%d(i) * x(i) - y(i) + end do + else + do i=1, n_row + y(i) = alpha * sv%d(i) * x(i) - y(i) + end do + end if + + else + + if (alpha == czero) then + y(1:n_row) = beta *y(1:n_row) + else if (alpha == cone) then + do i=1, n_row + y(i) = sv%d(i) * x(i) + beta*y(i) + end do + else if (alpha == -cone) then + do i=1, n_row + y(i) = -sv%d(i) * x(i) + beta*y(i) + end do + else + do i=1, n_row + y(i) = alpha * sv%d(i) * x(i) + beta*y(i) + end do + end if + + end if + + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_diag_solver_apply diff --git a/mlprec/impl/solver/amg_c_diag_solver_apply_vect.f90 b/mlprec/impl/solver/amg_c_diag_solver_apply_vect.f90 new file mode 100644 index 00000000..40b8174c --- /dev/null +++ b/mlprec/impl/solver/amg_c_diag_solver_apply_vect.f90 @@ -0,0 +1,117 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_diag_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_c_diag_solver, amg_protect_name => amg_c_diag_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_diag_solver_type), intent(inout) :: sv + type(psb_c_vect_type), intent(inout) :: x + type(psb_c_vect_type), intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col + complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='c_diag_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + if (x%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/itwo,n_row,izero,izero,izero/)) + goto 9999 + end if + if (y%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/ithree,n_row,izero,izero,izero/)) + goto 9999 + end if + if (.not.allocated(sv%dv)) then + info = 1124 + call psb_errpush(info,name,a_err="preconditioner: D") + goto 9999 + end if + if (sv%dv%get_nrows() < n_row) then + info = 1124 + call psb_errpush(info,name,a_err="preconditioner: D") + goto 9999 + end if + + call y%mlt(alpha,sv%dv,x,beta,info,conjgx=trans_) + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='vect%mlt') + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_diag_solver_apply_vect diff --git a/mlprec/impl/solver/amg_c_diag_solver_bld.f90 b/mlprec/impl/solver/amg_c_diag_solver_bld.f90 new file mode 100644 index 00000000..f55312ea --- /dev/null +++ b/mlprec/impl/solver/amg_c_diag_solver_bld.f90 @@ -0,0 +1,191 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_c_diag_solver, amg_protect_name => amg_c_diag_solver_bld + + Implicit None + + ! Arguments + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type), intent(in), target, optional :: b + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + complex(psb_spk_), allocatable :: tdb(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='c_diag_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + nrow_a = a%get_nrows() + + sv%d = a%get_diag(info) + if (info == psb_success_) call psb_realloc(n_row,sv%d,info) + if (present(b)) then + tdb=b%get_diag(info) + if (size(tdb)+nrow_a > n_row) call psb_realloc(nrow_a+size(tdb),sv%d,info) + if (info == psb_success_) sv%d(nrow_a+1:nrow_a+size(tdb)) = tdb(:) + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='get_diag') + goto 9999 + end if + + do i=1,n_row + if (sv%d(i) == czero) then + sv%d(i) = cone + else + sv%d(i) = cone/sv%d(i) + end if + end do + allocate(sv%dv,stat=info) + if (info == psb_success_) then + call sv%dv%bld(sv%d) + if (present(vmold)) call sv%dv%cnv(vmold) + call sv%dv%sync() + else + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='Allocate sv%dv') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_diag_solver_bld + + +subroutine amg_c_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_c_l1_diag_solver, amg_protect_name => amg_c_l1_diag_solver_bld + + Implicit None + + ! Arguments + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_l1_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type), intent(in), target, optional :: b + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + complex(psb_spk_), allocatable :: tdb(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='c_l1_diag_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + nrow_a = a%get_nrows() + + sv%d = a%arwsum(info) + if (info == psb_success_) call psb_realloc(n_row,sv%d,info) + if (present(b)) then + tdb=b%arwsum(info) + if (size(tdb)+nrow_a > n_row) call psb_realloc(nrow_a+size(tdb),sv%d,info) + if (info == psb_success_) sv%d(nrow_a+1:nrow_a+size(tdb)) = tdb(:) + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='arwsum') + goto 9999 + end if + + do i=1,n_row + if (sv%d(i) == czero) then + sv%d(i) = cone + else + sv%d(i) = cone/sv%d(i) + end if + end do + allocate(sv%dv,stat=info) + if (info == psb_success_) then + call sv%dv%bld(sv%d) + if (present(vmold)) call sv%dv%cnv(vmold) + call sv%dv%sync() + else + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='Allocate sv%dv') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_l1_diag_solver_bld diff --git a/mlprec/impl/solver/amg_c_diag_solver_clear_data.f90 b/mlprec/impl/solver/amg_c_diag_solver_clear_data.f90 new file mode 100644 index 00000000..66ccccb3 --- /dev/null +++ b/mlprec/impl/solver/amg_c_diag_solver_clear_data.f90 @@ -0,0 +1,65 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_diag_solver_clear_data(sv,info) + + use psb_base_mod + use amg_c_diag_solver, amg_protect_name => amg_c_diag_solver_clear_data + + Implicit None + + ! Arguments + class(amg_c_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + call sv%dv%free(info) + if ((info ==0).and.allocated(sv%d)) deallocate(sv%d,stat=info) + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_diag_solver_clear_data diff --git a/mlprec/impl/solver/amg_c_diag_solver_clone.f90 b/mlprec/impl/solver/amg_c_diag_solver_clone.f90 new file mode 100644 index 00000000..fdd20e78 --- /dev/null +++ b/mlprec/impl/solver/amg_c_diag_solver_clone.f90 @@ -0,0 +1,83 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_diag_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_c_diag_solver, amg_protect_name => amg_c_diag_solver_clone + + Implicit None + + ! Arguments + class(amg_c_diag_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(svout)) then + call svout%free(info) + if (info == psb_success_) deallocate(svout, stat=info) + end if + if (info == psb_success_) & + & allocate(svout, mold=sv, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(svo => svout) + class is (amg_c_diag_solver_type) + call psb_safe_ab_cpy(sv%d,svo%d,info) + if (info == psb_success_) & + & call sv%dv%clone(svo%dv,info) + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_diag_solver_clone diff --git a/mlprec/impl/solver/amg_c_diag_solver_cnv.f90 b/mlprec/impl/solver/amg_c_diag_solver_cnv.f90 new file mode 100644 index 00000000..f3c5401e --- /dev/null +++ b/mlprec/impl/solver/amg_c_diag_solver_cnv.f90 @@ -0,0 +1,76 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_diag_solver_cnv(sv,info,amold,vmold,imold) + + use psb_base_mod + use amg_c_diag_solver, amg_protect_name => amg_c_diag_solver_cnv + + Implicit None + + ! Arguments + class(amg_c_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: err_act, debug_unit, debug_level + character(len=20) :: name='d_diag_solver_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) trim(name),' start' + + + if (allocated(sv%dv)) then + call sv%dv%cnv(vmold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_c_diag_solver_cnv diff --git a/mlprec/impl/solver/amg_c_diag_solver_dmp.f90 b/mlprec/impl/solver/amg_c_diag_solver_dmp.f90 new file mode 100644 index 00000000..beeeae6c --- /dev/null +++ b/mlprec/impl/solver/amg_c_diag_solver_dmp.f90 @@ -0,0 +1,133 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_c_diag_solver, amg_protect_name => amg_c_diag_solver_dmp + implicit none + class(amg_c_diag_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: solver_ + ! len of prefix_ + + info = 0 + + ictxt = desc%get_context() + + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + + if (solver_) then + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_c" + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' + if (allocated(sv%d)) & + & call psb_geprt(fname,sv%d,head=head) + + end if + +end subroutine amg_c_diag_solver_dmp +subroutine amg_c_l1_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_c_l1_diag_solver, amg_protect_name => amg_c_l1_diag_solver_dmp + implicit none + class(amg_c_l1_diag_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: solver_ + ! len of prefix_ + + info = 0 + + ictxt = desc%get_context() + + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + + if (solver_) then + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_c" + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_l1_diag.mtx' + if (allocated(sv%d)) & + & call psb_geprt(fname,sv%d,head=head) + + end if + +end subroutine amg_c_l1_diag_solver_dmp diff --git a/mlprec/impl/solver/amg_c_gs_solver_apply.f90 b/mlprec/impl/solver/amg_c_gs_solver_apply.f90 new file mode 100644 index 00000000..e85b6b65 --- /dev/null +++ b/mlprec/impl/solver/amg_c_gs_solver_apply.f90 @@ -0,0 +1,216 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_gs_solver_apply(alpha,sv,x,beta,y,desc_data,& + &trans,work,info,init,initu) + + use psb_base_mod + use amg_c_gs_solver, amg_protect_name => amg_c_gs_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_gs_solver_type), intent(inout) :: sv + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col, itx, itxst + complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + complex(psb_spk_), allocatable :: temp(:),wv(:),xit(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='c_gs_solver_apply' + + call psb_erractionsave(err_act) + ictxt = desc_data%get_ctxt() + call psb_info(ictxt,me,np) + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') +!!$ case('T') +!!$ case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + + call psb_geasb(wv,desc_data,info) + call psb_geasb(xit,desc_data,info) + itxst = 1 + select case (init_) + case('Z') + call psb_geaxpby(cone,x,czero,wv,desc_data,info) + call psb_spsm(cone,sv%l,wv,czero,xit,desc_data,info) + itxst = 2 + case('Y') + call psb_geaxpby(cone,y,czero,xit,desc_data,info) + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(cone,initu,czero,xit,desc_data,info) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + select case(trans_) + case('N') + if (sv%eps <=szero) then + ! + ! Fixed number of iterations + ! + ! + do itx=itxst,sv%sweeps + call psb_geaxpby(cone,x,czero,wv,desc_data,info) + ! Update with U. The off-diagonal block is taken care + ! from the Jacobi smoother, hence this is purely local. + call psb_spmm(-cone,sv%u,xit,cone,wv,desc_data,info,doswap=.false.) + call psb_spsm(cone,sv%l,wv,czero,xit,desc_data,info) + end do + + call psb_geaxpby(alpha,xit,beta,y,desc_data,info) + + else + ! + ! Iterations to convergence, not implemented right now. + ! + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') + goto 9999 + + end if +!!$ case('T') +!!$ call psb_spsm(cone,sv%u,x,czero,wv,desc_data,info,& +!!$ & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) +!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) +!!$ +!!$ case('C') +!!$ +!!$ call psb_spsm(cone,sv%u,x,czero,wv,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) +!!$ +!!$ call wv1%mlt(cone,sv%dv,wv,czero,info,conjgx=trans_) +!!$ +!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv1,beta,y,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid TRANS in GS subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_gs_solver_apply diff --git a/mlprec/impl/solver/amg_c_gs_solver_apply_vect.f90 b/mlprec/impl/solver/amg_c_gs_solver_apply_vect.f90 new file mode 100644 index 00000000..6f20700e --- /dev/null +++ b/mlprec/impl/solver/amg_c_gs_solver_apply_vect.f90 @@ -0,0 +1,211 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_gs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_c_gs_solver, amg_protect_name => amg_c_gs_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_gs_solver_type), intent(inout) :: sv + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col, itx, itxst + complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + complex(psb_spk_), allocatable :: temp(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='c_gs_solver_apply' + + call psb_erractionsave(err_act) + ictxt = desc_data%get_ctxt() + call psb_info(ictxt,me,np) + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') +!!$ case('T') +!!$ case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + + if (x%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/itwo,n_row,izero,izero,izero/)) + goto 9999 + end if + if (y%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/ithree,n_row,izero,izero,izero/)) + goto 9999 + end if + + + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + + if (size(wv) < 2) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size') + goto 9999 + end if + + associate(tw => wv(1), xit => wv(2)) + itxst = 1 + select case (init_) + case('Z') + call psb_geaxpby(cone,x,czero,tw,desc_data,info) + call psb_spsm(cone,sv%l,tw,czero,xit,desc_data,info) + itxst = 2 + case('Y') + call psb_geaxpby(cone,y,czero,xit,desc_data,info) + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(cone,initu,czero,xit,desc_data,info) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + select case(trans_) + case('N') + if (sv%eps <=szero) then + ! + ! Fixed number of iterations + ! + ! + do itx=itxst,sv%sweeps + call psb_geaxpby(cone,x,czero,tw,desc_data,info) + ! Update with U. The off-diagonal block is taken care + ! from the Jacobi smoother, hence this is purely local. + call psb_spmm(-cone,sv%u,xit,cone,tw,desc_data,info,doswap=.false.) + call psb_spsm(cone,sv%l,tw,czero,xit,desc_data,info) + end do + + call psb_geaxpby(alpha,xit,beta,y,desc_data,info) + + else + ! + ! Iterations to convergence, not implemented right now. + ! + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') + goto 9999 + + end if + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid TRANS in GS subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + end associate + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_gs_solver_apply_vect diff --git a/mlprec/impl/solver/amg_c_gs_solver_bld.f90 b/mlprec/impl/solver/amg_c_gs_solver_bld.f90 new file mode 100644 index 00000000..8f30c6a0 --- /dev/null +++ b/mlprec/impl/solver/amg_c_gs_solver_bld.f90 @@ -0,0 +1,109 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_gs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_c_gs_solver, amg_protect_name => amg_c_gs_solver_bld + + Implicit None + + ! Arguments + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type), intent(in), target, optional :: b + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='c_gs_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + + if (sv%eps <= dzero) then + ! + ! This cuts out the off-diagonal part, because it's supposed to + ! be handled by the outer Jacobi smoother. + ! + call a%tril(sv%l,info,diag=izero,jmax=nrow_a,u=sv%u) + + else + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end if + + + + call sv%l%set_asb() + call sv%l%trim() + call sv%u%set_asb() + call sv%u%trim() + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_gs_solver_bld diff --git a/mlprec/impl/solver/amg_c_gs_solver_clear_data.f90 b/mlprec/impl/solver/amg_c_gs_solver_clear_data.f90 new file mode 100644 index 00000000..5eba0b0c --- /dev/null +++ b/mlprec/impl/solver/amg_c_gs_solver_clear_data.f90 @@ -0,0 +1,65 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_gs_solver_clear_data(sv,info) + + use psb_base_mod + use amg_c_gs_solver, amg_protect_name => amg_c_gs_solver_clear_data + + Implicit None + + ! Arguments + class(amg_c_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + call sv%l%free() + call sv%u%free() + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_gs_solver_clear_data diff --git a/mlprec/impl/solver/amg_c_gs_solver_clone.f90 b/mlprec/impl/solver/amg_c_gs_solver_clone.f90 new file mode 100644 index 00000000..c85c2942 --- /dev/null +++ b/mlprec/impl/solver/amg_c_gs_solver_clone.f90 @@ -0,0 +1,87 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_gs_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_c_gs_solver, amg_protect_name => amg_c_gs_solver_clone + + Implicit None + + ! Arguments + class(amg_c_gs_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + if (allocated(svout)) then + call svout%free(info) + if (info == psb_success_) deallocate(svout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_c_gs_solver_type :: svout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(svo => svout) + type is (amg_c_gs_solver_type) + svo%sweeps = sv%sweeps + svo%eps = sv%eps + if (info == psb_success_) & + & call sv%l%clone(svo%l,info) + if (info == psb_success_) & + & call sv%u%clone(svo%u,info) + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_gs_solver_clone diff --git a/mlprec/impl/solver/amg_c_gs_solver_clone_settings.f90 b/mlprec/impl/solver/amg_c_gs_solver_clone_settings.f90 new file mode 100644 index 00000000..8b2131ea --- /dev/null +++ b/mlprec/impl/solver/amg_c_gs_solver_clone_settings.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_gs_solver_clone_settings(sv,svout,info) + + use psb_base_mod + use amg_c_gs_solver, amg_protect_name => amg_c_gs_solver_clone_settings + Implicit None + ! Arguments + class(amg_c_gs_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_gs_solver_clone_settings' + + call psb_erractionsave(err_act) + + select type(svout) + class is(amg_c_gs_solver_type) + svout%sweeps = sv%sweeps + svout%eps = sv%eps + + class default + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_gs_solver_clone_settings diff --git a/mlprec/impl/solver/amg_c_gs_solver_cnv.f90 b/mlprec/impl/solver/amg_c_gs_solver_cnv.f90 new file mode 100644 index 00000000..4fca695a --- /dev/null +++ b/mlprec/impl/solver/amg_c_gs_solver_cnv.f90 @@ -0,0 +1,74 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_gs_solver_cnv(sv,info,amold,vmold,imold) + + use psb_base_mod + use amg_c_gs_solver, amg_protect_name => amg_c_gs_solver_cnv + + Implicit None + + ! Arguments + class(amg_c_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: err_act, debug_unit, debug_level + character(len=20) :: name='c_gs_solver_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_gs_solver_cnv diff --git a/mlprec/impl/solver/amg_c_gs_solver_dmp.f90 b/mlprec/impl/solver/amg_c_gs_solver_dmp.f90 new file mode 100644 index 00000000..bb05bd3f --- /dev/null +++ b/mlprec/impl/solver/amg_c_gs_solver_dmp.f90 @@ -0,0 +1,102 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_gs_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_c_gs_solver, amg_protect_name => amg_c_gs_solver_dmp + implicit none + class(amg_c_gs_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + integer(psb_lpk_), allocatable :: iv(:) + logical :: solver_, global_num_ + ! len of prefix_ + + info = 0 + + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + + if (solver_) then + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_d" + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + if (global_num_) then + iv = desc%get_global_indices(owned=.false.) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' + if (sv%l%is_asb()) & + & call sv%l%print(fname,head=head,iv=iv) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' + if (sv%u%is_asb()) & + & call sv%u%print(fname,head=head,iv=iv) + else + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' + if (sv%l%is_asb()) & + & call sv%l%print(fname,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' + if (sv%u%is_asb()) & + & call sv%u%print(fname,head=head) + end if + end if + +end subroutine amg_c_gs_solver_dmp diff --git a/mlprec/impl/solver/amg_c_id_solver_apply.f90 b/mlprec/impl/solver/amg_c_id_solver_apply.f90 new file mode 100644 index 00000000..28b36f48 --- /dev/null +++ b/mlprec/impl/solver/amg_c_id_solver_apply.f90 @@ -0,0 +1,86 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_id_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + + use psb_base_mod + use amg_c_id_solver, amg_protect_name => amg_c_id_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_id_solver_type), intent(inout) :: sv + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='c_id_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call psb_geaxpby(alpha,x,beta,y,desc_data,info) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_id_solver_apply diff --git a/mlprec/impl/solver/amg_c_id_solver_apply_vect.f90 b/mlprec/impl/solver/amg_c_id_solver_apply_vect.f90 new file mode 100644 index 00000000..3e387a1f --- /dev/null +++ b/mlprec/impl/solver/amg_c_id_solver_apply_vect.f90 @@ -0,0 +1,87 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_id_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_c_id_solver, amg_protect_name => amg_c_id_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_id_solver_type), intent(inout) :: sv + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='c_id_solver_apply_vect' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call psb_geaxpby(alpha,x,beta,y,desc_data,info) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_id_solver_apply_vect diff --git a/mlprec/impl/solver/amg_c_id_solver_clone.f90 b/mlprec/impl/solver/amg_c_id_solver_clone.f90 new file mode 100644 index 00000000..f6030a1f --- /dev/null +++ b/mlprec/impl/solver/amg_c_id_solver_clone.f90 @@ -0,0 +1,81 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_id_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_c_id_solver, amg_protect_name => amg_c_id_solver_clone + + Implicit None + + ! Arguments + class(amg_c_id_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(svout)) then + call svout%free(info) + if (info == psb_success_) deallocate(svout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_c_id_solver_type :: svout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(svo => svout) + type is (amg_c_id_solver_type) + ! Nothing to be done. + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_id_solver_clone diff --git a/mlprec/impl/solver/amg_c_ilu_solver_apply.f90 b/mlprec/impl/solver/amg_c_ilu_solver_apply.f90 new file mode 100644 index 00000000..88dde6ab --- /dev/null +++ b/mlprec/impl/solver/amg_c_ilu_solver_apply.f90 @@ -0,0 +1,153 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + + use psb_base_mod + use amg_c_ilu_solver, amg_protect_name => amg_c_ilu_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_ilu_solver_type), intent(inout) :: sv + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col + complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='c_ilu_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + endif + + select case(trans_) + case('N') + call psb_spsm(cone,sv%l,x,czero,ww,desc_data,info,& + & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) + + if (info == psb_success_) call psb_spsm(alpha,sv%u,ww,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_, work=aux) + + case('T') + call psb_spsm(cone,sv%u,x,czero,ww,desc_data,info,& + & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) + if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + case('C') + call psb_spsm(cone,sv%u,x,czero,ww,desc_data,info,& + & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) + if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid TRANS in ILU subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_ilu_solver_apply diff --git a/mlprec/impl/solver/amg_c_ilu_solver_apply_vect.f90 b/mlprec/impl/solver/amg_c_ilu_solver_apply_vect.f90 new file mode 100644 index 00000000..82b3435c --- /dev/null +++ b/mlprec/impl/solver/amg_c_ilu_solver_apply_vect.f90 @@ -0,0 +1,194 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_c_ilu_solver, amg_protect_name => amg_c_ilu_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_ilu_solver_type), intent(inout) :: sv + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col + type(psb_c_vect_type) :: tw, tw1 + complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='c_ilu_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + + if (x%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/itwo,n_row,izero,izero,izero/)) + goto 9999 + end if + if (y%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/ithree,n_row,izero,izero,izero/)) + goto 9999 + end if + if (.not.allocated(sv%dv%v)) then + info = 1124 + call psb_errpush(info,name,a_err="preconditioner: D") + goto 9999 + end if + if (sv%dv%get_nrows() < n_row) then + info = 1124 + call psb_errpush(info,name,a_err="preconditioner: DV") + goto 9999 + end if + + + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + + + if (size(wv) < 2) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size') + goto 9999 + end if + + + associate(tw => wv(1), tw1 => wv(2)) + + select case(trans_) + case('N') + call psb_spsm(cone,sv%l,x,czero,tw,desc_data,info,& + & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) + + if (info == psb_success_) call psb_spsm(alpha,sv%u,tw,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_, work=aux) + + case('T') + call psb_spsm(cone,sv%u,x,czero,tw,desc_data,info,& + & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) + if (info == psb_success_) call psb_spsm(alpha,sv%l,tw,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + + case('C') + + call psb_spsm(cone,sv%u,x,czero,tw,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + + call tw1%mlt(cone,sv%dv,tw,czero,info,conjgx=trans_) + + if (info == psb_success_) call psb_spsm(alpha,sv%l,tw1,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid TRANS in ILU subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + end associate + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_c_ilu_solver_apply_vect diff --git a/mlprec/impl/solver/amg_c_ilu_solver_bld.f90 b/mlprec/impl/solver/amg_c_ilu_solver_bld.f90 new file mode 100644 index 00000000..489f0814 --- /dev/null +++ b/mlprec/impl/solver/amg_c_ilu_solver_bld.f90 @@ -0,0 +1,191 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_ilu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_c_ilu_solver, amg_protect_name => amg_c_ilu_solver_bld + + Implicit None + + ! Arguments + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type), intent(in), target, optional :: b + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota +!!$ complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='c_ilu_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + if (present(b)) then + nztota = nztota + b%get_nzeros() + end if + + call sv%l%csall(n_row,n_row,info,nztota) + if (info == psb_success_) call sv%u%csall(n_row,n_row,info,nztota) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_sp_all' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + if (allocated(sv%d)) then + if (size(sv%d) < n_row) then + deallocate(sv%d) + endif + endif + if (.not.allocated(sv%d)) allocate(sv%d(n_row),stat=info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') + goto 9999 + endif + + + select case(sv%fact_type) + + case (psb_ilu_t_) + ! + ! ILU(k,t) + ! + select case(sv%fill_in) + + case(:-1) + ! Error: fill-in <= -1 + call psb_errpush(psb_err_input_value_invalid_i_,& + & name,i_err=(/ithree,sv%fill_in,izero,izero,izero/)) + goto 9999 + + case(0:) + ! Fill-in >= 0 + call psb_ilut_fact(sv%fill_in,sv%thresh,& + & a, sv%l,sv%u,sv%d,info,blck=b) + end select + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ilut_fact' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + case(psb_ilu_n_,psb_milu_n_) + ! + ! ILU(k) and MILU(k) + ! + select case(sv%fill_in) + case(:-1) + ! Error: fill-in <= -1 + call psb_errpush(psb_err_input_value_invalid_i_,& + & name,i_err=(/ithree,sv%fill_in,izero,izero,izero/)) + goto 9999 + case(0) + ! Fill-in 0 + ! Separate implementation of ILU(0) for better performance. + ! There seems to be a problem with the separate implementation of MILU(0), + ! contained into psb_ilu0_fact. This must be investigated. For the time being, + ! resort to the implementation of MILU(k) with k=0. + if (sv%fact_type == psb_ilu_n_) then + call psb_ilu0_fact(sv%fact_type,a,sv%l,sv%u,& + & sv%d,info,blck=b) + else + call psb_iluk_fact(sv%fill_in,sv%fact_type,& + & a,sv%l,sv%u,sv%d,info,blck=b) + endif + case(1:) + ! Fill-in >= 1 + ! The same routine implements both ILU(k) and MILU(k) + call psb_iluk_fact(sv%fill_in,sv%fact_type,& + & a,sv%l,sv%u,sv%d,info,blck=b) + end select + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_iluk_fact' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + case default + ! If we end up here, something was wrong up in the call chain. + info = psb_err_input_value_invalid_i_ + call psb_errpush(psb_err_input_value_invalid_i_,name,& + & i_err=(/ithree,sv%fact_type,izero,izero,izero/)) + goto 9999 + + end select + + call sv%l%set_asb() + call sv%l%trim() + call sv%u%set_asb() + call sv%u%trim() + call sv%dv%bld(sv%d,mold=vmold) + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_ilu_solver_bld diff --git a/mlprec/impl/solver/amg_c_ilu_solver_clear_data.f90 b/mlprec/impl/solver/amg_c_ilu_solver_clear_data.f90 new file mode 100644 index 00000000..07903fa5 --- /dev/null +++ b/mlprec/impl/solver/amg_c_ilu_solver_clear_data.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_ilu_solver_clear_data(sv,info) + + use psb_base_mod + use amg_c_ilu_solver, amg_protect_name => amg_c_ilu_solver_clear_data + + Implicit None + + ! Arguments + class(amg_c_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + call sv%l%free() + call sv%u%free() + call sv%dv%free(info) + if ((info==0).and.allocated(sv%d)) deallocate(sv%d,stat=info) + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_ilu_solver_clear_data diff --git a/mlprec/impl/solver/amg_c_ilu_solver_clone.f90 b/mlprec/impl/solver/amg_c_ilu_solver_clone.f90 new file mode 100644 index 00000000..1d5b5098 --- /dev/null +++ b/mlprec/impl/solver/amg_c_ilu_solver_clone.f90 @@ -0,0 +1,91 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_ilu_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_c_ilu_solver, amg_protect_name => amg_c_ilu_solver_clone + + Implicit None + + ! Arguments + class(amg_c_ilu_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + if (allocated(svout)) then + call svout%free(info) + if (info == psb_success_) deallocate(svout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_c_ilu_solver_type :: svout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(svo => svout) + type is (amg_c_ilu_solver_type) + svo%fact_type = sv%fact_type + svo%fill_in = sv%fill_in + svo%thresh = sv%thresh + call psb_safe_ab_cpy(sv%d,svo%d,info) + if (info == psb_success_) & + & call sv%dv%clone(svo%dv,info) + if (info == psb_success_) & + & call sv%l%clone(svo%l,info) + if (info == psb_success_) & + & call sv%u%clone(svo%u,info) + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_ilu_solver_clone diff --git a/mlprec/impl/solver/amg_c_ilu_solver_clone_settings.f90 b/mlprec/impl/solver/amg_c_ilu_solver_clone_settings.f90 new file mode 100644 index 00000000..b8cb430f --- /dev/null +++ b/mlprec/impl/solver/amg_c_ilu_solver_clone_settings.f90 @@ -0,0 +1,70 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_ilu_solver_clone_settings(sv,svout,info) + + use psb_base_mod + use amg_c_ilu_solver, amg_protect_name => amg_c_ilu_solver_clone_settings + Implicit None + ! Arguments + class(amg_c_ilu_solver_type), intent(inout) :: sv + class(amg_c_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_ilu_solver_clone_settings' + + call psb_erractionsave(err_act) + + select type(svout) + class is(amg_c_ilu_solver_type) + svout%fact_type = sv%fact_type + svout%fill_in = sv%fill_in + svout%thresh = sv%thresh + + class default + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_ilu_solver_clone_settings diff --git a/mlprec/impl/solver/amg_c_ilu_solver_cnv.f90 b/mlprec/impl/solver/amg_c_ilu_solver_cnv.f90 new file mode 100644 index 00000000..fb742814 --- /dev/null +++ b/mlprec/impl/solver/amg_c_ilu_solver_cnv.f90 @@ -0,0 +1,76 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_ilu_solver_cnv(sv,info,amold,vmold,imold) + + use psb_base_mod + use amg_c_ilu_solver, amg_protect_name => amg_c_ilu_solver_cnv + + Implicit None + + ! Arguments + class(amg_c_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: err_act, debug_unit, debug_level + character(len=20) :: name='d_ilu_solver_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + call sv%dv%cnv(mold=vmold) + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_c_ilu_solver_cnv diff --git a/mlprec/impl/solver/amg_c_ilu_solver_dmp.f90 b/mlprec/impl/solver/amg_c_ilu_solver_dmp.f90 new file mode 100644 index 00000000..e4c53a03 --- /dev/null +++ b/mlprec/impl/solver/amg_c_ilu_solver_dmp.f90 @@ -0,0 +1,112 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_c_ilu_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_c_ilu_solver, amg_protect_name => amg_c_ilu_solver_dmp + implicit none + class(amg_c_ilu_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: solver_, global_num_ + integer(psb_lpk_), allocatable :: iv(:) + ! len of prefix_ + + info = 0 + + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + + + if (solver_) then + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_c" + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + if (global_num_) then + iv = desc%get_global_indices(owned=.false.) + + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' + if (sv%l%is_asb()) & + & call sv%l%print(fname,head=head,iv=iv) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' + if (allocated(sv%d)) & + & call psb_geprt(fname,sv%d,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' + if (sv%u%is_asb()) & + & call sv%u%print(fname,head=head,iv=iv) + + else + + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' + if (sv%l%is_asb()) & + & call sv%l%print(fname,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' + if (allocated(sv%d)) & + & call psb_geprt(fname,sv%d,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' + if (sv%u%is_asb()) & + & call sv%u%print(fname,head=head) + end if + end if + +end subroutine amg_c_ilu_solver_dmp diff --git a/mlprec/impl/solver/amg_c_mumps_solver_apply.F90 b/mlprec/impl/solver/amg_c_mumps_solver_apply.F90 new file mode 100644 index 00000000..533048f0 --- /dev/null +++ b/mlprec/impl/solver/amg_c_mumps_solver_apply.F90 @@ -0,0 +1,169 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.0) +! +! (C) Copyright 2008,2009,2010,2012,2013 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +subroutine c_mumps_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + use psb_base_mod + use amg_c_mumps_solver + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_mumps_solver_type), intent(inout) :: sv + complex(psb_spk_),intent(inout) :: x(:) + complex(psb_spk_),intent(inout) :: y(:) + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row, n_col + integer(psb_lpk_) :: nglob + integer(psb_epk_) :: eng + complex(psb_spk_), allocatable :: ww(:) + complex(psb_spk_), allocatable, target :: gx(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='c_mumps_solver_apply' + + call psb_erractionsave(err_act) + +#if defined(HAVE_MUMPS_) + info = psb_success_ + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + nglob = desc_data%get_global_rows() + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + ! Running in local mode? + if (sv%ipar(1) == amg_local_solver_ ) then + gx = x + else if (sv%ipar(1) == amg_global_solver_ ) then + + if (n_col <= size(work)) then + ww = work(1:n_col) + else + allocate(ww(n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/n_col/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + end if + allocate(gx(nglob),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_; eng = nglob + call psb_errpush(info,name,e_err=(/eng/),& + & a_err='complex(psb_spk_)') + goto 9999 + end if + call psb_gather(gx, x, desc_data, info, root=izero) + else + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid local/global solver in MUMPS') + goto 9999 + end if + + select case(trans_) + case('N') + sv%id%icntl(9) = 1 + case('T') + sv%id%icntl(9) = 2 + case default + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Invalid TRANS in subsolve') + goto 9999 + end select + + sv%id%rhs => gx + sv%id%nrhs = 1 + sv%id%icntl(1)=-1 + sv%id%icntl(2)=-1 + sv%id%icntl(3)=-1 + sv%id%icntl(4)=-1 + sv%id%job = 3 + call cmumps(sv%id) + if (sv%ipar(1) == amg_local_solver_ ) then + call psb_geaxpby(alpha,gx,beta,y,desc_data,info) + else + call psb_scatter(gx, ww, desc_data, info, root=izero) + if (info == psb_success_) then + call psb_geaxpby(alpha,ww,beta,y,desc_data,info) + end if + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in subsolve') + goto 9999 + endif + + if (allocated(ww)) deallocate(ww) + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return + +#else + write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " +#endif +end subroutine c_mumps_solver_apply + diff --git a/mlprec/impl/solver/amg_c_mumps_solver_apply_vect.F90 b/mlprec/impl/solver/amg_c_mumps_solver_apply_vect.F90 new file mode 100644 index 00000000..9f0360df --- /dev/null +++ b/mlprec/impl/solver/amg_c_mumps_solver_apply_vect.F90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.0) +! +! (C) Copyright 2008,2009,2010,2012,2013 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +subroutine c_mumps_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + use psb_base_mod + use amg_c_mumps_solver + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_c_mumps_solver_type), intent(inout) :: sv + type(psb_c_vect_type),intent(inout) :: x + type(psb_c_vect_type),intent(inout) :: y + complex(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_spk_),target, intent(inout) :: work(:) + type(psb_c_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_c_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: err_act + character(len=20) :: name='c_mumps_solver_apply_vect' + +#if defined(HAVE_MUMPS_) + + call psb_erractionsave(err_act) + + info = psb_success_ + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call x%v%sync() + call y%v%sync() + call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) + call y%v%set_host() + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return + +#else + write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " +#endif + +end subroutine c_mumps_solver_apply_vect + diff --git a/mlprec/impl/solver/amg_c_mumps_solver_bld.F90 b/mlprec/impl/solver/amg_c_mumps_solver_bld.F90 new file mode 100644 index 00000000..19c325a5 --- /dev/null +++ b/mlprec/impl/solver/amg_c_mumps_solver_bld.F90 @@ -0,0 +1,262 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.0) +! +! (C) Copyright 2008,2009,2010,2012,2013 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +subroutine c_mumps_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_c_mumps_solver + Implicit None + + ! Arguments + type(psb_cspmat_type) :: c + type(psb_cspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_c_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_cspmat_type), intent(in), target, optional :: b + class(psb_c_base_sparse_mat), intent(in), optional :: amold + class(psb_c_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + type(psb_cspmat_type) :: atmp + type(psb_c_coo_sparse_mat), target :: acoo +#if defined(IPK4) && defined(LPK8) + integer(psb_lpk_), allocatable :: gia(:), gja(:) +#endif + integer(psb_ipk_) :: n_row,n_col, nrow_a, nza, npr, npc + integer(psb_lpk_) :: nglob, nglobrec, nzt + integer(psb_ipk_) :: ifrst, ibcheck + integer(psb_ipk_) :: ictxt, ictxt1, icomm, np, iam, me, i, err_act, debug_unit, debug_level + character(len=20) :: name='c_mumps_solver_bld', ch_err + +#if defined(HAVE_MUMPS_) + + info=psb_success_ + + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, iam, np) + if (sv%ipar(1) == amg_local_solver_ ) then + call psb_init(ictxt1,np=1,basectxt=ictxt,ids=(/iam/)) + icomm = psb_get_mpi_comm(ictxt1) + allocate(sv%local_ictxt,stat=info) + sv%local_ictxt = ictxt1 + !write(*,*)iam,'mumps_bld: local +++++>',icomm,sv%local_ictxt + call psb_info(ictxt1, me, np) + npr = np + else if (sv%ipar(1) == amg_global_solver_ ) then + icomm = psb_get_mpi_comm(ictxt) + !write(*,*)iam,'mumps_bld: global +++++>',icomm,ictxt + call psb_info(ictxt, iam, np) + me = iam + npr = np + else + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid local/global solver in MUMPS') + goto 9999 + end if + npc = 1 + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + ! if (allocated(sv%id)) then + ! call sv%free(info) + + ! deallocate(sv%id) + ! end if + if(.not.allocated(sv%id)) then + allocate(sv%id,stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_dealloc_ + call psb_errpush(info,name,a_err='amg_cmumps_default') + goto 9999 + end if + end if + + + sv%id%comm = icomm + sv%id%job = -1 + sv%id%par = 1 + if (sv%ipar(3) == 2) then + sv%id%sym = 2 + else + sv%id%sym = 0 + end if + + call cmumps(sv%id) + !WARNING: CALLING cmumps WITH JOB=-1 DESTROY THE SETTING OF DEFAULT:TO FIX + if (allocated(sv%icntl)) then + do i=1,amg_mumps_icntl_size + if (allocated(sv%icntl(i)%item)) then + !write(0,*) 'MUMPS_BLD: setting entry ',i,' to ', sv%icntl(i)%item + sv%id%icntl(i) = sv%icntl(i)%item + end if + end do + end if + if (allocated(sv%rcntl)) then + do i=1,amg_mumps_rcntl_size + if (allocated(sv%rcntl(i)%item)) sv%id%cntl(i) = sv%rcntl(i)%item + end do + end if + sv%id%icntl(3)=sv%ipar(2) + + nglob = desc_a%get_global_rows() + if (sv%ipar(1) == amg_local_solver_ ) then + nglobrec=desc_a%get_local_rows() + if (sv%ipar(3) == 2) then + ! Always pass the upper triangle to MUMPS + call a%triu(c,info,jmax=a%get_nrows()) + call c%set_symmetric() + else + call a%csclip(c,info,jmax=a%get_nrows()) + end if + call c%cp_to(acoo) + nglob = c%get_nrows() + if (nglobrec /= nglob) then + write(*,*)'WARNING: MUMPS solver does not allow overlap in AS yet. ' + write(*,*)'A zero-overlap is used instead' + end if + else + call a%cp_to(acoo) + end if + nza = acoo%get_nzeros() + + ! switch to global numbering + if (sv%ipar(1) == amg_global_solver_ ) then +#if defined(IPK4) && defined(LPK8) + ! + ! Strategy here is as follows: because a call to MUMPS + ! as a gobal solver is mostly done at the coarsest level, + ! even if we start from a problem requiring 8 bytes, chances + ! are that the global size will be suitable for 4 bytes + ! anyway, so we hope for the best, and throw an error + ! if something goes wrong. + ! + if (nglob > huge(1_psb_ipk_)) then + write(0,*) iam,' ',trim(name),': Error: overflow of local indices ' + info=psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + gia = acoo%ia(1:nza) + gja = acoo%ja(1:nza) + call psb_loc_to_glob(gia(1:nza), desc_a, info, iact='I') + call psb_loc_to_glob(gja(1:nza), desc_a, info, iact='I') + acoo%ia(1:nza) = gia(1:nza) + acoo%ja(1:nza) = gja(1:nza) +#else + ! + ! Here global and local numbers have the same size, so this must work. + ! + call psb_loc_to_glob(acoo%ja(1:nza), desc_a, info, iact='I') + call psb_loc_to_glob(acoo%ia(1:nza), desc_a, info, iact='I') +#endif + if (sv%ipar(3) == 2 ) then + ! Always pass the upper triangle to MUMPS + block + integer(psb_ipk_) :: j,nz + nz = 0 + do j=1,nza + if (acoo%ja(j) >= acoo%ia(j)) then + nz = nz + 1 + acoo%ia(nz) = acoo%ia(j) + acoo%ja(nz) = acoo%ja(j) + acoo%val(nz) = acoo%val(j) + end if + end do + call acoo%set_nzeros(nz) + call acoo%set_triangle() + call acoo%set_upper() + call acoo%set_symmetric() + end block + end if + end if + sv%id%irn_loc => acoo%ia + sv%id%jcn_loc => acoo%ja + sv%id%a_loc => acoo%val + sv%id%icntl(18) = 3 + sv%id%n = nglob + ! there should be a better way for this + sv%id%nnz_loc = acoo%get_nzeros() + sv%id%nnz = acoo%get_nzeros() + sv%id%job = 4 + if (sv%ipar(1) == amg_global_solver_ ) then + call psb_sum(ictxt,sv%id%nnz) + end if + !call psb_barrier(ictxt) + write(*,*)iam, ' calling mumps N,nz,nz_loc',sv%id%n,sv%id%nnz,sv%id%nnz_loc + call cmumps(sv%id) + !call psb_barrier(ictxt) + info = sv%id%infog(1) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='amg_cmumps_fact ' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + nullify(sv%id%irn) + nullify(sv%id%jcn) + nullify(sv%id%a) + + call acoo%free() + sv%built=.true. + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) iam,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +#else + write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " +#endif +end subroutine c_mumps_solver_bld + diff --git a/mlprec/impl/solver/amg_d_base_solver_apply.f90 b/mlprec/impl/solver/amg_d_base_solver_apply.f90 new file mode 100644 index 00000000..f9d23999 --- /dev/null +++ b/mlprec/impl/solver/amg_d_base_solver_apply.f90 @@ -0,0 +1,71 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + + use psb_base_mod + use amg_d_base_solver_mod, amg_protect_name => amg_d_base_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_base_solver_type), intent(inout) :: sv + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_base_solver_apply diff --git a/mlprec/impl/solver/amg_d_base_solver_apply_vect.f90 b/mlprec/impl/solver/amg_d_base_solver_apply_vect.f90 new file mode 100644 index 00000000..f2b3989b --- /dev/null +++ b/mlprec/impl/solver/amg_d_base_solver_apply_vect.f90 @@ -0,0 +1,72 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_d_base_solver_mod, amg_protect_name => amg_d_base_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_base_solver_type), intent(inout) :: sv + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_apply_vect' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_base_solver_apply_vect diff --git a/mlprec/impl/solver/amg_d_base_solver_bld.f90 b/mlprec/impl/solver/amg_d_base_solver_bld.f90 new file mode 100644 index 00000000..5db987e9 --- /dev/null +++ b/mlprec/impl/solver/amg_d_base_solver_bld.f90 @@ -0,0 +1,68 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_d_base_solver_mod, amg_protect_name => amg_d_base_solver_bld + Implicit None + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_bld' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_solver_bld diff --git a/mlprec/impl/solver/amg_d_base_solver_check.f90 b/mlprec/impl/solver/amg_d_base_solver_check.f90 new file mode 100644 index 00000000..3f2fc837 --- /dev/null +++ b/mlprec/impl/solver/amg_d_base_solver_check.f90 @@ -0,0 +1,61 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_solver_check(sv,info) + + use psb_base_mod + use amg_d_base_solver_mod, amg_protect_name => amg_d_base_solver_check + Implicit None + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_solver_check diff --git a/mlprec/impl/solver/amg_d_base_solver_clear_data.f90 b/mlprec/impl/solver/amg_d_base_solver_clear_data.f90 new file mode 100644 index 00000000..d74ece28 --- /dev/null +++ b/mlprec/impl/solver/amg_d_base_solver_clear_data.f90 @@ -0,0 +1,60 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_solver_clear_data(sv,info) + + use psb_base_mod + use amg_d_base_solver_mod, amg_protect_name => amg_d_base_solver_clear_data + Implicit None + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_clear_data' + + call psb_erractionsave(err_act) + info = 0 + + ! Do nothing + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_solver_clear_data diff --git a/mlprec/impl/solver/amg_d_base_solver_clone.f90 b/mlprec/impl/solver/amg_d_base_solver_clone.f90 new file mode 100644 index 00000000..a82d33a6 --- /dev/null +++ b/mlprec/impl/solver/amg_d_base_solver_clone.f90 @@ -0,0 +1,62 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_d_base_solver_mod, amg_protect_name => amg_d_base_solver_clone + Implicit None + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_clone' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_solver_clone diff --git a/mlprec/impl/solver/amg_d_base_solver_clone_settings.f90 b/mlprec/impl/solver/amg_d_base_solver_clone_settings.f90 new file mode 100644 index 00000000..3feb2ddb --- /dev/null +++ b/mlprec/impl/solver/amg_d_base_solver_clone_settings.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_solver_clone_settings(sv,svout,info) + + use psb_base_mod + use amg_d_base_solver_mod, amg_protect_name => amg_d_base_solver_clone_settings + Implicit None + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_clone_settings' + + call psb_erractionsave(err_act) + + if (same_type_as(sv,svout)) then + ! Do nothing + else + + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_solver_clone_settings diff --git a/mlprec/impl/solver/amg_d_base_solver_cnv.f90 b/mlprec/impl/solver/amg_d_base_solver_cnv.f90 new file mode 100644 index 00000000..bdee6300 --- /dev/null +++ b/mlprec/impl/solver/amg_d_base_solver_cnv.f90 @@ -0,0 +1,63 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_solver_cnv(sv,info,amold,vmold,imold) + + use psb_base_mod + use amg_d_base_solver_mod, amg_protect_name => amg_d_base_solver_cnv + Implicit None + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_cnv' + + call psb_erractionsave(err_act) + + info = psb_success_ + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_solver_cnv diff --git a/mlprec/impl/solver/amg_d_base_solver_csetc.f90 b/mlprec/impl/solver/amg_d_base_solver_csetc.f90 new file mode 100644 index 00000000..0ef6dcdc --- /dev/null +++ b/mlprec/impl/solver/amg_d_base_solver_csetc.f90 @@ -0,0 +1,63 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_solver_csetc(sv,what,val,info,idx) + + use psb_base_mod + use amg_d_base_solver_mod, amg_protect_name => amg_d_base_solver_csetc + Implicit None + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + Integer(Psb_ipk_) :: err_act, ival + character(len=20) :: name='d_base_solver_csetc' + + call psb_erractionsave(err_act) + + info = psb_success_ + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_solver_csetc diff --git a/mlprec/impl/solver/amg_d_base_solver_cseti.f90 b/mlprec/impl/solver/amg_d_base_solver_cseti.f90 new file mode 100644 index 00000000..22a20f96 --- /dev/null +++ b/mlprec/impl/solver/amg_d_base_solver_cseti.f90 @@ -0,0 +1,56 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_solver_cseti(sv,what,val,info,idx) + + use psb_base_mod + use amg_d_base_solver_mod, amg_protect_name => amg_d_base_solver_cseti + Implicit None + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_cseti' + + ! Correct action here is doing nothing. + info = 0 + + return +end subroutine amg_d_base_solver_cseti diff --git a/mlprec/impl/solver/amg_d_base_solver_csetr.f90 b/mlprec/impl/solver/amg_d_base_solver_csetr.f90 new file mode 100644 index 00000000..a5a094a6 --- /dev/null +++ b/mlprec/impl/solver/amg_d_base_solver_csetr.f90 @@ -0,0 +1,57 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_solver_csetr(sv,what,val,info,idx) + + use psb_base_mod + use amg_d_base_solver_mod, amg_protect_name => amg_d_base_solver_csetr + Implicit None + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_csetr' + + + ! Correct action here is doing nothing. + info = 0 + + return +end subroutine amg_d_base_solver_csetr diff --git a/mlprec/impl/solver/amg_d_base_solver_descr.f90 b/mlprec/impl/solver/amg_d_base_solver_descr.f90 new file mode 100644 index 00000000..9bd132b4 --- /dev/null +++ b/mlprec/impl/solver/amg_d_base_solver_descr.f90 @@ -0,0 +1,66 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_solver_descr(sv,info,iout,coarse) + + use psb_base_mod + use amg_d_base_solver_mod, amg_protect_name => amg_d_base_solver_descr + Implicit None + ! Arguments + class(amg_d_base_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_d_base_solver_descr' + + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_solver_descr diff --git a/mlprec/impl/solver/amg_d_base_solver_dmp.f90 b/mlprec/impl/solver/amg_d_base_solver_dmp.f90 new file mode 100644 index 00000000..ca194426 --- /dev/null +++ b/mlprec/impl/solver/amg_d_base_solver_dmp.f90 @@ -0,0 +1,78 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_d_base_solver_mod, amg_protect_name => amg_d_base_solver_dmp + implicit none + class(amg_d_base_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: solver_ + ! len of prefix_ + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_d" + end if + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + ! At base level do nothing for the solver + +end subroutine amg_d_base_solver_dmp diff --git a/mlprec/impl/solver/amg_d_base_solver_free.f90 b/mlprec/impl/solver/amg_d_base_solver_free.f90 new file mode 100644 index 00000000..71166e0e --- /dev/null +++ b/mlprec/impl/solver/amg_d_base_solver_free.f90 @@ -0,0 +1,60 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_base_solver_free(sv,info) + + use psb_base_mod + use amg_d_base_solver_mod, amg_protect_name => amg_d_base_solver_free + Implicit None + ! Arguments + class(amg_d_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_free' + + call psb_erractionsave(err_act) + + ! Do nothing + info = psb_success_ + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_base_solver_free diff --git a/mlprec/impl/solver/amg_d_bwgs_solver_apply.f90 b/mlprec/impl/solver/amg_d_bwgs_solver_apply.f90 new file mode 100644 index 00000000..45a7bbcb --- /dev/null +++ b/mlprec/impl/solver/amg_d_bwgs_solver_apply.f90 @@ -0,0 +1,216 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_bwgs_solver_apply(alpha,sv,x,beta,y,desc_data,& + &trans,work,info,init,initu) + + use psb_base_mod + use amg_d_gs_solver, amg_protect_name => amg_d_bwgs_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_bwgs_solver_type), intent(inout) :: sv + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col, itx, itxst + real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + real(psb_dpk_), allocatable :: temp(:),wv(:),xit(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='d_bwgs_solver_apply' + + call psb_erractionsave(err_act) + ictxt = desc_data%get_ctxt() + call psb_info(ictxt,me,np) + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') +!!$ case('T') +!!$ case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + + call psb_geasb(wv,desc_data,info) + call psb_geasb(xit,desc_data,info) + itxst = 1 + select case (init_) + case('Z') + call psb_geaxpby(done,x,dzero,wv,desc_data,info) + call psb_spsm(done,sv%u,wv,dzero,xit,desc_data,info) + itxst = 2 + case('Y') + call psb_geaxpby(done,y,dzero,xit,desc_data,info) + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(done,initu,dzero,xit,desc_data,info) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + select case(trans_) + case('N') + if (sv%eps <=dzero) then + ! + ! Fixed number of iterations + ! + ! + do itx=itxst, sv%sweeps + call psb_geaxpby(done,x,dzero,wv,desc_data,info) + ! Update with L. The off-diagonal block is taken care + ! from the Jacobi smoother, hence this is purely local. + call psb_spmm(-done,sv%l,xit,done,wv,desc_data,info,doswap=.false.) + call psb_spsm(done,sv%u,wv,dzero,xit,desc_data,info) + end do + + call psb_geaxpby(alpha,xit,beta,y,desc_data,info) + + else + ! + ! Iterations to convergence, not implemented right now. + ! + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') + goto 9999 + + end if +!!$ case('T') +!!$ call psb_spsm(done,sv%u,x,dzero,wv,desc_data,info,& +!!$ & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) +!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) +!!$ +!!$ case('C') +!!$ +!!$ call psb_spsm(done,sv%u,x,dzero,wv,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) +!!$ +!!$ call wv1%mlt(done,sv%dv,wv,dzero,info,conjgx=trans_) +!!$ +!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv1,beta,y,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid TRANS in GS subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_bwgs_solver_apply diff --git a/mlprec/impl/solver/amg_d_bwgs_solver_apply_vect.f90 b/mlprec/impl/solver/amg_d_bwgs_solver_apply_vect.f90 new file mode 100644 index 00000000..5c9f6d13 --- /dev/null +++ b/mlprec/impl/solver/amg_d_bwgs_solver_apply_vect.f90 @@ -0,0 +1,211 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_bwgs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_d_gs_solver, amg_protect_name => amg_d_bwgs_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_bwgs_solver_type), intent(inout) :: sv + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col, itx, itxst + real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + real(psb_dpk_), allocatable :: temp(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='d_bwgs_solver_apply' + + call psb_erractionsave(err_act) + ictxt = desc_data%get_ctxt() + call psb_info(ictxt,me,np) + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') +!!$ case('T') +!!$ case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + + if (x%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/itwo,n_row,izero,izero,izero/)) + goto 9999 + end if + if (y%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/ithree,n_row,izero,izero,izero/)) + goto 9999 + end if + + + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + + if (size(wv) < 2) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size') + goto 9999 + end if + + associate(tw => wv(1), xit => wv(2)) + itxst = 1 + select case (init_) + case('Z') + call psb_geaxpby(done,x,dzero,tw,desc_data,info) + call psb_spsm(done,sv%u,tw,dzero,xit,desc_data,info) + itxst = 2 + case('Y') + call psb_geaxpby(done,y,dzero,xit,desc_data,info) + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(done,initu,dzero,xit,desc_data,info) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + select case(trans_) + case('N') + if (sv%eps <=dzero) then + ! + ! Fixed number of iterations + ! + ! + do itx=itxst,sv%sweeps + call psb_geaxpby(done,x,dzero,tw,desc_data,info) + ! Update with L. The off-diagonal block is taken care + ! from the Jacobi smoother, hence this is purely local. + call psb_spmm(-done,sv%l,xit,done,tw,desc_data,info,doswap=.false.) + call psb_spsm(done,sv%u,tw,dzero,xit,desc_data,info) + end do + + call psb_geaxpby(alpha,xit,beta,y,desc_data,info) + + else + ! + ! Iterations to convergence, not implemented right now. + ! + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') + goto 9999 + + end if + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid TRANS in GS subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + end associate + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_bwgs_solver_apply_vect diff --git a/mlprec/impl/solver/amg_d_bwgs_solver_bld.f90 b/mlprec/impl/solver/amg_d_bwgs_solver_bld.f90 new file mode 100644 index 00000000..138c199d --- /dev/null +++ b/mlprec/impl/solver/amg_d_bwgs_solver_bld.f90 @@ -0,0 +1,110 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_bwgs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_d_gs_solver, amg_protect_name => amg_d_bwgs_solver_bld + + Implicit None + + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(in) :: desc_a + class(amg_d_bwgs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_bwgs_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + + if (sv%eps <= dzero) then + ! + ! This cuts out the off-diagonal part, because it's supposed to + ! be handled by the outer Jacobi smoother. + ! + call a%tril(sv%l,info,diag=-ione,jmax=nrow_a,u=sv%u) + + else + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end if + + + + call sv%l%set_asb() + call sv%l%trim() + call sv%u%set_asb() + call sv%u%trim() + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_bwgs_solver_bld diff --git a/mlprec/impl/solver/amg_d_diag_solver_apply.f90 b/mlprec/impl/solver/amg_d_diag_solver_apply.f90 new file mode 100644 index 00000000..43177c2a --- /dev/null +++ b/mlprec/impl/solver/amg_d_diag_solver_apply.f90 @@ -0,0 +1,240 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_diag_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + + use psb_base_mod + use amg_d_diag_solver, amg_protect_name => amg_d_diag_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_diag_solver_type), intent(inout) :: sv + real(psb_dpk_), intent(inout) :: x(:) + real(psb_dpk_), intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col + real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='d_diag_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (trans_ == 'C') then + if (beta == dzero) then + + if (alpha == dzero) then + y(1:n_row) = dzero + else if (alpha == done) then + do i=1, n_row + y(i) = (sv%d(i)) * x(i) + end do + else if (alpha == -done) then + do i=1, n_row + y(i) = -(sv%d(i)) * x(i) + end do + else + do i=1, n_row + y(i) = alpha * (sv%d(i)) * x(i) + end do + end if + + else if (beta == done) then + + if (alpha == dzero) then + !y(1:n_row) = dzero + else if (alpha == done) then + do i=1, n_row + y(i) = (sv%d(i)) * x(i) + y(i) + end do + else if (alpha == -done) then + do i=1, n_row + y(i) = -(sv%d(i)) * x(i) + y(i) + end do + else + do i=1, n_row + y(i) = alpha * (sv%d(i)) * x(i) + y(i) + end do + end if + + else if (beta == -done) then + + if (alpha == dzero) then + y(1:n_row) = -y(1:n_row) + else if (alpha == done) then + do i=1, n_row + y(i) = (sv%d(i)) * x(i) - y(i) + end do + else if (alpha == -done) then + do i=1, n_row + y(i) = -(sv%d(i)) * x(i) - y(i) + end do + else + do i=1, n_row + y(i) = alpha * (sv%d(i)) * x(i) - y(i) + end do + end if + + else + + if (alpha == dzero) then + y(1:n_row) = beta *y(1:n_row) + else if (alpha == done) then + do i=1, n_row + y(i) = (sv%d(i)) * x(i) + beta*y(i) + end do + else if (alpha == -done) then + do i=1, n_row + y(i) = -(sv%d(i)) * x(i) + beta*y(i) + end do + else + do i=1, n_row + y(i) = alpha * (sv%d(i)) * x(i) + beta*y(i) + end do + end if + + end if + + else if (trans_ /= 'C') then + + if (beta == dzero) then + + if (alpha == dzero) then + y(1:n_row) = dzero + else if (alpha == done) then + do i=1, n_row + y(i) = sv%d(i) * x(i) + end do + else if (alpha == -done) then + do i=1, n_row + y(i) = -sv%d(i) * x(i) + end do + else + do i=1, n_row + y(i) = alpha * sv%d(i) * x(i) + end do + end if + + else if (beta == done) then + + if (alpha == dzero) then + !y(1:n_row) = dzero + else if (alpha == done) then + do i=1, n_row + y(i) = sv%d(i) * x(i) + y(i) + end do + else if (alpha == -done) then + do i=1, n_row + y(i) = -sv%d(i) * x(i) + y(i) + end do + else + do i=1, n_row + y(i) = alpha * sv%d(i) * x(i) + y(i) + end do + end if + + else if (beta == -done) then + + if (alpha == dzero) then + y(1:n_row) = -y(1:n_row) + else if (alpha == done) then + do i=1, n_row + y(i) = sv%d(i) * x(i) - y(i) + end do + else if (alpha == -done) then + do i=1, n_row + y(i) = -sv%d(i) * x(i) - y(i) + end do + else + do i=1, n_row + y(i) = alpha * sv%d(i) * x(i) - y(i) + end do + end if + + else + + if (alpha == dzero) then + y(1:n_row) = beta *y(1:n_row) + else if (alpha == done) then + do i=1, n_row + y(i) = sv%d(i) * x(i) + beta*y(i) + end do + else if (alpha == -done) then + do i=1, n_row + y(i) = -sv%d(i) * x(i) + beta*y(i) + end do + else + do i=1, n_row + y(i) = alpha * sv%d(i) * x(i) + beta*y(i) + end do + end if + + end if + + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_diag_solver_apply diff --git a/mlprec/impl/solver/amg_d_diag_solver_apply_vect.f90 b/mlprec/impl/solver/amg_d_diag_solver_apply_vect.f90 new file mode 100644 index 00000000..db721cc0 --- /dev/null +++ b/mlprec/impl/solver/amg_d_diag_solver_apply_vect.f90 @@ -0,0 +1,117 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_diag_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_d_diag_solver, amg_protect_name => amg_d_diag_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_diag_solver_type), intent(inout) :: sv + type(psb_d_vect_type), intent(inout) :: x + type(psb_d_vect_type), intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col + real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='d_diag_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + if (x%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/itwo,n_row,izero,izero,izero/)) + goto 9999 + end if + if (y%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/ithree,n_row,izero,izero,izero/)) + goto 9999 + end if + if (.not.allocated(sv%dv)) then + info = 1124 + call psb_errpush(info,name,a_err="preconditioner: D") + goto 9999 + end if + if (sv%dv%get_nrows() < n_row) then + info = 1124 + call psb_errpush(info,name,a_err="preconditioner: D") + goto 9999 + end if + + call y%mlt(alpha,sv%dv,x,beta,info,conjgx=trans_) + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='vect%mlt') + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_diag_solver_apply_vect diff --git a/mlprec/impl/solver/amg_d_diag_solver_bld.f90 b/mlprec/impl/solver/amg_d_diag_solver_bld.f90 new file mode 100644 index 00000000..a8a421e0 --- /dev/null +++ b/mlprec/impl/solver/amg_d_diag_solver_bld.f90 @@ -0,0 +1,191 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_d_diag_solver, amg_protect_name => amg_d_diag_solver_bld + + Implicit None + + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + real(psb_dpk_), allocatable :: tdb(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_diag_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + nrow_a = a%get_nrows() + + sv%d = a%get_diag(info) + if (info == psb_success_) call psb_realloc(n_row,sv%d,info) + if (present(b)) then + tdb=b%get_diag(info) + if (size(tdb)+nrow_a > n_row) call psb_realloc(nrow_a+size(tdb),sv%d,info) + if (info == psb_success_) sv%d(nrow_a+1:nrow_a+size(tdb)) = tdb(:) + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='get_diag') + goto 9999 + end if + + do i=1,n_row + if (sv%d(i) == dzero) then + sv%d(i) = done + else + sv%d(i) = done/sv%d(i) + end if + end do + allocate(sv%dv,stat=info) + if (info == psb_success_) then + call sv%dv%bld(sv%d) + if (present(vmold)) call sv%dv%cnv(vmold) + call sv%dv%sync() + else + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='Allocate sv%dv') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_diag_solver_bld + + +subroutine amg_d_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_d_l1_diag_solver, amg_protect_name => amg_d_l1_diag_solver_bld + + Implicit None + + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_l1_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + real(psb_dpk_), allocatable :: tdb(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_l1_diag_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + nrow_a = a%get_nrows() + + sv%d = a%arwsum(info) + if (info == psb_success_) call psb_realloc(n_row,sv%d,info) + if (present(b)) then + tdb=b%arwsum(info) + if (size(tdb)+nrow_a > n_row) call psb_realloc(nrow_a+size(tdb),sv%d,info) + if (info == psb_success_) sv%d(nrow_a+1:nrow_a+size(tdb)) = tdb(:) + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='arwsum') + goto 9999 + end if + + do i=1,n_row + if (sv%d(i) == dzero) then + sv%d(i) = done + else + sv%d(i) = done/sv%d(i) + end if + end do + allocate(sv%dv,stat=info) + if (info == psb_success_) then + call sv%dv%bld(sv%d) + if (present(vmold)) call sv%dv%cnv(vmold) + call sv%dv%sync() + else + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='Allocate sv%dv') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_l1_diag_solver_bld diff --git a/mlprec/impl/solver/amg_d_diag_solver_clear_data.f90 b/mlprec/impl/solver/amg_d_diag_solver_clear_data.f90 new file mode 100644 index 00000000..448a9e8c --- /dev/null +++ b/mlprec/impl/solver/amg_d_diag_solver_clear_data.f90 @@ -0,0 +1,65 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_diag_solver_clear_data(sv,info) + + use psb_base_mod + use amg_d_diag_solver, amg_protect_name => amg_d_diag_solver_clear_data + + Implicit None + + ! Arguments + class(amg_d_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + call sv%dv%free(info) + if ((info ==0).and.allocated(sv%d)) deallocate(sv%d,stat=info) + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_diag_solver_clear_data diff --git a/mlprec/impl/solver/amg_d_diag_solver_clone.f90 b/mlprec/impl/solver/amg_d_diag_solver_clone.f90 new file mode 100644 index 00000000..54b46601 --- /dev/null +++ b/mlprec/impl/solver/amg_d_diag_solver_clone.f90 @@ -0,0 +1,83 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_diag_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_d_diag_solver, amg_protect_name => amg_d_diag_solver_clone + + Implicit None + + ! Arguments + class(amg_d_diag_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(svout)) then + call svout%free(info) + if (info == psb_success_) deallocate(svout, stat=info) + end if + if (info == psb_success_) & + & allocate(svout, mold=sv, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(svo => svout) + class is (amg_d_diag_solver_type) + call psb_safe_ab_cpy(sv%d,svo%d,info) + if (info == psb_success_) & + & call sv%dv%clone(svo%dv,info) + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_diag_solver_clone diff --git a/mlprec/impl/solver/amg_d_diag_solver_cnv.f90 b/mlprec/impl/solver/amg_d_diag_solver_cnv.f90 new file mode 100644 index 00000000..634d8e47 --- /dev/null +++ b/mlprec/impl/solver/amg_d_diag_solver_cnv.f90 @@ -0,0 +1,76 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_diag_solver_cnv(sv,info,amold,vmold,imold) + + use psb_base_mod + use amg_d_diag_solver, amg_protect_name => amg_d_diag_solver_cnv + + Implicit None + + ! Arguments + class(amg_d_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: err_act, debug_unit, debug_level + character(len=20) :: name='d_diag_solver_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) trim(name),' start' + + + if (allocated(sv%dv)) then + call sv%dv%cnv(vmold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_d_diag_solver_cnv diff --git a/mlprec/impl/solver/amg_d_diag_solver_dmp.f90 b/mlprec/impl/solver/amg_d_diag_solver_dmp.f90 new file mode 100644 index 00000000..031a82c1 --- /dev/null +++ b/mlprec/impl/solver/amg_d_diag_solver_dmp.f90 @@ -0,0 +1,133 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_d_diag_solver, amg_protect_name => amg_d_diag_solver_dmp + implicit none + class(amg_d_diag_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: solver_ + ! len of prefix_ + + info = 0 + + ictxt = desc%get_context() + + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + + if (solver_) then + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_d" + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' + if (allocated(sv%d)) & + & call psb_geprt(fname,sv%d,head=head) + + end if + +end subroutine amg_d_diag_solver_dmp +subroutine amg_d_l1_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_d_l1_diag_solver, amg_protect_name => amg_d_l1_diag_solver_dmp + implicit none + class(amg_d_l1_diag_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: solver_ + ! len of prefix_ + + info = 0 + + ictxt = desc%get_context() + + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + + if (solver_) then + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_d" + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_l1_diag.mtx' + if (allocated(sv%d)) & + & call psb_geprt(fname,sv%d,head=head) + + end if + +end subroutine amg_d_l1_diag_solver_dmp diff --git a/mlprec/impl/solver/amg_d_gs_solver_apply.f90 b/mlprec/impl/solver/amg_d_gs_solver_apply.f90 new file mode 100644 index 00000000..52ceac8b --- /dev/null +++ b/mlprec/impl/solver/amg_d_gs_solver_apply.f90 @@ -0,0 +1,216 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_gs_solver_apply(alpha,sv,x,beta,y,desc_data,& + &trans,work,info,init,initu) + + use psb_base_mod + use amg_d_gs_solver, amg_protect_name => amg_d_gs_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_gs_solver_type), intent(inout) :: sv + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col, itx, itxst + real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + real(psb_dpk_), allocatable :: temp(:),wv(:),xit(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='d_gs_solver_apply' + + call psb_erractionsave(err_act) + ictxt = desc_data%get_ctxt() + call psb_info(ictxt,me,np) + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') +!!$ case('T') +!!$ case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + + call psb_geasb(wv,desc_data,info) + call psb_geasb(xit,desc_data,info) + itxst = 1 + select case (init_) + case('Z') + call psb_geaxpby(done,x,dzero,wv,desc_data,info) + call psb_spsm(done,sv%l,wv,dzero,xit,desc_data,info) + itxst = 2 + case('Y') + call psb_geaxpby(done,y,dzero,xit,desc_data,info) + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(done,initu,dzero,xit,desc_data,info) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + select case(trans_) + case('N') + if (sv%eps <=dzero) then + ! + ! Fixed number of iterations + ! + ! + do itx=itxst,sv%sweeps + call psb_geaxpby(done,x,dzero,wv,desc_data,info) + ! Update with U. The off-diagonal block is taken care + ! from the Jacobi smoother, hence this is purely local. + call psb_spmm(-done,sv%u,xit,done,wv,desc_data,info,doswap=.false.) + call psb_spsm(done,sv%l,wv,dzero,xit,desc_data,info) + end do + + call psb_geaxpby(alpha,xit,beta,y,desc_data,info) + + else + ! + ! Iterations to convergence, not implemented right now. + ! + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') + goto 9999 + + end if +!!$ case('T') +!!$ call psb_spsm(done,sv%u,x,dzero,wv,desc_data,info,& +!!$ & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) +!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) +!!$ +!!$ case('C') +!!$ +!!$ call psb_spsm(done,sv%u,x,dzero,wv,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) +!!$ +!!$ call wv1%mlt(done,sv%dv,wv,dzero,info,conjgx=trans_) +!!$ +!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv1,beta,y,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid TRANS in GS subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_gs_solver_apply diff --git a/mlprec/impl/solver/amg_d_gs_solver_apply_vect.f90 b/mlprec/impl/solver/amg_d_gs_solver_apply_vect.f90 new file mode 100644 index 00000000..7acd2edf --- /dev/null +++ b/mlprec/impl/solver/amg_d_gs_solver_apply_vect.f90 @@ -0,0 +1,211 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_gs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_d_gs_solver, amg_protect_name => amg_d_gs_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_gs_solver_type), intent(inout) :: sv + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col, itx, itxst + real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + real(psb_dpk_), allocatable :: temp(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='d_gs_solver_apply' + + call psb_erractionsave(err_act) + ictxt = desc_data%get_ctxt() + call psb_info(ictxt,me,np) + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') +!!$ case('T') +!!$ case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + + if (x%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/itwo,n_row,izero,izero,izero/)) + goto 9999 + end if + if (y%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/ithree,n_row,izero,izero,izero/)) + goto 9999 + end if + + + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + + if (size(wv) < 2) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size') + goto 9999 + end if + + associate(tw => wv(1), xit => wv(2)) + itxst = 1 + select case (init_) + case('Z') + call psb_geaxpby(done,x,dzero,tw,desc_data,info) + call psb_spsm(done,sv%l,tw,dzero,xit,desc_data,info) + itxst = 2 + case('Y') + call psb_geaxpby(done,y,dzero,xit,desc_data,info) + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(done,initu,dzero,xit,desc_data,info) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + select case(trans_) + case('N') + if (sv%eps <=dzero) then + ! + ! Fixed number of iterations + ! + ! + do itx=itxst,sv%sweeps + call psb_geaxpby(done,x,dzero,tw,desc_data,info) + ! Update with U. The off-diagonal block is taken care + ! from the Jacobi smoother, hence this is purely local. + call psb_spmm(-done,sv%u,xit,done,tw,desc_data,info,doswap=.false.) + call psb_spsm(done,sv%l,tw,dzero,xit,desc_data,info) + end do + + call psb_geaxpby(alpha,xit,beta,y,desc_data,info) + + else + ! + ! Iterations to convergence, not implemented right now. + ! + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') + goto 9999 + + end if + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid TRANS in GS subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + end associate + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_gs_solver_apply_vect diff --git a/mlprec/impl/solver/amg_d_gs_solver_bld.f90 b/mlprec/impl/solver/amg_d_gs_solver_bld.f90 new file mode 100644 index 00000000..46a3d74e --- /dev/null +++ b/mlprec/impl/solver/amg_d_gs_solver_bld.f90 @@ -0,0 +1,109 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_gs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_d_gs_solver, amg_protect_name => amg_d_gs_solver_bld + + Implicit None + + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_gs_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + + if (sv%eps <= dzero) then + ! + ! This cuts out the off-diagonal part, because it's supposed to + ! be handled by the outer Jacobi smoother. + ! + call a%tril(sv%l,info,diag=izero,jmax=nrow_a,u=sv%u) + + else + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end if + + + + call sv%l%set_asb() + call sv%l%trim() + call sv%u%set_asb() + call sv%u%trim() + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_gs_solver_bld diff --git a/mlprec/impl/solver/amg_d_gs_solver_clear_data.f90 b/mlprec/impl/solver/amg_d_gs_solver_clear_data.f90 new file mode 100644 index 00000000..2f30228f --- /dev/null +++ b/mlprec/impl/solver/amg_d_gs_solver_clear_data.f90 @@ -0,0 +1,65 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_gs_solver_clear_data(sv,info) + + use psb_base_mod + use amg_d_gs_solver, amg_protect_name => amg_d_gs_solver_clear_data + + Implicit None + + ! Arguments + class(amg_d_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + call sv%l%free() + call sv%u%free() + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_gs_solver_clear_data diff --git a/mlprec/impl/solver/amg_d_gs_solver_clone.f90 b/mlprec/impl/solver/amg_d_gs_solver_clone.f90 new file mode 100644 index 00000000..5ab3ecc9 --- /dev/null +++ b/mlprec/impl/solver/amg_d_gs_solver_clone.f90 @@ -0,0 +1,87 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_gs_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_d_gs_solver, amg_protect_name => amg_d_gs_solver_clone + + Implicit None + + ! Arguments + class(amg_d_gs_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + if (allocated(svout)) then + call svout%free(info) + if (info == psb_success_) deallocate(svout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_d_gs_solver_type :: svout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(svo => svout) + type is (amg_d_gs_solver_type) + svo%sweeps = sv%sweeps + svo%eps = sv%eps + if (info == psb_success_) & + & call sv%l%clone(svo%l,info) + if (info == psb_success_) & + & call sv%u%clone(svo%u,info) + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_gs_solver_clone diff --git a/mlprec/impl/solver/amg_d_gs_solver_clone_settings.f90 b/mlprec/impl/solver/amg_d_gs_solver_clone_settings.f90 new file mode 100644 index 00000000..ad7a6325 --- /dev/null +++ b/mlprec/impl/solver/amg_d_gs_solver_clone_settings.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_gs_solver_clone_settings(sv,svout,info) + + use psb_base_mod + use amg_d_gs_solver, amg_protect_name => amg_d_gs_solver_clone_settings + Implicit None + ! Arguments + class(amg_d_gs_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_gs_solver_clone_settings' + + call psb_erractionsave(err_act) + + select type(svout) + class is(amg_d_gs_solver_type) + svout%sweeps = sv%sweeps + svout%eps = sv%eps + + class default + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_gs_solver_clone_settings diff --git a/mlprec/impl/solver/amg_d_gs_solver_cnv.f90 b/mlprec/impl/solver/amg_d_gs_solver_cnv.f90 new file mode 100644 index 00000000..c6c304c9 --- /dev/null +++ b/mlprec/impl/solver/amg_d_gs_solver_cnv.f90 @@ -0,0 +1,74 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_gs_solver_cnv(sv,info,amold,vmold,imold) + + use psb_base_mod + use amg_d_gs_solver, amg_protect_name => amg_d_gs_solver_cnv + + Implicit None + + ! Arguments + class(amg_d_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: err_act, debug_unit, debug_level + character(len=20) :: name='d_gs_solver_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_gs_solver_cnv diff --git a/mlprec/impl/solver/amg_d_gs_solver_dmp.f90 b/mlprec/impl/solver/amg_d_gs_solver_dmp.f90 new file mode 100644 index 00000000..811e932d --- /dev/null +++ b/mlprec/impl/solver/amg_d_gs_solver_dmp.f90 @@ -0,0 +1,102 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_gs_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_d_gs_solver, amg_protect_name => amg_d_gs_solver_dmp + implicit none + class(amg_d_gs_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + integer(psb_lpk_), allocatable :: iv(:) + logical :: solver_, global_num_ + ! len of prefix_ + + info = 0 + + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + + if (solver_) then + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_d" + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + if (global_num_) then + iv = desc%get_global_indices(owned=.false.) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' + if (sv%l%is_asb()) & + & call sv%l%print(fname,head=head,iv=iv) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' + if (sv%u%is_asb()) & + & call sv%u%print(fname,head=head,iv=iv) + else + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' + if (sv%l%is_asb()) & + & call sv%l%print(fname,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' + if (sv%u%is_asb()) & + & call sv%u%print(fname,head=head) + end if + end if + +end subroutine amg_d_gs_solver_dmp diff --git a/mlprec/impl/solver/amg_d_id_solver_apply.f90 b/mlprec/impl/solver/amg_d_id_solver_apply.f90 new file mode 100644 index 00000000..4b6757a8 --- /dev/null +++ b/mlprec/impl/solver/amg_d_id_solver_apply.f90 @@ -0,0 +1,86 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_id_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + + use psb_base_mod + use amg_d_id_solver, amg_protect_name => amg_d_id_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_id_solver_type), intent(inout) :: sv + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='d_id_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call psb_geaxpby(alpha,x,beta,y,desc_data,info) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_id_solver_apply diff --git a/mlprec/impl/solver/amg_d_id_solver_apply_vect.f90 b/mlprec/impl/solver/amg_d_id_solver_apply_vect.f90 new file mode 100644 index 00000000..e4c9adbf --- /dev/null +++ b/mlprec/impl/solver/amg_d_id_solver_apply_vect.f90 @@ -0,0 +1,87 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_id_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_d_id_solver, amg_protect_name => amg_d_id_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_id_solver_type), intent(inout) :: sv + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='d_id_solver_apply_vect' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call psb_geaxpby(alpha,x,beta,y,desc_data,info) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_id_solver_apply_vect diff --git a/mlprec/impl/solver/amg_d_id_solver_clone.f90 b/mlprec/impl/solver/amg_d_id_solver_clone.f90 new file mode 100644 index 00000000..31c91e46 --- /dev/null +++ b/mlprec/impl/solver/amg_d_id_solver_clone.f90 @@ -0,0 +1,81 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_id_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_d_id_solver, amg_protect_name => amg_d_id_solver_clone + + Implicit None + + ! Arguments + class(amg_d_id_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(svout)) then + call svout%free(info) + if (info == psb_success_) deallocate(svout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_d_id_solver_type :: svout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(svo => svout) + type is (amg_d_id_solver_type) + ! Nothing to be done. + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_id_solver_clone diff --git a/mlprec/impl/solver/amg_d_ilu_solver_apply.f90 b/mlprec/impl/solver/amg_d_ilu_solver_apply.f90 new file mode 100644 index 00000000..cdecc46d --- /dev/null +++ b/mlprec/impl/solver/amg_d_ilu_solver_apply.f90 @@ -0,0 +1,153 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + + use psb_base_mod + use amg_d_ilu_solver, amg_protect_name => amg_d_ilu_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_ilu_solver_type), intent(inout) :: sv + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col + real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='d_ilu_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + endif + + select case(trans_) + case('N') + call psb_spsm(done,sv%l,x,dzero,ww,desc_data,info,& + & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) + + if (info == psb_success_) call psb_spsm(alpha,sv%u,ww,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_, work=aux) + + case('T') + call psb_spsm(done,sv%u,x,dzero,ww,desc_data,info,& + & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) + if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + case('C') + call psb_spsm(done,sv%u,x,dzero,ww,desc_data,info,& + & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) + if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid TRANS in ILU subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_ilu_solver_apply diff --git a/mlprec/impl/solver/amg_d_ilu_solver_apply_vect.f90 b/mlprec/impl/solver/amg_d_ilu_solver_apply_vect.f90 new file mode 100644 index 00000000..8966739a --- /dev/null +++ b/mlprec/impl/solver/amg_d_ilu_solver_apply_vect.f90 @@ -0,0 +1,194 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_d_ilu_solver, amg_protect_name => amg_d_ilu_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_ilu_solver_type), intent(inout) :: sv + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col + type(psb_d_vect_type) :: tw, tw1 + real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='d_ilu_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + + if (x%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/itwo,n_row,izero,izero,izero/)) + goto 9999 + end if + if (y%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/ithree,n_row,izero,izero,izero/)) + goto 9999 + end if + if (.not.allocated(sv%dv%v)) then + info = 1124 + call psb_errpush(info,name,a_err="preconditioner: D") + goto 9999 + end if + if (sv%dv%get_nrows() < n_row) then + info = 1124 + call psb_errpush(info,name,a_err="preconditioner: DV") + goto 9999 + end if + + + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + + + if (size(wv) < 2) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size') + goto 9999 + end if + + + associate(tw => wv(1), tw1 => wv(2)) + + select case(trans_) + case('N') + call psb_spsm(done,sv%l,x,dzero,tw,desc_data,info,& + & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) + + if (info == psb_success_) call psb_spsm(alpha,sv%u,tw,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_, work=aux) + + case('T') + call psb_spsm(done,sv%u,x,dzero,tw,desc_data,info,& + & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) + if (info == psb_success_) call psb_spsm(alpha,sv%l,tw,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + + case('C') + + call psb_spsm(done,sv%u,x,dzero,tw,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + + call tw1%mlt(done,sv%dv,tw,dzero,info,conjgx=trans_) + + if (info == psb_success_) call psb_spsm(alpha,sv%l,tw1,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid TRANS in ILU subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + end associate + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_d_ilu_solver_apply_vect diff --git a/mlprec/impl/solver/amg_d_ilu_solver_bld.f90 b/mlprec/impl/solver/amg_d_ilu_solver_bld.f90 new file mode 100644 index 00000000..0a1dfd5d --- /dev/null +++ b/mlprec/impl/solver/amg_d_ilu_solver_bld.f90 @@ -0,0 +1,191 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_ilu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_d_ilu_solver, amg_protect_name => amg_d_ilu_solver_bld + + Implicit None + + ! Arguments + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota +!!$ real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_ilu_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + if (present(b)) then + nztota = nztota + b%get_nzeros() + end if + + call sv%l%csall(n_row,n_row,info,nztota) + if (info == psb_success_) call sv%u%csall(n_row,n_row,info,nztota) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_sp_all' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + if (allocated(sv%d)) then + if (size(sv%d) < n_row) then + deallocate(sv%d) + endif + endif + if (.not.allocated(sv%d)) allocate(sv%d(n_row),stat=info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') + goto 9999 + endif + + + select case(sv%fact_type) + + case (psb_ilu_t_) + ! + ! ILU(k,t) + ! + select case(sv%fill_in) + + case(:-1) + ! Error: fill-in <= -1 + call psb_errpush(psb_err_input_value_invalid_i_,& + & name,i_err=(/ithree,sv%fill_in,izero,izero,izero/)) + goto 9999 + + case(0:) + ! Fill-in >= 0 + call psb_ilut_fact(sv%fill_in,sv%thresh,& + & a, sv%l,sv%u,sv%d,info,blck=b) + end select + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ilut_fact' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + case(psb_ilu_n_,psb_milu_n_) + ! + ! ILU(k) and MILU(k) + ! + select case(sv%fill_in) + case(:-1) + ! Error: fill-in <= -1 + call psb_errpush(psb_err_input_value_invalid_i_,& + & name,i_err=(/ithree,sv%fill_in,izero,izero,izero/)) + goto 9999 + case(0) + ! Fill-in 0 + ! Separate implementation of ILU(0) for better performance. + ! There seems to be a problem with the separate implementation of MILU(0), + ! contained into psb_ilu0_fact. This must be investigated. For the time being, + ! resort to the implementation of MILU(k) with k=0. + if (sv%fact_type == psb_ilu_n_) then + call psb_ilu0_fact(sv%fact_type,a,sv%l,sv%u,& + & sv%d,info,blck=b) + else + call psb_iluk_fact(sv%fill_in,sv%fact_type,& + & a,sv%l,sv%u,sv%d,info,blck=b) + endif + case(1:) + ! Fill-in >= 1 + ! The same routine implements both ILU(k) and MILU(k) + call psb_iluk_fact(sv%fill_in,sv%fact_type,& + & a,sv%l,sv%u,sv%d,info,blck=b) + end select + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_iluk_fact' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + case default + ! If we end up here, something was wrong up in the call chain. + info = psb_err_input_value_invalid_i_ + call psb_errpush(psb_err_input_value_invalid_i_,name,& + & i_err=(/ithree,sv%fact_type,izero,izero,izero/)) + goto 9999 + + end select + + call sv%l%set_asb() + call sv%l%trim() + call sv%u%set_asb() + call sv%u%trim() + call sv%dv%bld(sv%d,mold=vmold) + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_ilu_solver_bld diff --git a/mlprec/impl/solver/amg_d_ilu_solver_clear_data.f90 b/mlprec/impl/solver/amg_d_ilu_solver_clear_data.f90 new file mode 100644 index 00000000..9b66a853 --- /dev/null +++ b/mlprec/impl/solver/amg_d_ilu_solver_clear_data.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_ilu_solver_clear_data(sv,info) + + use psb_base_mod + use amg_d_ilu_solver, amg_protect_name => amg_d_ilu_solver_clear_data + + Implicit None + + ! Arguments + class(amg_d_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + call sv%l%free() + call sv%u%free() + call sv%dv%free(info) + if ((info==0).and.allocated(sv%d)) deallocate(sv%d,stat=info) + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_ilu_solver_clear_data diff --git a/mlprec/impl/solver/amg_d_ilu_solver_clone.f90 b/mlprec/impl/solver/amg_d_ilu_solver_clone.f90 new file mode 100644 index 00000000..7364ecfd --- /dev/null +++ b/mlprec/impl/solver/amg_d_ilu_solver_clone.f90 @@ -0,0 +1,91 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_ilu_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_d_ilu_solver, amg_protect_name => amg_d_ilu_solver_clone + + Implicit None + + ! Arguments + class(amg_d_ilu_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + if (allocated(svout)) then + call svout%free(info) + if (info == psb_success_) deallocate(svout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_d_ilu_solver_type :: svout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(svo => svout) + type is (amg_d_ilu_solver_type) + svo%fact_type = sv%fact_type + svo%fill_in = sv%fill_in + svo%thresh = sv%thresh + call psb_safe_ab_cpy(sv%d,svo%d,info) + if (info == psb_success_) & + & call sv%dv%clone(svo%dv,info) + if (info == psb_success_) & + & call sv%l%clone(svo%l,info) + if (info == psb_success_) & + & call sv%u%clone(svo%u,info) + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_ilu_solver_clone diff --git a/mlprec/impl/solver/amg_d_ilu_solver_clone_settings.f90 b/mlprec/impl/solver/amg_d_ilu_solver_clone_settings.f90 new file mode 100644 index 00000000..645ac808 --- /dev/null +++ b/mlprec/impl/solver/amg_d_ilu_solver_clone_settings.f90 @@ -0,0 +1,70 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_ilu_solver_clone_settings(sv,svout,info) + + use psb_base_mod + use amg_d_ilu_solver, amg_protect_name => amg_d_ilu_solver_clone_settings + Implicit None + ! Arguments + class(amg_d_ilu_solver_type), intent(inout) :: sv + class(amg_d_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_ilu_solver_clone_settings' + + call psb_erractionsave(err_act) + + select type(svout) + class is(amg_d_ilu_solver_type) + svout%fact_type = sv%fact_type + svout%fill_in = sv%fill_in + svout%thresh = sv%thresh + + class default + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_ilu_solver_clone_settings diff --git a/mlprec/impl/solver/amg_d_ilu_solver_cnv.f90 b/mlprec/impl/solver/amg_d_ilu_solver_cnv.f90 new file mode 100644 index 00000000..2ec39cb4 --- /dev/null +++ b/mlprec/impl/solver/amg_d_ilu_solver_cnv.f90 @@ -0,0 +1,76 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_ilu_solver_cnv(sv,info,amold,vmold,imold) + + use psb_base_mod + use amg_d_ilu_solver, amg_protect_name => amg_d_ilu_solver_cnv + + Implicit None + + ! Arguments + class(amg_d_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: err_act, debug_unit, debug_level + character(len=20) :: name='d_ilu_solver_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + call sv%dv%cnv(mold=vmold) + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_d_ilu_solver_cnv diff --git a/mlprec/impl/solver/amg_d_ilu_solver_dmp.f90 b/mlprec/impl/solver/amg_d_ilu_solver_dmp.f90 new file mode 100644 index 00000000..07410fad --- /dev/null +++ b/mlprec/impl/solver/amg_d_ilu_solver_dmp.f90 @@ -0,0 +1,112 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_d_ilu_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_d_ilu_solver, amg_protect_name => amg_d_ilu_solver_dmp + implicit none + class(amg_d_ilu_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: solver_, global_num_ + integer(psb_lpk_), allocatable :: iv(:) + ! len of prefix_ + + info = 0 + + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + + + if (solver_) then + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_d" + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + if (global_num_) then + iv = desc%get_global_indices(owned=.false.) + + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' + if (sv%l%is_asb()) & + & call sv%l%print(fname,head=head,iv=iv) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' + if (allocated(sv%d)) & + & call psb_geprt(fname,sv%d,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' + if (sv%u%is_asb()) & + & call sv%u%print(fname,head=head,iv=iv) + + else + + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' + if (sv%l%is_asb()) & + & call sv%l%print(fname,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' + if (allocated(sv%d)) & + & call psb_geprt(fname,sv%d,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' + if (sv%u%is_asb()) & + & call sv%u%print(fname,head=head) + end if + end if + +end subroutine amg_d_ilu_solver_dmp diff --git a/mlprec/impl/solver/amg_d_mumps_solver_apply.F90 b/mlprec/impl/solver/amg_d_mumps_solver_apply.F90 new file mode 100644 index 00000000..c1d509db --- /dev/null +++ b/mlprec/impl/solver/amg_d_mumps_solver_apply.F90 @@ -0,0 +1,169 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.0) +! +! (C) Copyright 2008,2009,2010,2012,2013 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +subroutine d_mumps_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + use psb_base_mod + use amg_d_mumps_solver + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_mumps_solver_type), intent(inout) :: sv + real(psb_dpk_),intent(inout) :: x(:) + real(psb_dpk_),intent(inout) :: y(:) + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row, n_col + integer(psb_lpk_) :: nglob + integer(psb_epk_) :: eng + real(psb_dpk_), allocatable :: ww(:) + real(psb_dpk_), allocatable, target :: gx(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='d_mumps_solver_apply' + + call psb_erractionsave(err_act) + +#if defined(HAVE_MUMPS_) + info = psb_success_ + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + nglob = desc_data%get_global_rows() + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + ! Running in local mode? + if (sv%ipar(1) == amg_local_solver_ ) then + gx = x + else if (sv%ipar(1) == amg_global_solver_ ) then + + if (n_col <= size(work)) then + ww = work(1:n_col) + else + allocate(ww(n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/n_col/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + end if + allocate(gx(nglob),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_; eng = nglob + call psb_errpush(info,name,e_err=(/eng/),& + & a_err='real(psb_dpk_)') + goto 9999 + end if + call psb_gather(gx, x, desc_data, info, root=izero) + else + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid local/global solver in MUMPS') + goto 9999 + end if + + select case(trans_) + case('N') + sv%id%icntl(9) = 1 + case('T') + sv%id%icntl(9) = 2 + case default + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Invalid TRANS in subsolve') + goto 9999 + end select + + sv%id%rhs => gx + sv%id%nrhs = 1 + sv%id%icntl(1)=-1 + sv%id%icntl(2)=-1 + sv%id%icntl(3)=-1 + sv%id%icntl(4)=-1 + sv%id%job = 3 + call dmumps(sv%id) + if (sv%ipar(1) == amg_local_solver_ ) then + call psb_geaxpby(alpha,gx,beta,y,desc_data,info) + else + call psb_scatter(gx, ww, desc_data, info, root=izero) + if (info == psb_success_) then + call psb_geaxpby(alpha,ww,beta,y,desc_data,info) + end if + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in subsolve') + goto 9999 + endif + + if (allocated(ww)) deallocate(ww) + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return + +#else + write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " +#endif +end subroutine d_mumps_solver_apply + diff --git a/mlprec/impl/solver/amg_d_mumps_solver_apply_vect.F90 b/mlprec/impl/solver/amg_d_mumps_solver_apply_vect.F90 new file mode 100644 index 00000000..dcac11df --- /dev/null +++ b/mlprec/impl/solver/amg_d_mumps_solver_apply_vect.F90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.0) +! +! (C) Copyright 2008,2009,2010,2012,2013 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +subroutine d_mumps_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + use psb_base_mod + use amg_d_mumps_solver + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_d_mumps_solver_type), intent(inout) :: sv + type(psb_d_vect_type),intent(inout) :: x + type(psb_d_vect_type),intent(inout) :: y + real(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_dpk_),target, intent(inout) :: work(:) + type(psb_d_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_d_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_mumps_solver_apply_vect' + +#if defined(HAVE_MUMPS_) + + call psb_erractionsave(err_act) + + info = psb_success_ + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call x%v%sync() + call y%v%sync() + call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) + call y%v%set_host() + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return + +#else + write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " +#endif + +end subroutine d_mumps_solver_apply_vect + diff --git a/mlprec/impl/solver/amg_d_mumps_solver_bld.F90 b/mlprec/impl/solver/amg_d_mumps_solver_bld.F90 new file mode 100644 index 00000000..b2ad4d9d --- /dev/null +++ b/mlprec/impl/solver/amg_d_mumps_solver_bld.F90 @@ -0,0 +1,262 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.0) +! +! (C) Copyright 2008,2009,2010,2012,2013 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +subroutine d_mumps_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_d_mumps_solver + Implicit None + + ! Arguments + type(psb_dspmat_type) :: c + type(psb_dspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_d_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_dspmat_type), intent(in), target, optional :: b + class(psb_d_base_sparse_mat), intent(in), optional :: amold + class(psb_d_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + type(psb_dspmat_type) :: atmp + type(psb_d_coo_sparse_mat), target :: acoo +#if defined(IPK4) && defined(LPK8) + integer(psb_lpk_), allocatable :: gia(:), gja(:) +#endif + integer(psb_ipk_) :: n_row,n_col, nrow_a, nza, npr, npc + integer(psb_lpk_) :: nglob, nglobrec, nzt + integer(psb_ipk_) :: ifrst, ibcheck + integer(psb_ipk_) :: ictxt, ictxt1, icomm, np, iam, me, i, err_act, debug_unit, debug_level + character(len=20) :: name='d_mumps_solver_bld', ch_err + +#if defined(HAVE_MUMPS_) + + info=psb_success_ + + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, iam, np) + if (sv%ipar(1) == amg_local_solver_ ) then + call psb_init(ictxt1,np=1,basectxt=ictxt,ids=(/iam/)) + icomm = psb_get_mpi_comm(ictxt1) + allocate(sv%local_ictxt,stat=info) + sv%local_ictxt = ictxt1 + !write(*,*)iam,'mumps_bld: local +++++>',icomm,sv%local_ictxt + call psb_info(ictxt1, me, np) + npr = np + else if (sv%ipar(1) == amg_global_solver_ ) then + icomm = psb_get_mpi_comm(ictxt) + !write(*,*)iam,'mumps_bld: global +++++>',icomm,ictxt + call psb_info(ictxt, iam, np) + me = iam + npr = np + else + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid local/global solver in MUMPS') + goto 9999 + end if + npc = 1 + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + ! if (allocated(sv%id)) then + ! call sv%free(info) + + ! deallocate(sv%id) + ! end if + if(.not.allocated(sv%id)) then + allocate(sv%id,stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_dealloc_ + call psb_errpush(info,name,a_err='amg_dmumps_default') + goto 9999 + end if + end if + + + sv%id%comm = icomm + sv%id%job = -1 + sv%id%par = 1 + if (sv%ipar(3) == 2) then + sv%id%sym = 2 + else + sv%id%sym = 0 + end if + + call dmumps(sv%id) + !WARNING: CALLING dmumps WITH JOB=-1 DESTROY THE SETTING OF DEFAULT:TO FIX + if (allocated(sv%icntl)) then + do i=1,amg_mumps_icntl_size + if (allocated(sv%icntl(i)%item)) then + !write(0,*) 'MUMPS_BLD: setting entry ',i,' to ', sv%icntl(i)%item + sv%id%icntl(i) = sv%icntl(i)%item + end if + end do + end if + if (allocated(sv%rcntl)) then + do i=1,amg_mumps_rcntl_size + if (allocated(sv%rcntl(i)%item)) sv%id%cntl(i) = sv%rcntl(i)%item + end do + end if + sv%id%icntl(3)=sv%ipar(2) + + nglob = desc_a%get_global_rows() + if (sv%ipar(1) == amg_local_solver_ ) then + nglobrec=desc_a%get_local_rows() + if (sv%ipar(3) == 2) then + ! Always pass the upper triangle to MUMPS + call a%triu(c,info,jmax=a%get_nrows()) + call c%set_symmetric() + else + call a%csclip(c,info,jmax=a%get_nrows()) + end if + call c%cp_to(acoo) + nglob = c%get_nrows() + if (nglobrec /= nglob) then + write(*,*)'WARNING: MUMPS solver does not allow overlap in AS yet. ' + write(*,*)'A zero-overlap is used instead' + end if + else + call a%cp_to(acoo) + end if + nza = acoo%get_nzeros() + + ! switch to global numbering + if (sv%ipar(1) == amg_global_solver_ ) then +#if defined(IPK4) && defined(LPK8) + ! + ! Strategy here is as follows: because a call to MUMPS + ! as a gobal solver is mostly done at the coarsest level, + ! even if we start from a problem requiring 8 bytes, chances + ! are that the global size will be suitable for 4 bytes + ! anyway, so we hope for the best, and throw an error + ! if something goes wrong. + ! + if (nglob > huge(1_psb_ipk_)) then + write(0,*) iam,' ',trim(name),': Error: overflow of local indices ' + info=psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + gia = acoo%ia(1:nza) + gja = acoo%ja(1:nza) + call psb_loc_to_glob(gia(1:nza), desc_a, info, iact='I') + call psb_loc_to_glob(gja(1:nza), desc_a, info, iact='I') + acoo%ia(1:nza) = gia(1:nza) + acoo%ja(1:nza) = gja(1:nza) +#else + ! + ! Here global and local numbers have the same size, so this must work. + ! + call psb_loc_to_glob(acoo%ja(1:nza), desc_a, info, iact='I') + call psb_loc_to_glob(acoo%ia(1:nza), desc_a, info, iact='I') +#endif + if (sv%ipar(3) == 2 ) then + ! Always pass the upper triangle to MUMPS + block + integer(psb_ipk_) :: j,nz + nz = 0 + do j=1,nza + if (acoo%ja(j) >= acoo%ia(j)) then + nz = nz + 1 + acoo%ia(nz) = acoo%ia(j) + acoo%ja(nz) = acoo%ja(j) + acoo%val(nz) = acoo%val(j) + end if + end do + call acoo%set_nzeros(nz) + call acoo%set_triangle() + call acoo%set_upper() + call acoo%set_symmetric() + end block + end if + end if + sv%id%irn_loc => acoo%ia + sv%id%jcn_loc => acoo%ja + sv%id%a_loc => acoo%val + sv%id%icntl(18) = 3 + sv%id%n = nglob + ! there should be a better way for this + sv%id%nnz_loc = acoo%get_nzeros() + sv%id%nnz = acoo%get_nzeros() + sv%id%job = 4 + if (sv%ipar(1) == amg_global_solver_ ) then + call psb_sum(ictxt,sv%id%nnz) + end if + !call psb_barrier(ictxt) + write(*,*)iam, ' calling mumps N,nz,nz_loc',sv%id%n,sv%id%nnz,sv%id%nnz_loc + call dmumps(sv%id) + !call psb_barrier(ictxt) + info = sv%id%infog(1) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='amg_dmumps_fact ' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + nullify(sv%id%irn) + nullify(sv%id%jcn) + nullify(sv%id%a) + + call acoo%free() + sv%built=.true. + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) iam,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +#else + write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " +#endif +end subroutine d_mumps_solver_bld + diff --git a/mlprec/impl/solver/amg_s_base_solver_apply.f90 b/mlprec/impl/solver/amg_s_base_solver_apply.f90 new file mode 100644 index 00000000..a9906da8 --- /dev/null +++ b/mlprec/impl/solver/amg_s_base_solver_apply.f90 @@ -0,0 +1,71 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + + use psb_base_mod + use amg_s_base_solver_mod, amg_protect_name => amg_s_base_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_base_solver_type), intent(inout) :: sv + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_base_solver_apply diff --git a/mlprec/impl/solver/amg_s_base_solver_apply_vect.f90 b/mlprec/impl/solver/amg_s_base_solver_apply_vect.f90 new file mode 100644 index 00000000..b2defb3b --- /dev/null +++ b/mlprec/impl/solver/amg_s_base_solver_apply_vect.f90 @@ -0,0 +1,72 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_s_base_solver_mod, amg_protect_name => amg_s_base_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_base_solver_type), intent(inout) :: sv + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_solver_apply_vect' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_base_solver_apply_vect diff --git a/mlprec/impl/solver/amg_s_base_solver_bld.f90 b/mlprec/impl/solver/amg_s_base_solver_bld.f90 new file mode 100644 index 00000000..cca8c891 --- /dev/null +++ b/mlprec/impl/solver/amg_s_base_solver_bld.f90 @@ -0,0 +1,68 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_s_base_solver_mod, amg_protect_name => amg_s_base_solver_bld + Implicit None + ! Arguments + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type), intent(in), target, optional :: b + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_bld' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_solver_bld diff --git a/mlprec/impl/solver/amg_s_base_solver_check.f90 b/mlprec/impl/solver/amg_s_base_solver_check.f90 new file mode 100644 index 00000000..697a93f4 --- /dev/null +++ b/mlprec/impl/solver/amg_s_base_solver_check.f90 @@ -0,0 +1,61 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_solver_check(sv,info) + + use psb_base_mod + use amg_s_base_solver_mod, amg_protect_name => amg_s_base_solver_check + Implicit None + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_solver_check diff --git a/mlprec/impl/solver/amg_s_base_solver_clear_data.f90 b/mlprec/impl/solver/amg_s_base_solver_clear_data.f90 new file mode 100644 index 00000000..abf04c38 --- /dev/null +++ b/mlprec/impl/solver/amg_s_base_solver_clear_data.f90 @@ -0,0 +1,60 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_solver_clear_data(sv,info) + + use psb_base_mod + use amg_s_base_solver_mod, amg_protect_name => amg_s_base_solver_clear_data + Implicit None + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_solver_clear_data' + + call psb_erractionsave(err_act) + info = 0 + + ! Do nothing + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_solver_clear_data diff --git a/mlprec/impl/solver/amg_s_base_solver_clone.f90 b/mlprec/impl/solver/amg_s_base_solver_clone.f90 new file mode 100644 index 00000000..6bd51c0a --- /dev/null +++ b/mlprec/impl/solver/amg_s_base_solver_clone.f90 @@ -0,0 +1,62 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_s_base_solver_mod, amg_protect_name => amg_s_base_solver_clone + Implicit None + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_solver_clone' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_solver_clone diff --git a/mlprec/impl/solver/amg_s_base_solver_clone_settings.f90 b/mlprec/impl/solver/amg_s_base_solver_clone_settings.f90 new file mode 100644 index 00000000..167bed47 --- /dev/null +++ b/mlprec/impl/solver/amg_s_base_solver_clone_settings.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_solver_clone_settings(sv,svout,info) + + use psb_base_mod + use amg_s_base_solver_mod, amg_protect_name => amg_s_base_solver_clone_settings + Implicit None + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_base_solver_clone_settings' + + call psb_erractionsave(err_act) + + if (same_type_as(sv,svout)) then + ! Do nothing + else + + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_solver_clone_settings diff --git a/mlprec/impl/solver/amg_s_base_solver_cnv.f90 b/mlprec/impl/solver/amg_s_base_solver_cnv.f90 new file mode 100644 index 00000000..07598028 --- /dev/null +++ b/mlprec/impl/solver/amg_s_base_solver_cnv.f90 @@ -0,0 +1,63 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_solver_cnv(sv,info,amold,vmold,imold) + + use psb_base_mod + use amg_s_base_solver_mod, amg_protect_name => amg_s_base_solver_cnv + Implicit None + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_cnv' + + call psb_erractionsave(err_act) + + info = psb_success_ + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_solver_cnv diff --git a/mlprec/impl/solver/amg_s_base_solver_csetc.f90 b/mlprec/impl/solver/amg_s_base_solver_csetc.f90 new file mode 100644 index 00000000..6caf43da --- /dev/null +++ b/mlprec/impl/solver/amg_s_base_solver_csetc.f90 @@ -0,0 +1,63 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_solver_csetc(sv,what,val,info,idx) + + use psb_base_mod + use amg_s_base_solver_mod, amg_protect_name => amg_s_base_solver_csetc + Implicit None + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + Integer(Psb_ipk_) :: err_act, ival + character(len=20) :: name='d_base_solver_csetc' + + call psb_erractionsave(err_act) + + info = psb_success_ + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_solver_csetc diff --git a/mlprec/impl/solver/amg_s_base_solver_cseti.f90 b/mlprec/impl/solver/amg_s_base_solver_cseti.f90 new file mode 100644 index 00000000..6b80bed3 --- /dev/null +++ b/mlprec/impl/solver/amg_s_base_solver_cseti.f90 @@ -0,0 +1,56 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_solver_cseti(sv,what,val,info,idx) + + use psb_base_mod + use amg_s_base_solver_mod, amg_protect_name => amg_s_base_solver_cseti + Implicit None + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_cseti' + + ! Correct action here is doing nothing. + info = 0 + + return +end subroutine amg_s_base_solver_cseti diff --git a/mlprec/impl/solver/amg_s_base_solver_csetr.f90 b/mlprec/impl/solver/amg_s_base_solver_csetr.f90 new file mode 100644 index 00000000..84bc12e3 --- /dev/null +++ b/mlprec/impl/solver/amg_s_base_solver_csetr.f90 @@ -0,0 +1,57 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_solver_csetr(sv,what,val,info,idx) + + use psb_base_mod + use amg_s_base_solver_mod, amg_protect_name => amg_s_base_solver_csetr + Implicit None + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(in) :: what + real(psb_spk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_csetr' + + + ! Correct action here is doing nothing. + info = 0 + + return +end subroutine amg_s_base_solver_csetr diff --git a/mlprec/impl/solver/amg_s_base_solver_descr.f90 b/mlprec/impl/solver/amg_s_base_solver_descr.f90 new file mode 100644 index 00000000..17711737 --- /dev/null +++ b/mlprec/impl/solver/amg_s_base_solver_descr.f90 @@ -0,0 +1,66 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_solver_descr(sv,info,iout,coarse) + + use psb_base_mod + use amg_s_base_solver_mod, amg_protect_name => amg_s_base_solver_descr + Implicit None + ! Arguments + class(amg_s_base_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_s_base_solver_descr' + + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_solver_descr diff --git a/mlprec/impl/solver/amg_s_base_solver_dmp.f90 b/mlprec/impl/solver/amg_s_base_solver_dmp.f90 new file mode 100644 index 00000000..cdf202bd --- /dev/null +++ b/mlprec/impl/solver/amg_s_base_solver_dmp.f90 @@ -0,0 +1,78 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_s_base_solver_mod, amg_protect_name => amg_s_base_solver_dmp + implicit none + class(amg_s_base_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: solver_ + ! len of prefix_ + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_s" + end if + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + ! At base level do nothing for the solver + +end subroutine amg_s_base_solver_dmp diff --git a/mlprec/impl/solver/amg_s_base_solver_free.f90 b/mlprec/impl/solver/amg_s_base_solver_free.f90 new file mode 100644 index 00000000..a59859dd --- /dev/null +++ b/mlprec/impl/solver/amg_s_base_solver_free.f90 @@ -0,0 +1,60 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_base_solver_free(sv,info) + + use psb_base_mod + use amg_s_base_solver_mod, amg_protect_name => amg_s_base_solver_free + Implicit None + ! Arguments + class(amg_s_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_free' + + call psb_erractionsave(err_act) + + ! Do nothing + info = psb_success_ + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_base_solver_free diff --git a/mlprec/impl/solver/amg_s_bwgs_solver_apply.f90 b/mlprec/impl/solver/amg_s_bwgs_solver_apply.f90 new file mode 100644 index 00000000..a6abfac1 --- /dev/null +++ b/mlprec/impl/solver/amg_s_bwgs_solver_apply.f90 @@ -0,0 +1,216 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_bwgs_solver_apply(alpha,sv,x,beta,y,desc_data,& + &trans,work,info,init,initu) + + use psb_base_mod + use amg_s_gs_solver, amg_protect_name => amg_s_bwgs_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_bwgs_solver_type), intent(inout) :: sv + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col, itx, itxst + real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + real(psb_spk_), allocatable :: temp(:),wv(:),xit(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='s_bwgs_solver_apply' + + call psb_erractionsave(err_act) + ictxt = desc_data%get_ctxt() + call psb_info(ictxt,me,np) + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') +!!$ case('T') +!!$ case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + + call psb_geasb(wv,desc_data,info) + call psb_geasb(xit,desc_data,info) + itxst = 1 + select case (init_) + case('Z') + call psb_geaxpby(sone,x,szero,wv,desc_data,info) + call psb_spsm(sone,sv%u,wv,szero,xit,desc_data,info) + itxst = 2 + case('Y') + call psb_geaxpby(sone,y,szero,xit,desc_data,info) + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(sone,initu,szero,xit,desc_data,info) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + select case(trans_) + case('N') + if (sv%eps <=szero) then + ! + ! Fixed number of iterations + ! + ! + do itx=itxst, sv%sweeps + call psb_geaxpby(sone,x,szero,wv,desc_data,info) + ! Update with L. The off-diagonal block is taken care + ! from the Jacobi smoother, hence this is purely local. + call psb_spmm(-sone,sv%l,xit,sone,wv,desc_data,info,doswap=.false.) + call psb_spsm(sone,sv%u,wv,szero,xit,desc_data,info) + end do + + call psb_geaxpby(alpha,xit,beta,y,desc_data,info) + + else + ! + ! Iterations to convergence, not implemented right now. + ! + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') + goto 9999 + + end if +!!$ case('T') +!!$ call psb_spsm(sone,sv%u,x,szero,wv,desc_data,info,& +!!$ & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) +!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) +!!$ +!!$ case('C') +!!$ +!!$ call psb_spsm(sone,sv%u,x,szero,wv,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) +!!$ +!!$ call wv1%mlt(sone,sv%dv,wv,szero,info,conjgx=trans_) +!!$ +!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv1,beta,y,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid TRANS in GS subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_bwgs_solver_apply diff --git a/mlprec/impl/solver/amg_s_bwgs_solver_apply_vect.f90 b/mlprec/impl/solver/amg_s_bwgs_solver_apply_vect.f90 new file mode 100644 index 00000000..0ffbcd5f --- /dev/null +++ b/mlprec/impl/solver/amg_s_bwgs_solver_apply_vect.f90 @@ -0,0 +1,211 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_bwgs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_s_gs_solver, amg_protect_name => amg_s_bwgs_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_bwgs_solver_type), intent(inout) :: sv + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col, itx, itxst + real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + real(psb_spk_), allocatable :: temp(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='s_bwgs_solver_apply' + + call psb_erractionsave(err_act) + ictxt = desc_data%get_ctxt() + call psb_info(ictxt,me,np) + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') +!!$ case('T') +!!$ case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + + if (x%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/itwo,n_row,izero,izero,izero/)) + goto 9999 + end if + if (y%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/ithree,n_row,izero,izero,izero/)) + goto 9999 + end if + + + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + + if (size(wv) < 2) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size') + goto 9999 + end if + + associate(tw => wv(1), xit => wv(2)) + itxst = 1 + select case (init_) + case('Z') + call psb_geaxpby(sone,x,szero,tw,desc_data,info) + call psb_spsm(sone,sv%u,tw,szero,xit,desc_data,info) + itxst = 2 + case('Y') + call psb_geaxpby(sone,y,szero,xit,desc_data,info) + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(sone,initu,szero,xit,desc_data,info) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + select case(trans_) + case('N') + if (sv%eps <=szero) then + ! + ! Fixed number of iterations + ! + ! + do itx=itxst,sv%sweeps + call psb_geaxpby(sone,x,szero,tw,desc_data,info) + ! Update with L. The off-diagonal block is taken care + ! from the Jacobi smoother, hence this is purely local. + call psb_spmm(-sone,sv%l,xit,sone,tw,desc_data,info,doswap=.false.) + call psb_spsm(sone,sv%u,tw,szero,xit,desc_data,info) + end do + + call psb_geaxpby(alpha,xit,beta,y,desc_data,info) + + else + ! + ! Iterations to convergence, not implemented right now. + ! + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') + goto 9999 + + end if + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid TRANS in GS subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + end associate + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_bwgs_solver_apply_vect diff --git a/mlprec/impl/solver/amg_s_bwgs_solver_bld.f90 b/mlprec/impl/solver/amg_s_bwgs_solver_bld.f90 new file mode 100644 index 00000000..f2856cb5 --- /dev/null +++ b/mlprec/impl/solver/amg_s_bwgs_solver_bld.f90 @@ -0,0 +1,110 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_bwgs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_s_gs_solver, amg_protect_name => amg_s_bwgs_solver_bld + + Implicit None + + ! Arguments + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(in) :: desc_a + class(amg_s_bwgs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type), intent(in), target, optional :: b + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_bwgs_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + + if (sv%eps <= dzero) then + ! + ! This cuts out the off-diagonal part, because it's supposed to + ! be handled by the outer Jacobi smoother. + ! + call a%tril(sv%l,info,diag=-ione,jmax=nrow_a,u=sv%u) + + else + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end if + + + + call sv%l%set_asb() + call sv%l%trim() + call sv%u%set_asb() + call sv%u%trim() + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_bwgs_solver_bld diff --git a/mlprec/impl/solver/amg_s_diag_solver_apply.f90 b/mlprec/impl/solver/amg_s_diag_solver_apply.f90 new file mode 100644 index 00000000..4a31e974 --- /dev/null +++ b/mlprec/impl/solver/amg_s_diag_solver_apply.f90 @@ -0,0 +1,240 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_diag_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + + use psb_base_mod + use amg_s_diag_solver, amg_protect_name => amg_s_diag_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_diag_solver_type), intent(inout) :: sv + real(psb_spk_), intent(inout) :: x(:) + real(psb_spk_), intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col + real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='s_diag_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (trans_ == 'C') then + if (beta == szero) then + + if (alpha == szero) then + y(1:n_row) = szero + else if (alpha == sone) then + do i=1, n_row + y(i) = (sv%d(i)) * x(i) + end do + else if (alpha == -sone) then + do i=1, n_row + y(i) = -(sv%d(i)) * x(i) + end do + else + do i=1, n_row + y(i) = alpha * (sv%d(i)) * x(i) + end do + end if + + else if (beta == sone) then + + if (alpha == szero) then + !y(1:n_row) = szero + else if (alpha == sone) then + do i=1, n_row + y(i) = (sv%d(i)) * x(i) + y(i) + end do + else if (alpha == -sone) then + do i=1, n_row + y(i) = -(sv%d(i)) * x(i) + y(i) + end do + else + do i=1, n_row + y(i) = alpha * (sv%d(i)) * x(i) + y(i) + end do + end if + + else if (beta == -sone) then + + if (alpha == szero) then + y(1:n_row) = -y(1:n_row) + else if (alpha == sone) then + do i=1, n_row + y(i) = (sv%d(i)) * x(i) - y(i) + end do + else if (alpha == -sone) then + do i=1, n_row + y(i) = -(sv%d(i)) * x(i) - y(i) + end do + else + do i=1, n_row + y(i) = alpha * (sv%d(i)) * x(i) - y(i) + end do + end if + + else + + if (alpha == szero) then + y(1:n_row) = beta *y(1:n_row) + else if (alpha == sone) then + do i=1, n_row + y(i) = (sv%d(i)) * x(i) + beta*y(i) + end do + else if (alpha == -sone) then + do i=1, n_row + y(i) = -(sv%d(i)) * x(i) + beta*y(i) + end do + else + do i=1, n_row + y(i) = alpha * (sv%d(i)) * x(i) + beta*y(i) + end do + end if + + end if + + else if (trans_ /= 'C') then + + if (beta == szero) then + + if (alpha == szero) then + y(1:n_row) = szero + else if (alpha == sone) then + do i=1, n_row + y(i) = sv%d(i) * x(i) + end do + else if (alpha == -sone) then + do i=1, n_row + y(i) = -sv%d(i) * x(i) + end do + else + do i=1, n_row + y(i) = alpha * sv%d(i) * x(i) + end do + end if + + else if (beta == sone) then + + if (alpha == szero) then + !y(1:n_row) = szero + else if (alpha == sone) then + do i=1, n_row + y(i) = sv%d(i) * x(i) + y(i) + end do + else if (alpha == -sone) then + do i=1, n_row + y(i) = -sv%d(i) * x(i) + y(i) + end do + else + do i=1, n_row + y(i) = alpha * sv%d(i) * x(i) + y(i) + end do + end if + + else if (beta == -sone) then + + if (alpha == szero) then + y(1:n_row) = -y(1:n_row) + else if (alpha == sone) then + do i=1, n_row + y(i) = sv%d(i) * x(i) - y(i) + end do + else if (alpha == -sone) then + do i=1, n_row + y(i) = -sv%d(i) * x(i) - y(i) + end do + else + do i=1, n_row + y(i) = alpha * sv%d(i) * x(i) - y(i) + end do + end if + + else + + if (alpha == szero) then + y(1:n_row) = beta *y(1:n_row) + else if (alpha == sone) then + do i=1, n_row + y(i) = sv%d(i) * x(i) + beta*y(i) + end do + else if (alpha == -sone) then + do i=1, n_row + y(i) = -sv%d(i) * x(i) + beta*y(i) + end do + else + do i=1, n_row + y(i) = alpha * sv%d(i) * x(i) + beta*y(i) + end do + end if + + end if + + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_diag_solver_apply diff --git a/mlprec/impl/solver/amg_s_diag_solver_apply_vect.f90 b/mlprec/impl/solver/amg_s_diag_solver_apply_vect.f90 new file mode 100644 index 00000000..da68210e --- /dev/null +++ b/mlprec/impl/solver/amg_s_diag_solver_apply_vect.f90 @@ -0,0 +1,117 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_diag_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_s_diag_solver, amg_protect_name => amg_s_diag_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_diag_solver_type), intent(inout) :: sv + type(psb_s_vect_type), intent(inout) :: x + type(psb_s_vect_type), intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col + real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='s_diag_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + if (x%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/itwo,n_row,izero,izero,izero/)) + goto 9999 + end if + if (y%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/ithree,n_row,izero,izero,izero/)) + goto 9999 + end if + if (.not.allocated(sv%dv)) then + info = 1124 + call psb_errpush(info,name,a_err="preconditioner: D") + goto 9999 + end if + if (sv%dv%get_nrows() < n_row) then + info = 1124 + call psb_errpush(info,name,a_err="preconditioner: D") + goto 9999 + end if + + call y%mlt(alpha,sv%dv,x,beta,info,conjgx=trans_) + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='vect%mlt') + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_diag_solver_apply_vect diff --git a/mlprec/impl/solver/amg_s_diag_solver_bld.f90 b/mlprec/impl/solver/amg_s_diag_solver_bld.f90 new file mode 100644 index 00000000..625dc506 --- /dev/null +++ b/mlprec/impl/solver/amg_s_diag_solver_bld.f90 @@ -0,0 +1,191 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_s_diag_solver, amg_protect_name => amg_s_diag_solver_bld + + Implicit None + + ! Arguments + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type), intent(in), target, optional :: b + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + real(psb_spk_), allocatable :: tdb(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='s_diag_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + nrow_a = a%get_nrows() + + sv%d = a%get_diag(info) + if (info == psb_success_) call psb_realloc(n_row,sv%d,info) + if (present(b)) then + tdb=b%get_diag(info) + if (size(tdb)+nrow_a > n_row) call psb_realloc(nrow_a+size(tdb),sv%d,info) + if (info == psb_success_) sv%d(nrow_a+1:nrow_a+size(tdb)) = tdb(:) + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='get_diag') + goto 9999 + end if + + do i=1,n_row + if (sv%d(i) == szero) then + sv%d(i) = sone + else + sv%d(i) = sone/sv%d(i) + end if + end do + allocate(sv%dv,stat=info) + if (info == psb_success_) then + call sv%dv%bld(sv%d) + if (present(vmold)) call sv%dv%cnv(vmold) + call sv%dv%sync() + else + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='Allocate sv%dv') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_diag_solver_bld + + +subroutine amg_s_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_s_l1_diag_solver, amg_protect_name => amg_s_l1_diag_solver_bld + + Implicit None + + ! Arguments + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_l1_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type), intent(in), target, optional :: b + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + real(psb_spk_), allocatable :: tdb(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='s_l1_diag_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + nrow_a = a%get_nrows() + + sv%d = a%arwsum(info) + if (info == psb_success_) call psb_realloc(n_row,sv%d,info) + if (present(b)) then + tdb=b%arwsum(info) + if (size(tdb)+nrow_a > n_row) call psb_realloc(nrow_a+size(tdb),sv%d,info) + if (info == psb_success_) sv%d(nrow_a+1:nrow_a+size(tdb)) = tdb(:) + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='arwsum') + goto 9999 + end if + + do i=1,n_row + if (sv%d(i) == szero) then + sv%d(i) = sone + else + sv%d(i) = sone/sv%d(i) + end if + end do + allocate(sv%dv,stat=info) + if (info == psb_success_) then + call sv%dv%bld(sv%d) + if (present(vmold)) call sv%dv%cnv(vmold) + call sv%dv%sync() + else + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='Allocate sv%dv') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_l1_diag_solver_bld diff --git a/mlprec/impl/solver/amg_s_diag_solver_clear_data.f90 b/mlprec/impl/solver/amg_s_diag_solver_clear_data.f90 new file mode 100644 index 00000000..6ed79256 --- /dev/null +++ b/mlprec/impl/solver/amg_s_diag_solver_clear_data.f90 @@ -0,0 +1,65 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_diag_solver_clear_data(sv,info) + + use psb_base_mod + use amg_s_diag_solver, amg_protect_name => amg_s_diag_solver_clear_data + + Implicit None + + ! Arguments + class(amg_s_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + call sv%dv%free(info) + if ((info ==0).and.allocated(sv%d)) deallocate(sv%d,stat=info) + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_diag_solver_clear_data diff --git a/mlprec/impl/solver/amg_s_diag_solver_clone.f90 b/mlprec/impl/solver/amg_s_diag_solver_clone.f90 new file mode 100644 index 00000000..d46d7a16 --- /dev/null +++ b/mlprec/impl/solver/amg_s_diag_solver_clone.f90 @@ -0,0 +1,83 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_diag_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_s_diag_solver, amg_protect_name => amg_s_diag_solver_clone + + Implicit None + + ! Arguments + class(amg_s_diag_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(svout)) then + call svout%free(info) + if (info == psb_success_) deallocate(svout, stat=info) + end if + if (info == psb_success_) & + & allocate(svout, mold=sv, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(svo => svout) + class is (amg_s_diag_solver_type) + call psb_safe_ab_cpy(sv%d,svo%d,info) + if (info == psb_success_) & + & call sv%dv%clone(svo%dv,info) + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_diag_solver_clone diff --git a/mlprec/impl/solver/amg_s_diag_solver_cnv.f90 b/mlprec/impl/solver/amg_s_diag_solver_cnv.f90 new file mode 100644 index 00000000..b8a3014e --- /dev/null +++ b/mlprec/impl/solver/amg_s_diag_solver_cnv.f90 @@ -0,0 +1,76 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_diag_solver_cnv(sv,info,amold,vmold,imold) + + use psb_base_mod + use amg_s_diag_solver, amg_protect_name => amg_s_diag_solver_cnv + + Implicit None + + ! Arguments + class(amg_s_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: err_act, debug_unit, debug_level + character(len=20) :: name='d_diag_solver_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) trim(name),' start' + + + if (allocated(sv%dv)) then + call sv%dv%cnv(vmold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_s_diag_solver_cnv diff --git a/mlprec/impl/solver/amg_s_diag_solver_dmp.f90 b/mlprec/impl/solver/amg_s_diag_solver_dmp.f90 new file mode 100644 index 00000000..863bccee --- /dev/null +++ b/mlprec/impl/solver/amg_s_diag_solver_dmp.f90 @@ -0,0 +1,133 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_s_diag_solver, amg_protect_name => amg_s_diag_solver_dmp + implicit none + class(amg_s_diag_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: solver_ + ! len of prefix_ + + info = 0 + + ictxt = desc%get_context() + + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + + if (solver_) then + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_s" + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' + if (allocated(sv%d)) & + & call psb_geprt(fname,sv%d,head=head) + + end if + +end subroutine amg_s_diag_solver_dmp +subroutine amg_s_l1_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_s_l1_diag_solver, amg_protect_name => amg_s_l1_diag_solver_dmp + implicit none + class(amg_s_l1_diag_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: solver_ + ! len of prefix_ + + info = 0 + + ictxt = desc%get_context() + + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + + if (solver_) then + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_s" + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_l1_diag.mtx' + if (allocated(sv%d)) & + & call psb_geprt(fname,sv%d,head=head) + + end if + +end subroutine amg_s_l1_diag_solver_dmp diff --git a/mlprec/impl/solver/amg_s_gs_solver_apply.f90 b/mlprec/impl/solver/amg_s_gs_solver_apply.f90 new file mode 100644 index 00000000..a9fc60d0 --- /dev/null +++ b/mlprec/impl/solver/amg_s_gs_solver_apply.f90 @@ -0,0 +1,216 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_gs_solver_apply(alpha,sv,x,beta,y,desc_data,& + &trans,work,info,init,initu) + + use psb_base_mod + use amg_s_gs_solver, amg_protect_name => amg_s_gs_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_gs_solver_type), intent(inout) :: sv + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col, itx, itxst + real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + real(psb_spk_), allocatable :: temp(:),wv(:),xit(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='s_gs_solver_apply' + + call psb_erractionsave(err_act) + ictxt = desc_data%get_ctxt() + call psb_info(ictxt,me,np) + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') +!!$ case('T') +!!$ case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + + call psb_geasb(wv,desc_data,info) + call psb_geasb(xit,desc_data,info) + itxst = 1 + select case (init_) + case('Z') + call psb_geaxpby(sone,x,szero,wv,desc_data,info) + call psb_spsm(sone,sv%l,wv,szero,xit,desc_data,info) + itxst = 2 + case('Y') + call psb_geaxpby(sone,y,szero,xit,desc_data,info) + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(sone,initu,szero,xit,desc_data,info) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + select case(trans_) + case('N') + if (sv%eps <=szero) then + ! + ! Fixed number of iterations + ! + ! + do itx=itxst,sv%sweeps + call psb_geaxpby(sone,x,szero,wv,desc_data,info) + ! Update with U. The off-diagonal block is taken care + ! from the Jacobi smoother, hence this is purely local. + call psb_spmm(-sone,sv%u,xit,sone,wv,desc_data,info,doswap=.false.) + call psb_spsm(sone,sv%l,wv,szero,xit,desc_data,info) + end do + + call psb_geaxpby(alpha,xit,beta,y,desc_data,info) + + else + ! + ! Iterations to convergence, not implemented right now. + ! + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') + goto 9999 + + end if +!!$ case('T') +!!$ call psb_spsm(sone,sv%u,x,szero,wv,desc_data,info,& +!!$ & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) +!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) +!!$ +!!$ case('C') +!!$ +!!$ call psb_spsm(sone,sv%u,x,szero,wv,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) +!!$ +!!$ call wv1%mlt(sone,sv%dv,wv,szero,info,conjgx=trans_) +!!$ +!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv1,beta,y,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid TRANS in GS subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_gs_solver_apply diff --git a/mlprec/impl/solver/amg_s_gs_solver_apply_vect.f90 b/mlprec/impl/solver/amg_s_gs_solver_apply_vect.f90 new file mode 100644 index 00000000..a097b91d --- /dev/null +++ b/mlprec/impl/solver/amg_s_gs_solver_apply_vect.f90 @@ -0,0 +1,211 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_gs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_s_gs_solver, amg_protect_name => amg_s_gs_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_gs_solver_type), intent(inout) :: sv + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col, itx, itxst + real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + real(psb_spk_), allocatable :: temp(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='s_gs_solver_apply' + + call psb_erractionsave(err_act) + ictxt = desc_data%get_ctxt() + call psb_info(ictxt,me,np) + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') +!!$ case('T') +!!$ case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + + if (x%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/itwo,n_row,izero,izero,izero/)) + goto 9999 + end if + if (y%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/ithree,n_row,izero,izero,izero/)) + goto 9999 + end if + + + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + + if (size(wv) < 2) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size') + goto 9999 + end if + + associate(tw => wv(1), xit => wv(2)) + itxst = 1 + select case (init_) + case('Z') + call psb_geaxpby(sone,x,szero,tw,desc_data,info) + call psb_spsm(sone,sv%l,tw,szero,xit,desc_data,info) + itxst = 2 + case('Y') + call psb_geaxpby(sone,y,szero,xit,desc_data,info) + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(sone,initu,szero,xit,desc_data,info) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + select case(trans_) + case('N') + if (sv%eps <=szero) then + ! + ! Fixed number of iterations + ! + ! + do itx=itxst,sv%sweeps + call psb_geaxpby(sone,x,szero,tw,desc_data,info) + ! Update with U. The off-diagonal block is taken care + ! from the Jacobi smoother, hence this is purely local. + call psb_spmm(-sone,sv%u,xit,sone,tw,desc_data,info,doswap=.false.) + call psb_spsm(sone,sv%l,tw,szero,xit,desc_data,info) + end do + + call psb_geaxpby(alpha,xit,beta,y,desc_data,info) + + else + ! + ! Iterations to convergence, not implemented right now. + ! + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') + goto 9999 + + end if + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid TRANS in GS subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + end associate + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_gs_solver_apply_vect diff --git a/mlprec/impl/solver/amg_s_gs_solver_bld.f90 b/mlprec/impl/solver/amg_s_gs_solver_bld.f90 new file mode 100644 index 00000000..f08d048d --- /dev/null +++ b/mlprec/impl/solver/amg_s_gs_solver_bld.f90 @@ -0,0 +1,109 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_gs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_s_gs_solver, amg_protect_name => amg_s_gs_solver_bld + + Implicit None + + ! Arguments + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type), intent(in), target, optional :: b + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='s_gs_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + + if (sv%eps <= dzero) then + ! + ! This cuts out the off-diagonal part, because it's supposed to + ! be handled by the outer Jacobi smoother. + ! + call a%tril(sv%l,info,diag=izero,jmax=nrow_a,u=sv%u) + + else + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end if + + + + call sv%l%set_asb() + call sv%l%trim() + call sv%u%set_asb() + call sv%u%trim() + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_gs_solver_bld diff --git a/mlprec/impl/solver/amg_s_gs_solver_clear_data.f90 b/mlprec/impl/solver/amg_s_gs_solver_clear_data.f90 new file mode 100644 index 00000000..83690765 --- /dev/null +++ b/mlprec/impl/solver/amg_s_gs_solver_clear_data.f90 @@ -0,0 +1,65 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_gs_solver_clear_data(sv,info) + + use psb_base_mod + use amg_s_gs_solver, amg_protect_name => amg_s_gs_solver_clear_data + + Implicit None + + ! Arguments + class(amg_s_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + call sv%l%free() + call sv%u%free() + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_gs_solver_clear_data diff --git a/mlprec/impl/solver/amg_s_gs_solver_clone.f90 b/mlprec/impl/solver/amg_s_gs_solver_clone.f90 new file mode 100644 index 00000000..5351a57a --- /dev/null +++ b/mlprec/impl/solver/amg_s_gs_solver_clone.f90 @@ -0,0 +1,87 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_gs_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_s_gs_solver, amg_protect_name => amg_s_gs_solver_clone + + Implicit None + + ! Arguments + class(amg_s_gs_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + if (allocated(svout)) then + call svout%free(info) + if (info == psb_success_) deallocate(svout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_s_gs_solver_type :: svout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(svo => svout) + type is (amg_s_gs_solver_type) + svo%sweeps = sv%sweeps + svo%eps = sv%eps + if (info == psb_success_) & + & call sv%l%clone(svo%l,info) + if (info == psb_success_) & + & call sv%u%clone(svo%u,info) + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_gs_solver_clone diff --git a/mlprec/impl/solver/amg_s_gs_solver_clone_settings.f90 b/mlprec/impl/solver/amg_s_gs_solver_clone_settings.f90 new file mode 100644 index 00000000..bdc9a4d3 --- /dev/null +++ b/mlprec/impl/solver/amg_s_gs_solver_clone_settings.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_gs_solver_clone_settings(sv,svout,info) + + use psb_base_mod + use amg_s_gs_solver, amg_protect_name => amg_s_gs_solver_clone_settings + Implicit None + ! Arguments + class(amg_s_gs_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_gs_solver_clone_settings' + + call psb_erractionsave(err_act) + + select type(svout) + class is(amg_s_gs_solver_type) + svout%sweeps = sv%sweeps + svout%eps = sv%eps + + class default + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_gs_solver_clone_settings diff --git a/mlprec/impl/solver/amg_s_gs_solver_cnv.f90 b/mlprec/impl/solver/amg_s_gs_solver_cnv.f90 new file mode 100644 index 00000000..d276d856 --- /dev/null +++ b/mlprec/impl/solver/amg_s_gs_solver_cnv.f90 @@ -0,0 +1,74 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_gs_solver_cnv(sv,info,amold,vmold,imold) + + use psb_base_mod + use amg_s_gs_solver, amg_protect_name => amg_s_gs_solver_cnv + + Implicit None + + ! Arguments + class(amg_s_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: err_act, debug_unit, debug_level + character(len=20) :: name='s_gs_solver_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_gs_solver_cnv diff --git a/mlprec/impl/solver/amg_s_gs_solver_dmp.f90 b/mlprec/impl/solver/amg_s_gs_solver_dmp.f90 new file mode 100644 index 00000000..ef913d5d --- /dev/null +++ b/mlprec/impl/solver/amg_s_gs_solver_dmp.f90 @@ -0,0 +1,102 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_gs_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_s_gs_solver, amg_protect_name => amg_s_gs_solver_dmp + implicit none + class(amg_s_gs_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + integer(psb_lpk_), allocatable :: iv(:) + logical :: solver_, global_num_ + ! len of prefix_ + + info = 0 + + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + + if (solver_) then + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_d" + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + if (global_num_) then + iv = desc%get_global_indices(owned=.false.) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' + if (sv%l%is_asb()) & + & call sv%l%print(fname,head=head,iv=iv) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' + if (sv%u%is_asb()) & + & call sv%u%print(fname,head=head,iv=iv) + else + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' + if (sv%l%is_asb()) & + & call sv%l%print(fname,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' + if (sv%u%is_asb()) & + & call sv%u%print(fname,head=head) + end if + end if + +end subroutine amg_s_gs_solver_dmp diff --git a/mlprec/impl/solver/amg_s_id_solver_apply.f90 b/mlprec/impl/solver/amg_s_id_solver_apply.f90 new file mode 100644 index 00000000..6b5114af --- /dev/null +++ b/mlprec/impl/solver/amg_s_id_solver_apply.f90 @@ -0,0 +1,86 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_id_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + + use psb_base_mod + use amg_s_id_solver, amg_protect_name => amg_s_id_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_id_solver_type), intent(inout) :: sv + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='s_id_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call psb_geaxpby(alpha,x,beta,y,desc_data,info) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_id_solver_apply diff --git a/mlprec/impl/solver/amg_s_id_solver_apply_vect.f90 b/mlprec/impl/solver/amg_s_id_solver_apply_vect.f90 new file mode 100644 index 00000000..dfffa5d9 --- /dev/null +++ b/mlprec/impl/solver/amg_s_id_solver_apply_vect.f90 @@ -0,0 +1,87 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_id_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_s_id_solver, amg_protect_name => amg_s_id_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_id_solver_type), intent(inout) :: sv + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='s_id_solver_apply_vect' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call psb_geaxpby(alpha,x,beta,y,desc_data,info) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_id_solver_apply_vect diff --git a/mlprec/impl/solver/amg_s_id_solver_clone.f90 b/mlprec/impl/solver/amg_s_id_solver_clone.f90 new file mode 100644 index 00000000..afc46498 --- /dev/null +++ b/mlprec/impl/solver/amg_s_id_solver_clone.f90 @@ -0,0 +1,81 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_id_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_s_id_solver, amg_protect_name => amg_s_id_solver_clone + + Implicit None + + ! Arguments + class(amg_s_id_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(svout)) then + call svout%free(info) + if (info == psb_success_) deallocate(svout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_s_id_solver_type :: svout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(svo => svout) + type is (amg_s_id_solver_type) + ! Nothing to be done. + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_id_solver_clone diff --git a/mlprec/impl/solver/amg_s_ilu_solver_apply.f90 b/mlprec/impl/solver/amg_s_ilu_solver_apply.f90 new file mode 100644 index 00000000..bfda1cb4 --- /dev/null +++ b/mlprec/impl/solver/amg_s_ilu_solver_apply.f90 @@ -0,0 +1,153 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + + use psb_base_mod + use amg_s_ilu_solver, amg_protect_name => amg_s_ilu_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_ilu_solver_type), intent(inout) :: sv + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col + real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='s_ilu_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + endif + + select case(trans_) + case('N') + call psb_spsm(sone,sv%l,x,szero,ww,desc_data,info,& + & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) + + if (info == psb_success_) call psb_spsm(alpha,sv%u,ww,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_, work=aux) + + case('T') + call psb_spsm(sone,sv%u,x,szero,ww,desc_data,info,& + & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) + if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + case('C') + call psb_spsm(sone,sv%u,x,szero,ww,desc_data,info,& + & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) + if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid TRANS in ILU subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_ilu_solver_apply diff --git a/mlprec/impl/solver/amg_s_ilu_solver_apply_vect.f90 b/mlprec/impl/solver/amg_s_ilu_solver_apply_vect.f90 new file mode 100644 index 00000000..48509187 --- /dev/null +++ b/mlprec/impl/solver/amg_s_ilu_solver_apply_vect.f90 @@ -0,0 +1,194 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_s_ilu_solver, amg_protect_name => amg_s_ilu_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_ilu_solver_type), intent(inout) :: sv + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col + type(psb_s_vect_type) :: tw, tw1 + real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='s_ilu_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + + if (x%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/itwo,n_row,izero,izero,izero/)) + goto 9999 + end if + if (y%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/ithree,n_row,izero,izero,izero/)) + goto 9999 + end if + if (.not.allocated(sv%dv%v)) then + info = 1124 + call psb_errpush(info,name,a_err="preconditioner: D") + goto 9999 + end if + if (sv%dv%get_nrows() < n_row) then + info = 1124 + call psb_errpush(info,name,a_err="preconditioner: DV") + goto 9999 + end if + + + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + + + if (size(wv) < 2) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size') + goto 9999 + end if + + + associate(tw => wv(1), tw1 => wv(2)) + + select case(trans_) + case('N') + call psb_spsm(sone,sv%l,x,szero,tw,desc_data,info,& + & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) + + if (info == psb_success_) call psb_spsm(alpha,sv%u,tw,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_, work=aux) + + case('T') + call psb_spsm(sone,sv%u,x,szero,tw,desc_data,info,& + & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) + if (info == psb_success_) call psb_spsm(alpha,sv%l,tw,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + + case('C') + + call psb_spsm(sone,sv%u,x,szero,tw,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + + call tw1%mlt(sone,sv%dv,tw,szero,info,conjgx=trans_) + + if (info == psb_success_) call psb_spsm(alpha,sv%l,tw1,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid TRANS in ILU subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + end associate + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_s_ilu_solver_apply_vect diff --git a/mlprec/impl/solver/amg_s_ilu_solver_bld.f90 b/mlprec/impl/solver/amg_s_ilu_solver_bld.f90 new file mode 100644 index 00000000..13979edd --- /dev/null +++ b/mlprec/impl/solver/amg_s_ilu_solver_bld.f90 @@ -0,0 +1,191 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_ilu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_s_ilu_solver, amg_protect_name => amg_s_ilu_solver_bld + + Implicit None + + ! Arguments + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type), intent(in), target, optional :: b + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota +!!$ real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='s_ilu_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + if (present(b)) then + nztota = nztota + b%get_nzeros() + end if + + call sv%l%csall(n_row,n_row,info,nztota) + if (info == psb_success_) call sv%u%csall(n_row,n_row,info,nztota) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_sp_all' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + if (allocated(sv%d)) then + if (size(sv%d) < n_row) then + deallocate(sv%d) + endif + endif + if (.not.allocated(sv%d)) allocate(sv%d(n_row),stat=info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') + goto 9999 + endif + + + select case(sv%fact_type) + + case (psb_ilu_t_) + ! + ! ILU(k,t) + ! + select case(sv%fill_in) + + case(:-1) + ! Error: fill-in <= -1 + call psb_errpush(psb_err_input_value_invalid_i_,& + & name,i_err=(/ithree,sv%fill_in,izero,izero,izero/)) + goto 9999 + + case(0:) + ! Fill-in >= 0 + call psb_ilut_fact(sv%fill_in,sv%thresh,& + & a, sv%l,sv%u,sv%d,info,blck=b) + end select + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ilut_fact' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + case(psb_ilu_n_,psb_milu_n_) + ! + ! ILU(k) and MILU(k) + ! + select case(sv%fill_in) + case(:-1) + ! Error: fill-in <= -1 + call psb_errpush(psb_err_input_value_invalid_i_,& + & name,i_err=(/ithree,sv%fill_in,izero,izero,izero/)) + goto 9999 + case(0) + ! Fill-in 0 + ! Separate implementation of ILU(0) for better performance. + ! There seems to be a problem with the separate implementation of MILU(0), + ! contained into psb_ilu0_fact. This must be investigated. For the time being, + ! resort to the implementation of MILU(k) with k=0. + if (sv%fact_type == psb_ilu_n_) then + call psb_ilu0_fact(sv%fact_type,a,sv%l,sv%u,& + & sv%d,info,blck=b) + else + call psb_iluk_fact(sv%fill_in,sv%fact_type,& + & a,sv%l,sv%u,sv%d,info,blck=b) + endif + case(1:) + ! Fill-in >= 1 + ! The same routine implements both ILU(k) and MILU(k) + call psb_iluk_fact(sv%fill_in,sv%fact_type,& + & a,sv%l,sv%u,sv%d,info,blck=b) + end select + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_iluk_fact' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + case default + ! If we end up here, something was wrong up in the call chain. + info = psb_err_input_value_invalid_i_ + call psb_errpush(psb_err_input_value_invalid_i_,name,& + & i_err=(/ithree,sv%fact_type,izero,izero,izero/)) + goto 9999 + + end select + + call sv%l%set_asb() + call sv%l%trim() + call sv%u%set_asb() + call sv%u%trim() + call sv%dv%bld(sv%d,mold=vmold) + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_ilu_solver_bld diff --git a/mlprec/impl/solver/amg_s_ilu_solver_clear_data.f90 b/mlprec/impl/solver/amg_s_ilu_solver_clear_data.f90 new file mode 100644 index 00000000..0079db18 --- /dev/null +++ b/mlprec/impl/solver/amg_s_ilu_solver_clear_data.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_ilu_solver_clear_data(sv,info) + + use psb_base_mod + use amg_s_ilu_solver, amg_protect_name => amg_s_ilu_solver_clear_data + + Implicit None + + ! Arguments + class(amg_s_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + call sv%l%free() + call sv%u%free() + call sv%dv%free(info) + if ((info==0).and.allocated(sv%d)) deallocate(sv%d,stat=info) + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_ilu_solver_clear_data diff --git a/mlprec/impl/solver/amg_s_ilu_solver_clone.f90 b/mlprec/impl/solver/amg_s_ilu_solver_clone.f90 new file mode 100644 index 00000000..7abbe99a --- /dev/null +++ b/mlprec/impl/solver/amg_s_ilu_solver_clone.f90 @@ -0,0 +1,91 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_ilu_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_s_ilu_solver, amg_protect_name => amg_s_ilu_solver_clone + + Implicit None + + ! Arguments + class(amg_s_ilu_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + if (allocated(svout)) then + call svout%free(info) + if (info == psb_success_) deallocate(svout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_s_ilu_solver_type :: svout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(svo => svout) + type is (amg_s_ilu_solver_type) + svo%fact_type = sv%fact_type + svo%fill_in = sv%fill_in + svo%thresh = sv%thresh + call psb_safe_ab_cpy(sv%d,svo%d,info) + if (info == psb_success_) & + & call sv%dv%clone(svo%dv,info) + if (info == psb_success_) & + & call sv%l%clone(svo%l,info) + if (info == psb_success_) & + & call sv%u%clone(svo%u,info) + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_ilu_solver_clone diff --git a/mlprec/impl/solver/amg_s_ilu_solver_clone_settings.f90 b/mlprec/impl/solver/amg_s_ilu_solver_clone_settings.f90 new file mode 100644 index 00000000..303c3524 --- /dev/null +++ b/mlprec/impl/solver/amg_s_ilu_solver_clone_settings.f90 @@ -0,0 +1,70 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_ilu_solver_clone_settings(sv,svout,info) + + use psb_base_mod + use amg_s_ilu_solver, amg_protect_name => amg_s_ilu_solver_clone_settings + Implicit None + ! Arguments + class(amg_s_ilu_solver_type), intent(inout) :: sv + class(amg_s_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_ilu_solver_clone_settings' + + call psb_erractionsave(err_act) + + select type(svout) + class is(amg_s_ilu_solver_type) + svout%fact_type = sv%fact_type + svout%fill_in = sv%fill_in + svout%thresh = sv%thresh + + class default + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_ilu_solver_clone_settings diff --git a/mlprec/impl/solver/amg_s_ilu_solver_cnv.f90 b/mlprec/impl/solver/amg_s_ilu_solver_cnv.f90 new file mode 100644 index 00000000..cbf64546 --- /dev/null +++ b/mlprec/impl/solver/amg_s_ilu_solver_cnv.f90 @@ -0,0 +1,76 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_ilu_solver_cnv(sv,info,amold,vmold,imold) + + use psb_base_mod + use amg_s_ilu_solver, amg_protect_name => amg_s_ilu_solver_cnv + + Implicit None + + ! Arguments + class(amg_s_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: err_act, debug_unit, debug_level + character(len=20) :: name='d_ilu_solver_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + call sv%dv%cnv(mold=vmold) + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_s_ilu_solver_cnv diff --git a/mlprec/impl/solver/amg_s_ilu_solver_dmp.f90 b/mlprec/impl/solver/amg_s_ilu_solver_dmp.f90 new file mode 100644 index 00000000..b821d5ff --- /dev/null +++ b/mlprec/impl/solver/amg_s_ilu_solver_dmp.f90 @@ -0,0 +1,112 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_s_ilu_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_s_ilu_solver, amg_protect_name => amg_s_ilu_solver_dmp + implicit none + class(amg_s_ilu_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: solver_, global_num_ + integer(psb_lpk_), allocatable :: iv(:) + ! len of prefix_ + + info = 0 + + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + + + if (solver_) then + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_s" + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + if (global_num_) then + iv = desc%get_global_indices(owned=.false.) + + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' + if (sv%l%is_asb()) & + & call sv%l%print(fname,head=head,iv=iv) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' + if (allocated(sv%d)) & + & call psb_geprt(fname,sv%d,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' + if (sv%u%is_asb()) & + & call sv%u%print(fname,head=head,iv=iv) + + else + + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' + if (sv%l%is_asb()) & + & call sv%l%print(fname,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' + if (allocated(sv%d)) & + & call psb_geprt(fname,sv%d,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' + if (sv%u%is_asb()) & + & call sv%u%print(fname,head=head) + end if + end if + +end subroutine amg_s_ilu_solver_dmp diff --git a/mlprec/impl/solver/amg_s_mumps_solver_apply.F90 b/mlprec/impl/solver/amg_s_mumps_solver_apply.F90 new file mode 100644 index 00000000..5187428a --- /dev/null +++ b/mlprec/impl/solver/amg_s_mumps_solver_apply.F90 @@ -0,0 +1,169 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.0) +! +! (C) Copyright 2008,2009,2010,2012,2013 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +subroutine s_mumps_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + use psb_base_mod + use amg_s_mumps_solver + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_mumps_solver_type), intent(inout) :: sv + real(psb_spk_),intent(inout) :: x(:) + real(psb_spk_),intent(inout) :: y(:) + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + real(psb_spk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row, n_col + integer(psb_lpk_) :: nglob + integer(psb_epk_) :: eng + real(psb_spk_), allocatable :: ww(:) + real(psb_spk_), allocatable, target :: gx(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='s_mumps_solver_apply' + + call psb_erractionsave(err_act) + +#if defined(HAVE_MUMPS_) + info = psb_success_ + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + nglob = desc_data%get_global_rows() + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + ! Running in local mode? + if (sv%ipar(1) == amg_local_solver_ ) then + gx = x + else if (sv%ipar(1) == amg_global_solver_ ) then + + if (n_col <= size(work)) then + ww = work(1:n_col) + else + allocate(ww(n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/n_col/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + end if + allocate(gx(nglob),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_; eng = nglob + call psb_errpush(info,name,e_err=(/eng/),& + & a_err='real(psb_spk_)') + goto 9999 + end if + call psb_gather(gx, x, desc_data, info, root=izero) + else + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid local/global solver in MUMPS') + goto 9999 + end if + + select case(trans_) + case('N') + sv%id%icntl(9) = 1 + case('T') + sv%id%icntl(9) = 2 + case default + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Invalid TRANS in subsolve') + goto 9999 + end select + + sv%id%rhs => gx + sv%id%nrhs = 1 + sv%id%icntl(1)=-1 + sv%id%icntl(2)=-1 + sv%id%icntl(3)=-1 + sv%id%icntl(4)=-1 + sv%id%job = 3 + call smumps(sv%id) + if (sv%ipar(1) == amg_local_solver_ ) then + call psb_geaxpby(alpha,gx,beta,y,desc_data,info) + else + call psb_scatter(gx, ww, desc_data, info, root=izero) + if (info == psb_success_) then + call psb_geaxpby(alpha,ww,beta,y,desc_data,info) + end if + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in subsolve') + goto 9999 + endif + + if (allocated(ww)) deallocate(ww) + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return + +#else + write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " +#endif +end subroutine s_mumps_solver_apply + diff --git a/mlprec/impl/solver/amg_s_mumps_solver_apply_vect.F90 b/mlprec/impl/solver/amg_s_mumps_solver_apply_vect.F90 new file mode 100644 index 00000000..c851fe6d --- /dev/null +++ b/mlprec/impl/solver/amg_s_mumps_solver_apply_vect.F90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.0) +! +! (C) Copyright 2008,2009,2010,2012,2013 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +subroutine s_mumps_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + use psb_base_mod + use amg_s_mumps_solver + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_s_mumps_solver_type), intent(inout) :: sv + type(psb_s_vect_type),intent(inout) :: x + type(psb_s_vect_type),intent(inout) :: y + real(psb_spk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + real(psb_spk_),target, intent(inout) :: work(:) + type(psb_s_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_s_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: err_act + character(len=20) :: name='s_mumps_solver_apply_vect' + +#if defined(HAVE_MUMPS_) + + call psb_erractionsave(err_act) + + info = psb_success_ + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call x%v%sync() + call y%v%sync() + call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) + call y%v%set_host() + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return + +#else + write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " +#endif + +end subroutine s_mumps_solver_apply_vect + diff --git a/mlprec/impl/solver/amg_s_mumps_solver_bld.F90 b/mlprec/impl/solver/amg_s_mumps_solver_bld.F90 new file mode 100644 index 00000000..b8111ec7 --- /dev/null +++ b/mlprec/impl/solver/amg_s_mumps_solver_bld.F90 @@ -0,0 +1,262 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.0) +! +! (C) Copyright 2008,2009,2010,2012,2013 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +subroutine s_mumps_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_s_mumps_solver + Implicit None + + ! Arguments + type(psb_sspmat_type) :: c + type(psb_sspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_s_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_sspmat_type), intent(in), target, optional :: b + class(psb_s_base_sparse_mat), intent(in), optional :: amold + class(psb_s_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + type(psb_sspmat_type) :: atmp + type(psb_s_coo_sparse_mat), target :: acoo +#if defined(IPK4) && defined(LPK8) + integer(psb_lpk_), allocatable :: gia(:), gja(:) +#endif + integer(psb_ipk_) :: n_row,n_col, nrow_a, nza, npr, npc + integer(psb_lpk_) :: nglob, nglobrec, nzt + integer(psb_ipk_) :: ifrst, ibcheck + integer(psb_ipk_) :: ictxt, ictxt1, icomm, np, iam, me, i, err_act, debug_unit, debug_level + character(len=20) :: name='s_mumps_solver_bld', ch_err + +#if defined(HAVE_MUMPS_) + + info=psb_success_ + + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, iam, np) + if (sv%ipar(1) == amg_local_solver_ ) then + call psb_init(ictxt1,np=1,basectxt=ictxt,ids=(/iam/)) + icomm = psb_get_mpi_comm(ictxt1) + allocate(sv%local_ictxt,stat=info) + sv%local_ictxt = ictxt1 + !write(*,*)iam,'mumps_bld: local +++++>',icomm,sv%local_ictxt + call psb_info(ictxt1, me, np) + npr = np + else if (sv%ipar(1) == amg_global_solver_ ) then + icomm = psb_get_mpi_comm(ictxt) + !write(*,*)iam,'mumps_bld: global +++++>',icomm,ictxt + call psb_info(ictxt, iam, np) + me = iam + npr = np + else + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid local/global solver in MUMPS') + goto 9999 + end if + npc = 1 + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + ! if (allocated(sv%id)) then + ! call sv%free(info) + + ! deallocate(sv%id) + ! end if + if(.not.allocated(sv%id)) then + allocate(sv%id,stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_dealloc_ + call psb_errpush(info,name,a_err='amg_smumps_default') + goto 9999 + end if + end if + + + sv%id%comm = icomm + sv%id%job = -1 + sv%id%par = 1 + if (sv%ipar(3) == 2) then + sv%id%sym = 2 + else + sv%id%sym = 0 + end if + + call smumps(sv%id) + !WARNING: CALLING smumps WITH JOB=-1 DESTROY THE SETTING OF DEFAULT:TO FIX + if (allocated(sv%icntl)) then + do i=1,amg_mumps_icntl_size + if (allocated(sv%icntl(i)%item)) then + !write(0,*) 'MUMPS_BLD: setting entry ',i,' to ', sv%icntl(i)%item + sv%id%icntl(i) = sv%icntl(i)%item + end if + end do + end if + if (allocated(sv%rcntl)) then + do i=1,amg_mumps_rcntl_size + if (allocated(sv%rcntl(i)%item)) sv%id%cntl(i) = sv%rcntl(i)%item + end do + end if + sv%id%icntl(3)=sv%ipar(2) + + nglob = desc_a%get_global_rows() + if (sv%ipar(1) == amg_local_solver_ ) then + nglobrec=desc_a%get_local_rows() + if (sv%ipar(3) == 2) then + ! Always pass the upper triangle to MUMPS + call a%triu(c,info,jmax=a%get_nrows()) + call c%set_symmetric() + else + call a%csclip(c,info,jmax=a%get_nrows()) + end if + call c%cp_to(acoo) + nglob = c%get_nrows() + if (nglobrec /= nglob) then + write(*,*)'WARNING: MUMPS solver does not allow overlap in AS yet. ' + write(*,*)'A zero-overlap is used instead' + end if + else + call a%cp_to(acoo) + end if + nza = acoo%get_nzeros() + + ! switch to global numbering + if (sv%ipar(1) == amg_global_solver_ ) then +#if defined(IPK4) && defined(LPK8) + ! + ! Strategy here is as follows: because a call to MUMPS + ! as a gobal solver is mostly done at the coarsest level, + ! even if we start from a problem requiring 8 bytes, chances + ! are that the global size will be suitable for 4 bytes + ! anyway, so we hope for the best, and throw an error + ! if something goes wrong. + ! + if (nglob > huge(1_psb_ipk_)) then + write(0,*) iam,' ',trim(name),': Error: overflow of local indices ' + info=psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + gia = acoo%ia(1:nza) + gja = acoo%ja(1:nza) + call psb_loc_to_glob(gia(1:nza), desc_a, info, iact='I') + call psb_loc_to_glob(gja(1:nza), desc_a, info, iact='I') + acoo%ia(1:nza) = gia(1:nza) + acoo%ja(1:nza) = gja(1:nza) +#else + ! + ! Here global and local numbers have the same size, so this must work. + ! + call psb_loc_to_glob(acoo%ja(1:nza), desc_a, info, iact='I') + call psb_loc_to_glob(acoo%ia(1:nza), desc_a, info, iact='I') +#endif + if (sv%ipar(3) == 2 ) then + ! Always pass the upper triangle to MUMPS + block + integer(psb_ipk_) :: j,nz + nz = 0 + do j=1,nza + if (acoo%ja(j) >= acoo%ia(j)) then + nz = nz + 1 + acoo%ia(nz) = acoo%ia(j) + acoo%ja(nz) = acoo%ja(j) + acoo%val(nz) = acoo%val(j) + end if + end do + call acoo%set_nzeros(nz) + call acoo%set_triangle() + call acoo%set_upper() + call acoo%set_symmetric() + end block + end if + end if + sv%id%irn_loc => acoo%ia + sv%id%jcn_loc => acoo%ja + sv%id%a_loc => acoo%val + sv%id%icntl(18) = 3 + sv%id%n = nglob + ! there should be a better way for this + sv%id%nnz_loc = acoo%get_nzeros() + sv%id%nnz = acoo%get_nzeros() + sv%id%job = 4 + if (sv%ipar(1) == amg_global_solver_ ) then + call psb_sum(ictxt,sv%id%nnz) + end if + !call psb_barrier(ictxt) + write(*,*)iam, ' calling mumps N,nz,nz_loc',sv%id%n,sv%id%nnz,sv%id%nnz_loc + call smumps(sv%id) + !call psb_barrier(ictxt) + info = sv%id%infog(1) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='amg_smumps_fact ' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + nullify(sv%id%irn) + nullify(sv%id%jcn) + nullify(sv%id%a) + + call acoo%free() + sv%built=.true. + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) iam,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +#else + write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " +#endif +end subroutine s_mumps_solver_bld + diff --git a/mlprec/impl/solver/amg_z_base_solver_apply.f90 b/mlprec/impl/solver/amg_z_base_solver_apply.f90 new file mode 100644 index 00000000..834a9b75 --- /dev/null +++ b/mlprec/impl/solver/amg_z_base_solver_apply.f90 @@ -0,0 +1,71 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + + use psb_base_mod + use amg_z_base_solver_mod, amg_protect_name => amg_z_base_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_base_solver_type), intent(inout) :: sv + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_base_solver_apply diff --git a/mlprec/impl/solver/amg_z_base_solver_apply_vect.f90 b/mlprec/impl/solver/amg_z_base_solver_apply_vect.f90 new file mode 100644 index 00000000..43b6241d --- /dev/null +++ b/mlprec/impl/solver/amg_z_base_solver_apply_vect.f90 @@ -0,0 +1,72 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_z_base_solver_mod, amg_protect_name => amg_z_base_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_base_solver_type), intent(inout) :: sv + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_solver_apply_vect' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_base_solver_apply_vect diff --git a/mlprec/impl/solver/amg_z_base_solver_bld.f90 b/mlprec/impl/solver/amg_z_base_solver_bld.f90 new file mode 100644 index 00000000..bb3b4f95 --- /dev/null +++ b/mlprec/impl/solver/amg_z_base_solver_bld.f90 @@ -0,0 +1,68 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_z_base_solver_mod, amg_protect_name => amg_z_base_solver_bld + Implicit None + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_bld' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_solver_bld diff --git a/mlprec/impl/solver/amg_z_base_solver_check.f90 b/mlprec/impl/solver/amg_z_base_solver_check.f90 new file mode 100644 index 00000000..f45744f1 --- /dev/null +++ b/mlprec/impl/solver/amg_z_base_solver_check.f90 @@ -0,0 +1,61 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_solver_check(sv,info) + + use psb_base_mod + use amg_z_base_solver_mod, amg_protect_name => amg_z_base_solver_check + Implicit None + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_check' + + call psb_erractionsave(err_act) + info = psb_success_ + + + if (info /= psb_success_) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_solver_check diff --git a/mlprec/impl/solver/amg_z_base_solver_clear_data.f90 b/mlprec/impl/solver/amg_z_base_solver_clear_data.f90 new file mode 100644 index 00000000..c92fb3d2 --- /dev/null +++ b/mlprec/impl/solver/amg_z_base_solver_clear_data.f90 @@ -0,0 +1,60 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_solver_clear_data(sv,info) + + use psb_base_mod + use amg_z_base_solver_mod, amg_protect_name => amg_z_base_solver_clear_data + Implicit None + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_solver_clear_data' + + call psb_erractionsave(err_act) + info = 0 + + ! Do nothing + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_solver_clear_data diff --git a/mlprec/impl/solver/amg_z_base_solver_clone.f90 b/mlprec/impl/solver/amg_z_base_solver_clone.f90 new file mode 100644 index 00000000..48184c54 --- /dev/null +++ b/mlprec/impl/solver/amg_z_base_solver_clone.f90 @@ -0,0 +1,62 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_z_base_solver_mod, amg_protect_name => amg_z_base_solver_clone + Implicit None + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_solver_clone' + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_solver_clone diff --git a/mlprec/impl/solver/amg_z_base_solver_clone_settings.f90 b/mlprec/impl/solver/amg_z_base_solver_clone_settings.f90 new file mode 100644 index 00000000..419ead2b --- /dev/null +++ b/mlprec/impl/solver/amg_z_base_solver_clone_settings.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_solver_clone_settings(sv,svout,info) + + use psb_base_mod + use amg_z_base_solver_mod, amg_protect_name => amg_z_base_solver_clone_settings + Implicit None + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_base_solver_clone_settings' + + call psb_erractionsave(err_act) + + if (same_type_as(sv,svout)) then + ! Do nothing + else + + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_solver_clone_settings diff --git a/mlprec/impl/solver/amg_z_base_solver_cnv.f90 b/mlprec/impl/solver/amg_z_base_solver_cnv.f90 new file mode 100644 index 00000000..d79d14e5 --- /dev/null +++ b/mlprec/impl/solver/amg_z_base_solver_cnv.f90 @@ -0,0 +1,63 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_solver_cnv(sv,info,amold,vmold,imold) + + use psb_base_mod + use amg_z_base_solver_mod, amg_protect_name => amg_z_base_solver_cnv + Implicit None + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_cnv' + + call psb_erractionsave(err_act) + + info = psb_success_ + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_solver_cnv diff --git a/mlprec/impl/solver/amg_z_base_solver_csetc.f90 b/mlprec/impl/solver/amg_z_base_solver_csetc.f90 new file mode 100644 index 00000000..30176bc7 --- /dev/null +++ b/mlprec/impl/solver/amg_z_base_solver_csetc.f90 @@ -0,0 +1,63 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_solver_csetc(sv,what,val,info,idx) + + use psb_base_mod + use amg_z_base_solver_mod, amg_protect_name => amg_z_base_solver_csetc + Implicit None + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + character(len=*), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + Integer(Psb_ipk_) :: err_act, ival + character(len=20) :: name='d_base_solver_csetc' + + call psb_erractionsave(err_act) + + info = psb_success_ + + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_solver_csetc diff --git a/mlprec/impl/solver/amg_z_base_solver_cseti.f90 b/mlprec/impl/solver/amg_z_base_solver_cseti.f90 new file mode 100644 index 00000000..271ac70c --- /dev/null +++ b/mlprec/impl/solver/amg_z_base_solver_cseti.f90 @@ -0,0 +1,56 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_solver_cseti(sv,what,val,info,idx) + + use psb_base_mod + use amg_z_base_solver_mod, amg_protect_name => amg_z_base_solver_cseti + Implicit None + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + character(len=*), intent(in) :: what + integer(psb_ipk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_cseti' + + ! Correct action here is doing nothing. + info = 0 + + return +end subroutine amg_z_base_solver_cseti diff --git a/mlprec/impl/solver/amg_z_base_solver_csetr.f90 b/mlprec/impl/solver/amg_z_base_solver_csetr.f90 new file mode 100644 index 00000000..87fc9837 --- /dev/null +++ b/mlprec/impl/solver/amg_z_base_solver_csetr.f90 @@ -0,0 +1,57 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_solver_csetr(sv,what,val,info,idx) + + use psb_base_mod + use amg_z_base_solver_mod, amg_protect_name => amg_z_base_solver_csetr + Implicit None + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(in) :: what + real(psb_dpk_), intent(in) :: val + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: idx + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_csetr' + + + ! Correct action here is doing nothing. + info = 0 + + return +end subroutine amg_z_base_solver_csetr diff --git a/mlprec/impl/solver/amg_z_base_solver_descr.f90 b/mlprec/impl/solver/amg_z_base_solver_descr.f90 new file mode 100644 index 00000000..7506d33d --- /dev/null +++ b/mlprec/impl/solver/amg_z_base_solver_descr.f90 @@ -0,0 +1,66 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_solver_descr(sv,info,iout,coarse) + + use psb_base_mod + use amg_z_base_solver_mod, amg_protect_name => amg_z_base_solver_descr + Implicit None + ! Arguments + class(amg_z_base_solver_type), intent(in) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_), intent(in), optional :: iout + logical, intent(in), optional :: coarse + + ! Local variables + integer(psb_ipk_) :: err_act + character(len=20), parameter :: name='amg_z_base_solver_descr' + + + call psb_erractionsave(err_act) + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_solver_descr diff --git a/mlprec/impl/solver/amg_z_base_solver_dmp.f90 b/mlprec/impl/solver/amg_z_base_solver_dmp.f90 new file mode 100644 index 00000000..1e1ec3ca --- /dev/null +++ b/mlprec/impl/solver/amg_z_base_solver_dmp.f90 @@ -0,0 +1,78 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_z_base_solver_mod, amg_protect_name => amg_z_base_solver_dmp + implicit none + class(amg_z_base_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: solver_ + ! len of prefix_ + + info = 0 + + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_z" + end if + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + ! At base level do nothing for the solver + +end subroutine amg_z_base_solver_dmp diff --git a/mlprec/impl/solver/amg_z_base_solver_free.f90 b/mlprec/impl/solver/amg_z_base_solver_free.f90 new file mode 100644 index 00000000..eeabf4d8 --- /dev/null +++ b/mlprec/impl/solver/amg_z_base_solver_free.f90 @@ -0,0 +1,60 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_base_solver_free(sv,info) + + use psb_base_mod + use amg_z_base_solver_mod, amg_protect_name => amg_z_base_solver_free + Implicit None + ! Arguments + class(amg_z_base_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='d_base_solver_free' + + call psb_erractionsave(err_act) + + ! Do nothing + info = psb_success_ + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_base_solver_free diff --git a/mlprec/impl/solver/amg_z_bwgs_solver_apply.f90 b/mlprec/impl/solver/amg_z_bwgs_solver_apply.f90 new file mode 100644 index 00000000..819eb50e --- /dev/null +++ b/mlprec/impl/solver/amg_z_bwgs_solver_apply.f90 @@ -0,0 +1,216 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_bwgs_solver_apply(alpha,sv,x,beta,y,desc_data,& + &trans,work,info,init,initu) + + use psb_base_mod + use amg_z_gs_solver, amg_protect_name => amg_z_bwgs_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_bwgs_solver_type), intent(inout) :: sv + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col, itx, itxst + complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + complex(psb_dpk_), allocatable :: temp(:),wv(:),xit(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='z_bwgs_solver_apply' + + call psb_erractionsave(err_act) + ictxt = desc_data%get_ctxt() + call psb_info(ictxt,me,np) + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') +!!$ case('T') +!!$ case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + + call psb_geasb(wv,desc_data,info) + call psb_geasb(xit,desc_data,info) + itxst = 1 + select case (init_) + case('Z') + call psb_geaxpby(zone,x,zzero,wv,desc_data,info) + call psb_spsm(zone,sv%u,wv,zzero,xit,desc_data,info) + itxst = 2 + case('Y') + call psb_geaxpby(zone,y,zzero,xit,desc_data,info) + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(zone,initu,zzero,xit,desc_data,info) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + select case(trans_) + case('N') + if (sv%eps <=dzero) then + ! + ! Fixed number of iterations + ! + ! + do itx=itxst, sv%sweeps + call psb_geaxpby(zone,x,zzero,wv,desc_data,info) + ! Update with L. The off-diagonal block is taken care + ! from the Jacobi smoother, hence this is purely local. + call psb_spmm(-zone,sv%l,xit,zone,wv,desc_data,info,doswap=.false.) + call psb_spsm(zone,sv%u,wv,zzero,xit,desc_data,info) + end do + + call psb_geaxpby(alpha,xit,beta,y,desc_data,info) + + else + ! + ! Iterations to convergence, not implemented right now. + ! + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') + goto 9999 + + end if +!!$ case('T') +!!$ call psb_spsm(zone,sv%u,x,zzero,wv,desc_data,info,& +!!$ & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) +!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) +!!$ +!!$ case('C') +!!$ +!!$ call psb_spsm(zone,sv%u,x,zzero,wv,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) +!!$ +!!$ call wv1%mlt(zone,sv%dv,wv,zzero,info,conjgx=trans_) +!!$ +!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv1,beta,y,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid TRANS in GS subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_bwgs_solver_apply diff --git a/mlprec/impl/solver/amg_z_bwgs_solver_apply_vect.f90 b/mlprec/impl/solver/amg_z_bwgs_solver_apply_vect.f90 new file mode 100644 index 00000000..0bfa7d06 --- /dev/null +++ b/mlprec/impl/solver/amg_z_bwgs_solver_apply_vect.f90 @@ -0,0 +1,211 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_bwgs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_z_gs_solver, amg_protect_name => amg_z_bwgs_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_bwgs_solver_type), intent(inout) :: sv + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col, itx, itxst + complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + complex(psb_dpk_), allocatable :: temp(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='z_bwgs_solver_apply' + + call psb_erractionsave(err_act) + ictxt = desc_data%get_ctxt() + call psb_info(ictxt,me,np) + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') +!!$ case('T') +!!$ case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + + if (x%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/itwo,n_row,izero,izero,izero/)) + goto 9999 + end if + if (y%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/ithree,n_row,izero,izero,izero/)) + goto 9999 + end if + + + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + + if (size(wv) < 2) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size') + goto 9999 + end if + + associate(tw => wv(1), xit => wv(2)) + itxst = 1 + select case (init_) + case('Z') + call psb_geaxpby(zone,x,zzero,tw,desc_data,info) + call psb_spsm(zone,sv%u,tw,zzero,xit,desc_data,info) + itxst = 2 + case('Y') + call psb_geaxpby(zone,y,zzero,xit,desc_data,info) + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(zone,initu,zzero,xit,desc_data,info) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + select case(trans_) + case('N') + if (sv%eps <=dzero) then + ! + ! Fixed number of iterations + ! + ! + do itx=itxst,sv%sweeps + call psb_geaxpby(zone,x,zzero,tw,desc_data,info) + ! Update with L. The off-diagonal block is taken care + ! from the Jacobi smoother, hence this is purely local. + call psb_spmm(-zone,sv%l,xit,zone,tw,desc_data,info,doswap=.false.) + call psb_spsm(zone,sv%u,tw,zzero,xit,desc_data,info) + end do + + call psb_geaxpby(alpha,xit,beta,y,desc_data,info) + + else + ! + ! Iterations to convergence, not implemented right now. + ! + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') + goto 9999 + + end if + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid TRANS in GS subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + end associate + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_bwgs_solver_apply_vect diff --git a/mlprec/impl/solver/amg_z_bwgs_solver_bld.f90 b/mlprec/impl/solver/amg_z_bwgs_solver_bld.f90 new file mode 100644 index 00000000..9070aa45 --- /dev/null +++ b/mlprec/impl/solver/amg_z_bwgs_solver_bld.f90 @@ -0,0 +1,110 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_bwgs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_z_gs_solver, amg_protect_name => amg_z_bwgs_solver_bld + + Implicit None + + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(in) :: desc_a + class(amg_z_bwgs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='d_bwgs_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + + if (sv%eps <= dzero) then + ! + ! This cuts out the off-diagonal part, because it's supposed to + ! be handled by the outer Jacobi smoother. + ! + call a%tril(sv%l,info,diag=-ione,jmax=nrow_a,u=sv%u) + + else + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end if + + + + call sv%l%set_asb() + call sv%l%trim() + call sv%u%set_asb() + call sv%u%trim() + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_bwgs_solver_bld diff --git a/mlprec/impl/solver/amg_z_diag_solver_apply.f90 b/mlprec/impl/solver/amg_z_diag_solver_apply.f90 new file mode 100644 index 00000000..e988a185 --- /dev/null +++ b/mlprec/impl/solver/amg_z_diag_solver_apply.f90 @@ -0,0 +1,240 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_diag_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + + use psb_base_mod + use amg_z_diag_solver, amg_protect_name => amg_z_diag_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_diag_solver_type), intent(inout) :: sv + complex(psb_dpk_), intent(inout) :: x(:) + complex(psb_dpk_), intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col + complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='z_diag_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (trans_ == 'C') then + if (beta == zzero) then + + if (alpha == zzero) then + y(1:n_row) = zzero + else if (alpha == zone) then + do i=1, n_row + y(i) = conjg(sv%d(i)) * x(i) + end do + else if (alpha == -zone) then + do i=1, n_row + y(i) = -conjg(sv%d(i)) * x(i) + end do + else + do i=1, n_row + y(i) = alpha * conjg(sv%d(i)) * x(i) + end do + end if + + else if (beta == zone) then + + if (alpha == zzero) then + !y(1:n_row) = zzero + else if (alpha == zone) then + do i=1, n_row + y(i) = conjg(sv%d(i)) * x(i) + y(i) + end do + else if (alpha == -zone) then + do i=1, n_row + y(i) = -conjg(sv%d(i)) * x(i) + y(i) + end do + else + do i=1, n_row + y(i) = alpha * conjg(sv%d(i)) * x(i) + y(i) + end do + end if + + else if (beta == -zone) then + + if (alpha == zzero) then + y(1:n_row) = -y(1:n_row) + else if (alpha == zone) then + do i=1, n_row + y(i) = conjg(sv%d(i)) * x(i) - y(i) + end do + else if (alpha == -zone) then + do i=1, n_row + y(i) = -conjg(sv%d(i)) * x(i) - y(i) + end do + else + do i=1, n_row + y(i) = alpha * conjg(sv%d(i)) * x(i) - y(i) + end do + end if + + else + + if (alpha == zzero) then + y(1:n_row) = beta *y(1:n_row) + else if (alpha == zone) then + do i=1, n_row + y(i) = conjg(sv%d(i)) * x(i) + beta*y(i) + end do + else if (alpha == -zone) then + do i=1, n_row + y(i) = -conjg(sv%d(i)) * x(i) + beta*y(i) + end do + else + do i=1, n_row + y(i) = alpha * conjg(sv%d(i)) * x(i) + beta*y(i) + end do + end if + + end if + + else if (trans_ /= 'C') then + + if (beta == zzero) then + + if (alpha == zzero) then + y(1:n_row) = zzero + else if (alpha == zone) then + do i=1, n_row + y(i) = sv%d(i) * x(i) + end do + else if (alpha == -zone) then + do i=1, n_row + y(i) = -sv%d(i) * x(i) + end do + else + do i=1, n_row + y(i) = alpha * sv%d(i) * x(i) + end do + end if + + else if (beta == zone) then + + if (alpha == zzero) then + !y(1:n_row) = zzero + else if (alpha == zone) then + do i=1, n_row + y(i) = sv%d(i) * x(i) + y(i) + end do + else if (alpha == -zone) then + do i=1, n_row + y(i) = -sv%d(i) * x(i) + y(i) + end do + else + do i=1, n_row + y(i) = alpha * sv%d(i) * x(i) + y(i) + end do + end if + + else if (beta == -zone) then + + if (alpha == zzero) then + y(1:n_row) = -y(1:n_row) + else if (alpha == zone) then + do i=1, n_row + y(i) = sv%d(i) * x(i) - y(i) + end do + else if (alpha == -zone) then + do i=1, n_row + y(i) = -sv%d(i) * x(i) - y(i) + end do + else + do i=1, n_row + y(i) = alpha * sv%d(i) * x(i) - y(i) + end do + end if + + else + + if (alpha == zzero) then + y(1:n_row) = beta *y(1:n_row) + else if (alpha == zone) then + do i=1, n_row + y(i) = sv%d(i) * x(i) + beta*y(i) + end do + else if (alpha == -zone) then + do i=1, n_row + y(i) = -sv%d(i) * x(i) + beta*y(i) + end do + else + do i=1, n_row + y(i) = alpha * sv%d(i) * x(i) + beta*y(i) + end do + end if + + end if + + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_diag_solver_apply diff --git a/mlprec/impl/solver/amg_z_diag_solver_apply_vect.f90 b/mlprec/impl/solver/amg_z_diag_solver_apply_vect.f90 new file mode 100644 index 00000000..2ceac284 --- /dev/null +++ b/mlprec/impl/solver/amg_z_diag_solver_apply_vect.f90 @@ -0,0 +1,117 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_diag_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_z_diag_solver, amg_protect_name => amg_z_diag_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_diag_solver_type), intent(inout) :: sv + type(psb_z_vect_type), intent(inout) :: x + type(psb_z_vect_type), intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col + complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='z_diag_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + if (x%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/itwo,n_row,izero,izero,izero/)) + goto 9999 + end if + if (y%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/ithree,n_row,izero,izero,izero/)) + goto 9999 + end if + if (.not.allocated(sv%dv)) then + info = 1124 + call psb_errpush(info,name,a_err="preconditioner: D") + goto 9999 + end if + if (sv%dv%get_nrows() < n_row) then + info = 1124 + call psb_errpush(info,name,a_err="preconditioner: D") + goto 9999 + end if + + call y%mlt(alpha,sv%dv,x,beta,info,conjgx=trans_) + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='vect%mlt') + goto 9999 + end if + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_diag_solver_apply_vect diff --git a/mlprec/impl/solver/amg_z_diag_solver_bld.f90 b/mlprec/impl/solver/amg_z_diag_solver_bld.f90 new file mode 100644 index 00000000..cc8f80d6 --- /dev/null +++ b/mlprec/impl/solver/amg_z_diag_solver_bld.f90 @@ -0,0 +1,191 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_z_diag_solver, amg_protect_name => amg_z_diag_solver_bld + + Implicit None + + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + complex(psb_dpk_), allocatable :: tdb(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='z_diag_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + nrow_a = a%get_nrows() + + sv%d = a%get_diag(info) + if (info == psb_success_) call psb_realloc(n_row,sv%d,info) + if (present(b)) then + tdb=b%get_diag(info) + if (size(tdb)+nrow_a > n_row) call psb_realloc(nrow_a+size(tdb),sv%d,info) + if (info == psb_success_) sv%d(nrow_a+1:nrow_a+size(tdb)) = tdb(:) + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='get_diag') + goto 9999 + end if + + do i=1,n_row + if (sv%d(i) == zzero) then + sv%d(i) = zone + else + sv%d(i) = zone/sv%d(i) + end if + end do + allocate(sv%dv,stat=info) + if (info == psb_success_) then + call sv%dv%bld(sv%d) + if (present(vmold)) call sv%dv%cnv(vmold) + call sv%dv%sync() + else + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='Allocate sv%dv') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_diag_solver_bld + + +subroutine amg_z_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_z_l1_diag_solver, amg_protect_name => amg_z_l1_diag_solver_bld + + Implicit None + + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_l1_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + complex(psb_dpk_), allocatable :: tdb(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='z_l1_diag_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + nrow_a = a%get_nrows() + + sv%d = a%arwsum(info) + if (info == psb_success_) call psb_realloc(n_row,sv%d,info) + if (present(b)) then + tdb=b%arwsum(info) + if (size(tdb)+nrow_a > n_row) call psb_realloc(nrow_a+size(tdb),sv%d,info) + if (info == psb_success_) sv%d(nrow_a+1:nrow_a+size(tdb)) = tdb(:) + end if + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='arwsum') + goto 9999 + end if + + do i=1,n_row + if (sv%d(i) == zzero) then + sv%d(i) = zone + else + sv%d(i) = zone/sv%d(i) + end if + end do + allocate(sv%dv,stat=info) + if (info == psb_success_) then + call sv%dv%bld(sv%d) + if (present(vmold)) call sv%dv%cnv(vmold) + call sv%dv%sync() + else + call psb_errpush(psb_err_from_subroutine_,name,& + & a_err='Allocate sv%dv') + goto 9999 + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_l1_diag_solver_bld diff --git a/mlprec/impl/solver/amg_z_diag_solver_clear_data.f90 b/mlprec/impl/solver/amg_z_diag_solver_clear_data.f90 new file mode 100644 index 00000000..14dceae3 --- /dev/null +++ b/mlprec/impl/solver/amg_z_diag_solver_clear_data.f90 @@ -0,0 +1,65 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_diag_solver_clear_data(sv,info) + + use psb_base_mod + use amg_z_diag_solver, amg_protect_name => amg_z_diag_solver_clear_data + + Implicit None + + ! Arguments + class(amg_z_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + call sv%dv%free(info) + if ((info ==0).and.allocated(sv%d)) deallocate(sv%d,stat=info) + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_diag_solver_clear_data diff --git a/mlprec/impl/solver/amg_z_diag_solver_clone.f90 b/mlprec/impl/solver/amg_z_diag_solver_clone.f90 new file mode 100644 index 00000000..5f42e069 --- /dev/null +++ b/mlprec/impl/solver/amg_z_diag_solver_clone.f90 @@ -0,0 +1,83 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_diag_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_z_diag_solver, amg_protect_name => amg_z_diag_solver_clone + + Implicit None + + ! Arguments + class(amg_z_diag_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(svout)) then + call svout%free(info) + if (info == psb_success_) deallocate(svout, stat=info) + end if + if (info == psb_success_) & + & allocate(svout, mold=sv, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(svo => svout) + class is (amg_z_diag_solver_type) + call psb_safe_ab_cpy(sv%d,svo%d,info) + if (info == psb_success_) & + & call sv%dv%clone(svo%dv,info) + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_diag_solver_clone diff --git a/mlprec/impl/solver/amg_z_diag_solver_cnv.f90 b/mlprec/impl/solver/amg_z_diag_solver_cnv.f90 new file mode 100644 index 00000000..bd34d376 --- /dev/null +++ b/mlprec/impl/solver/amg_z_diag_solver_cnv.f90 @@ -0,0 +1,76 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_diag_solver_cnv(sv,info,amold,vmold,imold) + + use psb_base_mod + use amg_z_diag_solver, amg_protect_name => amg_z_diag_solver_cnv + + Implicit None + + ! Arguments + class(amg_z_diag_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: err_act, debug_unit, debug_level + character(len=20) :: name='d_diag_solver_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) trim(name),' start' + + + if (allocated(sv%dv)) then + call sv%dv%cnv(vmold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + return + + end subroutine amg_z_diag_solver_cnv diff --git a/mlprec/impl/solver/amg_z_diag_solver_dmp.f90 b/mlprec/impl/solver/amg_z_diag_solver_dmp.f90 new file mode 100644 index 00000000..17a14955 --- /dev/null +++ b/mlprec/impl/solver/amg_z_diag_solver_dmp.f90 @@ -0,0 +1,133 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_z_diag_solver, amg_protect_name => amg_z_diag_solver_dmp + implicit none + class(amg_z_diag_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: solver_ + ! len of prefix_ + + info = 0 + + ictxt = desc%get_context() + + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + + if (solver_) then + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_z" + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' + if (allocated(sv%d)) & + & call psb_geprt(fname,sv%d,head=head) + + end if + +end subroutine amg_z_diag_solver_dmp +subroutine amg_z_l1_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_z_l1_diag_solver, amg_protect_name => amg_z_l1_diag_solver_dmp + implicit none + class(amg_z_l1_diag_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: solver_ + ! len of prefix_ + + info = 0 + + ictxt = desc%get_context() + + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + + if (solver_) then + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_z" + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_l1_diag.mtx' + if (allocated(sv%d)) & + & call psb_geprt(fname,sv%d,head=head) + + end if + +end subroutine amg_z_l1_diag_solver_dmp diff --git a/mlprec/impl/solver/amg_z_gs_solver_apply.f90 b/mlprec/impl/solver/amg_z_gs_solver_apply.f90 new file mode 100644 index 00000000..0e9b0a11 --- /dev/null +++ b/mlprec/impl/solver/amg_z_gs_solver_apply.f90 @@ -0,0 +1,216 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_gs_solver_apply(alpha,sv,x,beta,y,desc_data,& + &trans,work,info,init,initu) + + use psb_base_mod + use amg_z_gs_solver, amg_protect_name => amg_z_gs_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_gs_solver_type), intent(inout) :: sv + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col, itx, itxst + complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + complex(psb_dpk_), allocatable :: temp(:),wv(:),xit(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='z_gs_solver_apply' + + call psb_erractionsave(err_act) + ictxt = desc_data%get_ctxt() + call psb_info(ictxt,me,np) + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') +!!$ case('T') +!!$ case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + + call psb_geasb(wv,desc_data,info) + call psb_geasb(xit,desc_data,info) + itxst = 1 + select case (init_) + case('Z') + call psb_geaxpby(zone,x,zzero,wv,desc_data,info) + call psb_spsm(zone,sv%l,wv,zzero,xit,desc_data,info) + itxst = 2 + case('Y') + call psb_geaxpby(zone,y,zzero,xit,desc_data,info) + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(zone,initu,zzero,xit,desc_data,info) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + select case(trans_) + case('N') + if (sv%eps <=dzero) then + ! + ! Fixed number of iterations + ! + ! + do itx=itxst,sv%sweeps + call psb_geaxpby(zone,x,zzero,wv,desc_data,info) + ! Update with U. The off-diagonal block is taken care + ! from the Jacobi smoother, hence this is purely local. + call psb_spmm(-zone,sv%u,xit,zone,wv,desc_data,info,doswap=.false.) + call psb_spsm(zone,sv%l,wv,zzero,xit,desc_data,info) + end do + + call psb_geaxpby(alpha,xit,beta,y,desc_data,info) + + else + ! + ! Iterations to convergence, not implemented right now. + ! + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') + goto 9999 + + end if +!!$ case('T') +!!$ call psb_spsm(zone,sv%u,x,zzero,wv,desc_data,info,& +!!$ & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) +!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) +!!$ +!!$ case('C') +!!$ +!!$ call psb_spsm(zone,sv%u,x,zzero,wv,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) +!!$ +!!$ call wv1%mlt(zone,sv%dv,wv,zzero,info,conjgx=trans_) +!!$ +!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv1,beta,y,desc_data,info,& +!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid TRANS in GS subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_gs_solver_apply diff --git a/mlprec/impl/solver/amg_z_gs_solver_apply_vect.f90 b/mlprec/impl/solver/amg_z_gs_solver_apply_vect.f90 new file mode 100644 index 00000000..5a288432 --- /dev/null +++ b/mlprec/impl/solver/amg_z_gs_solver_apply_vect.f90 @@ -0,0 +1,211 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_gs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_z_gs_solver, amg_protect_name => amg_z_gs_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_gs_solver_type), intent(inout) :: sv + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col, itx, itxst + complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + complex(psb_dpk_), allocatable :: temp(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_, init_ + character(len=20) :: name='z_gs_solver_apply' + + call psb_erractionsave(err_act) + ictxt = desc_data%get_ctxt() + call psb_info(ictxt,me,np) + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') +!!$ case('T') +!!$ case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + + if (present(init)) then + init_ = psb_toupper(init) + else + init_='Z' + end if + + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + + if (x%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/itwo,n_row,izero,izero,izero/)) + goto 9999 + end if + if (y%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/ithree,n_row,izero,izero,izero/)) + goto 9999 + end if + + + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + + if (size(wv) < 2) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size') + goto 9999 + end if + + associate(tw => wv(1), xit => wv(2)) + itxst = 1 + select case (init_) + case('Z') + call psb_geaxpby(zone,x,zzero,tw,desc_data,info) + call psb_spsm(zone,sv%l,tw,zzero,xit,desc_data,info) + itxst = 2 + case('Y') + call psb_geaxpby(zone,y,zzero,xit,desc_data,info) + case('U') + if (.not.present(initu)) then + call psb_errpush(psb_err_internal_error_,name,& + & a_err='missing initu to smoother_apply') + goto 9999 + end if + call psb_geaxpby(zone,initu,zzero,xit,desc_data,info) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='wrong init to smoother_apply') + goto 9999 + end select + + select case(trans_) + case('N') + if (sv%eps <=dzero) then + ! + ! Fixed number of iterations + ! + ! + do itx=itxst,sv%sweeps + call psb_geaxpby(zone,x,zzero,tw,desc_data,info) + ! Update with U. The off-diagonal block is taken care + ! from the Jacobi smoother, hence this is purely local. + call psb_spmm(-zone,sv%u,xit,zone,tw,desc_data,info,doswap=.false.) + call psb_spsm(zone,sv%l,tw,zzero,xit,desc_data,info) + end do + + call psb_geaxpby(alpha,xit,beta,y,desc_data,info) + + else + ! + ! Iterations to convergence, not implemented right now. + ! + info = psb_err_internal_error_ + call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') + goto 9999 + + end if + + case default + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid TRANS in GS subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + end associate + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_gs_solver_apply_vect diff --git a/mlprec/impl/solver/amg_z_gs_solver_bld.f90 b/mlprec/impl/solver/amg_z_gs_solver_bld.f90 new file mode 100644 index 00000000..bd4769dd --- /dev/null +++ b/mlprec/impl/solver/amg_z_gs_solver_bld.f90 @@ -0,0 +1,109 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_gs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_z_gs_solver, amg_protect_name => amg_z_gs_solver_bld + + Implicit None + + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='z_gs_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + + if (sv%eps <= dzero) then + ! + ! This cuts out the off-diagonal part, because it's supposed to + ! be handled by the outer Jacobi smoother. + ! + call a%tril(sv%l,info,diag=izero,jmax=nrow_a,u=sv%u) + + else + + info = psb_err_missing_override_method_ + call psb_errpush(info,name) + goto 9999 + end if + + + + call sv%l%set_asb() + call sv%l%trim() + call sv%u%set_asb() + call sv%u%trim() + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_gs_solver_bld diff --git a/mlprec/impl/solver/amg_z_gs_solver_clear_data.f90 b/mlprec/impl/solver/amg_z_gs_solver_clear_data.f90 new file mode 100644 index 00000000..59f8c329 --- /dev/null +++ b/mlprec/impl/solver/amg_z_gs_solver_clear_data.f90 @@ -0,0 +1,65 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_gs_solver_clear_data(sv,info) + + use psb_base_mod + use amg_z_gs_solver, amg_protect_name => amg_z_gs_solver_clear_data + + Implicit None + + ! Arguments + class(amg_z_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + call sv%l%free() + call sv%u%free() + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_gs_solver_clear_data diff --git a/mlprec/impl/solver/amg_z_gs_solver_clone.f90 b/mlprec/impl/solver/amg_z_gs_solver_clone.f90 new file mode 100644 index 00000000..249e1f02 --- /dev/null +++ b/mlprec/impl/solver/amg_z_gs_solver_clone.f90 @@ -0,0 +1,87 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_gs_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_z_gs_solver, amg_protect_name => amg_z_gs_solver_clone + + Implicit None + + ! Arguments + class(amg_z_gs_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + if (allocated(svout)) then + call svout%free(info) + if (info == psb_success_) deallocate(svout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_z_gs_solver_type :: svout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(svo => svout) + type is (amg_z_gs_solver_type) + svo%sweeps = sv%sweeps + svo%eps = sv%eps + if (info == psb_success_) & + & call sv%l%clone(svo%l,info) + if (info == psb_success_) & + & call sv%u%clone(svo%u,info) + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_gs_solver_clone diff --git a/mlprec/impl/solver/amg_z_gs_solver_clone_settings.f90 b/mlprec/impl/solver/amg_z_gs_solver_clone_settings.f90 new file mode 100644 index 00000000..5d7193d7 --- /dev/null +++ b/mlprec/impl/solver/amg_z_gs_solver_clone_settings.f90 @@ -0,0 +1,69 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_gs_solver_clone_settings(sv,svout,info) + + use psb_base_mod + use amg_z_gs_solver, amg_protect_name => amg_z_gs_solver_clone_settings + Implicit None + ! Arguments + class(amg_z_gs_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_gs_solver_clone_settings' + + call psb_erractionsave(err_act) + + select type(svout) + class is(amg_z_gs_solver_type) + svout%sweeps = sv%sweeps + svout%eps = sv%eps + + class default + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_gs_solver_clone_settings diff --git a/mlprec/impl/solver/amg_z_gs_solver_cnv.f90 b/mlprec/impl/solver/amg_z_gs_solver_cnv.f90 new file mode 100644 index 00000000..1e46e1a4 --- /dev/null +++ b/mlprec/impl/solver/amg_z_gs_solver_cnv.f90 @@ -0,0 +1,74 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_gs_solver_cnv(sv,info,amold,vmold,imold) + + use psb_base_mod + use amg_z_gs_solver, amg_protect_name => amg_z_gs_solver_cnv + + Implicit None + + ! Arguments + class(amg_z_gs_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: err_act, debug_unit, debug_level + character(len=20) :: name='z_gs_solver_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_gs_solver_cnv diff --git a/mlprec/impl/solver/amg_z_gs_solver_dmp.f90 b/mlprec/impl/solver/amg_z_gs_solver_dmp.f90 new file mode 100644 index 00000000..478035e7 --- /dev/null +++ b/mlprec/impl/solver/amg_z_gs_solver_dmp.f90 @@ -0,0 +1,102 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_gs_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_z_gs_solver, amg_protect_name => amg_z_gs_solver_dmp + implicit none + class(amg_z_gs_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + integer(psb_lpk_), allocatable :: iv(:) + logical :: solver_, global_num_ + ! len of prefix_ + + info = 0 + + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + + if (solver_) then + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_d" + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + if (global_num_) then + iv = desc%get_global_indices(owned=.false.) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' + if (sv%l%is_asb()) & + & call sv%l%print(fname,head=head,iv=iv) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' + if (sv%u%is_asb()) & + & call sv%u%print(fname,head=head,iv=iv) + else + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' + if (sv%l%is_asb()) & + & call sv%l%print(fname,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' + if (sv%u%is_asb()) & + & call sv%u%print(fname,head=head) + end if + end if + +end subroutine amg_z_gs_solver_dmp diff --git a/mlprec/impl/solver/amg_z_id_solver_apply.f90 b/mlprec/impl/solver/amg_z_id_solver_apply.f90 new file mode 100644 index 00000000..aefda51f --- /dev/null +++ b/mlprec/impl/solver/amg_z_id_solver_apply.f90 @@ -0,0 +1,86 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_id_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + + use psb_base_mod + use amg_z_id_solver, amg_protect_name => amg_z_id_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_id_solver_type), intent(inout) :: sv + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='z_id_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call psb_geaxpby(alpha,x,beta,y,desc_data,info) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_id_solver_apply diff --git a/mlprec/impl/solver/amg_z_id_solver_apply_vect.f90 b/mlprec/impl/solver/amg_z_id_solver_apply_vect.f90 new file mode 100644 index 00000000..2e05340e --- /dev/null +++ b/mlprec/impl/solver/amg_z_id_solver_apply_vect.f90 @@ -0,0 +1,87 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_id_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_z_id_solver, amg_protect_name => amg_z_id_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_id_solver_type), intent(inout) :: sv + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='z_id_solver_apply_vect' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call psb_geaxpby(alpha,x,beta,y,desc_data,info) + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_id_solver_apply_vect diff --git a/mlprec/impl/solver/amg_z_id_solver_clone.f90 b/mlprec/impl/solver/amg_z_id_solver_clone.f90 new file mode 100644 index 00000000..fbdd605e --- /dev/null +++ b/mlprec/impl/solver/amg_z_id_solver_clone.f90 @@ -0,0 +1,81 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_id_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_z_id_solver, amg_protect_name => amg_z_id_solver_clone + + Implicit None + + ! Arguments + class(amg_z_id_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + if (allocated(svout)) then + call svout%free(info) + if (info == psb_success_) deallocate(svout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_z_id_solver_type :: svout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(svo => svout) + type is (amg_z_id_solver_type) + ! Nothing to be done. + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_id_solver_clone diff --git a/mlprec/impl/solver/amg_z_ilu_solver_apply.f90 b/mlprec/impl/solver/amg_z_ilu_solver_apply.f90 new file mode 100644 index 00000000..7d44085d --- /dev/null +++ b/mlprec/impl/solver/amg_z_ilu_solver_apply.f90 @@ -0,0 +1,153 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + + use psb_base_mod + use amg_z_ilu_solver, amg_protect_name => amg_z_ilu_solver_apply + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_ilu_solver_type), intent(inout) :: sv + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row,n_col + complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='z_ilu_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T','C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/4*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + endif + + select case(trans_) + case('N') + call psb_spsm(zone,sv%l,x,zzero,ww,desc_data,info,& + & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) + + if (info == psb_success_) call psb_spsm(alpha,sv%u,ww,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_, work=aux) + + case('T') + call psb_spsm(zone,sv%u,x,zzero,ww,desc_data,info,& + & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) + if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + case('C') + call psb_spsm(zone,sv%u,x,zzero,ww,desc_data,info,& + & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) + if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid TRANS in ILU subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_ilu_solver_apply diff --git a/mlprec/impl/solver/amg_z_ilu_solver_apply_vect.f90 b/mlprec/impl/solver/amg_z_ilu_solver_apply_vect.f90 new file mode 100644 index 00000000..cf162114 --- /dev/null +++ b/mlprec/impl/solver/amg_z_ilu_solver_apply_vect.f90 @@ -0,0 +1,194 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + + use psb_base_mod + use amg_z_ilu_solver, amg_protect_name => amg_z_ilu_solver_apply_vect + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_ilu_solver_type), intent(inout) :: sv + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: n_row,n_col + type(psb_z_vect_type) :: tw, tw1 + complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='z_ilu_solver_apply' + + call psb_erractionsave(err_act) + + info = psb_success_ + + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case('C') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + + if (x%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/itwo,n_row,izero,izero,izero/)) + goto 9999 + end if + if (y%get_nrows() < n_row) then + info = 36 + call psb_errpush(info,name,& + & i_err=(/ithree,n_row,izero,izero,izero/)) + goto 9999 + end if + if (.not.allocated(sv%dv%v)) then + info = 1124 + call psb_errpush(info,name,a_err="preconditioner: D") + goto 9999 + end if + if (sv%dv%get_nrows() < n_row) then + info = 1124 + call psb_errpush(info,name,a_err="preconditioner: DV") + goto 9999 + end if + + + + if (n_col <= size(work)) then + ww => work(1:n_col) + if ((4*n_col+n_col) <= size(work)) then + aux => work(n_col+1:) + else + allocate(aux(4*n_col),stat=info) + endif + else + allocate(ww(n_col),aux(4*n_col),stat=info) + endif + + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,& + & i_err=(/5*n_col,izero,izero,izero,izero/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + + + if (size(wv) < 2) then + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='invalid wv size') + goto 9999 + end if + + + associate(tw => wv(1), tw1 => wv(2)) + + select case(trans_) + case('N') + call psb_spsm(zone,sv%l,x,zzero,tw,desc_data,info,& + & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) + + if (info == psb_success_) call psb_spsm(alpha,sv%u,tw,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_, work=aux) + + case('T') + call psb_spsm(zone,sv%u,x,zzero,tw,desc_data,info,& + & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) + if (info == psb_success_) call psb_spsm(alpha,sv%l,tw,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + + case('C') + + call psb_spsm(zone,sv%u,x,zzero,tw,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + + call tw1%mlt(zone,sv%dv,tw,zzero,info,conjgx=trans_) + + if (info == psb_success_) call psb_spsm(alpha,sv%l,tw1,beta,y,desc_data,info,& + & trans=trans_,scale='U',choice=psb_none_,work=aux) + + case default + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Invalid TRANS in ILU subsolve') + goto 9999 + end select + + + if (info /= psb_success_) then + + call psb_errpush(psb_err_internal_error_,name,& + & a_err='Error in subsolve') + goto 9999 + endif + end associate + + if (n_col <= size(work)) then + if ((4*n_col+n_col) <= size(work)) then + else + deallocate(aux) + endif + else + deallocate(ww,aux) + endif + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return + +end subroutine amg_z_ilu_solver_apply_vect diff --git a/mlprec/impl/solver/amg_z_ilu_solver_bld.f90 b/mlprec/impl/solver/amg_z_ilu_solver_bld.f90 new file mode 100644 index 00000000..d84ba26b --- /dev/null +++ b/mlprec/impl/solver/amg_z_ilu_solver_bld.f90 @@ -0,0 +1,191 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_ilu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_z_ilu_solver, amg_protect_name => amg_z_ilu_solver_bld + + Implicit None + + ! Arguments + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota +!!$ complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level + character(len=20) :: name='z_ilu_solver_bld', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + + + n_row = desc_a%get_local_rows() + + nrow_a = a%get_nrows() + nztota = a%get_nzeros() + if (present(b)) then + nztota = nztota + b%get_nzeros() + end if + + call sv%l%csall(n_row,n_row,info,nztota) + if (info == psb_success_) call sv%u%csall(n_row,n_row,info,nztota) + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_sp_all' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + if (allocated(sv%d)) then + if (size(sv%d) < n_row) then + deallocate(sv%d) + endif + endif + if (.not.allocated(sv%d)) allocate(sv%d(n_row),stat=info) + + if (info /= psb_success_) then + call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') + goto 9999 + endif + + + select case(sv%fact_type) + + case (psb_ilu_t_) + ! + ! ILU(k,t) + ! + select case(sv%fill_in) + + case(:-1) + ! Error: fill-in <= -1 + call psb_errpush(psb_err_input_value_invalid_i_,& + & name,i_err=(/ithree,sv%fill_in,izero,izero,izero/)) + goto 9999 + + case(0:) + ! Fill-in >= 0 + call psb_ilut_fact(sv%fill_in,sv%thresh,& + & a, sv%l,sv%u,sv%d,info,blck=b) + end select + if(info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_ilut_fact' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + case(psb_ilu_n_,psb_milu_n_) + ! + ! ILU(k) and MILU(k) + ! + select case(sv%fill_in) + case(:-1) + ! Error: fill-in <= -1 + call psb_errpush(psb_err_input_value_invalid_i_,& + & name,i_err=(/ithree,sv%fill_in,izero,izero,izero/)) + goto 9999 + case(0) + ! Fill-in 0 + ! Separate implementation of ILU(0) for better performance. + ! There seems to be a problem with the separate implementation of MILU(0), + ! contained into psb_ilu0_fact. This must be investigated. For the time being, + ! resort to the implementation of MILU(k) with k=0. + if (sv%fact_type == psb_ilu_n_) then + call psb_ilu0_fact(sv%fact_type,a,sv%l,sv%u,& + & sv%d,info,blck=b) + else + call psb_iluk_fact(sv%fill_in,sv%fact_type,& + & a,sv%l,sv%u,sv%d,info,blck=b) + endif + case(1:) + ! Fill-in >= 1 + ! The same routine implements both ILU(k) and MILU(k) + call psb_iluk_fact(sv%fill_in,sv%fact_type,& + & a,sv%l,sv%u,sv%d,info,blck=b) + end select + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='psb_iluk_fact' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + case default + ! If we end up here, something was wrong up in the call chain. + info = psb_err_input_value_invalid_i_ + call psb_errpush(psb_err_input_value_invalid_i_,name,& + & i_err=(/ithree,sv%fact_type,izero,izero,izero/)) + goto 9999 + + end select + + call sv%l%set_asb() + call sv%l%trim() + call sv%u%set_asb() + call sv%u%trim() + call sv%dv%bld(sv%d,mold=vmold) + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_ilu_solver_bld diff --git a/mlprec/impl/solver/amg_z_ilu_solver_clear_data.f90 b/mlprec/impl/solver/amg_z_ilu_solver_clear_data.f90 new file mode 100644 index 00000000..45bdcc63 --- /dev/null +++ b/mlprec/impl/solver/amg_z_ilu_solver_clear_data.f90 @@ -0,0 +1,67 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_ilu_solver_clear_data(sv,info) + + use psb_base_mod + use amg_z_ilu_solver, amg_protect_name => amg_z_ilu_solver_clear_data + + Implicit None + + ! Arguments + class(amg_z_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + info=psb_success_ + call psb_erractionsave(err_act) + + call sv%l%free() + call sv%u%free() + call sv%dv%free(info) + if ((info==0).and.allocated(sv%d)) deallocate(sv%d,stat=info) + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_ilu_solver_clear_data diff --git a/mlprec/impl/solver/amg_z_ilu_solver_clone.f90 b/mlprec/impl/solver/amg_z_ilu_solver_clone.f90 new file mode 100644 index 00000000..a9e05eba --- /dev/null +++ b/mlprec/impl/solver/amg_z_ilu_solver_clone.f90 @@ -0,0 +1,91 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_ilu_solver_clone(sv,svout,info) + + use psb_base_mod + use amg_z_ilu_solver, amg_protect_name => amg_z_ilu_solver_clone + + Implicit None + + ! Arguments + class(amg_z_ilu_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), allocatable, intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + ! Local variables + integer(psb_ipk_) :: err_act + + + info=psb_success_ + call psb_erractionsave(err_act) + if (allocated(svout)) then + call svout%free(info) + if (info == psb_success_) deallocate(svout, stat=info) + end if + if (info == psb_success_) & + & allocate(amg_z_ilu_solver_type :: svout, stat=info) + if (info /= 0) then + info = psb_err_alloc_dealloc_ + goto 9999 + end if + + select type(svo => svout) + type is (amg_z_ilu_solver_type) + svo%fact_type = sv%fact_type + svo%fill_in = sv%fill_in + svo%thresh = sv%thresh + call psb_safe_ab_cpy(sv%d,svo%d,info) + if (info == psb_success_) & + & call sv%dv%clone(svo%dv,info) + if (info == psb_success_) & + & call sv%l%clone(svo%l,info) + if (info == psb_success_) & + & call sv%u%clone(svo%u,info) + + class default + info = psb_err_internal_error_ + end select + + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_ilu_solver_clone diff --git a/mlprec/impl/solver/amg_z_ilu_solver_clone_settings.f90 b/mlprec/impl/solver/amg_z_ilu_solver_clone_settings.f90 new file mode 100644 index 00000000..90096b99 --- /dev/null +++ b/mlprec/impl/solver/amg_z_ilu_solver_clone_settings.f90 @@ -0,0 +1,70 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_ilu_solver_clone_settings(sv,svout,info) + + use psb_base_mod + use amg_z_ilu_solver, amg_protect_name => amg_z_ilu_solver_clone_settings + Implicit None + ! Arguments + class(amg_z_ilu_solver_type), intent(inout) :: sv + class(amg_z_base_solver_type), intent(inout) :: svout + integer(psb_ipk_), intent(out) :: info + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_ilu_solver_clone_settings' + + call psb_erractionsave(err_act) + + select type(svout) + class is(amg_z_ilu_solver_type) + svout%fact_type = sv%fact_type + svout%fill_in = sv%fill_in + svout%thresh = sv%thresh + + class default + info = psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end select + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_ilu_solver_clone_settings diff --git a/mlprec/impl/solver/amg_z_ilu_solver_cnv.f90 b/mlprec/impl/solver/amg_z_ilu_solver_cnv.f90 new file mode 100644 index 00000000..09b4cb42 --- /dev/null +++ b/mlprec/impl/solver/amg_z_ilu_solver_cnv.f90 @@ -0,0 +1,76 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_ilu_solver_cnv(sv,info,amold,vmold,imold) + + use psb_base_mod + use amg_z_ilu_solver, amg_protect_name => amg_z_ilu_solver_cnv + + Implicit None + + ! Arguments + class(amg_z_ilu_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + integer(psb_ipk_) :: err_act, debug_unit, debug_level + character(len=20) :: name='d_ilu_solver_cnv', ch_err + + info=psb_success_ + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + call sv%dv%cnv(mold=vmold) + + if (present(amold)) then + call sv%l%cscnv(info,mold=amold) + call sv%u%cscnv(info,mold=amold) + end if + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 call psb_error_handler(err_act) + + return +end subroutine amg_z_ilu_solver_cnv diff --git a/mlprec/impl/solver/amg_z_ilu_solver_dmp.f90 b/mlprec/impl/solver/amg_z_ilu_solver_dmp.f90 new file mode 100644 index 00000000..7ed781bd --- /dev/null +++ b/mlprec/impl/solver/amg_z_ilu_solver_dmp.f90 @@ -0,0 +1,112 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.5) +! +! (C) Copyright 2008-2018 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +subroutine amg_z_ilu_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) + + use psb_base_mod + use amg_z_ilu_solver, amg_protect_name => amg_z_ilu_solver_dmp + implicit none + class(amg_z_ilu_solver_type), intent(in) :: sv + type(psb_desc_type), intent(in) :: desc + integer(psb_ipk_), intent(in) :: level + integer(psb_ipk_), intent(out) :: info + character(len=*), intent(in), optional :: prefix, head + logical, optional, intent(in) :: solver, global_num + integer(psb_ipk_) :: i, j, il1, iln, lname, lev + integer(psb_ipk_) :: ictxt,iam, np + character(len=80) :: prefix_ + character(len=120) :: fname ! len should be at least 20 more than + logical :: solver_, global_num_ + integer(psb_lpk_), allocatable :: iv(:) + ! len of prefix_ + + info = 0 + + ictxt = desc%get_context() + call psb_info(ictxt,iam,np) + + if (present(solver)) then + solver_ = solver + else + solver_ = .false. + end if + if (present(global_num)) then + global_num_ = global_num + else + global_num_ = .false. + end if + + + if (solver_) then + if (present(prefix)) then + prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) + else + prefix_ = "dump_slv_z" + end if + lname = len_trim(prefix_) + fname = trim(prefix_) + write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam + lname = lname + 5 + + if (global_num_) then + iv = desc%get_global_indices(owned=.false.) + + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' + if (sv%l%is_asb()) & + & call sv%l%print(fname,head=head,iv=iv) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' + if (allocated(sv%d)) & + & call psb_geprt(fname,sv%d,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' + if (sv%u%is_asb()) & + & call sv%u%print(fname,head=head,iv=iv) + + else + + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' + if (sv%l%is_asb()) & + & call sv%l%print(fname,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' + if (allocated(sv%d)) & + & call psb_geprt(fname,sv%d,head=head) + write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' + if (sv%u%is_asb()) & + & call sv%u%print(fname,head=head) + end if + end if + +end subroutine amg_z_ilu_solver_dmp diff --git a/mlprec/impl/solver/amg_z_mumps_solver_apply.F90 b/mlprec/impl/solver/amg_z_mumps_solver_apply.F90 new file mode 100644 index 00000000..749c6fbf --- /dev/null +++ b/mlprec/impl/solver/amg_z_mumps_solver_apply.F90 @@ -0,0 +1,169 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.0) +! +! (C) Copyright 2008,2009,2010,2012,2013 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +subroutine z_mumps_solver_apply(alpha,sv,x,beta,y,desc_data,& + & trans,work,info,init,initu) + use psb_base_mod + use amg_z_mumps_solver + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_mumps_solver_type), intent(inout) :: sv + complex(psb_dpk_),intent(inout) :: x(:) + complex(psb_dpk_),intent(inout) :: y(:) + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + complex(psb_dpk_),intent(inout), optional :: initu(:) + + integer(psb_ipk_) :: n_row, n_col + integer(psb_lpk_) :: nglob + integer(psb_epk_) :: eng + complex(psb_dpk_), allocatable :: ww(:) + complex(psb_dpk_), allocatable, target :: gx(:) + integer(psb_ipk_) :: ictxt,np,me,i, err_act + character :: trans_ + character(len=20) :: name='z_mumps_solver_apply' + + call psb_erractionsave(err_act) + +#if defined(HAVE_MUMPS_) + info = psb_success_ + trans_ = psb_toupper(trans) + select case(trans_) + case('N') + case('T') + case default + call psb_errpush(psb_err_iarg_invalid_i_,name) + goto 9999 + end select + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + nglob = desc_data%get_global_rows() + n_row = desc_data%get_local_rows() + n_col = desc_data%get_local_cols() + + ! Running in local mode? + if (sv%ipar(1) == amg_local_solver_ ) then + gx = x + else if (sv%ipar(1) == amg_global_solver_ ) then + + if (n_col <= size(work)) then + ww = work(1:n_col) + else + allocate(ww(n_col),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_ + call psb_errpush(info,name,i_err=(/n_col/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + end if + allocate(gx(nglob),stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_request_; eng = nglob + call psb_errpush(info,name,e_err=(/eng/),& + & a_err='complex(psb_dpk_)') + goto 9999 + end if + call psb_gather(gx, x, desc_data, info, root=izero) + else + info=psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid local/global solver in MUMPS') + goto 9999 + end if + + select case(trans_) + case('N') + sv%id%icntl(9) = 1 + case('T') + sv%id%icntl(9) = 2 + case default + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Invalid TRANS in subsolve') + goto 9999 + end select + + sv%id%rhs => gx + sv%id%nrhs = 1 + sv%id%icntl(1)=-1 + sv%id%icntl(2)=-1 + sv%id%icntl(3)=-1 + sv%id%icntl(4)=-1 + sv%id%job = 3 + call zmumps(sv%id) + if (sv%ipar(1) == amg_local_solver_ ) then + call psb_geaxpby(alpha,gx,beta,y,desc_data,info) + else + call psb_scatter(gx, ww, desc_data, info, root=izero) + if (info == psb_success_) then + call psb_geaxpby(alpha,ww,beta,y,desc_data,info) + end if + end if + + if (info /= psb_success_) then + call psb_errpush(psb_err_internal_error_,& + & name,a_err='Error in subsolve') + goto 9999 + endif + + if (allocated(ww)) deallocate(ww) + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return + +#else + write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " +#endif +end subroutine z_mumps_solver_apply + diff --git a/mlprec/impl/solver/amg_z_mumps_solver_apply_vect.F90 b/mlprec/impl/solver/amg_z_mumps_solver_apply_vect.F90 new file mode 100644 index 00000000..a3538807 --- /dev/null +++ b/mlprec/impl/solver/amg_z_mumps_solver_apply_vect.F90 @@ -0,0 +1,93 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.0) +! +! (C) Copyright 2008,2009,2010,2012,2013 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +subroutine z_mumps_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& + & trans,work,wv,info,init,initu) + use psb_base_mod + use amg_z_mumps_solver + implicit none + type(psb_desc_type), intent(in) :: desc_data + class(amg_z_mumps_solver_type), intent(inout) :: sv + type(psb_z_vect_type),intent(inout) :: x + type(psb_z_vect_type),intent(inout) :: y + complex(psb_dpk_),intent(in) :: alpha,beta + character(len=1),intent(in) :: trans + complex(psb_dpk_),target, intent(inout) :: work(:) + type(psb_z_vect_type),intent(inout) :: wv(:) + integer(psb_ipk_), intent(out) :: info + character, intent(in), optional :: init + type(psb_z_vect_type),intent(inout), optional :: initu + + integer(psb_ipk_) :: err_act + character(len=20) :: name='z_mumps_solver_apply_vect' + +#if defined(HAVE_MUMPS_) + + call psb_erractionsave(err_act) + + info = psb_success_ + ! + ! For non-iterative solvers, init and initu are ignored. + ! + + call x%v%sync() + call y%v%sync() + call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) + call y%v%set_host() + if (info /= 0) goto 9999 + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return + +#else + write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " +#endif + +end subroutine z_mumps_solver_apply_vect + diff --git a/mlprec/impl/solver/amg_z_mumps_solver_bld.F90 b/mlprec/impl/solver/amg_z_mumps_solver_bld.F90 new file mode 100644 index 00000000..d2dd8202 --- /dev/null +++ b/mlprec/impl/solver/amg_z_mumps_solver_bld.F90 @@ -0,0 +1,262 @@ +! +! +! MLD2P4 version 2.2 +! MultiLevel Domain Decomposition Parallel Preconditioners Package +! based on PSBLAS (Parallel Sparse BLAS version 3.0) +! +! (C) Copyright 2008,2009,2010,2012,2013 +! +! Salvatore Filippone +! Pasqua D'Ambra +! Daniela di Serafino +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions +! are met: +! 1. Redistributions of source code must retain the above copyright +! notice, this list of conditions and the following disclaimer. +! 2. Redistributions in binary form must reproduce the above copyright +! notice, this list of conditions, and the following disclaimer in the +! documentation and/or other materials provided with the distribution. +! 3. The name of the MLD2P4 group or the names of its contributors may +! not be used to endorse or promote products derived from this +! software without specific written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS +! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +! POSSIBILITY OF SUCH DAMAGE. +! +! +! Current version of this file contributed by: +! Ambra Abdullahi Hassan +! +! +subroutine z_mumps_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) + + use psb_base_mod + use amg_z_mumps_solver + Implicit None + + ! Arguments + type(psb_zspmat_type) :: c + type(psb_zspmat_type), intent(in), target :: a + Type(psb_desc_type), Intent(inout) :: desc_a + class(amg_z_mumps_solver_type), intent(inout) :: sv + integer(psb_ipk_), intent(out) :: info + type(psb_zspmat_type), intent(in), target, optional :: b + class(psb_z_base_sparse_mat), intent(in), optional :: amold + class(psb_z_base_vect_type), intent(in), optional :: vmold + class(psb_i_base_vect_type), intent(in), optional :: imold + ! Local variables + type(psb_zspmat_type) :: atmp + type(psb_z_coo_sparse_mat), target :: acoo +#if defined(IPK4) && defined(LPK8) + integer(psb_lpk_), allocatable :: gia(:), gja(:) +#endif + integer(psb_ipk_) :: n_row,n_col, nrow_a, nza, npr, npc + integer(psb_lpk_) :: nglob, nglobrec, nzt + integer(psb_ipk_) :: ifrst, ibcheck + integer(psb_ipk_) :: ictxt, ictxt1, icomm, np, iam, me, i, err_act, debug_unit, debug_level + character(len=20) :: name='z_mumps_solver_bld', ch_err + +#if defined(HAVE_MUMPS_) + + info=psb_success_ + + call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + ictxt = desc_a%get_context() + call psb_info(ictxt, iam, np) + if (sv%ipar(1) == amg_local_solver_ ) then + call psb_init(ictxt1,np=1,basectxt=ictxt,ids=(/iam/)) + icomm = psb_get_mpi_comm(ictxt1) + allocate(sv%local_ictxt,stat=info) + sv%local_ictxt = ictxt1 + !write(*,*)iam,'mumps_bld: local +++++>',icomm,sv%local_ictxt + call psb_info(ictxt1, me, np) + npr = np + else if (sv%ipar(1) == amg_global_solver_ ) then + icomm = psb_get_mpi_comm(ictxt) + !write(*,*)iam,'mumps_bld: global +++++>',icomm,ictxt + call psb_info(ictxt, iam, np) + me = iam + npr = np + else + info = psb_err_internal_error_ + call psb_errpush(info,name,& + & a_err='Invalid local/global solver in MUMPS') + goto 9999 + end if + npc = 1 + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),' start' + ! if (allocated(sv%id)) then + ! call sv%free(info) + + ! deallocate(sv%id) + ! end if + if(.not.allocated(sv%id)) then + allocate(sv%id,stat=info) + if (info /= psb_success_) then + info=psb_err_alloc_dealloc_ + call psb_errpush(info,name,a_err='amg_zmumps_default') + goto 9999 + end if + end if + + + sv%id%comm = icomm + sv%id%job = -1 + sv%id%par = 1 + if (sv%ipar(3) == 2) then + sv%id%sym = 2 + else + sv%id%sym = 0 + end if + + call zmumps(sv%id) + !WARNING: CALLING zmumps WITH JOB=-1 DESTROY THE SETTING OF DEFAULT:TO FIX + if (allocated(sv%icntl)) then + do i=1,amg_mumps_icntl_size + if (allocated(sv%icntl(i)%item)) then + !write(0,*) 'MUMPS_BLD: setting entry ',i,' to ', sv%icntl(i)%item + sv%id%icntl(i) = sv%icntl(i)%item + end if + end do + end if + if (allocated(sv%rcntl)) then + do i=1,amg_mumps_rcntl_size + if (allocated(sv%rcntl(i)%item)) sv%id%cntl(i) = sv%rcntl(i)%item + end do + end if + sv%id%icntl(3)=sv%ipar(2) + + nglob = desc_a%get_global_rows() + if (sv%ipar(1) == amg_local_solver_ ) then + nglobrec=desc_a%get_local_rows() + if (sv%ipar(3) == 2) then + ! Always pass the upper triangle to MUMPS + call a%triu(c,info,jmax=a%get_nrows()) + call c%set_symmetric() + else + call a%csclip(c,info,jmax=a%get_nrows()) + end if + call c%cp_to(acoo) + nglob = c%get_nrows() + if (nglobrec /= nglob) then + write(*,*)'WARNING: MUMPS solver does not allow overlap in AS yet. ' + write(*,*)'A zero-overlap is used instead' + end if + else + call a%cp_to(acoo) + end if + nza = acoo%get_nzeros() + + ! switch to global numbering + if (sv%ipar(1) == amg_global_solver_ ) then +#if defined(IPK4) && defined(LPK8) + ! + ! Strategy here is as follows: because a call to MUMPS + ! as a gobal solver is mostly done at the coarsest level, + ! even if we start from a problem requiring 8 bytes, chances + ! are that the global size will be suitable for 4 bytes + ! anyway, so we hope for the best, and throw an error + ! if something goes wrong. + ! + if (nglob > huge(1_psb_ipk_)) then + write(0,*) iam,' ',trim(name),': Error: overflow of local indices ' + info=psb_err_internal_error_ + call psb_errpush(info,name) + goto 9999 + end if + + gia = acoo%ia(1:nza) + gja = acoo%ja(1:nza) + call psb_loc_to_glob(gia(1:nza), desc_a, info, iact='I') + call psb_loc_to_glob(gja(1:nza), desc_a, info, iact='I') + acoo%ia(1:nza) = gia(1:nza) + acoo%ja(1:nza) = gja(1:nza) +#else + ! + ! Here global and local numbers have the same size, so this must work. + ! + call psb_loc_to_glob(acoo%ja(1:nza), desc_a, info, iact='I') + call psb_loc_to_glob(acoo%ia(1:nza), desc_a, info, iact='I') +#endif + if (sv%ipar(3) == 2 ) then + ! Always pass the upper triangle to MUMPS + block + integer(psb_ipk_) :: j,nz + nz = 0 + do j=1,nza + if (acoo%ja(j) >= acoo%ia(j)) then + nz = nz + 1 + acoo%ia(nz) = acoo%ia(j) + acoo%ja(nz) = acoo%ja(j) + acoo%val(nz) = acoo%val(j) + end if + end do + call acoo%set_nzeros(nz) + call acoo%set_triangle() + call acoo%set_upper() + call acoo%set_symmetric() + end block + end if + end if + sv%id%irn_loc => acoo%ia + sv%id%jcn_loc => acoo%ja + sv%id%a_loc => acoo%val + sv%id%icntl(18) = 3 + sv%id%n = nglob + ! there should be a better way for this + sv%id%nnz_loc = acoo%get_nzeros() + sv%id%nnz = acoo%get_nzeros() + sv%id%job = 4 + if (sv%ipar(1) == amg_global_solver_ ) then + call psb_sum(ictxt,sv%id%nnz) + end if + !call psb_barrier(ictxt) + write(*,*)iam, ' calling mumps N,nz,nz_loc',sv%id%n,sv%id%nnz,sv%id%nnz_loc + call zmumps(sv%id) + !call psb_barrier(ictxt) + info = sv%id%infog(1) + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + ch_err='amg_zmumps_fact ' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + nullify(sv%id%irn) + nullify(sv%id%jcn) + nullify(sv%id%a) + + call acoo%free() + sv%built=.true. + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) iam,' ',trim(name),' end' + + call psb_erractionrestore(err_act) + return + +9999 continue + call psb_erractionrestore(err_act) + if (err_act == psb_act_abort_) then + call psb_error() + return + end if + return +#else + write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " +#endif +end subroutine z_mumps_solver_bld + diff --git a/mlprec/impl/solver/mld_c_base_solver_apply.f90 b/mlprec/impl/solver/mld_c_base_solver_apply.f90 deleted file mode 100644 index d15667d9..00000000 --- a/mlprec/impl/solver/mld_c_base_solver_apply.f90 +++ /dev/null @@ -1,71 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - - use psb_base_mod - use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_base_solver_type), intent(inout) :: sv - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_base_solver_apply diff --git a/mlprec/impl/solver/mld_c_base_solver_apply_vect.f90 b/mlprec/impl/solver/mld_c_base_solver_apply_vect.f90 deleted file mode 100644 index 46531fbf..00000000 --- a/mlprec/impl/solver/mld_c_base_solver_apply_vect.f90 +++ /dev/null @@ -1,72 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_base_solver_type), intent(inout) :: sv - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_solver_apply_vect' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_base_solver_apply_vect diff --git a/mlprec/impl/solver/mld_c_base_solver_bld.f90 b/mlprec/impl/solver/mld_c_base_solver_bld.f90 deleted file mode 100644 index 6f68f361..00000000 --- a/mlprec/impl/solver/mld_c_base_solver_bld.f90 +++ /dev/null @@ -1,68 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_bld - Implicit None - ! Arguments - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type), intent(in), target, optional :: b - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_bld' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_solver_bld diff --git a/mlprec/impl/solver/mld_c_base_solver_check.f90 b/mlprec/impl/solver/mld_c_base_solver_check.f90 deleted file mode 100644 index a4f62967..00000000 --- a/mlprec/impl/solver/mld_c_base_solver_check.f90 +++ /dev/null @@ -1,61 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_solver_check(sv,info) - - use psb_base_mod - use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_check - Implicit None - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_solver_check diff --git a/mlprec/impl/solver/mld_c_base_solver_clear_data.f90 b/mlprec/impl/solver/mld_c_base_solver_clear_data.f90 deleted file mode 100644 index 53da468c..00000000 --- a/mlprec/impl/solver/mld_c_base_solver_clear_data.f90 +++ /dev/null @@ -1,60 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_solver_clear_data(sv,info) - - use psb_base_mod - use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_clear_data - Implicit None - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_solver_clear_data' - - call psb_erractionsave(err_act) - info = 0 - - ! Do nothing - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_solver_clear_data diff --git a/mlprec/impl/solver/mld_c_base_solver_clone.f90 b/mlprec/impl/solver/mld_c_base_solver_clone.f90 deleted file mode 100644 index 666d2d39..00000000 --- a/mlprec/impl/solver/mld_c_base_solver_clone.f90 +++ /dev/null @@ -1,62 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_clone - Implicit None - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_solver_clone' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_solver_clone diff --git a/mlprec/impl/solver/mld_c_base_solver_clone_settings.f90 b/mlprec/impl/solver/mld_c_base_solver_clone_settings.f90 deleted file mode 100644 index 07f54168..00000000 --- a/mlprec/impl/solver/mld_c_base_solver_clone_settings.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_solver_clone_settings(sv,svout,info) - - use psb_base_mod - use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_clone_settings - Implicit None - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_solver_clone_settings' - - call psb_erractionsave(err_act) - - if (same_type_as(sv,svout)) then - ! Do nothing - else - - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_solver_clone_settings diff --git a/mlprec/impl/solver/mld_c_base_solver_cnv.f90 b/mlprec/impl/solver/mld_c_base_solver_cnv.f90 deleted file mode 100644 index 1c8b9416..00000000 --- a/mlprec/impl/solver/mld_c_base_solver_cnv.f90 +++ /dev/null @@ -1,63 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_solver_cnv(sv,info,amold,vmold,imold) - - use psb_base_mod - use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_cnv - Implicit None - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_cnv' - - call psb_erractionsave(err_act) - - info = psb_success_ - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_solver_cnv diff --git a/mlprec/impl/solver/mld_c_base_solver_csetc.f90 b/mlprec/impl/solver/mld_c_base_solver_csetc.f90 deleted file mode 100644 index af908807..00000000 --- a/mlprec/impl/solver/mld_c_base_solver_csetc.f90 +++ /dev/null @@ -1,63 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_solver_csetc(sv,what,val,info,idx) - - use psb_base_mod - use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_csetc - Implicit None - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - Integer(Psb_ipk_) :: err_act, ival - character(len=20) :: name='d_base_solver_csetc' - - call psb_erractionsave(err_act) - - info = psb_success_ - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_solver_csetc diff --git a/mlprec/impl/solver/mld_c_base_solver_cseti.f90 b/mlprec/impl/solver/mld_c_base_solver_cseti.f90 deleted file mode 100644 index be11d0b3..00000000 --- a/mlprec/impl/solver/mld_c_base_solver_cseti.f90 +++ /dev/null @@ -1,56 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_solver_cseti(sv,what,val,info,idx) - - use psb_base_mod - use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_cseti - Implicit None - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_cseti' - - ! Correct action here is doing nothing. - info = 0 - - return -end subroutine mld_c_base_solver_cseti diff --git a/mlprec/impl/solver/mld_c_base_solver_csetr.f90 b/mlprec/impl/solver/mld_c_base_solver_csetr.f90 deleted file mode 100644 index b0373816..00000000 --- a/mlprec/impl/solver/mld_c_base_solver_csetr.f90 +++ /dev/null @@ -1,57 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_solver_csetr(sv,what,val,info,idx) - - use psb_base_mod - use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_csetr - Implicit None - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_csetr' - - - ! Correct action here is doing nothing. - info = 0 - - return -end subroutine mld_c_base_solver_csetr diff --git a/mlprec/impl/solver/mld_c_base_solver_descr.f90 b/mlprec/impl/solver/mld_c_base_solver_descr.f90 deleted file mode 100644 index e988194c..00000000 --- a/mlprec/impl/solver/mld_c_base_solver_descr.f90 +++ /dev/null @@ -1,66 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_solver_descr(sv,info,iout,coarse) - - use psb_base_mod - use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_descr - Implicit None - ! Arguments - class(mld_c_base_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_c_base_solver_descr' - - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_solver_descr diff --git a/mlprec/impl/solver/mld_c_base_solver_dmp.f90 b/mlprec/impl/solver/mld_c_base_solver_dmp.f90 deleted file mode 100644 index dd23bc36..00000000 --- a/mlprec/impl/solver/mld_c_base_solver_dmp.f90 +++ /dev/null @@ -1,78 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_dmp - implicit none - class(mld_c_base_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: solver_ - ! len of prefix_ - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_c" - end if - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - ! At base level do nothing for the solver - -end subroutine mld_c_base_solver_dmp diff --git a/mlprec/impl/solver/mld_c_base_solver_free.f90 b/mlprec/impl/solver/mld_c_base_solver_free.f90 deleted file mode 100644 index 002e5b2a..00000000 --- a/mlprec/impl/solver/mld_c_base_solver_free.f90 +++ /dev/null @@ -1,60 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_base_solver_free(sv,info) - - use psb_base_mod - use mld_c_base_solver_mod, mld_protect_name => mld_c_base_solver_free - Implicit None - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_free' - - call psb_erractionsave(err_act) - - ! Do nothing - info = psb_success_ - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_base_solver_free diff --git a/mlprec/impl/solver/mld_c_bwgs_solver_apply.f90 b/mlprec/impl/solver/mld_c_bwgs_solver_apply.f90 deleted file mode 100644 index e70bd789..00000000 --- a/mlprec/impl/solver/mld_c_bwgs_solver_apply.f90 +++ /dev/null @@ -1,216 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_bwgs_solver_apply(alpha,sv,x,beta,y,desc_data,& - &trans,work,info,init,initu) - - use psb_base_mod - use mld_c_gs_solver, mld_protect_name => mld_c_bwgs_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_bwgs_solver_type), intent(inout) :: sv - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col, itx, itxst - complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - complex(psb_spk_), allocatable :: temp(:),wv(:),xit(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='c_bwgs_solver_apply' - - call psb_erractionsave(err_act) - ictxt = desc_data%get_ctxt() - call psb_info(ictxt,me,np) - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') -!!$ case('T') -!!$ case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - - call psb_geasb(wv,desc_data,info) - call psb_geasb(xit,desc_data,info) - itxst = 1 - select case (init_) - case('Z') - call psb_geaxpby(cone,x,czero,wv,desc_data,info) - call psb_spsm(cone,sv%u,wv,czero,xit,desc_data,info) - itxst = 2 - case('Y') - call psb_geaxpby(cone,y,czero,xit,desc_data,info) - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(cone,initu,czero,xit,desc_data,info) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - select case(trans_) - case('N') - if (sv%eps <=szero) then - ! - ! Fixed number of iterations - ! - ! - do itx=itxst, sv%sweeps - call psb_geaxpby(cone,x,czero,wv,desc_data,info) - ! Update with L. The off-diagonal block is taken care - ! from the Jacobi smoother, hence this is purely local. - call psb_spmm(-cone,sv%l,xit,cone,wv,desc_data,info,doswap=.false.) - call psb_spsm(cone,sv%u,wv,czero,xit,desc_data,info) - end do - - call psb_geaxpby(alpha,xit,beta,y,desc_data,info) - - else - ! - ! Iterations to convergence, not implemented right now. - ! - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') - goto 9999 - - end if -!!$ case('T') -!!$ call psb_spsm(cone,sv%u,x,czero,wv,desc_data,info,& -!!$ & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) -!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) -!!$ -!!$ case('C') -!!$ -!!$ call psb_spsm(cone,sv%u,x,czero,wv,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) -!!$ -!!$ call wv1%mlt(cone,sv%dv,wv,czero,info,conjgx=trans_) -!!$ -!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv1,beta,y,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid TRANS in GS subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_bwgs_solver_apply diff --git a/mlprec/impl/solver/mld_c_bwgs_solver_apply_vect.f90 b/mlprec/impl/solver/mld_c_bwgs_solver_apply_vect.f90 deleted file mode 100644 index 41d645fc..00000000 --- a/mlprec/impl/solver/mld_c_bwgs_solver_apply_vect.f90 +++ /dev/null @@ -1,211 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_bwgs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_c_gs_solver, mld_protect_name => mld_c_bwgs_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_bwgs_solver_type), intent(inout) :: sv - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col, itx, itxst - complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - complex(psb_spk_), allocatable :: temp(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='c_bwgs_solver_apply' - - call psb_erractionsave(err_act) - ictxt = desc_data%get_ctxt() - call psb_info(ictxt,me,np) - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') -!!$ case('T') -!!$ case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - - if (x%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/itwo,n_row,izero,izero,izero/)) - goto 9999 - end if - if (y%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/ithree,n_row,izero,izero,izero/)) - goto 9999 - end if - - - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - - if (size(wv) < 2) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size') - goto 9999 - end if - - associate(tw => wv(1), xit => wv(2)) - itxst = 1 - select case (init_) - case('Z') - call psb_geaxpby(cone,x,czero,tw,desc_data,info) - call psb_spsm(cone,sv%u,tw,czero,xit,desc_data,info) - itxst = 2 - case('Y') - call psb_geaxpby(cone,y,czero,xit,desc_data,info) - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(cone,initu,czero,xit,desc_data,info) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - select case(trans_) - case('N') - if (sv%eps <=szero) then - ! - ! Fixed number of iterations - ! - ! - do itx=itxst,sv%sweeps - call psb_geaxpby(cone,x,czero,tw,desc_data,info) - ! Update with L. The off-diagonal block is taken care - ! from the Jacobi smoother, hence this is purely local. - call psb_spmm(-cone,sv%l,xit,cone,tw,desc_data,info,doswap=.false.) - call psb_spsm(cone,sv%u,tw,czero,xit,desc_data,info) - end do - - call psb_geaxpby(alpha,xit,beta,y,desc_data,info) - - else - ! - ! Iterations to convergence, not implemented right now. - ! - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') - goto 9999 - - end if - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid TRANS in GS subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - end associate - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_bwgs_solver_apply_vect diff --git a/mlprec/impl/solver/mld_c_bwgs_solver_bld.f90 b/mlprec/impl/solver/mld_c_bwgs_solver_bld.f90 deleted file mode 100644 index 4771eee2..00000000 --- a/mlprec/impl/solver/mld_c_bwgs_solver_bld.f90 +++ /dev/null @@ -1,110 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_bwgs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_c_gs_solver, mld_protect_name => mld_c_bwgs_solver_bld - - Implicit None - - ! Arguments - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(in) :: desc_a - class(mld_c_bwgs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type), intent(in), target, optional :: b - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_bwgs_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - - if (sv%eps <= dzero) then - ! - ! This cuts out the off-diagonal part, because it's supposed to - ! be handled by the outer Jacobi smoother. - ! - call a%tril(sv%l,info,diag=-ione,jmax=nrow_a,u=sv%u) - - else - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end if - - - - call sv%l%set_asb() - call sv%l%trim() - call sv%u%set_asb() - call sv%u%trim() - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_bwgs_solver_bld diff --git a/mlprec/impl/solver/mld_c_diag_solver_apply.f90 b/mlprec/impl/solver/mld_c_diag_solver_apply.f90 deleted file mode 100644 index 120e4c29..00000000 --- a/mlprec/impl/solver/mld_c_diag_solver_apply.f90 +++ /dev/null @@ -1,240 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_diag_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - - use psb_base_mod - use mld_c_diag_solver, mld_protect_name => mld_c_diag_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_diag_solver_type), intent(inout) :: sv - complex(psb_spk_), intent(inout) :: x(:) - complex(psb_spk_), intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col - complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='c_diag_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (trans_ == 'C') then - if (beta == czero) then - - if (alpha == czero) then - y(1:n_row) = czero - else if (alpha == cone) then - do i=1, n_row - y(i) = conjg(sv%d(i)) * x(i) - end do - else if (alpha == -cone) then - do i=1, n_row - y(i) = -conjg(sv%d(i)) * x(i) - end do - else - do i=1, n_row - y(i) = alpha * conjg(sv%d(i)) * x(i) - end do - end if - - else if (beta == cone) then - - if (alpha == czero) then - !y(1:n_row) = czero - else if (alpha == cone) then - do i=1, n_row - y(i) = conjg(sv%d(i)) * x(i) + y(i) - end do - else if (alpha == -cone) then - do i=1, n_row - y(i) = -conjg(sv%d(i)) * x(i) + y(i) - end do - else - do i=1, n_row - y(i) = alpha * conjg(sv%d(i)) * x(i) + y(i) - end do - end if - - else if (beta == -cone) then - - if (alpha == czero) then - y(1:n_row) = -y(1:n_row) - else if (alpha == cone) then - do i=1, n_row - y(i) = conjg(sv%d(i)) * x(i) - y(i) - end do - else if (alpha == -cone) then - do i=1, n_row - y(i) = -conjg(sv%d(i)) * x(i) - y(i) - end do - else - do i=1, n_row - y(i) = alpha * conjg(sv%d(i)) * x(i) - y(i) - end do - end if - - else - - if (alpha == czero) then - y(1:n_row) = beta *y(1:n_row) - else if (alpha == cone) then - do i=1, n_row - y(i) = conjg(sv%d(i)) * x(i) + beta*y(i) - end do - else if (alpha == -cone) then - do i=1, n_row - y(i) = -conjg(sv%d(i)) * x(i) + beta*y(i) - end do - else - do i=1, n_row - y(i) = alpha * conjg(sv%d(i)) * x(i) + beta*y(i) - end do - end if - - end if - - else if (trans_ /= 'C') then - - if (beta == czero) then - - if (alpha == czero) then - y(1:n_row) = czero - else if (alpha == cone) then - do i=1, n_row - y(i) = sv%d(i) * x(i) - end do - else if (alpha == -cone) then - do i=1, n_row - y(i) = -sv%d(i) * x(i) - end do - else - do i=1, n_row - y(i) = alpha * sv%d(i) * x(i) - end do - end if - - else if (beta == cone) then - - if (alpha == czero) then - !y(1:n_row) = czero - else if (alpha == cone) then - do i=1, n_row - y(i) = sv%d(i) * x(i) + y(i) - end do - else if (alpha == -cone) then - do i=1, n_row - y(i) = -sv%d(i) * x(i) + y(i) - end do - else - do i=1, n_row - y(i) = alpha * sv%d(i) * x(i) + y(i) - end do - end if - - else if (beta == -cone) then - - if (alpha == czero) then - y(1:n_row) = -y(1:n_row) - else if (alpha == cone) then - do i=1, n_row - y(i) = sv%d(i) * x(i) - y(i) - end do - else if (alpha == -cone) then - do i=1, n_row - y(i) = -sv%d(i) * x(i) - y(i) - end do - else - do i=1, n_row - y(i) = alpha * sv%d(i) * x(i) - y(i) - end do - end if - - else - - if (alpha == czero) then - y(1:n_row) = beta *y(1:n_row) - else if (alpha == cone) then - do i=1, n_row - y(i) = sv%d(i) * x(i) + beta*y(i) - end do - else if (alpha == -cone) then - do i=1, n_row - y(i) = -sv%d(i) * x(i) + beta*y(i) - end do - else - do i=1, n_row - y(i) = alpha * sv%d(i) * x(i) + beta*y(i) - end do - end if - - end if - - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_diag_solver_apply diff --git a/mlprec/impl/solver/mld_c_diag_solver_apply_vect.f90 b/mlprec/impl/solver/mld_c_diag_solver_apply_vect.f90 deleted file mode 100644 index 05841f2d..00000000 --- a/mlprec/impl/solver/mld_c_diag_solver_apply_vect.f90 +++ /dev/null @@ -1,117 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_diag_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_c_diag_solver, mld_protect_name => mld_c_diag_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_diag_solver_type), intent(inout) :: sv - type(psb_c_vect_type), intent(inout) :: x - type(psb_c_vect_type), intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col - complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='c_diag_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - if (x%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/itwo,n_row,izero,izero,izero/)) - goto 9999 - end if - if (y%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/ithree,n_row,izero,izero,izero/)) - goto 9999 - end if - if (.not.allocated(sv%dv)) then - info = 1124 - call psb_errpush(info,name,a_err="preconditioner: D") - goto 9999 - end if - if (sv%dv%get_nrows() < n_row) then - info = 1124 - call psb_errpush(info,name,a_err="preconditioner: D") - goto 9999 - end if - - call y%mlt(alpha,sv%dv,x,beta,info,conjgx=trans_) - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='vect%mlt') - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_diag_solver_apply_vect diff --git a/mlprec/impl/solver/mld_c_diag_solver_bld.f90 b/mlprec/impl/solver/mld_c_diag_solver_bld.f90 deleted file mode 100644 index 874b2ebc..00000000 --- a/mlprec/impl/solver/mld_c_diag_solver_bld.f90 +++ /dev/null @@ -1,191 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_c_diag_solver, mld_protect_name => mld_c_diag_solver_bld - - Implicit None - - ! Arguments - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type), intent(in), target, optional :: b - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - complex(psb_spk_), allocatable :: tdb(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='c_diag_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - nrow_a = a%get_nrows() - - sv%d = a%get_diag(info) - if (info == psb_success_) call psb_realloc(n_row,sv%d,info) - if (present(b)) then - tdb=b%get_diag(info) - if (size(tdb)+nrow_a > n_row) call psb_realloc(nrow_a+size(tdb),sv%d,info) - if (info == psb_success_) sv%d(nrow_a+1:nrow_a+size(tdb)) = tdb(:) - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='get_diag') - goto 9999 - end if - - do i=1,n_row - if (sv%d(i) == czero) then - sv%d(i) = cone - else - sv%d(i) = cone/sv%d(i) - end if - end do - allocate(sv%dv,stat=info) - if (info == psb_success_) then - call sv%dv%bld(sv%d) - if (present(vmold)) call sv%dv%cnv(vmold) - call sv%dv%sync() - else - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='Allocate sv%dv') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_diag_solver_bld - - -subroutine mld_c_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_c_l1_diag_solver, mld_protect_name => mld_c_l1_diag_solver_bld - - Implicit None - - ! Arguments - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_l1_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type), intent(in), target, optional :: b - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - complex(psb_spk_), allocatable :: tdb(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='c_l1_diag_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - nrow_a = a%get_nrows() - - sv%d = a%arwsum(info) - if (info == psb_success_) call psb_realloc(n_row,sv%d,info) - if (present(b)) then - tdb=b%arwsum(info) - if (size(tdb)+nrow_a > n_row) call psb_realloc(nrow_a+size(tdb),sv%d,info) - if (info == psb_success_) sv%d(nrow_a+1:nrow_a+size(tdb)) = tdb(:) - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='arwsum') - goto 9999 - end if - - do i=1,n_row - if (sv%d(i) == czero) then - sv%d(i) = cone - else - sv%d(i) = cone/sv%d(i) - end if - end do - allocate(sv%dv,stat=info) - if (info == psb_success_) then - call sv%dv%bld(sv%d) - if (present(vmold)) call sv%dv%cnv(vmold) - call sv%dv%sync() - else - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='Allocate sv%dv') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_l1_diag_solver_bld diff --git a/mlprec/impl/solver/mld_c_diag_solver_clear_data.f90 b/mlprec/impl/solver/mld_c_diag_solver_clear_data.f90 deleted file mode 100644 index fcf4f5bf..00000000 --- a/mlprec/impl/solver/mld_c_diag_solver_clear_data.f90 +++ /dev/null @@ -1,65 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_diag_solver_clear_data(sv,info) - - use psb_base_mod - use mld_c_diag_solver, mld_protect_name => mld_c_diag_solver_clear_data - - Implicit None - - ! Arguments - class(mld_c_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - call sv%dv%free(info) - if ((info ==0).and.allocated(sv%d)) deallocate(sv%d,stat=info) - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_diag_solver_clear_data diff --git a/mlprec/impl/solver/mld_c_diag_solver_clone.f90 b/mlprec/impl/solver/mld_c_diag_solver_clone.f90 deleted file mode 100644 index 935beafe..00000000 --- a/mlprec/impl/solver/mld_c_diag_solver_clone.f90 +++ /dev/null @@ -1,83 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_diag_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_c_diag_solver, mld_protect_name => mld_c_diag_solver_clone - - Implicit None - - ! Arguments - class(mld_c_diag_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(svout)) then - call svout%free(info) - if (info == psb_success_) deallocate(svout, stat=info) - end if - if (info == psb_success_) & - & allocate(svout, mold=sv, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(svo => svout) - class is (mld_c_diag_solver_type) - call psb_safe_ab_cpy(sv%d,svo%d,info) - if (info == psb_success_) & - & call sv%dv%clone(svo%dv,info) - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_diag_solver_clone diff --git a/mlprec/impl/solver/mld_c_diag_solver_cnv.f90 b/mlprec/impl/solver/mld_c_diag_solver_cnv.f90 deleted file mode 100644 index e1375a21..00000000 --- a/mlprec/impl/solver/mld_c_diag_solver_cnv.f90 +++ /dev/null @@ -1,76 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_diag_solver_cnv(sv,info,amold,vmold,imold) - - use psb_base_mod - use mld_c_diag_solver, mld_protect_name => mld_c_diag_solver_cnv - - Implicit None - - ! Arguments - class(mld_c_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: err_act, debug_unit, debug_level - character(len=20) :: name='d_diag_solver_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) trim(name),' start' - - - if (allocated(sv%dv)) then - call sv%dv%cnv(vmold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_c_diag_solver_cnv diff --git a/mlprec/impl/solver/mld_c_diag_solver_dmp.f90 b/mlprec/impl/solver/mld_c_diag_solver_dmp.f90 deleted file mode 100644 index 0d7f5047..00000000 --- a/mlprec/impl/solver/mld_c_diag_solver_dmp.f90 +++ /dev/null @@ -1,133 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_c_diag_solver, mld_protect_name => mld_c_diag_solver_dmp - implicit none - class(mld_c_diag_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: solver_ - ! len of prefix_ - - info = 0 - - ictxt = desc%get_context() - - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - - if (solver_) then - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_c" - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' - if (allocated(sv%d)) & - & call psb_geprt(fname,sv%d,head=head) - - end if - -end subroutine mld_c_diag_solver_dmp -subroutine mld_c_l1_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_c_l1_diag_solver, mld_protect_name => mld_c_l1_diag_solver_dmp - implicit none - class(mld_c_l1_diag_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: solver_ - ! len of prefix_ - - info = 0 - - ictxt = desc%get_context() - - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - - if (solver_) then - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_c" - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_l1_diag.mtx' - if (allocated(sv%d)) & - & call psb_geprt(fname,sv%d,head=head) - - end if - -end subroutine mld_c_l1_diag_solver_dmp diff --git a/mlprec/impl/solver/mld_c_gs_solver_apply.f90 b/mlprec/impl/solver/mld_c_gs_solver_apply.f90 deleted file mode 100644 index 2f053b08..00000000 --- a/mlprec/impl/solver/mld_c_gs_solver_apply.f90 +++ /dev/null @@ -1,216 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_gs_solver_apply(alpha,sv,x,beta,y,desc_data,& - &trans,work,info,init,initu) - - use psb_base_mod - use mld_c_gs_solver, mld_protect_name => mld_c_gs_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_gs_solver_type), intent(inout) :: sv - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col, itx, itxst - complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - complex(psb_spk_), allocatable :: temp(:),wv(:),xit(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='c_gs_solver_apply' - - call psb_erractionsave(err_act) - ictxt = desc_data%get_ctxt() - call psb_info(ictxt,me,np) - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') -!!$ case('T') -!!$ case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - - call psb_geasb(wv,desc_data,info) - call psb_geasb(xit,desc_data,info) - itxst = 1 - select case (init_) - case('Z') - call psb_geaxpby(cone,x,czero,wv,desc_data,info) - call psb_spsm(cone,sv%l,wv,czero,xit,desc_data,info) - itxst = 2 - case('Y') - call psb_geaxpby(cone,y,czero,xit,desc_data,info) - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(cone,initu,czero,xit,desc_data,info) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - select case(trans_) - case('N') - if (sv%eps <=szero) then - ! - ! Fixed number of iterations - ! - ! - do itx=itxst,sv%sweeps - call psb_geaxpby(cone,x,czero,wv,desc_data,info) - ! Update with U. The off-diagonal block is taken care - ! from the Jacobi smoother, hence this is purely local. - call psb_spmm(-cone,sv%u,xit,cone,wv,desc_data,info,doswap=.false.) - call psb_spsm(cone,sv%l,wv,czero,xit,desc_data,info) - end do - - call psb_geaxpby(alpha,xit,beta,y,desc_data,info) - - else - ! - ! Iterations to convergence, not implemented right now. - ! - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') - goto 9999 - - end if -!!$ case('T') -!!$ call psb_spsm(cone,sv%u,x,czero,wv,desc_data,info,& -!!$ & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) -!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) -!!$ -!!$ case('C') -!!$ -!!$ call psb_spsm(cone,sv%u,x,czero,wv,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) -!!$ -!!$ call wv1%mlt(cone,sv%dv,wv,czero,info,conjgx=trans_) -!!$ -!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv1,beta,y,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid TRANS in GS subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_gs_solver_apply diff --git a/mlprec/impl/solver/mld_c_gs_solver_apply_vect.f90 b/mlprec/impl/solver/mld_c_gs_solver_apply_vect.f90 deleted file mode 100644 index e322c164..00000000 --- a/mlprec/impl/solver/mld_c_gs_solver_apply_vect.f90 +++ /dev/null @@ -1,211 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_gs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_c_gs_solver, mld_protect_name => mld_c_gs_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_gs_solver_type), intent(inout) :: sv - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col, itx, itxst - complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - complex(psb_spk_), allocatable :: temp(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='c_gs_solver_apply' - - call psb_erractionsave(err_act) - ictxt = desc_data%get_ctxt() - call psb_info(ictxt,me,np) - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') -!!$ case('T') -!!$ case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - - if (x%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/itwo,n_row,izero,izero,izero/)) - goto 9999 - end if - if (y%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/ithree,n_row,izero,izero,izero/)) - goto 9999 - end if - - - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - - if (size(wv) < 2) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size') - goto 9999 - end if - - associate(tw => wv(1), xit => wv(2)) - itxst = 1 - select case (init_) - case('Z') - call psb_geaxpby(cone,x,czero,tw,desc_data,info) - call psb_spsm(cone,sv%l,tw,czero,xit,desc_data,info) - itxst = 2 - case('Y') - call psb_geaxpby(cone,y,czero,xit,desc_data,info) - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(cone,initu,czero,xit,desc_data,info) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - select case(trans_) - case('N') - if (sv%eps <=szero) then - ! - ! Fixed number of iterations - ! - ! - do itx=itxst,sv%sweeps - call psb_geaxpby(cone,x,czero,tw,desc_data,info) - ! Update with U. The off-diagonal block is taken care - ! from the Jacobi smoother, hence this is purely local. - call psb_spmm(-cone,sv%u,xit,cone,tw,desc_data,info,doswap=.false.) - call psb_spsm(cone,sv%l,tw,czero,xit,desc_data,info) - end do - - call psb_geaxpby(alpha,xit,beta,y,desc_data,info) - - else - ! - ! Iterations to convergence, not implemented right now. - ! - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') - goto 9999 - - end if - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid TRANS in GS subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - end associate - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_gs_solver_apply_vect diff --git a/mlprec/impl/solver/mld_c_gs_solver_bld.f90 b/mlprec/impl/solver/mld_c_gs_solver_bld.f90 deleted file mode 100644 index 37117275..00000000 --- a/mlprec/impl/solver/mld_c_gs_solver_bld.f90 +++ /dev/null @@ -1,109 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_gs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_c_gs_solver, mld_protect_name => mld_c_gs_solver_bld - - Implicit None - - ! Arguments - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type), intent(in), target, optional :: b - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='c_gs_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - - if (sv%eps <= dzero) then - ! - ! This cuts out the off-diagonal part, because it's supposed to - ! be handled by the outer Jacobi smoother. - ! - call a%tril(sv%l,info,diag=izero,jmax=nrow_a,u=sv%u) - - else - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end if - - - - call sv%l%set_asb() - call sv%l%trim() - call sv%u%set_asb() - call sv%u%trim() - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_gs_solver_bld diff --git a/mlprec/impl/solver/mld_c_gs_solver_clear_data.f90 b/mlprec/impl/solver/mld_c_gs_solver_clear_data.f90 deleted file mode 100644 index f780023f..00000000 --- a/mlprec/impl/solver/mld_c_gs_solver_clear_data.f90 +++ /dev/null @@ -1,65 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_gs_solver_clear_data(sv,info) - - use psb_base_mod - use mld_c_gs_solver, mld_protect_name => mld_c_gs_solver_clear_data - - Implicit None - - ! Arguments - class(mld_c_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - call sv%l%free() - call sv%u%free() - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_gs_solver_clear_data diff --git a/mlprec/impl/solver/mld_c_gs_solver_clone.f90 b/mlprec/impl/solver/mld_c_gs_solver_clone.f90 deleted file mode 100644 index a48a30d3..00000000 --- a/mlprec/impl/solver/mld_c_gs_solver_clone.f90 +++ /dev/null @@ -1,87 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_gs_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_c_gs_solver, mld_protect_name => mld_c_gs_solver_clone - - Implicit None - - ! Arguments - class(mld_c_gs_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - if (allocated(svout)) then - call svout%free(info) - if (info == psb_success_) deallocate(svout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_c_gs_solver_type :: svout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(svo => svout) - type is (mld_c_gs_solver_type) - svo%sweeps = sv%sweeps - svo%eps = sv%eps - if (info == psb_success_) & - & call sv%l%clone(svo%l,info) - if (info == psb_success_) & - & call sv%u%clone(svo%u,info) - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_gs_solver_clone diff --git a/mlprec/impl/solver/mld_c_gs_solver_clone_settings.f90 b/mlprec/impl/solver/mld_c_gs_solver_clone_settings.f90 deleted file mode 100644 index f4914392..00000000 --- a/mlprec/impl/solver/mld_c_gs_solver_clone_settings.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_gs_solver_clone_settings(sv,svout,info) - - use psb_base_mod - use mld_c_gs_solver, mld_protect_name => mld_c_gs_solver_clone_settings - Implicit None - ! Arguments - class(mld_c_gs_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_gs_solver_clone_settings' - - call psb_erractionsave(err_act) - - select type(svout) - class is(mld_c_gs_solver_type) - svout%sweeps = sv%sweeps - svout%eps = sv%eps - - class default - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_gs_solver_clone_settings diff --git a/mlprec/impl/solver/mld_c_gs_solver_cnv.f90 b/mlprec/impl/solver/mld_c_gs_solver_cnv.f90 deleted file mode 100644 index 143a6618..00000000 --- a/mlprec/impl/solver/mld_c_gs_solver_cnv.f90 +++ /dev/null @@ -1,74 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_gs_solver_cnv(sv,info,amold,vmold,imold) - - use psb_base_mod - use mld_c_gs_solver, mld_protect_name => mld_c_gs_solver_cnv - - Implicit None - - ! Arguments - class(mld_c_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: err_act, debug_unit, debug_level - character(len=20) :: name='c_gs_solver_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_gs_solver_cnv diff --git a/mlprec/impl/solver/mld_c_gs_solver_dmp.f90 b/mlprec/impl/solver/mld_c_gs_solver_dmp.f90 deleted file mode 100644 index 4da0c5dd..00000000 --- a/mlprec/impl/solver/mld_c_gs_solver_dmp.f90 +++ /dev/null @@ -1,102 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_gs_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_c_gs_solver, mld_protect_name => mld_c_gs_solver_dmp - implicit none - class(mld_c_gs_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - integer(psb_lpk_), allocatable :: iv(:) - logical :: solver_, global_num_ - ! len of prefix_ - - info = 0 - - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - - if (solver_) then - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_d" - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - if (global_num_) then - iv = desc%get_global_indices(owned=.false.) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' - if (sv%l%is_asb()) & - & call sv%l%print(fname,head=head,iv=iv) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' - if (sv%u%is_asb()) & - & call sv%u%print(fname,head=head,iv=iv) - else - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' - if (sv%l%is_asb()) & - & call sv%l%print(fname,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' - if (sv%u%is_asb()) & - & call sv%u%print(fname,head=head) - end if - end if - -end subroutine mld_c_gs_solver_dmp diff --git a/mlprec/impl/solver/mld_c_id_solver_apply.f90 b/mlprec/impl/solver/mld_c_id_solver_apply.f90 deleted file mode 100644 index 39142aec..00000000 --- a/mlprec/impl/solver/mld_c_id_solver_apply.f90 +++ /dev/null @@ -1,86 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_id_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - - use psb_base_mod - use mld_c_id_solver, mld_protect_name => mld_c_id_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_id_solver_type), intent(inout) :: sv - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='c_id_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call psb_geaxpby(alpha,x,beta,y,desc_data,info) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_id_solver_apply diff --git a/mlprec/impl/solver/mld_c_id_solver_apply_vect.f90 b/mlprec/impl/solver/mld_c_id_solver_apply_vect.f90 deleted file mode 100644 index e8de6596..00000000 --- a/mlprec/impl/solver/mld_c_id_solver_apply_vect.f90 +++ /dev/null @@ -1,87 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_id_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_c_id_solver, mld_protect_name => mld_c_id_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_id_solver_type), intent(inout) :: sv - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='c_id_solver_apply_vect' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call psb_geaxpby(alpha,x,beta,y,desc_data,info) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_id_solver_apply_vect diff --git a/mlprec/impl/solver/mld_c_id_solver_clone.f90 b/mlprec/impl/solver/mld_c_id_solver_clone.f90 deleted file mode 100644 index 9c108356..00000000 --- a/mlprec/impl/solver/mld_c_id_solver_clone.f90 +++ /dev/null @@ -1,81 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_id_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_c_id_solver, mld_protect_name => mld_c_id_solver_clone - - Implicit None - - ! Arguments - class(mld_c_id_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(svout)) then - call svout%free(info) - if (info == psb_success_) deallocate(svout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_c_id_solver_type :: svout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(svo => svout) - type is (mld_c_id_solver_type) - ! Nothing to be done. - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_id_solver_clone diff --git a/mlprec/impl/solver/mld_c_ilu_solver_apply.f90 b/mlprec/impl/solver/mld_c_ilu_solver_apply.f90 deleted file mode 100644 index 1b1606b8..00000000 --- a/mlprec/impl/solver/mld_c_ilu_solver_apply.f90 +++ /dev/null @@ -1,153 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - - use psb_base_mod - use mld_c_ilu_solver, mld_protect_name => mld_c_ilu_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_ilu_solver_type), intent(inout) :: sv - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col - complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='c_ilu_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - endif - - select case(trans_) - case('N') - call psb_spsm(cone,sv%l,x,czero,ww,desc_data,info,& - & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) - - if (info == psb_success_) call psb_spsm(alpha,sv%u,ww,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_, work=aux) - - case('T') - call psb_spsm(cone,sv%u,x,czero,ww,desc_data,info,& - & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) - if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - case('C') - call psb_spsm(cone,sv%u,x,czero,ww,desc_data,info,& - & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) - if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid TRANS in ILU subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_ilu_solver_apply diff --git a/mlprec/impl/solver/mld_c_ilu_solver_apply_vect.f90 b/mlprec/impl/solver/mld_c_ilu_solver_apply_vect.f90 deleted file mode 100644 index 617223c8..00000000 --- a/mlprec/impl/solver/mld_c_ilu_solver_apply_vect.f90 +++ /dev/null @@ -1,194 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_c_ilu_solver, mld_protect_name => mld_c_ilu_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_ilu_solver_type), intent(inout) :: sv - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col - type(psb_c_vect_type) :: tw, tw1 - complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='c_ilu_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - - if (x%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/itwo,n_row,izero,izero,izero/)) - goto 9999 - end if - if (y%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/ithree,n_row,izero,izero,izero/)) - goto 9999 - end if - if (.not.allocated(sv%dv%v)) then - info = 1124 - call psb_errpush(info,name,a_err="preconditioner: D") - goto 9999 - end if - if (sv%dv%get_nrows() < n_row) then - info = 1124 - call psb_errpush(info,name,a_err="preconditioner: DV") - goto 9999 - end if - - - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - - - if (size(wv) < 2) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size') - goto 9999 - end if - - - associate(tw => wv(1), tw1 => wv(2)) - - select case(trans_) - case('N') - call psb_spsm(cone,sv%l,x,czero,tw,desc_data,info,& - & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) - - if (info == psb_success_) call psb_spsm(alpha,sv%u,tw,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_, work=aux) - - case('T') - call psb_spsm(cone,sv%u,x,czero,tw,desc_data,info,& - & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) - if (info == psb_success_) call psb_spsm(alpha,sv%l,tw,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - - case('C') - - call psb_spsm(cone,sv%u,x,czero,tw,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - - call tw1%mlt(cone,sv%dv,tw,czero,info,conjgx=trans_) - - if (info == psb_success_) call psb_spsm(alpha,sv%l,tw1,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid TRANS in ILU subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - end associate - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_c_ilu_solver_apply_vect diff --git a/mlprec/impl/solver/mld_c_ilu_solver_bld.f90 b/mlprec/impl/solver/mld_c_ilu_solver_bld.f90 deleted file mode 100644 index 4974fcee..00000000 --- a/mlprec/impl/solver/mld_c_ilu_solver_bld.f90 +++ /dev/null @@ -1,191 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_ilu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_c_ilu_solver, mld_protect_name => mld_c_ilu_solver_bld - - Implicit None - - ! Arguments - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type), intent(in), target, optional :: b - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota -!!$ complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='c_ilu_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - if (present(b)) then - nztota = nztota + b%get_nzeros() - end if - - call sv%l%csall(n_row,n_row,info,nztota) - if (info == psb_success_) call sv%u%csall(n_row,n_row,info,nztota) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_sp_all' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if (allocated(sv%d)) then - if (size(sv%d) < n_row) then - deallocate(sv%d) - endif - endif - if (.not.allocated(sv%d)) allocate(sv%d(n_row),stat=info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') - goto 9999 - endif - - - select case(sv%fact_type) - - case (psb_ilu_t_) - ! - ! ILU(k,t) - ! - select case(sv%fill_in) - - case(:-1) - ! Error: fill-in <= -1 - call psb_errpush(psb_err_input_value_invalid_i_,& - & name,i_err=(/ithree,sv%fill_in,izero,izero,izero/)) - goto 9999 - - case(0:) - ! Fill-in >= 0 - call psb_ilut_fact(sv%fill_in,sv%thresh,& - & a, sv%l,sv%u,sv%d,info,blck=b) - end select - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ilut_fact' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - case(psb_ilu_n_,psb_milu_n_) - ! - ! ILU(k) and MILU(k) - ! - select case(sv%fill_in) - case(:-1) - ! Error: fill-in <= -1 - call psb_errpush(psb_err_input_value_invalid_i_,& - & name,i_err=(/ithree,sv%fill_in,izero,izero,izero/)) - goto 9999 - case(0) - ! Fill-in 0 - ! Separate implementation of ILU(0) for better performance. - ! There seems to be a problem with the separate implementation of MILU(0), - ! contained into psb_ilu0_fact. This must be investigated. For the time being, - ! resort to the implementation of MILU(k) with k=0. - if (sv%fact_type == psb_ilu_n_) then - call psb_ilu0_fact(sv%fact_type,a,sv%l,sv%u,& - & sv%d,info,blck=b) - else - call psb_iluk_fact(sv%fill_in,sv%fact_type,& - & a,sv%l,sv%u,sv%d,info,blck=b) - endif - case(1:) - ! Fill-in >= 1 - ! The same routine implements both ILU(k) and MILU(k) - call psb_iluk_fact(sv%fill_in,sv%fact_type,& - & a,sv%l,sv%u,sv%d,info,blck=b) - end select - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_iluk_fact' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - case default - ! If we end up here, something was wrong up in the call chain. - info = psb_err_input_value_invalid_i_ - call psb_errpush(psb_err_input_value_invalid_i_,name,& - & i_err=(/ithree,sv%fact_type,izero,izero,izero/)) - goto 9999 - - end select - - call sv%l%set_asb() - call sv%l%trim() - call sv%u%set_asb() - call sv%u%trim() - call sv%dv%bld(sv%d,mold=vmold) - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_ilu_solver_bld diff --git a/mlprec/impl/solver/mld_c_ilu_solver_clear_data.f90 b/mlprec/impl/solver/mld_c_ilu_solver_clear_data.f90 deleted file mode 100644 index 40b3e8cd..00000000 --- a/mlprec/impl/solver/mld_c_ilu_solver_clear_data.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_ilu_solver_clear_data(sv,info) - - use psb_base_mod - use mld_c_ilu_solver, mld_protect_name => mld_c_ilu_solver_clear_data - - Implicit None - - ! Arguments - class(mld_c_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - call sv%l%free() - call sv%u%free() - call sv%dv%free(info) - if ((info==0).and.allocated(sv%d)) deallocate(sv%d,stat=info) - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_ilu_solver_clear_data diff --git a/mlprec/impl/solver/mld_c_ilu_solver_clone.f90 b/mlprec/impl/solver/mld_c_ilu_solver_clone.f90 deleted file mode 100644 index f46d68a4..00000000 --- a/mlprec/impl/solver/mld_c_ilu_solver_clone.f90 +++ /dev/null @@ -1,91 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_ilu_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_c_ilu_solver, mld_protect_name => mld_c_ilu_solver_clone - - Implicit None - - ! Arguments - class(mld_c_ilu_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - if (allocated(svout)) then - call svout%free(info) - if (info == psb_success_) deallocate(svout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_c_ilu_solver_type :: svout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(svo => svout) - type is (mld_c_ilu_solver_type) - svo%fact_type = sv%fact_type - svo%fill_in = sv%fill_in - svo%thresh = sv%thresh - call psb_safe_ab_cpy(sv%d,svo%d,info) - if (info == psb_success_) & - & call sv%dv%clone(svo%dv,info) - if (info == psb_success_) & - & call sv%l%clone(svo%l,info) - if (info == psb_success_) & - & call sv%u%clone(svo%u,info) - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_ilu_solver_clone diff --git a/mlprec/impl/solver/mld_c_ilu_solver_clone_settings.f90 b/mlprec/impl/solver/mld_c_ilu_solver_clone_settings.f90 deleted file mode 100644 index 3e25e4e4..00000000 --- a/mlprec/impl/solver/mld_c_ilu_solver_clone_settings.f90 +++ /dev/null @@ -1,70 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_ilu_solver_clone_settings(sv,svout,info) - - use psb_base_mod - use mld_c_ilu_solver, mld_protect_name => mld_c_ilu_solver_clone_settings - Implicit None - ! Arguments - class(mld_c_ilu_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_ilu_solver_clone_settings' - - call psb_erractionsave(err_act) - - select type(svout) - class is(mld_c_ilu_solver_type) - svout%fact_type = sv%fact_type - svout%fill_in = sv%fill_in - svout%thresh = sv%thresh - - class default - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_ilu_solver_clone_settings diff --git a/mlprec/impl/solver/mld_c_ilu_solver_cnv.f90 b/mlprec/impl/solver/mld_c_ilu_solver_cnv.f90 deleted file mode 100644 index 2578e0cb..00000000 --- a/mlprec/impl/solver/mld_c_ilu_solver_cnv.f90 +++ /dev/null @@ -1,76 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_ilu_solver_cnv(sv,info,amold,vmold,imold) - - use psb_base_mod - use mld_c_ilu_solver, mld_protect_name => mld_c_ilu_solver_cnv - - Implicit None - - ! Arguments - class(mld_c_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: err_act, debug_unit, debug_level - character(len=20) :: name='d_ilu_solver_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - call sv%dv%cnv(mold=vmold) - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_c_ilu_solver_cnv diff --git a/mlprec/impl/solver/mld_c_ilu_solver_dmp.f90 b/mlprec/impl/solver/mld_c_ilu_solver_dmp.f90 deleted file mode 100644 index 11586e9d..00000000 --- a/mlprec/impl/solver/mld_c_ilu_solver_dmp.f90 +++ /dev/null @@ -1,112 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_c_ilu_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_c_ilu_solver, mld_protect_name => mld_c_ilu_solver_dmp - implicit none - class(mld_c_ilu_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: solver_, global_num_ - integer(psb_lpk_), allocatable :: iv(:) - ! len of prefix_ - - info = 0 - - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - - - if (solver_) then - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_c" - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - if (global_num_) then - iv = desc%get_global_indices(owned=.false.) - - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' - if (sv%l%is_asb()) & - & call sv%l%print(fname,head=head,iv=iv) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' - if (allocated(sv%d)) & - & call psb_geprt(fname,sv%d,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' - if (sv%u%is_asb()) & - & call sv%u%print(fname,head=head,iv=iv) - - else - - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' - if (sv%l%is_asb()) & - & call sv%l%print(fname,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' - if (allocated(sv%d)) & - & call psb_geprt(fname,sv%d,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' - if (sv%u%is_asb()) & - & call sv%u%print(fname,head=head) - end if - end if - -end subroutine mld_c_ilu_solver_dmp diff --git a/mlprec/impl/solver/mld_c_mumps_solver_apply.F90 b/mlprec/impl/solver/mld_c_mumps_solver_apply.F90 deleted file mode 100644 index ee00b9f5..00000000 --- a/mlprec/impl/solver/mld_c_mumps_solver_apply.F90 +++ /dev/null @@ -1,169 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.0) -! -! (C) Copyright 2008,2009,2010,2012,2013 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -subroutine c_mumps_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - use psb_base_mod - use mld_c_mumps_solver - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_mumps_solver_type), intent(inout) :: sv - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row, n_col - integer(psb_lpk_) :: nglob - integer(psb_epk_) :: eng - complex(psb_spk_), allocatable :: ww(:) - complex(psb_spk_), allocatable, target :: gx(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='c_mumps_solver_apply' - - call psb_erractionsave(err_act) - -#if defined(HAVE_MUMPS_) - info = psb_success_ - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - nglob = desc_data%get_global_rows() - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - ! Running in local mode? - if (sv%ipar(1) == mld_local_solver_ ) then - gx = x - else if (sv%ipar(1) == mld_global_solver_ ) then - - if (n_col <= size(work)) then - ww = work(1:n_col) - else - allocate(ww(n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/n_col/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - end if - allocate(gx(nglob),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_; eng = nglob - call psb_errpush(info,name,e_err=(/eng/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - call psb_gather(gx, x, desc_data, info, root=izero) - else - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid local/global solver in MUMPS') - goto 9999 - end if - - select case(trans_) - case('N') - sv%id%icntl(9) = 1 - case('T') - sv%id%icntl(9) = 2 - case default - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Invalid TRANS in subsolve') - goto 9999 - end select - - sv%id%rhs => gx - sv%id%nrhs = 1 - sv%id%icntl(1)=-1 - sv%id%icntl(2)=-1 - sv%id%icntl(3)=-1 - sv%id%icntl(4)=-1 - sv%id%job = 3 - call cmumps(sv%id) - if (sv%ipar(1) == mld_local_solver_ ) then - call psb_geaxpby(alpha,gx,beta,y,desc_data,info) - else - call psb_scatter(gx, ww, desc_data, info, root=izero) - if (info == psb_success_) then - call psb_geaxpby(alpha,ww,beta,y,desc_data,info) - end if - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in subsolve') - goto 9999 - endif - - if (allocated(ww)) deallocate(ww) - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return - -#else - write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " -#endif -end subroutine c_mumps_solver_apply - diff --git a/mlprec/impl/solver/mld_c_mumps_solver_apply_vect.F90 b/mlprec/impl/solver/mld_c_mumps_solver_apply_vect.F90 deleted file mode 100644 index 8711486b..00000000 --- a/mlprec/impl/solver/mld_c_mumps_solver_apply_vect.F90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.0) -! -! (C) Copyright 2008,2009,2010,2012,2013 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -subroutine c_mumps_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - use psb_base_mod - use mld_c_mumps_solver - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_mumps_solver_type), intent(inout) :: sv - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_mumps_solver_apply_vect' - -#if defined(HAVE_MUMPS_) - - call psb_erractionsave(err_act) - - info = psb_success_ - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call x%v%sync() - call y%v%sync() - call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) - call y%v%set_host() - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return - -#else - write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " -#endif - -end subroutine c_mumps_solver_apply_vect - diff --git a/mlprec/impl/solver/mld_c_mumps_solver_bld.F90 b/mlprec/impl/solver/mld_c_mumps_solver_bld.F90 deleted file mode 100644 index a1c8a9e1..00000000 --- a/mlprec/impl/solver/mld_c_mumps_solver_bld.F90 +++ /dev/null @@ -1,262 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.0) -! -! (C) Copyright 2008,2009,2010,2012,2013 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -subroutine c_mumps_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_c_mumps_solver - Implicit None - - ! Arguments - type(psb_cspmat_type) :: c - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type), intent(in), target, optional :: b - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - type(psb_cspmat_type) :: atmp - type(psb_c_coo_sparse_mat), target :: acoo -#if defined(IPK4) && defined(LPK8) - integer(psb_lpk_), allocatable :: gia(:), gja(:) -#endif - integer(psb_ipk_) :: n_row,n_col, nrow_a, nza, npr, npc - integer(psb_lpk_) :: nglob, nglobrec, nzt - integer(psb_ipk_) :: ifrst, ibcheck - integer(psb_ipk_) :: ictxt, ictxt1, icomm, np, iam, me, i, err_act, debug_unit, debug_level - character(len=20) :: name='c_mumps_solver_bld', ch_err - -#if defined(HAVE_MUMPS_) - - info=psb_success_ - - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, iam, np) - if (sv%ipar(1) == mld_local_solver_ ) then - call psb_init(ictxt1,np=1,basectxt=ictxt,ids=(/iam/)) - icomm = psb_get_mpi_comm(ictxt1) - allocate(sv%local_ictxt,stat=info) - sv%local_ictxt = ictxt1 - !write(*,*)iam,'mumps_bld: local +++++>',icomm,sv%local_ictxt - call psb_info(ictxt1, me, np) - npr = np - else if (sv%ipar(1) == mld_global_solver_ ) then - icomm = psb_get_mpi_comm(ictxt) - !write(*,*)iam,'mumps_bld: global +++++>',icomm,ictxt - call psb_info(ictxt, iam, np) - me = iam - npr = np - else - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid local/global solver in MUMPS') - goto 9999 - end if - npc = 1 - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - ! if (allocated(sv%id)) then - ! call sv%free(info) - - ! deallocate(sv%id) - ! end if - if(.not.allocated(sv%id)) then - allocate(sv%id,stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_dealloc_ - call psb_errpush(info,name,a_err='mld_cmumps_default') - goto 9999 - end if - end if - - - sv%id%comm = icomm - sv%id%job = -1 - sv%id%par = 1 - if (sv%ipar(3) == 2) then - sv%id%sym = 2 - else - sv%id%sym = 0 - end if - - call cmumps(sv%id) - !WARNING: CALLING cmumps WITH JOB=-1 DESTROY THE SETTING OF DEFAULT:TO FIX - if (allocated(sv%icntl)) then - do i=1,mld_mumps_icntl_size - if (allocated(sv%icntl(i)%item)) then - !write(0,*) 'MUMPS_BLD: setting entry ',i,' to ', sv%icntl(i)%item - sv%id%icntl(i) = sv%icntl(i)%item - end if - end do - end if - if (allocated(sv%rcntl)) then - do i=1,mld_mumps_rcntl_size - if (allocated(sv%rcntl(i)%item)) sv%id%cntl(i) = sv%rcntl(i)%item - end do - end if - sv%id%icntl(3)=sv%ipar(2) - - nglob = desc_a%get_global_rows() - if (sv%ipar(1) == mld_local_solver_ ) then - nglobrec=desc_a%get_local_rows() - if (sv%ipar(3) == 2) then - ! Always pass the upper triangle to MUMPS - call a%triu(c,info,jmax=a%get_nrows()) - call c%set_symmetric() - else - call a%csclip(c,info,jmax=a%get_nrows()) - end if - call c%cp_to(acoo) - nglob = c%get_nrows() - if (nglobrec /= nglob) then - write(*,*)'WARNING: MUMPS solver does not allow overlap in AS yet. ' - write(*,*)'A zero-overlap is used instead' - end if - else - call a%cp_to(acoo) - end if - nza = acoo%get_nzeros() - - ! switch to global numbering - if (sv%ipar(1) == mld_global_solver_ ) then -#if defined(IPK4) && defined(LPK8) - ! - ! Strategy here is as follows: because a call to MUMPS - ! as a gobal solver is mostly done at the coarsest level, - ! even if we start from a problem requiring 8 bytes, chances - ! are that the global size will be suitable for 4 bytes - ! anyway, so we hope for the best, and throw an error - ! if something goes wrong. - ! - if (nglob > huge(1_psb_ipk_)) then - write(0,*) iam,' ',trim(name),': Error: overflow of local indices ' - info=psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - gia = acoo%ia(1:nza) - gja = acoo%ja(1:nza) - call psb_loc_to_glob(gia(1:nza), desc_a, info, iact='I') - call psb_loc_to_glob(gja(1:nza), desc_a, info, iact='I') - acoo%ia(1:nza) = gia(1:nza) - acoo%ja(1:nza) = gja(1:nza) -#else - ! - ! Here global and local numbers have the same size, so this must work. - ! - call psb_loc_to_glob(acoo%ja(1:nza), desc_a, info, iact='I') - call psb_loc_to_glob(acoo%ia(1:nza), desc_a, info, iact='I') -#endif - if (sv%ipar(3) == 2 ) then - ! Always pass the upper triangle to MUMPS - block - integer(psb_ipk_) :: j,nz - nz = 0 - do j=1,nza - if (acoo%ja(j) >= acoo%ia(j)) then - nz = nz + 1 - acoo%ia(nz) = acoo%ia(j) - acoo%ja(nz) = acoo%ja(j) - acoo%val(nz) = acoo%val(j) - end if - end do - call acoo%set_nzeros(nz) - call acoo%set_triangle() - call acoo%set_upper() - call acoo%set_symmetric() - end block - end if - end if - sv%id%irn_loc => acoo%ia - sv%id%jcn_loc => acoo%ja - sv%id%a_loc => acoo%val - sv%id%icntl(18) = 3 - sv%id%n = nglob - ! there should be a better way for this - sv%id%nnz_loc = acoo%get_nzeros() - sv%id%nnz = acoo%get_nzeros() - sv%id%job = 4 - if (sv%ipar(1) == mld_global_solver_ ) then - call psb_sum(ictxt,sv%id%nnz) - end if - !call psb_barrier(ictxt) - write(*,*)iam, ' calling mumps N,nz,nz_loc',sv%id%n,sv%id%nnz,sv%id%nnz_loc - call cmumps(sv%id) - !call psb_barrier(ictxt) - info = sv%id%infog(1) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='mld_cmumps_fact ' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - nullify(sv%id%irn) - nullify(sv%id%jcn) - nullify(sv%id%a) - - call acoo%free() - sv%built=.true. - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) iam,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -#else - write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " -#endif -end subroutine c_mumps_solver_bld - diff --git a/mlprec/impl/solver/mld_d_base_solver_apply.f90 b/mlprec/impl/solver/mld_d_base_solver_apply.f90 deleted file mode 100644 index 170a10d5..00000000 --- a/mlprec/impl/solver/mld_d_base_solver_apply.f90 +++ /dev/null @@ -1,71 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - - use psb_base_mod - use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_base_solver_type), intent(inout) :: sv - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_base_solver_apply diff --git a/mlprec/impl/solver/mld_d_base_solver_apply_vect.f90 b/mlprec/impl/solver/mld_d_base_solver_apply_vect.f90 deleted file mode 100644 index b2208ba9..00000000 --- a/mlprec/impl/solver/mld_d_base_solver_apply_vect.f90 +++ /dev/null @@ -1,72 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_base_solver_type), intent(inout) :: sv - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_apply_vect' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_base_solver_apply_vect diff --git a/mlprec/impl/solver/mld_d_base_solver_bld.f90 b/mlprec/impl/solver/mld_d_base_solver_bld.f90 deleted file mode 100644 index ac8b1231..00000000 --- a/mlprec/impl/solver/mld_d_base_solver_bld.f90 +++ /dev/null @@ -1,68 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_bld - Implicit None - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_bld' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_solver_bld diff --git a/mlprec/impl/solver/mld_d_base_solver_check.f90 b/mlprec/impl/solver/mld_d_base_solver_check.f90 deleted file mode 100644 index fbd7264f..00000000 --- a/mlprec/impl/solver/mld_d_base_solver_check.f90 +++ /dev/null @@ -1,61 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_solver_check(sv,info) - - use psb_base_mod - use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_check - Implicit None - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_solver_check diff --git a/mlprec/impl/solver/mld_d_base_solver_clear_data.f90 b/mlprec/impl/solver/mld_d_base_solver_clear_data.f90 deleted file mode 100644 index cbd0996c..00000000 --- a/mlprec/impl/solver/mld_d_base_solver_clear_data.f90 +++ /dev/null @@ -1,60 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_solver_clear_data(sv,info) - - use psb_base_mod - use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_clear_data - Implicit None - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_clear_data' - - call psb_erractionsave(err_act) - info = 0 - - ! Do nothing - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_solver_clear_data diff --git a/mlprec/impl/solver/mld_d_base_solver_clone.f90 b/mlprec/impl/solver/mld_d_base_solver_clone.f90 deleted file mode 100644 index 6fdb6ef8..00000000 --- a/mlprec/impl/solver/mld_d_base_solver_clone.f90 +++ /dev/null @@ -1,62 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_clone - Implicit None - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_clone' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_solver_clone diff --git a/mlprec/impl/solver/mld_d_base_solver_clone_settings.f90 b/mlprec/impl/solver/mld_d_base_solver_clone_settings.f90 deleted file mode 100644 index 8bad6f02..00000000 --- a/mlprec/impl/solver/mld_d_base_solver_clone_settings.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_solver_clone_settings(sv,svout,info) - - use psb_base_mod - use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_clone_settings - Implicit None - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_clone_settings' - - call psb_erractionsave(err_act) - - if (same_type_as(sv,svout)) then - ! Do nothing - else - - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_solver_clone_settings diff --git a/mlprec/impl/solver/mld_d_base_solver_cnv.f90 b/mlprec/impl/solver/mld_d_base_solver_cnv.f90 deleted file mode 100644 index 6f7774b8..00000000 --- a/mlprec/impl/solver/mld_d_base_solver_cnv.f90 +++ /dev/null @@ -1,63 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_solver_cnv(sv,info,amold,vmold,imold) - - use psb_base_mod - use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_cnv - Implicit None - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_cnv' - - call psb_erractionsave(err_act) - - info = psb_success_ - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_solver_cnv diff --git a/mlprec/impl/solver/mld_d_base_solver_csetc.f90 b/mlprec/impl/solver/mld_d_base_solver_csetc.f90 deleted file mode 100644 index ff90f415..00000000 --- a/mlprec/impl/solver/mld_d_base_solver_csetc.f90 +++ /dev/null @@ -1,63 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_solver_csetc(sv,what,val,info,idx) - - use psb_base_mod - use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_csetc - Implicit None - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - Integer(Psb_ipk_) :: err_act, ival - character(len=20) :: name='d_base_solver_csetc' - - call psb_erractionsave(err_act) - - info = psb_success_ - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_solver_csetc diff --git a/mlprec/impl/solver/mld_d_base_solver_cseti.f90 b/mlprec/impl/solver/mld_d_base_solver_cseti.f90 deleted file mode 100644 index c30cf96b..00000000 --- a/mlprec/impl/solver/mld_d_base_solver_cseti.f90 +++ /dev/null @@ -1,56 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_solver_cseti(sv,what,val,info,idx) - - use psb_base_mod - use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_cseti - Implicit None - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_cseti' - - ! Correct action here is doing nothing. - info = 0 - - return -end subroutine mld_d_base_solver_cseti diff --git a/mlprec/impl/solver/mld_d_base_solver_csetr.f90 b/mlprec/impl/solver/mld_d_base_solver_csetr.f90 deleted file mode 100644 index b55377be..00000000 --- a/mlprec/impl/solver/mld_d_base_solver_csetr.f90 +++ /dev/null @@ -1,57 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_solver_csetr(sv,what,val,info,idx) - - use psb_base_mod - use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_csetr - Implicit None - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_csetr' - - - ! Correct action here is doing nothing. - info = 0 - - return -end subroutine mld_d_base_solver_csetr diff --git a/mlprec/impl/solver/mld_d_base_solver_descr.f90 b/mlprec/impl/solver/mld_d_base_solver_descr.f90 deleted file mode 100644 index 2254482d..00000000 --- a/mlprec/impl/solver/mld_d_base_solver_descr.f90 +++ /dev/null @@ -1,66 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_solver_descr(sv,info,iout,coarse) - - use psb_base_mod - use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_descr - Implicit None - ! Arguments - class(mld_d_base_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_d_base_solver_descr' - - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_solver_descr diff --git a/mlprec/impl/solver/mld_d_base_solver_dmp.f90 b/mlprec/impl/solver/mld_d_base_solver_dmp.f90 deleted file mode 100644 index fd6e3242..00000000 --- a/mlprec/impl/solver/mld_d_base_solver_dmp.f90 +++ /dev/null @@ -1,78 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_dmp - implicit none - class(mld_d_base_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: solver_ - ! len of prefix_ - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_d" - end if - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - ! At base level do nothing for the solver - -end subroutine mld_d_base_solver_dmp diff --git a/mlprec/impl/solver/mld_d_base_solver_free.f90 b/mlprec/impl/solver/mld_d_base_solver_free.f90 deleted file mode 100644 index cbc271fd..00000000 --- a/mlprec/impl/solver/mld_d_base_solver_free.f90 +++ /dev/null @@ -1,60 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_base_solver_free(sv,info) - - use psb_base_mod - use mld_d_base_solver_mod, mld_protect_name => mld_d_base_solver_free - Implicit None - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_free' - - call psb_erractionsave(err_act) - - ! Do nothing - info = psb_success_ - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_base_solver_free diff --git a/mlprec/impl/solver/mld_d_bwgs_solver_apply.f90 b/mlprec/impl/solver/mld_d_bwgs_solver_apply.f90 deleted file mode 100644 index 6eaece03..00000000 --- a/mlprec/impl/solver/mld_d_bwgs_solver_apply.f90 +++ /dev/null @@ -1,216 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_bwgs_solver_apply(alpha,sv,x,beta,y,desc_data,& - &trans,work,info,init,initu) - - use psb_base_mod - use mld_d_gs_solver, mld_protect_name => mld_d_bwgs_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_bwgs_solver_type), intent(inout) :: sv - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col, itx, itxst - real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - real(psb_dpk_), allocatable :: temp(:),wv(:),xit(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='d_bwgs_solver_apply' - - call psb_erractionsave(err_act) - ictxt = desc_data%get_ctxt() - call psb_info(ictxt,me,np) - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') -!!$ case('T') -!!$ case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - - call psb_geasb(wv,desc_data,info) - call psb_geasb(xit,desc_data,info) - itxst = 1 - select case (init_) - case('Z') - call psb_geaxpby(done,x,dzero,wv,desc_data,info) - call psb_spsm(done,sv%u,wv,dzero,xit,desc_data,info) - itxst = 2 - case('Y') - call psb_geaxpby(done,y,dzero,xit,desc_data,info) - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(done,initu,dzero,xit,desc_data,info) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - select case(trans_) - case('N') - if (sv%eps <=dzero) then - ! - ! Fixed number of iterations - ! - ! - do itx=itxst, sv%sweeps - call psb_geaxpby(done,x,dzero,wv,desc_data,info) - ! Update with L. The off-diagonal block is taken care - ! from the Jacobi smoother, hence this is purely local. - call psb_spmm(-done,sv%l,xit,done,wv,desc_data,info,doswap=.false.) - call psb_spsm(done,sv%u,wv,dzero,xit,desc_data,info) - end do - - call psb_geaxpby(alpha,xit,beta,y,desc_data,info) - - else - ! - ! Iterations to convergence, not implemented right now. - ! - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') - goto 9999 - - end if -!!$ case('T') -!!$ call psb_spsm(done,sv%u,x,dzero,wv,desc_data,info,& -!!$ & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) -!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) -!!$ -!!$ case('C') -!!$ -!!$ call psb_spsm(done,sv%u,x,dzero,wv,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) -!!$ -!!$ call wv1%mlt(done,sv%dv,wv,dzero,info,conjgx=trans_) -!!$ -!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv1,beta,y,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid TRANS in GS subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_bwgs_solver_apply diff --git a/mlprec/impl/solver/mld_d_bwgs_solver_apply_vect.f90 b/mlprec/impl/solver/mld_d_bwgs_solver_apply_vect.f90 deleted file mode 100644 index 6ee62fef..00000000 --- a/mlprec/impl/solver/mld_d_bwgs_solver_apply_vect.f90 +++ /dev/null @@ -1,211 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_bwgs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_d_gs_solver, mld_protect_name => mld_d_bwgs_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_bwgs_solver_type), intent(inout) :: sv - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col, itx, itxst - real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - real(psb_dpk_), allocatable :: temp(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='d_bwgs_solver_apply' - - call psb_erractionsave(err_act) - ictxt = desc_data%get_ctxt() - call psb_info(ictxt,me,np) - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') -!!$ case('T') -!!$ case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - - if (x%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/itwo,n_row,izero,izero,izero/)) - goto 9999 - end if - if (y%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/ithree,n_row,izero,izero,izero/)) - goto 9999 - end if - - - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - - if (size(wv) < 2) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size') - goto 9999 - end if - - associate(tw => wv(1), xit => wv(2)) - itxst = 1 - select case (init_) - case('Z') - call psb_geaxpby(done,x,dzero,tw,desc_data,info) - call psb_spsm(done,sv%u,tw,dzero,xit,desc_data,info) - itxst = 2 - case('Y') - call psb_geaxpby(done,y,dzero,xit,desc_data,info) - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(done,initu,dzero,xit,desc_data,info) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - select case(trans_) - case('N') - if (sv%eps <=dzero) then - ! - ! Fixed number of iterations - ! - ! - do itx=itxst,sv%sweeps - call psb_geaxpby(done,x,dzero,tw,desc_data,info) - ! Update with L. The off-diagonal block is taken care - ! from the Jacobi smoother, hence this is purely local. - call psb_spmm(-done,sv%l,xit,done,tw,desc_data,info,doswap=.false.) - call psb_spsm(done,sv%u,tw,dzero,xit,desc_data,info) - end do - - call psb_geaxpby(alpha,xit,beta,y,desc_data,info) - - else - ! - ! Iterations to convergence, not implemented right now. - ! - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') - goto 9999 - - end if - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid TRANS in GS subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - end associate - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_bwgs_solver_apply_vect diff --git a/mlprec/impl/solver/mld_d_bwgs_solver_bld.f90 b/mlprec/impl/solver/mld_d_bwgs_solver_bld.f90 deleted file mode 100644 index decea6b1..00000000 --- a/mlprec/impl/solver/mld_d_bwgs_solver_bld.f90 +++ /dev/null @@ -1,110 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_bwgs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_d_gs_solver, mld_protect_name => mld_d_bwgs_solver_bld - - Implicit None - - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(in) :: desc_a - class(mld_d_bwgs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_bwgs_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - - if (sv%eps <= dzero) then - ! - ! This cuts out the off-diagonal part, because it's supposed to - ! be handled by the outer Jacobi smoother. - ! - call a%tril(sv%l,info,diag=-ione,jmax=nrow_a,u=sv%u) - - else - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end if - - - - call sv%l%set_asb() - call sv%l%trim() - call sv%u%set_asb() - call sv%u%trim() - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_bwgs_solver_bld diff --git a/mlprec/impl/solver/mld_d_diag_solver_apply.f90 b/mlprec/impl/solver/mld_d_diag_solver_apply.f90 deleted file mode 100644 index 45ac95e0..00000000 --- a/mlprec/impl/solver/mld_d_diag_solver_apply.f90 +++ /dev/null @@ -1,240 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_diag_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - - use psb_base_mod - use mld_d_diag_solver, mld_protect_name => mld_d_diag_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_diag_solver_type), intent(inout) :: sv - real(psb_dpk_), intent(inout) :: x(:) - real(psb_dpk_), intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col - real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='d_diag_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (trans_ == 'C') then - if (beta == dzero) then - - if (alpha == dzero) then - y(1:n_row) = dzero - else if (alpha == done) then - do i=1, n_row - y(i) = (sv%d(i)) * x(i) - end do - else if (alpha == -done) then - do i=1, n_row - y(i) = -(sv%d(i)) * x(i) - end do - else - do i=1, n_row - y(i) = alpha * (sv%d(i)) * x(i) - end do - end if - - else if (beta == done) then - - if (alpha == dzero) then - !y(1:n_row) = dzero - else if (alpha == done) then - do i=1, n_row - y(i) = (sv%d(i)) * x(i) + y(i) - end do - else if (alpha == -done) then - do i=1, n_row - y(i) = -(sv%d(i)) * x(i) + y(i) - end do - else - do i=1, n_row - y(i) = alpha * (sv%d(i)) * x(i) + y(i) - end do - end if - - else if (beta == -done) then - - if (alpha == dzero) then - y(1:n_row) = -y(1:n_row) - else if (alpha == done) then - do i=1, n_row - y(i) = (sv%d(i)) * x(i) - y(i) - end do - else if (alpha == -done) then - do i=1, n_row - y(i) = -(sv%d(i)) * x(i) - y(i) - end do - else - do i=1, n_row - y(i) = alpha * (sv%d(i)) * x(i) - y(i) - end do - end if - - else - - if (alpha == dzero) then - y(1:n_row) = beta *y(1:n_row) - else if (alpha == done) then - do i=1, n_row - y(i) = (sv%d(i)) * x(i) + beta*y(i) - end do - else if (alpha == -done) then - do i=1, n_row - y(i) = -(sv%d(i)) * x(i) + beta*y(i) - end do - else - do i=1, n_row - y(i) = alpha * (sv%d(i)) * x(i) + beta*y(i) - end do - end if - - end if - - else if (trans_ /= 'C') then - - if (beta == dzero) then - - if (alpha == dzero) then - y(1:n_row) = dzero - else if (alpha == done) then - do i=1, n_row - y(i) = sv%d(i) * x(i) - end do - else if (alpha == -done) then - do i=1, n_row - y(i) = -sv%d(i) * x(i) - end do - else - do i=1, n_row - y(i) = alpha * sv%d(i) * x(i) - end do - end if - - else if (beta == done) then - - if (alpha == dzero) then - !y(1:n_row) = dzero - else if (alpha == done) then - do i=1, n_row - y(i) = sv%d(i) * x(i) + y(i) - end do - else if (alpha == -done) then - do i=1, n_row - y(i) = -sv%d(i) * x(i) + y(i) - end do - else - do i=1, n_row - y(i) = alpha * sv%d(i) * x(i) + y(i) - end do - end if - - else if (beta == -done) then - - if (alpha == dzero) then - y(1:n_row) = -y(1:n_row) - else if (alpha == done) then - do i=1, n_row - y(i) = sv%d(i) * x(i) - y(i) - end do - else if (alpha == -done) then - do i=1, n_row - y(i) = -sv%d(i) * x(i) - y(i) - end do - else - do i=1, n_row - y(i) = alpha * sv%d(i) * x(i) - y(i) - end do - end if - - else - - if (alpha == dzero) then - y(1:n_row) = beta *y(1:n_row) - else if (alpha == done) then - do i=1, n_row - y(i) = sv%d(i) * x(i) + beta*y(i) - end do - else if (alpha == -done) then - do i=1, n_row - y(i) = -sv%d(i) * x(i) + beta*y(i) - end do - else - do i=1, n_row - y(i) = alpha * sv%d(i) * x(i) + beta*y(i) - end do - end if - - end if - - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_diag_solver_apply diff --git a/mlprec/impl/solver/mld_d_diag_solver_apply_vect.f90 b/mlprec/impl/solver/mld_d_diag_solver_apply_vect.f90 deleted file mode 100644 index 43012d16..00000000 --- a/mlprec/impl/solver/mld_d_diag_solver_apply_vect.f90 +++ /dev/null @@ -1,117 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_diag_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_d_diag_solver, mld_protect_name => mld_d_diag_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_diag_solver_type), intent(inout) :: sv - type(psb_d_vect_type), intent(inout) :: x - type(psb_d_vect_type), intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col - real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='d_diag_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - if (x%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/itwo,n_row,izero,izero,izero/)) - goto 9999 - end if - if (y%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/ithree,n_row,izero,izero,izero/)) - goto 9999 - end if - if (.not.allocated(sv%dv)) then - info = 1124 - call psb_errpush(info,name,a_err="preconditioner: D") - goto 9999 - end if - if (sv%dv%get_nrows() < n_row) then - info = 1124 - call psb_errpush(info,name,a_err="preconditioner: D") - goto 9999 - end if - - call y%mlt(alpha,sv%dv,x,beta,info,conjgx=trans_) - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='vect%mlt') - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_diag_solver_apply_vect diff --git a/mlprec/impl/solver/mld_d_diag_solver_bld.f90 b/mlprec/impl/solver/mld_d_diag_solver_bld.f90 deleted file mode 100644 index 37361b93..00000000 --- a/mlprec/impl/solver/mld_d_diag_solver_bld.f90 +++ /dev/null @@ -1,191 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_d_diag_solver, mld_protect_name => mld_d_diag_solver_bld - - Implicit None - - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - real(psb_dpk_), allocatable :: tdb(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_diag_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - nrow_a = a%get_nrows() - - sv%d = a%get_diag(info) - if (info == psb_success_) call psb_realloc(n_row,sv%d,info) - if (present(b)) then - tdb=b%get_diag(info) - if (size(tdb)+nrow_a > n_row) call psb_realloc(nrow_a+size(tdb),sv%d,info) - if (info == psb_success_) sv%d(nrow_a+1:nrow_a+size(tdb)) = tdb(:) - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='get_diag') - goto 9999 - end if - - do i=1,n_row - if (sv%d(i) == dzero) then - sv%d(i) = done - else - sv%d(i) = done/sv%d(i) - end if - end do - allocate(sv%dv,stat=info) - if (info == psb_success_) then - call sv%dv%bld(sv%d) - if (present(vmold)) call sv%dv%cnv(vmold) - call sv%dv%sync() - else - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='Allocate sv%dv') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_diag_solver_bld - - -subroutine mld_d_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_d_l1_diag_solver, mld_protect_name => mld_d_l1_diag_solver_bld - - Implicit None - - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_l1_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - real(psb_dpk_), allocatable :: tdb(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_l1_diag_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - nrow_a = a%get_nrows() - - sv%d = a%arwsum(info) - if (info == psb_success_) call psb_realloc(n_row,sv%d,info) - if (present(b)) then - tdb=b%arwsum(info) - if (size(tdb)+nrow_a > n_row) call psb_realloc(nrow_a+size(tdb),sv%d,info) - if (info == psb_success_) sv%d(nrow_a+1:nrow_a+size(tdb)) = tdb(:) - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='arwsum') - goto 9999 - end if - - do i=1,n_row - if (sv%d(i) == dzero) then - sv%d(i) = done - else - sv%d(i) = done/sv%d(i) - end if - end do - allocate(sv%dv,stat=info) - if (info == psb_success_) then - call sv%dv%bld(sv%d) - if (present(vmold)) call sv%dv%cnv(vmold) - call sv%dv%sync() - else - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='Allocate sv%dv') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_l1_diag_solver_bld diff --git a/mlprec/impl/solver/mld_d_diag_solver_clear_data.f90 b/mlprec/impl/solver/mld_d_diag_solver_clear_data.f90 deleted file mode 100644 index 5e246265..00000000 --- a/mlprec/impl/solver/mld_d_diag_solver_clear_data.f90 +++ /dev/null @@ -1,65 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_diag_solver_clear_data(sv,info) - - use psb_base_mod - use mld_d_diag_solver, mld_protect_name => mld_d_diag_solver_clear_data - - Implicit None - - ! Arguments - class(mld_d_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - call sv%dv%free(info) - if ((info ==0).and.allocated(sv%d)) deallocate(sv%d,stat=info) - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_diag_solver_clear_data diff --git a/mlprec/impl/solver/mld_d_diag_solver_clone.f90 b/mlprec/impl/solver/mld_d_diag_solver_clone.f90 deleted file mode 100644 index bf2238f0..00000000 --- a/mlprec/impl/solver/mld_d_diag_solver_clone.f90 +++ /dev/null @@ -1,83 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_diag_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_d_diag_solver, mld_protect_name => mld_d_diag_solver_clone - - Implicit None - - ! Arguments - class(mld_d_diag_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(svout)) then - call svout%free(info) - if (info == psb_success_) deallocate(svout, stat=info) - end if - if (info == psb_success_) & - & allocate(svout, mold=sv, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(svo => svout) - class is (mld_d_diag_solver_type) - call psb_safe_ab_cpy(sv%d,svo%d,info) - if (info == psb_success_) & - & call sv%dv%clone(svo%dv,info) - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_diag_solver_clone diff --git a/mlprec/impl/solver/mld_d_diag_solver_cnv.f90 b/mlprec/impl/solver/mld_d_diag_solver_cnv.f90 deleted file mode 100644 index 951615a4..00000000 --- a/mlprec/impl/solver/mld_d_diag_solver_cnv.f90 +++ /dev/null @@ -1,76 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_diag_solver_cnv(sv,info,amold,vmold,imold) - - use psb_base_mod - use mld_d_diag_solver, mld_protect_name => mld_d_diag_solver_cnv - - Implicit None - - ! Arguments - class(mld_d_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: err_act, debug_unit, debug_level - character(len=20) :: name='d_diag_solver_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) trim(name),' start' - - - if (allocated(sv%dv)) then - call sv%dv%cnv(vmold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_d_diag_solver_cnv diff --git a/mlprec/impl/solver/mld_d_diag_solver_dmp.f90 b/mlprec/impl/solver/mld_d_diag_solver_dmp.f90 deleted file mode 100644 index 50244998..00000000 --- a/mlprec/impl/solver/mld_d_diag_solver_dmp.f90 +++ /dev/null @@ -1,133 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_d_diag_solver, mld_protect_name => mld_d_diag_solver_dmp - implicit none - class(mld_d_diag_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: solver_ - ! len of prefix_ - - info = 0 - - ictxt = desc%get_context() - - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - - if (solver_) then - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_d" - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' - if (allocated(sv%d)) & - & call psb_geprt(fname,sv%d,head=head) - - end if - -end subroutine mld_d_diag_solver_dmp -subroutine mld_d_l1_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_d_l1_diag_solver, mld_protect_name => mld_d_l1_diag_solver_dmp - implicit none - class(mld_d_l1_diag_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: solver_ - ! len of prefix_ - - info = 0 - - ictxt = desc%get_context() - - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - - if (solver_) then - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_d" - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_l1_diag.mtx' - if (allocated(sv%d)) & - & call psb_geprt(fname,sv%d,head=head) - - end if - -end subroutine mld_d_l1_diag_solver_dmp diff --git a/mlprec/impl/solver/mld_d_gs_solver_apply.f90 b/mlprec/impl/solver/mld_d_gs_solver_apply.f90 deleted file mode 100644 index 0459a523..00000000 --- a/mlprec/impl/solver/mld_d_gs_solver_apply.f90 +++ /dev/null @@ -1,216 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_gs_solver_apply(alpha,sv,x,beta,y,desc_data,& - &trans,work,info,init,initu) - - use psb_base_mod - use mld_d_gs_solver, mld_protect_name => mld_d_gs_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_gs_solver_type), intent(inout) :: sv - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col, itx, itxst - real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - real(psb_dpk_), allocatable :: temp(:),wv(:),xit(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='d_gs_solver_apply' - - call psb_erractionsave(err_act) - ictxt = desc_data%get_ctxt() - call psb_info(ictxt,me,np) - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') -!!$ case('T') -!!$ case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - - call psb_geasb(wv,desc_data,info) - call psb_geasb(xit,desc_data,info) - itxst = 1 - select case (init_) - case('Z') - call psb_geaxpby(done,x,dzero,wv,desc_data,info) - call psb_spsm(done,sv%l,wv,dzero,xit,desc_data,info) - itxst = 2 - case('Y') - call psb_geaxpby(done,y,dzero,xit,desc_data,info) - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(done,initu,dzero,xit,desc_data,info) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - select case(trans_) - case('N') - if (sv%eps <=dzero) then - ! - ! Fixed number of iterations - ! - ! - do itx=itxst,sv%sweeps - call psb_geaxpby(done,x,dzero,wv,desc_data,info) - ! Update with U. The off-diagonal block is taken care - ! from the Jacobi smoother, hence this is purely local. - call psb_spmm(-done,sv%u,xit,done,wv,desc_data,info,doswap=.false.) - call psb_spsm(done,sv%l,wv,dzero,xit,desc_data,info) - end do - - call psb_geaxpby(alpha,xit,beta,y,desc_data,info) - - else - ! - ! Iterations to convergence, not implemented right now. - ! - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') - goto 9999 - - end if -!!$ case('T') -!!$ call psb_spsm(done,sv%u,x,dzero,wv,desc_data,info,& -!!$ & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) -!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) -!!$ -!!$ case('C') -!!$ -!!$ call psb_spsm(done,sv%u,x,dzero,wv,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) -!!$ -!!$ call wv1%mlt(done,sv%dv,wv,dzero,info,conjgx=trans_) -!!$ -!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv1,beta,y,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid TRANS in GS subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_gs_solver_apply diff --git a/mlprec/impl/solver/mld_d_gs_solver_apply_vect.f90 b/mlprec/impl/solver/mld_d_gs_solver_apply_vect.f90 deleted file mode 100644 index a5e30f44..00000000 --- a/mlprec/impl/solver/mld_d_gs_solver_apply_vect.f90 +++ /dev/null @@ -1,211 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_gs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_d_gs_solver, mld_protect_name => mld_d_gs_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_gs_solver_type), intent(inout) :: sv - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col, itx, itxst - real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - real(psb_dpk_), allocatable :: temp(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='d_gs_solver_apply' - - call psb_erractionsave(err_act) - ictxt = desc_data%get_ctxt() - call psb_info(ictxt,me,np) - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') -!!$ case('T') -!!$ case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - - if (x%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/itwo,n_row,izero,izero,izero/)) - goto 9999 - end if - if (y%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/ithree,n_row,izero,izero,izero/)) - goto 9999 - end if - - - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - - if (size(wv) < 2) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size') - goto 9999 - end if - - associate(tw => wv(1), xit => wv(2)) - itxst = 1 - select case (init_) - case('Z') - call psb_geaxpby(done,x,dzero,tw,desc_data,info) - call psb_spsm(done,sv%l,tw,dzero,xit,desc_data,info) - itxst = 2 - case('Y') - call psb_geaxpby(done,y,dzero,xit,desc_data,info) - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(done,initu,dzero,xit,desc_data,info) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - select case(trans_) - case('N') - if (sv%eps <=dzero) then - ! - ! Fixed number of iterations - ! - ! - do itx=itxst,sv%sweeps - call psb_geaxpby(done,x,dzero,tw,desc_data,info) - ! Update with U. The off-diagonal block is taken care - ! from the Jacobi smoother, hence this is purely local. - call psb_spmm(-done,sv%u,xit,done,tw,desc_data,info,doswap=.false.) - call psb_spsm(done,sv%l,tw,dzero,xit,desc_data,info) - end do - - call psb_geaxpby(alpha,xit,beta,y,desc_data,info) - - else - ! - ! Iterations to convergence, not implemented right now. - ! - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') - goto 9999 - - end if - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid TRANS in GS subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - end associate - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_gs_solver_apply_vect diff --git a/mlprec/impl/solver/mld_d_gs_solver_bld.f90 b/mlprec/impl/solver/mld_d_gs_solver_bld.f90 deleted file mode 100644 index 5357d294..00000000 --- a/mlprec/impl/solver/mld_d_gs_solver_bld.f90 +++ /dev/null @@ -1,109 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_gs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_d_gs_solver, mld_protect_name => mld_d_gs_solver_bld - - Implicit None - - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_gs_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - - if (sv%eps <= dzero) then - ! - ! This cuts out the off-diagonal part, because it's supposed to - ! be handled by the outer Jacobi smoother. - ! - call a%tril(sv%l,info,diag=izero,jmax=nrow_a,u=sv%u) - - else - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end if - - - - call sv%l%set_asb() - call sv%l%trim() - call sv%u%set_asb() - call sv%u%trim() - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_gs_solver_bld diff --git a/mlprec/impl/solver/mld_d_gs_solver_clear_data.f90 b/mlprec/impl/solver/mld_d_gs_solver_clear_data.f90 deleted file mode 100644 index ba015b9a..00000000 --- a/mlprec/impl/solver/mld_d_gs_solver_clear_data.f90 +++ /dev/null @@ -1,65 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_gs_solver_clear_data(sv,info) - - use psb_base_mod - use mld_d_gs_solver, mld_protect_name => mld_d_gs_solver_clear_data - - Implicit None - - ! Arguments - class(mld_d_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - call sv%l%free() - call sv%u%free() - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_gs_solver_clear_data diff --git a/mlprec/impl/solver/mld_d_gs_solver_clone.f90 b/mlprec/impl/solver/mld_d_gs_solver_clone.f90 deleted file mode 100644 index 5dae02e1..00000000 --- a/mlprec/impl/solver/mld_d_gs_solver_clone.f90 +++ /dev/null @@ -1,87 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_gs_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_d_gs_solver, mld_protect_name => mld_d_gs_solver_clone - - Implicit None - - ! Arguments - class(mld_d_gs_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - if (allocated(svout)) then - call svout%free(info) - if (info == psb_success_) deallocate(svout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_d_gs_solver_type :: svout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(svo => svout) - type is (mld_d_gs_solver_type) - svo%sweeps = sv%sweeps - svo%eps = sv%eps - if (info == psb_success_) & - & call sv%l%clone(svo%l,info) - if (info == psb_success_) & - & call sv%u%clone(svo%u,info) - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_gs_solver_clone diff --git a/mlprec/impl/solver/mld_d_gs_solver_clone_settings.f90 b/mlprec/impl/solver/mld_d_gs_solver_clone_settings.f90 deleted file mode 100644 index 230677ae..00000000 --- a/mlprec/impl/solver/mld_d_gs_solver_clone_settings.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_gs_solver_clone_settings(sv,svout,info) - - use psb_base_mod - use mld_d_gs_solver, mld_protect_name => mld_d_gs_solver_clone_settings - Implicit None - ! Arguments - class(mld_d_gs_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_gs_solver_clone_settings' - - call psb_erractionsave(err_act) - - select type(svout) - class is(mld_d_gs_solver_type) - svout%sweeps = sv%sweeps - svout%eps = sv%eps - - class default - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_gs_solver_clone_settings diff --git a/mlprec/impl/solver/mld_d_gs_solver_cnv.f90 b/mlprec/impl/solver/mld_d_gs_solver_cnv.f90 deleted file mode 100644 index 8253c863..00000000 --- a/mlprec/impl/solver/mld_d_gs_solver_cnv.f90 +++ /dev/null @@ -1,74 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_gs_solver_cnv(sv,info,amold,vmold,imold) - - use psb_base_mod - use mld_d_gs_solver, mld_protect_name => mld_d_gs_solver_cnv - - Implicit None - - ! Arguments - class(mld_d_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: err_act, debug_unit, debug_level - character(len=20) :: name='d_gs_solver_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_gs_solver_cnv diff --git a/mlprec/impl/solver/mld_d_gs_solver_dmp.f90 b/mlprec/impl/solver/mld_d_gs_solver_dmp.f90 deleted file mode 100644 index b1037f49..00000000 --- a/mlprec/impl/solver/mld_d_gs_solver_dmp.f90 +++ /dev/null @@ -1,102 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_gs_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_d_gs_solver, mld_protect_name => mld_d_gs_solver_dmp - implicit none - class(mld_d_gs_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - integer(psb_lpk_), allocatable :: iv(:) - logical :: solver_, global_num_ - ! len of prefix_ - - info = 0 - - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - - if (solver_) then - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_d" - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - if (global_num_) then - iv = desc%get_global_indices(owned=.false.) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' - if (sv%l%is_asb()) & - & call sv%l%print(fname,head=head,iv=iv) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' - if (sv%u%is_asb()) & - & call sv%u%print(fname,head=head,iv=iv) - else - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' - if (sv%l%is_asb()) & - & call sv%l%print(fname,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' - if (sv%u%is_asb()) & - & call sv%u%print(fname,head=head) - end if - end if - -end subroutine mld_d_gs_solver_dmp diff --git a/mlprec/impl/solver/mld_d_id_solver_apply.f90 b/mlprec/impl/solver/mld_d_id_solver_apply.f90 deleted file mode 100644 index ee3209ea..00000000 --- a/mlprec/impl/solver/mld_d_id_solver_apply.f90 +++ /dev/null @@ -1,86 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_id_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - - use psb_base_mod - use mld_d_id_solver, mld_protect_name => mld_d_id_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_id_solver_type), intent(inout) :: sv - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='d_id_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call psb_geaxpby(alpha,x,beta,y,desc_data,info) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_id_solver_apply diff --git a/mlprec/impl/solver/mld_d_id_solver_apply_vect.f90 b/mlprec/impl/solver/mld_d_id_solver_apply_vect.f90 deleted file mode 100644 index 9ab9f3af..00000000 --- a/mlprec/impl/solver/mld_d_id_solver_apply_vect.f90 +++ /dev/null @@ -1,87 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_id_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_d_id_solver, mld_protect_name => mld_d_id_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_id_solver_type), intent(inout) :: sv - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='d_id_solver_apply_vect' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call psb_geaxpby(alpha,x,beta,y,desc_data,info) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_id_solver_apply_vect diff --git a/mlprec/impl/solver/mld_d_id_solver_clone.f90 b/mlprec/impl/solver/mld_d_id_solver_clone.f90 deleted file mode 100644 index 895863a8..00000000 --- a/mlprec/impl/solver/mld_d_id_solver_clone.f90 +++ /dev/null @@ -1,81 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_id_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_d_id_solver, mld_protect_name => mld_d_id_solver_clone - - Implicit None - - ! Arguments - class(mld_d_id_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(svout)) then - call svout%free(info) - if (info == psb_success_) deallocate(svout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_d_id_solver_type :: svout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(svo => svout) - type is (mld_d_id_solver_type) - ! Nothing to be done. - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_id_solver_clone diff --git a/mlprec/impl/solver/mld_d_ilu_solver_apply.f90 b/mlprec/impl/solver/mld_d_ilu_solver_apply.f90 deleted file mode 100644 index a2e589f2..00000000 --- a/mlprec/impl/solver/mld_d_ilu_solver_apply.f90 +++ /dev/null @@ -1,153 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - - use psb_base_mod - use mld_d_ilu_solver, mld_protect_name => mld_d_ilu_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_ilu_solver_type), intent(inout) :: sv - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col - real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='d_ilu_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - endif - - select case(trans_) - case('N') - call psb_spsm(done,sv%l,x,dzero,ww,desc_data,info,& - & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) - - if (info == psb_success_) call psb_spsm(alpha,sv%u,ww,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_, work=aux) - - case('T') - call psb_spsm(done,sv%u,x,dzero,ww,desc_data,info,& - & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) - if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - case('C') - call psb_spsm(done,sv%u,x,dzero,ww,desc_data,info,& - & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) - if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid TRANS in ILU subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_ilu_solver_apply diff --git a/mlprec/impl/solver/mld_d_ilu_solver_apply_vect.f90 b/mlprec/impl/solver/mld_d_ilu_solver_apply_vect.f90 deleted file mode 100644 index 2ca9b278..00000000 --- a/mlprec/impl/solver/mld_d_ilu_solver_apply_vect.f90 +++ /dev/null @@ -1,194 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_d_ilu_solver, mld_protect_name => mld_d_ilu_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_ilu_solver_type), intent(inout) :: sv - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col - type(psb_d_vect_type) :: tw, tw1 - real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='d_ilu_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - - if (x%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/itwo,n_row,izero,izero,izero/)) - goto 9999 - end if - if (y%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/ithree,n_row,izero,izero,izero/)) - goto 9999 - end if - if (.not.allocated(sv%dv%v)) then - info = 1124 - call psb_errpush(info,name,a_err="preconditioner: D") - goto 9999 - end if - if (sv%dv%get_nrows() < n_row) then - info = 1124 - call psb_errpush(info,name,a_err="preconditioner: DV") - goto 9999 - end if - - - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - - - if (size(wv) < 2) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size') - goto 9999 - end if - - - associate(tw => wv(1), tw1 => wv(2)) - - select case(trans_) - case('N') - call psb_spsm(done,sv%l,x,dzero,tw,desc_data,info,& - & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) - - if (info == psb_success_) call psb_spsm(alpha,sv%u,tw,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_, work=aux) - - case('T') - call psb_spsm(done,sv%u,x,dzero,tw,desc_data,info,& - & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) - if (info == psb_success_) call psb_spsm(alpha,sv%l,tw,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - - case('C') - - call psb_spsm(done,sv%u,x,dzero,tw,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - - call tw1%mlt(done,sv%dv,tw,dzero,info,conjgx=trans_) - - if (info == psb_success_) call psb_spsm(alpha,sv%l,tw1,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid TRANS in ILU subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - end associate - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_d_ilu_solver_apply_vect diff --git a/mlprec/impl/solver/mld_d_ilu_solver_bld.f90 b/mlprec/impl/solver/mld_d_ilu_solver_bld.f90 deleted file mode 100644 index 39744d44..00000000 --- a/mlprec/impl/solver/mld_d_ilu_solver_bld.f90 +++ /dev/null @@ -1,191 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_ilu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_d_ilu_solver, mld_protect_name => mld_d_ilu_solver_bld - - Implicit None - - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota -!!$ real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_ilu_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - if (present(b)) then - nztota = nztota + b%get_nzeros() - end if - - call sv%l%csall(n_row,n_row,info,nztota) - if (info == psb_success_) call sv%u%csall(n_row,n_row,info,nztota) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_sp_all' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if (allocated(sv%d)) then - if (size(sv%d) < n_row) then - deallocate(sv%d) - endif - endif - if (.not.allocated(sv%d)) allocate(sv%d(n_row),stat=info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') - goto 9999 - endif - - - select case(sv%fact_type) - - case (psb_ilu_t_) - ! - ! ILU(k,t) - ! - select case(sv%fill_in) - - case(:-1) - ! Error: fill-in <= -1 - call psb_errpush(psb_err_input_value_invalid_i_,& - & name,i_err=(/ithree,sv%fill_in,izero,izero,izero/)) - goto 9999 - - case(0:) - ! Fill-in >= 0 - call psb_ilut_fact(sv%fill_in,sv%thresh,& - & a, sv%l,sv%u,sv%d,info,blck=b) - end select - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ilut_fact' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - case(psb_ilu_n_,psb_milu_n_) - ! - ! ILU(k) and MILU(k) - ! - select case(sv%fill_in) - case(:-1) - ! Error: fill-in <= -1 - call psb_errpush(psb_err_input_value_invalid_i_,& - & name,i_err=(/ithree,sv%fill_in,izero,izero,izero/)) - goto 9999 - case(0) - ! Fill-in 0 - ! Separate implementation of ILU(0) for better performance. - ! There seems to be a problem with the separate implementation of MILU(0), - ! contained into psb_ilu0_fact. This must be investigated. For the time being, - ! resort to the implementation of MILU(k) with k=0. - if (sv%fact_type == psb_ilu_n_) then - call psb_ilu0_fact(sv%fact_type,a,sv%l,sv%u,& - & sv%d,info,blck=b) - else - call psb_iluk_fact(sv%fill_in,sv%fact_type,& - & a,sv%l,sv%u,sv%d,info,blck=b) - endif - case(1:) - ! Fill-in >= 1 - ! The same routine implements both ILU(k) and MILU(k) - call psb_iluk_fact(sv%fill_in,sv%fact_type,& - & a,sv%l,sv%u,sv%d,info,blck=b) - end select - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_iluk_fact' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - case default - ! If we end up here, something was wrong up in the call chain. - info = psb_err_input_value_invalid_i_ - call psb_errpush(psb_err_input_value_invalid_i_,name,& - & i_err=(/ithree,sv%fact_type,izero,izero,izero/)) - goto 9999 - - end select - - call sv%l%set_asb() - call sv%l%trim() - call sv%u%set_asb() - call sv%u%trim() - call sv%dv%bld(sv%d,mold=vmold) - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_ilu_solver_bld diff --git a/mlprec/impl/solver/mld_d_ilu_solver_clear_data.f90 b/mlprec/impl/solver/mld_d_ilu_solver_clear_data.f90 deleted file mode 100644 index 11ce8e6d..00000000 --- a/mlprec/impl/solver/mld_d_ilu_solver_clear_data.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_ilu_solver_clear_data(sv,info) - - use psb_base_mod - use mld_d_ilu_solver, mld_protect_name => mld_d_ilu_solver_clear_data - - Implicit None - - ! Arguments - class(mld_d_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - call sv%l%free() - call sv%u%free() - call sv%dv%free(info) - if ((info==0).and.allocated(sv%d)) deallocate(sv%d,stat=info) - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_ilu_solver_clear_data diff --git a/mlprec/impl/solver/mld_d_ilu_solver_clone.f90 b/mlprec/impl/solver/mld_d_ilu_solver_clone.f90 deleted file mode 100644 index 5cc7ff72..00000000 --- a/mlprec/impl/solver/mld_d_ilu_solver_clone.f90 +++ /dev/null @@ -1,91 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_ilu_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_d_ilu_solver, mld_protect_name => mld_d_ilu_solver_clone - - Implicit None - - ! Arguments - class(mld_d_ilu_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - if (allocated(svout)) then - call svout%free(info) - if (info == psb_success_) deallocate(svout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_d_ilu_solver_type :: svout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(svo => svout) - type is (mld_d_ilu_solver_type) - svo%fact_type = sv%fact_type - svo%fill_in = sv%fill_in - svo%thresh = sv%thresh - call psb_safe_ab_cpy(sv%d,svo%d,info) - if (info == psb_success_) & - & call sv%dv%clone(svo%dv,info) - if (info == psb_success_) & - & call sv%l%clone(svo%l,info) - if (info == psb_success_) & - & call sv%u%clone(svo%u,info) - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_ilu_solver_clone diff --git a/mlprec/impl/solver/mld_d_ilu_solver_clone_settings.f90 b/mlprec/impl/solver/mld_d_ilu_solver_clone_settings.f90 deleted file mode 100644 index 8ab93e13..00000000 --- a/mlprec/impl/solver/mld_d_ilu_solver_clone_settings.f90 +++ /dev/null @@ -1,70 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_ilu_solver_clone_settings(sv,svout,info) - - use psb_base_mod - use mld_d_ilu_solver, mld_protect_name => mld_d_ilu_solver_clone_settings - Implicit None - ! Arguments - class(mld_d_ilu_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_ilu_solver_clone_settings' - - call psb_erractionsave(err_act) - - select type(svout) - class is(mld_d_ilu_solver_type) - svout%fact_type = sv%fact_type - svout%fill_in = sv%fill_in - svout%thresh = sv%thresh - - class default - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_ilu_solver_clone_settings diff --git a/mlprec/impl/solver/mld_d_ilu_solver_cnv.f90 b/mlprec/impl/solver/mld_d_ilu_solver_cnv.f90 deleted file mode 100644 index 1e0d1089..00000000 --- a/mlprec/impl/solver/mld_d_ilu_solver_cnv.f90 +++ /dev/null @@ -1,76 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_ilu_solver_cnv(sv,info,amold,vmold,imold) - - use psb_base_mod - use mld_d_ilu_solver, mld_protect_name => mld_d_ilu_solver_cnv - - Implicit None - - ! Arguments - class(mld_d_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: err_act, debug_unit, debug_level - character(len=20) :: name='d_ilu_solver_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - call sv%dv%cnv(mold=vmold) - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_d_ilu_solver_cnv diff --git a/mlprec/impl/solver/mld_d_ilu_solver_dmp.f90 b/mlprec/impl/solver/mld_d_ilu_solver_dmp.f90 deleted file mode 100644 index 8ab7f36c..00000000 --- a/mlprec/impl/solver/mld_d_ilu_solver_dmp.f90 +++ /dev/null @@ -1,112 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_d_ilu_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_d_ilu_solver, mld_protect_name => mld_d_ilu_solver_dmp - implicit none - class(mld_d_ilu_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: solver_, global_num_ - integer(psb_lpk_), allocatable :: iv(:) - ! len of prefix_ - - info = 0 - - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - - - if (solver_) then - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_d" - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - if (global_num_) then - iv = desc%get_global_indices(owned=.false.) - - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' - if (sv%l%is_asb()) & - & call sv%l%print(fname,head=head,iv=iv) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' - if (allocated(sv%d)) & - & call psb_geprt(fname,sv%d,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' - if (sv%u%is_asb()) & - & call sv%u%print(fname,head=head,iv=iv) - - else - - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' - if (sv%l%is_asb()) & - & call sv%l%print(fname,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' - if (allocated(sv%d)) & - & call psb_geprt(fname,sv%d,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' - if (sv%u%is_asb()) & - & call sv%u%print(fname,head=head) - end if - end if - -end subroutine mld_d_ilu_solver_dmp diff --git a/mlprec/impl/solver/mld_d_mumps_solver_apply.F90 b/mlprec/impl/solver/mld_d_mumps_solver_apply.F90 deleted file mode 100644 index 5ee8763d..00000000 --- a/mlprec/impl/solver/mld_d_mumps_solver_apply.F90 +++ /dev/null @@ -1,169 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.0) -! -! (C) Copyright 2008,2009,2010,2012,2013 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -subroutine d_mumps_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - use psb_base_mod - use mld_d_mumps_solver - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_mumps_solver_type), intent(inout) :: sv - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row, n_col - integer(psb_lpk_) :: nglob - integer(psb_epk_) :: eng - real(psb_dpk_), allocatable :: ww(:) - real(psb_dpk_), allocatable, target :: gx(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='d_mumps_solver_apply' - - call psb_erractionsave(err_act) - -#if defined(HAVE_MUMPS_) - info = psb_success_ - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - nglob = desc_data%get_global_rows() - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - ! Running in local mode? - if (sv%ipar(1) == mld_local_solver_ ) then - gx = x - else if (sv%ipar(1) == mld_global_solver_ ) then - - if (n_col <= size(work)) then - ww = work(1:n_col) - else - allocate(ww(n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/n_col/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - end if - allocate(gx(nglob),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_; eng = nglob - call psb_errpush(info,name,e_err=(/eng/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - call psb_gather(gx, x, desc_data, info, root=izero) - else - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid local/global solver in MUMPS') - goto 9999 - end if - - select case(trans_) - case('N') - sv%id%icntl(9) = 1 - case('T') - sv%id%icntl(9) = 2 - case default - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Invalid TRANS in subsolve') - goto 9999 - end select - - sv%id%rhs => gx - sv%id%nrhs = 1 - sv%id%icntl(1)=-1 - sv%id%icntl(2)=-1 - sv%id%icntl(3)=-1 - sv%id%icntl(4)=-1 - sv%id%job = 3 - call dmumps(sv%id) - if (sv%ipar(1) == mld_local_solver_ ) then - call psb_geaxpby(alpha,gx,beta,y,desc_data,info) - else - call psb_scatter(gx, ww, desc_data, info, root=izero) - if (info == psb_success_) then - call psb_geaxpby(alpha,ww,beta,y,desc_data,info) - end if - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in subsolve') - goto 9999 - endif - - if (allocated(ww)) deallocate(ww) - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return - -#else - write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " -#endif -end subroutine d_mumps_solver_apply - diff --git a/mlprec/impl/solver/mld_d_mumps_solver_apply_vect.F90 b/mlprec/impl/solver/mld_d_mumps_solver_apply_vect.F90 deleted file mode 100644 index 860d2193..00000000 --- a/mlprec/impl/solver/mld_d_mumps_solver_apply_vect.F90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.0) -! -! (C) Copyright 2008,2009,2010,2012,2013 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -subroutine d_mumps_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - use psb_base_mod - use mld_d_mumps_solver - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_mumps_solver_type), intent(inout) :: sv - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_mumps_solver_apply_vect' - -#if defined(HAVE_MUMPS_) - - call psb_erractionsave(err_act) - - info = psb_success_ - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call x%v%sync() - call y%v%sync() - call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) - call y%v%set_host() - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return - -#else - write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " -#endif - -end subroutine d_mumps_solver_apply_vect - diff --git a/mlprec/impl/solver/mld_d_mumps_solver_bld.F90 b/mlprec/impl/solver/mld_d_mumps_solver_bld.F90 deleted file mode 100644 index bcc4dc26..00000000 --- a/mlprec/impl/solver/mld_d_mumps_solver_bld.F90 +++ /dev/null @@ -1,262 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.0) -! -! (C) Copyright 2008,2009,2010,2012,2013 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -subroutine d_mumps_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_d_mumps_solver - Implicit None - - ! Arguments - type(psb_dspmat_type) :: c - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - type(psb_dspmat_type) :: atmp - type(psb_d_coo_sparse_mat), target :: acoo -#if defined(IPK4) && defined(LPK8) - integer(psb_lpk_), allocatable :: gia(:), gja(:) -#endif - integer(psb_ipk_) :: n_row,n_col, nrow_a, nza, npr, npc - integer(psb_lpk_) :: nglob, nglobrec, nzt - integer(psb_ipk_) :: ifrst, ibcheck - integer(psb_ipk_) :: ictxt, ictxt1, icomm, np, iam, me, i, err_act, debug_unit, debug_level - character(len=20) :: name='d_mumps_solver_bld', ch_err - -#if defined(HAVE_MUMPS_) - - info=psb_success_ - - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, iam, np) - if (sv%ipar(1) == mld_local_solver_ ) then - call psb_init(ictxt1,np=1,basectxt=ictxt,ids=(/iam/)) - icomm = psb_get_mpi_comm(ictxt1) - allocate(sv%local_ictxt,stat=info) - sv%local_ictxt = ictxt1 - !write(*,*)iam,'mumps_bld: local +++++>',icomm,sv%local_ictxt - call psb_info(ictxt1, me, np) - npr = np - else if (sv%ipar(1) == mld_global_solver_ ) then - icomm = psb_get_mpi_comm(ictxt) - !write(*,*)iam,'mumps_bld: global +++++>',icomm,ictxt - call psb_info(ictxt, iam, np) - me = iam - npr = np - else - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid local/global solver in MUMPS') - goto 9999 - end if - npc = 1 - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - ! if (allocated(sv%id)) then - ! call sv%free(info) - - ! deallocate(sv%id) - ! end if - if(.not.allocated(sv%id)) then - allocate(sv%id,stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_dealloc_ - call psb_errpush(info,name,a_err='mld_dmumps_default') - goto 9999 - end if - end if - - - sv%id%comm = icomm - sv%id%job = -1 - sv%id%par = 1 - if (sv%ipar(3) == 2) then - sv%id%sym = 2 - else - sv%id%sym = 0 - end if - - call dmumps(sv%id) - !WARNING: CALLING dmumps WITH JOB=-1 DESTROY THE SETTING OF DEFAULT:TO FIX - if (allocated(sv%icntl)) then - do i=1,mld_mumps_icntl_size - if (allocated(sv%icntl(i)%item)) then - !write(0,*) 'MUMPS_BLD: setting entry ',i,' to ', sv%icntl(i)%item - sv%id%icntl(i) = sv%icntl(i)%item - end if - end do - end if - if (allocated(sv%rcntl)) then - do i=1,mld_mumps_rcntl_size - if (allocated(sv%rcntl(i)%item)) sv%id%cntl(i) = sv%rcntl(i)%item - end do - end if - sv%id%icntl(3)=sv%ipar(2) - - nglob = desc_a%get_global_rows() - if (sv%ipar(1) == mld_local_solver_ ) then - nglobrec=desc_a%get_local_rows() - if (sv%ipar(3) == 2) then - ! Always pass the upper triangle to MUMPS - call a%triu(c,info,jmax=a%get_nrows()) - call c%set_symmetric() - else - call a%csclip(c,info,jmax=a%get_nrows()) - end if - call c%cp_to(acoo) - nglob = c%get_nrows() - if (nglobrec /= nglob) then - write(*,*)'WARNING: MUMPS solver does not allow overlap in AS yet. ' - write(*,*)'A zero-overlap is used instead' - end if - else - call a%cp_to(acoo) - end if - nza = acoo%get_nzeros() - - ! switch to global numbering - if (sv%ipar(1) == mld_global_solver_ ) then -#if defined(IPK4) && defined(LPK8) - ! - ! Strategy here is as follows: because a call to MUMPS - ! as a gobal solver is mostly done at the coarsest level, - ! even if we start from a problem requiring 8 bytes, chances - ! are that the global size will be suitable for 4 bytes - ! anyway, so we hope for the best, and throw an error - ! if something goes wrong. - ! - if (nglob > huge(1_psb_ipk_)) then - write(0,*) iam,' ',trim(name),': Error: overflow of local indices ' - info=psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - gia = acoo%ia(1:nza) - gja = acoo%ja(1:nza) - call psb_loc_to_glob(gia(1:nza), desc_a, info, iact='I') - call psb_loc_to_glob(gja(1:nza), desc_a, info, iact='I') - acoo%ia(1:nza) = gia(1:nza) - acoo%ja(1:nza) = gja(1:nza) -#else - ! - ! Here global and local numbers have the same size, so this must work. - ! - call psb_loc_to_glob(acoo%ja(1:nza), desc_a, info, iact='I') - call psb_loc_to_glob(acoo%ia(1:nza), desc_a, info, iact='I') -#endif - if (sv%ipar(3) == 2 ) then - ! Always pass the upper triangle to MUMPS - block - integer(psb_ipk_) :: j,nz - nz = 0 - do j=1,nza - if (acoo%ja(j) >= acoo%ia(j)) then - nz = nz + 1 - acoo%ia(nz) = acoo%ia(j) - acoo%ja(nz) = acoo%ja(j) - acoo%val(nz) = acoo%val(j) - end if - end do - call acoo%set_nzeros(nz) - call acoo%set_triangle() - call acoo%set_upper() - call acoo%set_symmetric() - end block - end if - end if - sv%id%irn_loc => acoo%ia - sv%id%jcn_loc => acoo%ja - sv%id%a_loc => acoo%val - sv%id%icntl(18) = 3 - sv%id%n = nglob - ! there should be a better way for this - sv%id%nnz_loc = acoo%get_nzeros() - sv%id%nnz = acoo%get_nzeros() - sv%id%job = 4 - if (sv%ipar(1) == mld_global_solver_ ) then - call psb_sum(ictxt,sv%id%nnz) - end if - !call psb_barrier(ictxt) - write(*,*)iam, ' calling mumps N,nz,nz_loc',sv%id%n,sv%id%nnz,sv%id%nnz_loc - call dmumps(sv%id) - !call psb_barrier(ictxt) - info = sv%id%infog(1) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='mld_dmumps_fact ' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - nullify(sv%id%irn) - nullify(sv%id%jcn) - nullify(sv%id%a) - - call acoo%free() - sv%built=.true. - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) iam,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -#else - write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " -#endif -end subroutine d_mumps_solver_bld - diff --git a/mlprec/impl/solver/mld_s_base_solver_apply.f90 b/mlprec/impl/solver/mld_s_base_solver_apply.f90 deleted file mode 100644 index 5605f4f8..00000000 --- a/mlprec/impl/solver/mld_s_base_solver_apply.f90 +++ /dev/null @@ -1,71 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - - use psb_base_mod - use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_base_solver_type), intent(inout) :: sv - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_base_solver_apply diff --git a/mlprec/impl/solver/mld_s_base_solver_apply_vect.f90 b/mlprec/impl/solver/mld_s_base_solver_apply_vect.f90 deleted file mode 100644 index e1dac965..00000000 --- a/mlprec/impl/solver/mld_s_base_solver_apply_vect.f90 +++ /dev/null @@ -1,72 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_base_solver_type), intent(inout) :: sv - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_solver_apply_vect' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_base_solver_apply_vect diff --git a/mlprec/impl/solver/mld_s_base_solver_bld.f90 b/mlprec/impl/solver/mld_s_base_solver_bld.f90 deleted file mode 100644 index b8d8999f..00000000 --- a/mlprec/impl/solver/mld_s_base_solver_bld.f90 +++ /dev/null @@ -1,68 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_bld - Implicit None - ! Arguments - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type), intent(in), target, optional :: b - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_bld' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_solver_bld diff --git a/mlprec/impl/solver/mld_s_base_solver_check.f90 b/mlprec/impl/solver/mld_s_base_solver_check.f90 deleted file mode 100644 index 0889c620..00000000 --- a/mlprec/impl/solver/mld_s_base_solver_check.f90 +++ /dev/null @@ -1,61 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_solver_check(sv,info) - - use psb_base_mod - use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_check - Implicit None - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_solver_check diff --git a/mlprec/impl/solver/mld_s_base_solver_clear_data.f90 b/mlprec/impl/solver/mld_s_base_solver_clear_data.f90 deleted file mode 100644 index 1954d507..00000000 --- a/mlprec/impl/solver/mld_s_base_solver_clear_data.f90 +++ /dev/null @@ -1,60 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_solver_clear_data(sv,info) - - use psb_base_mod - use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_clear_data - Implicit None - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_solver_clear_data' - - call psb_erractionsave(err_act) - info = 0 - - ! Do nothing - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_solver_clear_data diff --git a/mlprec/impl/solver/mld_s_base_solver_clone.f90 b/mlprec/impl/solver/mld_s_base_solver_clone.f90 deleted file mode 100644 index 7b1da808..00000000 --- a/mlprec/impl/solver/mld_s_base_solver_clone.f90 +++ /dev/null @@ -1,62 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_clone - Implicit None - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_solver_clone' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_solver_clone diff --git a/mlprec/impl/solver/mld_s_base_solver_clone_settings.f90 b/mlprec/impl/solver/mld_s_base_solver_clone_settings.f90 deleted file mode 100644 index a8ea77e1..00000000 --- a/mlprec/impl/solver/mld_s_base_solver_clone_settings.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_solver_clone_settings(sv,svout,info) - - use psb_base_mod - use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_clone_settings - Implicit None - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_solver_clone_settings' - - call psb_erractionsave(err_act) - - if (same_type_as(sv,svout)) then - ! Do nothing - else - - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_solver_clone_settings diff --git a/mlprec/impl/solver/mld_s_base_solver_cnv.f90 b/mlprec/impl/solver/mld_s_base_solver_cnv.f90 deleted file mode 100644 index acca2e24..00000000 --- a/mlprec/impl/solver/mld_s_base_solver_cnv.f90 +++ /dev/null @@ -1,63 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_solver_cnv(sv,info,amold,vmold,imold) - - use psb_base_mod - use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_cnv - Implicit None - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_cnv' - - call psb_erractionsave(err_act) - - info = psb_success_ - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_solver_cnv diff --git a/mlprec/impl/solver/mld_s_base_solver_csetc.f90 b/mlprec/impl/solver/mld_s_base_solver_csetc.f90 deleted file mode 100644 index 03e9042f..00000000 --- a/mlprec/impl/solver/mld_s_base_solver_csetc.f90 +++ /dev/null @@ -1,63 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_solver_csetc(sv,what,val,info,idx) - - use psb_base_mod - use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_csetc - Implicit None - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - Integer(Psb_ipk_) :: err_act, ival - character(len=20) :: name='d_base_solver_csetc' - - call psb_erractionsave(err_act) - - info = psb_success_ - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_solver_csetc diff --git a/mlprec/impl/solver/mld_s_base_solver_cseti.f90 b/mlprec/impl/solver/mld_s_base_solver_cseti.f90 deleted file mode 100644 index ff11aa50..00000000 --- a/mlprec/impl/solver/mld_s_base_solver_cseti.f90 +++ /dev/null @@ -1,56 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_solver_cseti(sv,what,val,info,idx) - - use psb_base_mod - use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_cseti - Implicit None - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_cseti' - - ! Correct action here is doing nothing. - info = 0 - - return -end subroutine mld_s_base_solver_cseti diff --git a/mlprec/impl/solver/mld_s_base_solver_csetr.f90 b/mlprec/impl/solver/mld_s_base_solver_csetr.f90 deleted file mode 100644 index bd646583..00000000 --- a/mlprec/impl/solver/mld_s_base_solver_csetr.f90 +++ /dev/null @@ -1,57 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_solver_csetr(sv,what,val,info,idx) - - use psb_base_mod - use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_csetr - Implicit None - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_csetr' - - - ! Correct action here is doing nothing. - info = 0 - - return -end subroutine mld_s_base_solver_csetr diff --git a/mlprec/impl/solver/mld_s_base_solver_descr.f90 b/mlprec/impl/solver/mld_s_base_solver_descr.f90 deleted file mode 100644 index 67fa0d35..00000000 --- a/mlprec/impl/solver/mld_s_base_solver_descr.f90 +++ /dev/null @@ -1,66 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_solver_descr(sv,info,iout,coarse) - - use psb_base_mod - use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_descr - Implicit None - ! Arguments - class(mld_s_base_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_s_base_solver_descr' - - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_solver_descr diff --git a/mlprec/impl/solver/mld_s_base_solver_dmp.f90 b/mlprec/impl/solver/mld_s_base_solver_dmp.f90 deleted file mode 100644 index ffe0141f..00000000 --- a/mlprec/impl/solver/mld_s_base_solver_dmp.f90 +++ /dev/null @@ -1,78 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_dmp - implicit none - class(mld_s_base_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: solver_ - ! len of prefix_ - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_s" - end if - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - ! At base level do nothing for the solver - -end subroutine mld_s_base_solver_dmp diff --git a/mlprec/impl/solver/mld_s_base_solver_free.f90 b/mlprec/impl/solver/mld_s_base_solver_free.f90 deleted file mode 100644 index f71e1cf8..00000000 --- a/mlprec/impl/solver/mld_s_base_solver_free.f90 +++ /dev/null @@ -1,60 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_base_solver_free(sv,info) - - use psb_base_mod - use mld_s_base_solver_mod, mld_protect_name => mld_s_base_solver_free - Implicit None - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_free' - - call psb_erractionsave(err_act) - - ! Do nothing - info = psb_success_ - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_base_solver_free diff --git a/mlprec/impl/solver/mld_s_bwgs_solver_apply.f90 b/mlprec/impl/solver/mld_s_bwgs_solver_apply.f90 deleted file mode 100644 index e232e393..00000000 --- a/mlprec/impl/solver/mld_s_bwgs_solver_apply.f90 +++ /dev/null @@ -1,216 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_bwgs_solver_apply(alpha,sv,x,beta,y,desc_data,& - &trans,work,info,init,initu) - - use psb_base_mod - use mld_s_gs_solver, mld_protect_name => mld_s_bwgs_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_bwgs_solver_type), intent(inout) :: sv - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col, itx, itxst - real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - real(psb_spk_), allocatable :: temp(:),wv(:),xit(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='s_bwgs_solver_apply' - - call psb_erractionsave(err_act) - ictxt = desc_data%get_ctxt() - call psb_info(ictxt,me,np) - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') -!!$ case('T') -!!$ case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - - call psb_geasb(wv,desc_data,info) - call psb_geasb(xit,desc_data,info) - itxst = 1 - select case (init_) - case('Z') - call psb_geaxpby(sone,x,szero,wv,desc_data,info) - call psb_spsm(sone,sv%u,wv,szero,xit,desc_data,info) - itxst = 2 - case('Y') - call psb_geaxpby(sone,y,szero,xit,desc_data,info) - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(sone,initu,szero,xit,desc_data,info) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - select case(trans_) - case('N') - if (sv%eps <=szero) then - ! - ! Fixed number of iterations - ! - ! - do itx=itxst, sv%sweeps - call psb_geaxpby(sone,x,szero,wv,desc_data,info) - ! Update with L. The off-diagonal block is taken care - ! from the Jacobi smoother, hence this is purely local. - call psb_spmm(-sone,sv%l,xit,sone,wv,desc_data,info,doswap=.false.) - call psb_spsm(sone,sv%u,wv,szero,xit,desc_data,info) - end do - - call psb_geaxpby(alpha,xit,beta,y,desc_data,info) - - else - ! - ! Iterations to convergence, not implemented right now. - ! - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') - goto 9999 - - end if -!!$ case('T') -!!$ call psb_spsm(sone,sv%u,x,szero,wv,desc_data,info,& -!!$ & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) -!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) -!!$ -!!$ case('C') -!!$ -!!$ call psb_spsm(sone,sv%u,x,szero,wv,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) -!!$ -!!$ call wv1%mlt(sone,sv%dv,wv,szero,info,conjgx=trans_) -!!$ -!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv1,beta,y,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid TRANS in GS subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_bwgs_solver_apply diff --git a/mlprec/impl/solver/mld_s_bwgs_solver_apply_vect.f90 b/mlprec/impl/solver/mld_s_bwgs_solver_apply_vect.f90 deleted file mode 100644 index 7f043d74..00000000 --- a/mlprec/impl/solver/mld_s_bwgs_solver_apply_vect.f90 +++ /dev/null @@ -1,211 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_bwgs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_s_gs_solver, mld_protect_name => mld_s_bwgs_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_bwgs_solver_type), intent(inout) :: sv - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col, itx, itxst - real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - real(psb_spk_), allocatable :: temp(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='s_bwgs_solver_apply' - - call psb_erractionsave(err_act) - ictxt = desc_data%get_ctxt() - call psb_info(ictxt,me,np) - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') -!!$ case('T') -!!$ case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - - if (x%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/itwo,n_row,izero,izero,izero/)) - goto 9999 - end if - if (y%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/ithree,n_row,izero,izero,izero/)) - goto 9999 - end if - - - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - - if (size(wv) < 2) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size') - goto 9999 - end if - - associate(tw => wv(1), xit => wv(2)) - itxst = 1 - select case (init_) - case('Z') - call psb_geaxpby(sone,x,szero,tw,desc_data,info) - call psb_spsm(sone,sv%u,tw,szero,xit,desc_data,info) - itxst = 2 - case('Y') - call psb_geaxpby(sone,y,szero,xit,desc_data,info) - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(sone,initu,szero,xit,desc_data,info) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - select case(trans_) - case('N') - if (sv%eps <=szero) then - ! - ! Fixed number of iterations - ! - ! - do itx=itxst,sv%sweeps - call psb_geaxpby(sone,x,szero,tw,desc_data,info) - ! Update with L. The off-diagonal block is taken care - ! from the Jacobi smoother, hence this is purely local. - call psb_spmm(-sone,sv%l,xit,sone,tw,desc_data,info,doswap=.false.) - call psb_spsm(sone,sv%u,tw,szero,xit,desc_data,info) - end do - - call psb_geaxpby(alpha,xit,beta,y,desc_data,info) - - else - ! - ! Iterations to convergence, not implemented right now. - ! - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') - goto 9999 - - end if - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid TRANS in GS subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - end associate - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_bwgs_solver_apply_vect diff --git a/mlprec/impl/solver/mld_s_bwgs_solver_bld.f90 b/mlprec/impl/solver/mld_s_bwgs_solver_bld.f90 deleted file mode 100644 index fe682caa..00000000 --- a/mlprec/impl/solver/mld_s_bwgs_solver_bld.f90 +++ /dev/null @@ -1,110 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_bwgs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_s_gs_solver, mld_protect_name => mld_s_bwgs_solver_bld - - Implicit None - - ! Arguments - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(in) :: desc_a - class(mld_s_bwgs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type), intent(in), target, optional :: b - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_bwgs_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - - if (sv%eps <= dzero) then - ! - ! This cuts out the off-diagonal part, because it's supposed to - ! be handled by the outer Jacobi smoother. - ! - call a%tril(sv%l,info,diag=-ione,jmax=nrow_a,u=sv%u) - - else - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end if - - - - call sv%l%set_asb() - call sv%l%trim() - call sv%u%set_asb() - call sv%u%trim() - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_bwgs_solver_bld diff --git a/mlprec/impl/solver/mld_s_diag_solver_apply.f90 b/mlprec/impl/solver/mld_s_diag_solver_apply.f90 deleted file mode 100644 index 4aab61c1..00000000 --- a/mlprec/impl/solver/mld_s_diag_solver_apply.f90 +++ /dev/null @@ -1,240 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_diag_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - - use psb_base_mod - use mld_s_diag_solver, mld_protect_name => mld_s_diag_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_diag_solver_type), intent(inout) :: sv - real(psb_spk_), intent(inout) :: x(:) - real(psb_spk_), intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col - real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='s_diag_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (trans_ == 'C') then - if (beta == szero) then - - if (alpha == szero) then - y(1:n_row) = szero - else if (alpha == sone) then - do i=1, n_row - y(i) = (sv%d(i)) * x(i) - end do - else if (alpha == -sone) then - do i=1, n_row - y(i) = -(sv%d(i)) * x(i) - end do - else - do i=1, n_row - y(i) = alpha * (sv%d(i)) * x(i) - end do - end if - - else if (beta == sone) then - - if (alpha == szero) then - !y(1:n_row) = szero - else if (alpha == sone) then - do i=1, n_row - y(i) = (sv%d(i)) * x(i) + y(i) - end do - else if (alpha == -sone) then - do i=1, n_row - y(i) = -(sv%d(i)) * x(i) + y(i) - end do - else - do i=1, n_row - y(i) = alpha * (sv%d(i)) * x(i) + y(i) - end do - end if - - else if (beta == -sone) then - - if (alpha == szero) then - y(1:n_row) = -y(1:n_row) - else if (alpha == sone) then - do i=1, n_row - y(i) = (sv%d(i)) * x(i) - y(i) - end do - else if (alpha == -sone) then - do i=1, n_row - y(i) = -(sv%d(i)) * x(i) - y(i) - end do - else - do i=1, n_row - y(i) = alpha * (sv%d(i)) * x(i) - y(i) - end do - end if - - else - - if (alpha == szero) then - y(1:n_row) = beta *y(1:n_row) - else if (alpha == sone) then - do i=1, n_row - y(i) = (sv%d(i)) * x(i) + beta*y(i) - end do - else if (alpha == -sone) then - do i=1, n_row - y(i) = -(sv%d(i)) * x(i) + beta*y(i) - end do - else - do i=1, n_row - y(i) = alpha * (sv%d(i)) * x(i) + beta*y(i) - end do - end if - - end if - - else if (trans_ /= 'C') then - - if (beta == szero) then - - if (alpha == szero) then - y(1:n_row) = szero - else if (alpha == sone) then - do i=1, n_row - y(i) = sv%d(i) * x(i) - end do - else if (alpha == -sone) then - do i=1, n_row - y(i) = -sv%d(i) * x(i) - end do - else - do i=1, n_row - y(i) = alpha * sv%d(i) * x(i) - end do - end if - - else if (beta == sone) then - - if (alpha == szero) then - !y(1:n_row) = szero - else if (alpha == sone) then - do i=1, n_row - y(i) = sv%d(i) * x(i) + y(i) - end do - else if (alpha == -sone) then - do i=1, n_row - y(i) = -sv%d(i) * x(i) + y(i) - end do - else - do i=1, n_row - y(i) = alpha * sv%d(i) * x(i) + y(i) - end do - end if - - else if (beta == -sone) then - - if (alpha == szero) then - y(1:n_row) = -y(1:n_row) - else if (alpha == sone) then - do i=1, n_row - y(i) = sv%d(i) * x(i) - y(i) - end do - else if (alpha == -sone) then - do i=1, n_row - y(i) = -sv%d(i) * x(i) - y(i) - end do - else - do i=1, n_row - y(i) = alpha * sv%d(i) * x(i) - y(i) - end do - end if - - else - - if (alpha == szero) then - y(1:n_row) = beta *y(1:n_row) - else if (alpha == sone) then - do i=1, n_row - y(i) = sv%d(i) * x(i) + beta*y(i) - end do - else if (alpha == -sone) then - do i=1, n_row - y(i) = -sv%d(i) * x(i) + beta*y(i) - end do - else - do i=1, n_row - y(i) = alpha * sv%d(i) * x(i) + beta*y(i) - end do - end if - - end if - - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_diag_solver_apply diff --git a/mlprec/impl/solver/mld_s_diag_solver_apply_vect.f90 b/mlprec/impl/solver/mld_s_diag_solver_apply_vect.f90 deleted file mode 100644 index 2e28ccfd..00000000 --- a/mlprec/impl/solver/mld_s_diag_solver_apply_vect.f90 +++ /dev/null @@ -1,117 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_diag_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_s_diag_solver, mld_protect_name => mld_s_diag_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_diag_solver_type), intent(inout) :: sv - type(psb_s_vect_type), intent(inout) :: x - type(psb_s_vect_type), intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col - real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='s_diag_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - if (x%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/itwo,n_row,izero,izero,izero/)) - goto 9999 - end if - if (y%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/ithree,n_row,izero,izero,izero/)) - goto 9999 - end if - if (.not.allocated(sv%dv)) then - info = 1124 - call psb_errpush(info,name,a_err="preconditioner: D") - goto 9999 - end if - if (sv%dv%get_nrows() < n_row) then - info = 1124 - call psb_errpush(info,name,a_err="preconditioner: D") - goto 9999 - end if - - call y%mlt(alpha,sv%dv,x,beta,info,conjgx=trans_) - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='vect%mlt') - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_diag_solver_apply_vect diff --git a/mlprec/impl/solver/mld_s_diag_solver_bld.f90 b/mlprec/impl/solver/mld_s_diag_solver_bld.f90 deleted file mode 100644 index b2fca56b..00000000 --- a/mlprec/impl/solver/mld_s_diag_solver_bld.f90 +++ /dev/null @@ -1,191 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_s_diag_solver, mld_protect_name => mld_s_diag_solver_bld - - Implicit None - - ! Arguments - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type), intent(in), target, optional :: b - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - real(psb_spk_), allocatable :: tdb(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='s_diag_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - nrow_a = a%get_nrows() - - sv%d = a%get_diag(info) - if (info == psb_success_) call psb_realloc(n_row,sv%d,info) - if (present(b)) then - tdb=b%get_diag(info) - if (size(tdb)+nrow_a > n_row) call psb_realloc(nrow_a+size(tdb),sv%d,info) - if (info == psb_success_) sv%d(nrow_a+1:nrow_a+size(tdb)) = tdb(:) - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='get_diag') - goto 9999 - end if - - do i=1,n_row - if (sv%d(i) == szero) then - sv%d(i) = sone - else - sv%d(i) = sone/sv%d(i) - end if - end do - allocate(sv%dv,stat=info) - if (info == psb_success_) then - call sv%dv%bld(sv%d) - if (present(vmold)) call sv%dv%cnv(vmold) - call sv%dv%sync() - else - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='Allocate sv%dv') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_diag_solver_bld - - -subroutine mld_s_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_s_l1_diag_solver, mld_protect_name => mld_s_l1_diag_solver_bld - - Implicit None - - ! Arguments - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_l1_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type), intent(in), target, optional :: b - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - real(psb_spk_), allocatable :: tdb(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='s_l1_diag_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - nrow_a = a%get_nrows() - - sv%d = a%arwsum(info) - if (info == psb_success_) call psb_realloc(n_row,sv%d,info) - if (present(b)) then - tdb=b%arwsum(info) - if (size(tdb)+nrow_a > n_row) call psb_realloc(nrow_a+size(tdb),sv%d,info) - if (info == psb_success_) sv%d(nrow_a+1:nrow_a+size(tdb)) = tdb(:) - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='arwsum') - goto 9999 - end if - - do i=1,n_row - if (sv%d(i) == szero) then - sv%d(i) = sone - else - sv%d(i) = sone/sv%d(i) - end if - end do - allocate(sv%dv,stat=info) - if (info == psb_success_) then - call sv%dv%bld(sv%d) - if (present(vmold)) call sv%dv%cnv(vmold) - call sv%dv%sync() - else - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='Allocate sv%dv') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_l1_diag_solver_bld diff --git a/mlprec/impl/solver/mld_s_diag_solver_clear_data.f90 b/mlprec/impl/solver/mld_s_diag_solver_clear_data.f90 deleted file mode 100644 index 83d0c6ac..00000000 --- a/mlprec/impl/solver/mld_s_diag_solver_clear_data.f90 +++ /dev/null @@ -1,65 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_diag_solver_clear_data(sv,info) - - use psb_base_mod - use mld_s_diag_solver, mld_protect_name => mld_s_diag_solver_clear_data - - Implicit None - - ! Arguments - class(mld_s_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - call sv%dv%free(info) - if ((info ==0).and.allocated(sv%d)) deallocate(sv%d,stat=info) - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_diag_solver_clear_data diff --git a/mlprec/impl/solver/mld_s_diag_solver_clone.f90 b/mlprec/impl/solver/mld_s_diag_solver_clone.f90 deleted file mode 100644 index c40b7fbc..00000000 --- a/mlprec/impl/solver/mld_s_diag_solver_clone.f90 +++ /dev/null @@ -1,83 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_diag_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_s_diag_solver, mld_protect_name => mld_s_diag_solver_clone - - Implicit None - - ! Arguments - class(mld_s_diag_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(svout)) then - call svout%free(info) - if (info == psb_success_) deallocate(svout, stat=info) - end if - if (info == psb_success_) & - & allocate(svout, mold=sv, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(svo => svout) - class is (mld_s_diag_solver_type) - call psb_safe_ab_cpy(sv%d,svo%d,info) - if (info == psb_success_) & - & call sv%dv%clone(svo%dv,info) - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_diag_solver_clone diff --git a/mlprec/impl/solver/mld_s_diag_solver_cnv.f90 b/mlprec/impl/solver/mld_s_diag_solver_cnv.f90 deleted file mode 100644 index fc4ff623..00000000 --- a/mlprec/impl/solver/mld_s_diag_solver_cnv.f90 +++ /dev/null @@ -1,76 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_diag_solver_cnv(sv,info,amold,vmold,imold) - - use psb_base_mod - use mld_s_diag_solver, mld_protect_name => mld_s_diag_solver_cnv - - Implicit None - - ! Arguments - class(mld_s_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: err_act, debug_unit, debug_level - character(len=20) :: name='d_diag_solver_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) trim(name),' start' - - - if (allocated(sv%dv)) then - call sv%dv%cnv(vmold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_s_diag_solver_cnv diff --git a/mlprec/impl/solver/mld_s_diag_solver_dmp.f90 b/mlprec/impl/solver/mld_s_diag_solver_dmp.f90 deleted file mode 100644 index d6143349..00000000 --- a/mlprec/impl/solver/mld_s_diag_solver_dmp.f90 +++ /dev/null @@ -1,133 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_s_diag_solver, mld_protect_name => mld_s_diag_solver_dmp - implicit none - class(mld_s_diag_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: solver_ - ! len of prefix_ - - info = 0 - - ictxt = desc%get_context() - - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - - if (solver_) then - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_s" - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' - if (allocated(sv%d)) & - & call psb_geprt(fname,sv%d,head=head) - - end if - -end subroutine mld_s_diag_solver_dmp -subroutine mld_s_l1_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_s_l1_diag_solver, mld_protect_name => mld_s_l1_diag_solver_dmp - implicit none - class(mld_s_l1_diag_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: solver_ - ! len of prefix_ - - info = 0 - - ictxt = desc%get_context() - - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - - if (solver_) then - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_s" - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_l1_diag.mtx' - if (allocated(sv%d)) & - & call psb_geprt(fname,sv%d,head=head) - - end if - -end subroutine mld_s_l1_diag_solver_dmp diff --git a/mlprec/impl/solver/mld_s_gs_solver_apply.f90 b/mlprec/impl/solver/mld_s_gs_solver_apply.f90 deleted file mode 100644 index 0148d03c..00000000 --- a/mlprec/impl/solver/mld_s_gs_solver_apply.f90 +++ /dev/null @@ -1,216 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_gs_solver_apply(alpha,sv,x,beta,y,desc_data,& - &trans,work,info,init,initu) - - use psb_base_mod - use mld_s_gs_solver, mld_protect_name => mld_s_gs_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_gs_solver_type), intent(inout) :: sv - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col, itx, itxst - real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - real(psb_spk_), allocatable :: temp(:),wv(:),xit(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='s_gs_solver_apply' - - call psb_erractionsave(err_act) - ictxt = desc_data%get_ctxt() - call psb_info(ictxt,me,np) - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') -!!$ case('T') -!!$ case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - - call psb_geasb(wv,desc_data,info) - call psb_geasb(xit,desc_data,info) - itxst = 1 - select case (init_) - case('Z') - call psb_geaxpby(sone,x,szero,wv,desc_data,info) - call psb_spsm(sone,sv%l,wv,szero,xit,desc_data,info) - itxst = 2 - case('Y') - call psb_geaxpby(sone,y,szero,xit,desc_data,info) - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(sone,initu,szero,xit,desc_data,info) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - select case(trans_) - case('N') - if (sv%eps <=szero) then - ! - ! Fixed number of iterations - ! - ! - do itx=itxst,sv%sweeps - call psb_geaxpby(sone,x,szero,wv,desc_data,info) - ! Update with U. The off-diagonal block is taken care - ! from the Jacobi smoother, hence this is purely local. - call psb_spmm(-sone,sv%u,xit,sone,wv,desc_data,info,doswap=.false.) - call psb_spsm(sone,sv%l,wv,szero,xit,desc_data,info) - end do - - call psb_geaxpby(alpha,xit,beta,y,desc_data,info) - - else - ! - ! Iterations to convergence, not implemented right now. - ! - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') - goto 9999 - - end if -!!$ case('T') -!!$ call psb_spsm(sone,sv%u,x,szero,wv,desc_data,info,& -!!$ & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) -!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) -!!$ -!!$ case('C') -!!$ -!!$ call psb_spsm(sone,sv%u,x,szero,wv,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) -!!$ -!!$ call wv1%mlt(sone,sv%dv,wv,szero,info,conjgx=trans_) -!!$ -!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv1,beta,y,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid TRANS in GS subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_gs_solver_apply diff --git a/mlprec/impl/solver/mld_s_gs_solver_apply_vect.f90 b/mlprec/impl/solver/mld_s_gs_solver_apply_vect.f90 deleted file mode 100644 index a52d4edf..00000000 --- a/mlprec/impl/solver/mld_s_gs_solver_apply_vect.f90 +++ /dev/null @@ -1,211 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_gs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_s_gs_solver, mld_protect_name => mld_s_gs_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_gs_solver_type), intent(inout) :: sv - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col, itx, itxst - real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - real(psb_spk_), allocatable :: temp(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='s_gs_solver_apply' - - call psb_erractionsave(err_act) - ictxt = desc_data%get_ctxt() - call psb_info(ictxt,me,np) - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') -!!$ case('T') -!!$ case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - - if (x%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/itwo,n_row,izero,izero,izero/)) - goto 9999 - end if - if (y%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/ithree,n_row,izero,izero,izero/)) - goto 9999 - end if - - - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - - if (size(wv) < 2) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size') - goto 9999 - end if - - associate(tw => wv(1), xit => wv(2)) - itxst = 1 - select case (init_) - case('Z') - call psb_geaxpby(sone,x,szero,tw,desc_data,info) - call psb_spsm(sone,sv%l,tw,szero,xit,desc_data,info) - itxst = 2 - case('Y') - call psb_geaxpby(sone,y,szero,xit,desc_data,info) - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(sone,initu,szero,xit,desc_data,info) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - select case(trans_) - case('N') - if (sv%eps <=szero) then - ! - ! Fixed number of iterations - ! - ! - do itx=itxst,sv%sweeps - call psb_geaxpby(sone,x,szero,tw,desc_data,info) - ! Update with U. The off-diagonal block is taken care - ! from the Jacobi smoother, hence this is purely local. - call psb_spmm(-sone,sv%u,xit,sone,tw,desc_data,info,doswap=.false.) - call psb_spsm(sone,sv%l,tw,szero,xit,desc_data,info) - end do - - call psb_geaxpby(alpha,xit,beta,y,desc_data,info) - - else - ! - ! Iterations to convergence, not implemented right now. - ! - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') - goto 9999 - - end if - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid TRANS in GS subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - end associate - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_gs_solver_apply_vect diff --git a/mlprec/impl/solver/mld_s_gs_solver_bld.f90 b/mlprec/impl/solver/mld_s_gs_solver_bld.f90 deleted file mode 100644 index d6e07ac0..00000000 --- a/mlprec/impl/solver/mld_s_gs_solver_bld.f90 +++ /dev/null @@ -1,109 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_gs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_s_gs_solver, mld_protect_name => mld_s_gs_solver_bld - - Implicit None - - ! Arguments - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type), intent(in), target, optional :: b - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='s_gs_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - - if (sv%eps <= dzero) then - ! - ! This cuts out the off-diagonal part, because it's supposed to - ! be handled by the outer Jacobi smoother. - ! - call a%tril(sv%l,info,diag=izero,jmax=nrow_a,u=sv%u) - - else - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end if - - - - call sv%l%set_asb() - call sv%l%trim() - call sv%u%set_asb() - call sv%u%trim() - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_gs_solver_bld diff --git a/mlprec/impl/solver/mld_s_gs_solver_clear_data.f90 b/mlprec/impl/solver/mld_s_gs_solver_clear_data.f90 deleted file mode 100644 index a2f5cf95..00000000 --- a/mlprec/impl/solver/mld_s_gs_solver_clear_data.f90 +++ /dev/null @@ -1,65 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_gs_solver_clear_data(sv,info) - - use psb_base_mod - use mld_s_gs_solver, mld_protect_name => mld_s_gs_solver_clear_data - - Implicit None - - ! Arguments - class(mld_s_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - call sv%l%free() - call sv%u%free() - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_gs_solver_clear_data diff --git a/mlprec/impl/solver/mld_s_gs_solver_clone.f90 b/mlprec/impl/solver/mld_s_gs_solver_clone.f90 deleted file mode 100644 index 3aa18c4d..00000000 --- a/mlprec/impl/solver/mld_s_gs_solver_clone.f90 +++ /dev/null @@ -1,87 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_gs_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_s_gs_solver, mld_protect_name => mld_s_gs_solver_clone - - Implicit None - - ! Arguments - class(mld_s_gs_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - if (allocated(svout)) then - call svout%free(info) - if (info == psb_success_) deallocate(svout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_s_gs_solver_type :: svout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(svo => svout) - type is (mld_s_gs_solver_type) - svo%sweeps = sv%sweeps - svo%eps = sv%eps - if (info == psb_success_) & - & call sv%l%clone(svo%l,info) - if (info == psb_success_) & - & call sv%u%clone(svo%u,info) - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_gs_solver_clone diff --git a/mlprec/impl/solver/mld_s_gs_solver_clone_settings.f90 b/mlprec/impl/solver/mld_s_gs_solver_clone_settings.f90 deleted file mode 100644 index e9d4dfd5..00000000 --- a/mlprec/impl/solver/mld_s_gs_solver_clone_settings.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_gs_solver_clone_settings(sv,svout,info) - - use psb_base_mod - use mld_s_gs_solver, mld_protect_name => mld_s_gs_solver_clone_settings - Implicit None - ! Arguments - class(mld_s_gs_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_gs_solver_clone_settings' - - call psb_erractionsave(err_act) - - select type(svout) - class is(mld_s_gs_solver_type) - svout%sweeps = sv%sweeps - svout%eps = sv%eps - - class default - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_gs_solver_clone_settings diff --git a/mlprec/impl/solver/mld_s_gs_solver_cnv.f90 b/mlprec/impl/solver/mld_s_gs_solver_cnv.f90 deleted file mode 100644 index 7e67b973..00000000 --- a/mlprec/impl/solver/mld_s_gs_solver_cnv.f90 +++ /dev/null @@ -1,74 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_gs_solver_cnv(sv,info,amold,vmold,imold) - - use psb_base_mod - use mld_s_gs_solver, mld_protect_name => mld_s_gs_solver_cnv - - Implicit None - - ! Arguments - class(mld_s_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: err_act, debug_unit, debug_level - character(len=20) :: name='s_gs_solver_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_gs_solver_cnv diff --git a/mlprec/impl/solver/mld_s_gs_solver_dmp.f90 b/mlprec/impl/solver/mld_s_gs_solver_dmp.f90 deleted file mode 100644 index 911d0104..00000000 --- a/mlprec/impl/solver/mld_s_gs_solver_dmp.f90 +++ /dev/null @@ -1,102 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_gs_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_s_gs_solver, mld_protect_name => mld_s_gs_solver_dmp - implicit none - class(mld_s_gs_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - integer(psb_lpk_), allocatable :: iv(:) - logical :: solver_, global_num_ - ! len of prefix_ - - info = 0 - - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - - if (solver_) then - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_d" - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - if (global_num_) then - iv = desc%get_global_indices(owned=.false.) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' - if (sv%l%is_asb()) & - & call sv%l%print(fname,head=head,iv=iv) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' - if (sv%u%is_asb()) & - & call sv%u%print(fname,head=head,iv=iv) - else - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' - if (sv%l%is_asb()) & - & call sv%l%print(fname,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' - if (sv%u%is_asb()) & - & call sv%u%print(fname,head=head) - end if - end if - -end subroutine mld_s_gs_solver_dmp diff --git a/mlprec/impl/solver/mld_s_id_solver_apply.f90 b/mlprec/impl/solver/mld_s_id_solver_apply.f90 deleted file mode 100644 index b7614844..00000000 --- a/mlprec/impl/solver/mld_s_id_solver_apply.f90 +++ /dev/null @@ -1,86 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_id_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - - use psb_base_mod - use mld_s_id_solver, mld_protect_name => mld_s_id_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_id_solver_type), intent(inout) :: sv - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='s_id_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call psb_geaxpby(alpha,x,beta,y,desc_data,info) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_id_solver_apply diff --git a/mlprec/impl/solver/mld_s_id_solver_apply_vect.f90 b/mlprec/impl/solver/mld_s_id_solver_apply_vect.f90 deleted file mode 100644 index 00b56862..00000000 --- a/mlprec/impl/solver/mld_s_id_solver_apply_vect.f90 +++ /dev/null @@ -1,87 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_id_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_s_id_solver, mld_protect_name => mld_s_id_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_id_solver_type), intent(inout) :: sv - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='s_id_solver_apply_vect' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call psb_geaxpby(alpha,x,beta,y,desc_data,info) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_id_solver_apply_vect diff --git a/mlprec/impl/solver/mld_s_id_solver_clone.f90 b/mlprec/impl/solver/mld_s_id_solver_clone.f90 deleted file mode 100644 index 8cc886a6..00000000 --- a/mlprec/impl/solver/mld_s_id_solver_clone.f90 +++ /dev/null @@ -1,81 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_id_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_s_id_solver, mld_protect_name => mld_s_id_solver_clone - - Implicit None - - ! Arguments - class(mld_s_id_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(svout)) then - call svout%free(info) - if (info == psb_success_) deallocate(svout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_s_id_solver_type :: svout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(svo => svout) - type is (mld_s_id_solver_type) - ! Nothing to be done. - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_id_solver_clone diff --git a/mlprec/impl/solver/mld_s_ilu_solver_apply.f90 b/mlprec/impl/solver/mld_s_ilu_solver_apply.f90 deleted file mode 100644 index 3e33c108..00000000 --- a/mlprec/impl/solver/mld_s_ilu_solver_apply.f90 +++ /dev/null @@ -1,153 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - - use psb_base_mod - use mld_s_ilu_solver, mld_protect_name => mld_s_ilu_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_ilu_solver_type), intent(inout) :: sv - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col - real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='s_ilu_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - endif - - select case(trans_) - case('N') - call psb_spsm(sone,sv%l,x,szero,ww,desc_data,info,& - & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) - - if (info == psb_success_) call psb_spsm(alpha,sv%u,ww,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_, work=aux) - - case('T') - call psb_spsm(sone,sv%u,x,szero,ww,desc_data,info,& - & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) - if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - case('C') - call psb_spsm(sone,sv%u,x,szero,ww,desc_data,info,& - & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) - if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid TRANS in ILU subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_ilu_solver_apply diff --git a/mlprec/impl/solver/mld_s_ilu_solver_apply_vect.f90 b/mlprec/impl/solver/mld_s_ilu_solver_apply_vect.f90 deleted file mode 100644 index fb320a8d..00000000 --- a/mlprec/impl/solver/mld_s_ilu_solver_apply_vect.f90 +++ /dev/null @@ -1,194 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_s_ilu_solver, mld_protect_name => mld_s_ilu_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_ilu_solver_type), intent(inout) :: sv - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col - type(psb_s_vect_type) :: tw, tw1 - real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='s_ilu_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - - if (x%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/itwo,n_row,izero,izero,izero/)) - goto 9999 - end if - if (y%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/ithree,n_row,izero,izero,izero/)) - goto 9999 - end if - if (.not.allocated(sv%dv%v)) then - info = 1124 - call psb_errpush(info,name,a_err="preconditioner: D") - goto 9999 - end if - if (sv%dv%get_nrows() < n_row) then - info = 1124 - call psb_errpush(info,name,a_err="preconditioner: DV") - goto 9999 - end if - - - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - - - if (size(wv) < 2) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size') - goto 9999 - end if - - - associate(tw => wv(1), tw1 => wv(2)) - - select case(trans_) - case('N') - call psb_spsm(sone,sv%l,x,szero,tw,desc_data,info,& - & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) - - if (info == psb_success_) call psb_spsm(alpha,sv%u,tw,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_, work=aux) - - case('T') - call psb_spsm(sone,sv%u,x,szero,tw,desc_data,info,& - & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) - if (info == psb_success_) call psb_spsm(alpha,sv%l,tw,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - - case('C') - - call psb_spsm(sone,sv%u,x,szero,tw,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - - call tw1%mlt(sone,sv%dv,tw,szero,info,conjgx=trans_) - - if (info == psb_success_) call psb_spsm(alpha,sv%l,tw1,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid TRANS in ILU subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - end associate - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_s_ilu_solver_apply_vect diff --git a/mlprec/impl/solver/mld_s_ilu_solver_bld.f90 b/mlprec/impl/solver/mld_s_ilu_solver_bld.f90 deleted file mode 100644 index 9094445f..00000000 --- a/mlprec/impl/solver/mld_s_ilu_solver_bld.f90 +++ /dev/null @@ -1,191 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_ilu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_s_ilu_solver, mld_protect_name => mld_s_ilu_solver_bld - - Implicit None - - ! Arguments - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type), intent(in), target, optional :: b - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota -!!$ real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='s_ilu_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - if (present(b)) then - nztota = nztota + b%get_nzeros() - end if - - call sv%l%csall(n_row,n_row,info,nztota) - if (info == psb_success_) call sv%u%csall(n_row,n_row,info,nztota) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_sp_all' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if (allocated(sv%d)) then - if (size(sv%d) < n_row) then - deallocate(sv%d) - endif - endif - if (.not.allocated(sv%d)) allocate(sv%d(n_row),stat=info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') - goto 9999 - endif - - - select case(sv%fact_type) - - case (psb_ilu_t_) - ! - ! ILU(k,t) - ! - select case(sv%fill_in) - - case(:-1) - ! Error: fill-in <= -1 - call psb_errpush(psb_err_input_value_invalid_i_,& - & name,i_err=(/ithree,sv%fill_in,izero,izero,izero/)) - goto 9999 - - case(0:) - ! Fill-in >= 0 - call psb_ilut_fact(sv%fill_in,sv%thresh,& - & a, sv%l,sv%u,sv%d,info,blck=b) - end select - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ilut_fact' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - case(psb_ilu_n_,psb_milu_n_) - ! - ! ILU(k) and MILU(k) - ! - select case(sv%fill_in) - case(:-1) - ! Error: fill-in <= -1 - call psb_errpush(psb_err_input_value_invalid_i_,& - & name,i_err=(/ithree,sv%fill_in,izero,izero,izero/)) - goto 9999 - case(0) - ! Fill-in 0 - ! Separate implementation of ILU(0) for better performance. - ! There seems to be a problem with the separate implementation of MILU(0), - ! contained into psb_ilu0_fact. This must be investigated. For the time being, - ! resort to the implementation of MILU(k) with k=0. - if (sv%fact_type == psb_ilu_n_) then - call psb_ilu0_fact(sv%fact_type,a,sv%l,sv%u,& - & sv%d,info,blck=b) - else - call psb_iluk_fact(sv%fill_in,sv%fact_type,& - & a,sv%l,sv%u,sv%d,info,blck=b) - endif - case(1:) - ! Fill-in >= 1 - ! The same routine implements both ILU(k) and MILU(k) - call psb_iluk_fact(sv%fill_in,sv%fact_type,& - & a,sv%l,sv%u,sv%d,info,blck=b) - end select - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_iluk_fact' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - case default - ! If we end up here, something was wrong up in the call chain. - info = psb_err_input_value_invalid_i_ - call psb_errpush(psb_err_input_value_invalid_i_,name,& - & i_err=(/ithree,sv%fact_type,izero,izero,izero/)) - goto 9999 - - end select - - call sv%l%set_asb() - call sv%l%trim() - call sv%u%set_asb() - call sv%u%trim() - call sv%dv%bld(sv%d,mold=vmold) - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_ilu_solver_bld diff --git a/mlprec/impl/solver/mld_s_ilu_solver_clear_data.f90 b/mlprec/impl/solver/mld_s_ilu_solver_clear_data.f90 deleted file mode 100644 index 19f43c0e..00000000 --- a/mlprec/impl/solver/mld_s_ilu_solver_clear_data.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_ilu_solver_clear_data(sv,info) - - use psb_base_mod - use mld_s_ilu_solver, mld_protect_name => mld_s_ilu_solver_clear_data - - Implicit None - - ! Arguments - class(mld_s_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - call sv%l%free() - call sv%u%free() - call sv%dv%free(info) - if ((info==0).and.allocated(sv%d)) deallocate(sv%d,stat=info) - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_ilu_solver_clear_data diff --git a/mlprec/impl/solver/mld_s_ilu_solver_clone.f90 b/mlprec/impl/solver/mld_s_ilu_solver_clone.f90 deleted file mode 100644 index 2c742b74..00000000 --- a/mlprec/impl/solver/mld_s_ilu_solver_clone.f90 +++ /dev/null @@ -1,91 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_ilu_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_s_ilu_solver, mld_protect_name => mld_s_ilu_solver_clone - - Implicit None - - ! Arguments - class(mld_s_ilu_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - if (allocated(svout)) then - call svout%free(info) - if (info == psb_success_) deallocate(svout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_s_ilu_solver_type :: svout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(svo => svout) - type is (mld_s_ilu_solver_type) - svo%fact_type = sv%fact_type - svo%fill_in = sv%fill_in - svo%thresh = sv%thresh - call psb_safe_ab_cpy(sv%d,svo%d,info) - if (info == psb_success_) & - & call sv%dv%clone(svo%dv,info) - if (info == psb_success_) & - & call sv%l%clone(svo%l,info) - if (info == psb_success_) & - & call sv%u%clone(svo%u,info) - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_ilu_solver_clone diff --git a/mlprec/impl/solver/mld_s_ilu_solver_clone_settings.f90 b/mlprec/impl/solver/mld_s_ilu_solver_clone_settings.f90 deleted file mode 100644 index c918bde7..00000000 --- a/mlprec/impl/solver/mld_s_ilu_solver_clone_settings.f90 +++ /dev/null @@ -1,70 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_ilu_solver_clone_settings(sv,svout,info) - - use psb_base_mod - use mld_s_ilu_solver, mld_protect_name => mld_s_ilu_solver_clone_settings - Implicit None - ! Arguments - class(mld_s_ilu_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_ilu_solver_clone_settings' - - call psb_erractionsave(err_act) - - select type(svout) - class is(mld_s_ilu_solver_type) - svout%fact_type = sv%fact_type - svout%fill_in = sv%fill_in - svout%thresh = sv%thresh - - class default - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_ilu_solver_clone_settings diff --git a/mlprec/impl/solver/mld_s_ilu_solver_cnv.f90 b/mlprec/impl/solver/mld_s_ilu_solver_cnv.f90 deleted file mode 100644 index eb55738f..00000000 --- a/mlprec/impl/solver/mld_s_ilu_solver_cnv.f90 +++ /dev/null @@ -1,76 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_ilu_solver_cnv(sv,info,amold,vmold,imold) - - use psb_base_mod - use mld_s_ilu_solver, mld_protect_name => mld_s_ilu_solver_cnv - - Implicit None - - ! Arguments - class(mld_s_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: err_act, debug_unit, debug_level - character(len=20) :: name='d_ilu_solver_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - call sv%dv%cnv(mold=vmold) - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_s_ilu_solver_cnv diff --git a/mlprec/impl/solver/mld_s_ilu_solver_dmp.f90 b/mlprec/impl/solver/mld_s_ilu_solver_dmp.f90 deleted file mode 100644 index f388bbc5..00000000 --- a/mlprec/impl/solver/mld_s_ilu_solver_dmp.f90 +++ /dev/null @@ -1,112 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_s_ilu_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_s_ilu_solver, mld_protect_name => mld_s_ilu_solver_dmp - implicit none - class(mld_s_ilu_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: solver_, global_num_ - integer(psb_lpk_), allocatable :: iv(:) - ! len of prefix_ - - info = 0 - - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - - - if (solver_) then - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_s" - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - if (global_num_) then - iv = desc%get_global_indices(owned=.false.) - - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' - if (sv%l%is_asb()) & - & call sv%l%print(fname,head=head,iv=iv) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' - if (allocated(sv%d)) & - & call psb_geprt(fname,sv%d,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' - if (sv%u%is_asb()) & - & call sv%u%print(fname,head=head,iv=iv) - - else - - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' - if (sv%l%is_asb()) & - & call sv%l%print(fname,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' - if (allocated(sv%d)) & - & call psb_geprt(fname,sv%d,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' - if (sv%u%is_asb()) & - & call sv%u%print(fname,head=head) - end if - end if - -end subroutine mld_s_ilu_solver_dmp diff --git a/mlprec/impl/solver/mld_s_mumps_solver_apply.F90 b/mlprec/impl/solver/mld_s_mumps_solver_apply.F90 deleted file mode 100644 index 8870dbe4..00000000 --- a/mlprec/impl/solver/mld_s_mumps_solver_apply.F90 +++ /dev/null @@ -1,169 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.0) -! -! (C) Copyright 2008,2009,2010,2012,2013 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -subroutine s_mumps_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - use psb_base_mod - use mld_s_mumps_solver - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_mumps_solver_type), intent(inout) :: sv - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row, n_col - integer(psb_lpk_) :: nglob - integer(psb_epk_) :: eng - real(psb_spk_), allocatable :: ww(:) - real(psb_spk_), allocatable, target :: gx(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='s_mumps_solver_apply' - - call psb_erractionsave(err_act) - -#if defined(HAVE_MUMPS_) - info = psb_success_ - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - nglob = desc_data%get_global_rows() - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - ! Running in local mode? - if (sv%ipar(1) == mld_local_solver_ ) then - gx = x - else if (sv%ipar(1) == mld_global_solver_ ) then - - if (n_col <= size(work)) then - ww = work(1:n_col) - else - allocate(ww(n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/n_col/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - end if - allocate(gx(nglob),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_; eng = nglob - call psb_errpush(info,name,e_err=(/eng/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - call psb_gather(gx, x, desc_data, info, root=izero) - else - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid local/global solver in MUMPS') - goto 9999 - end if - - select case(trans_) - case('N') - sv%id%icntl(9) = 1 - case('T') - sv%id%icntl(9) = 2 - case default - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Invalid TRANS in subsolve') - goto 9999 - end select - - sv%id%rhs => gx - sv%id%nrhs = 1 - sv%id%icntl(1)=-1 - sv%id%icntl(2)=-1 - sv%id%icntl(3)=-1 - sv%id%icntl(4)=-1 - sv%id%job = 3 - call smumps(sv%id) - if (sv%ipar(1) == mld_local_solver_ ) then - call psb_geaxpby(alpha,gx,beta,y,desc_data,info) - else - call psb_scatter(gx, ww, desc_data, info, root=izero) - if (info == psb_success_) then - call psb_geaxpby(alpha,ww,beta,y,desc_data,info) - end if - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in subsolve') - goto 9999 - endif - - if (allocated(ww)) deallocate(ww) - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return - -#else - write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " -#endif -end subroutine s_mumps_solver_apply - diff --git a/mlprec/impl/solver/mld_s_mumps_solver_apply_vect.F90 b/mlprec/impl/solver/mld_s_mumps_solver_apply_vect.F90 deleted file mode 100644 index 6c50c81e..00000000 --- a/mlprec/impl/solver/mld_s_mumps_solver_apply_vect.F90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.0) -! -! (C) Copyright 2008,2009,2010,2012,2013 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -subroutine s_mumps_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - use psb_base_mod - use mld_s_mumps_solver - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_mumps_solver_type), intent(inout) :: sv - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_mumps_solver_apply_vect' - -#if defined(HAVE_MUMPS_) - - call psb_erractionsave(err_act) - - info = psb_success_ - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call x%v%sync() - call y%v%sync() - call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) - call y%v%set_host() - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return - -#else - write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " -#endif - -end subroutine s_mumps_solver_apply_vect - diff --git a/mlprec/impl/solver/mld_s_mumps_solver_bld.F90 b/mlprec/impl/solver/mld_s_mumps_solver_bld.F90 deleted file mode 100644 index f1c7ebc3..00000000 --- a/mlprec/impl/solver/mld_s_mumps_solver_bld.F90 +++ /dev/null @@ -1,262 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.0) -! -! (C) Copyright 2008,2009,2010,2012,2013 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -subroutine s_mumps_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_s_mumps_solver - Implicit None - - ! Arguments - type(psb_sspmat_type) :: c - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type), intent(in), target, optional :: b - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - type(psb_sspmat_type) :: atmp - type(psb_s_coo_sparse_mat), target :: acoo -#if defined(IPK4) && defined(LPK8) - integer(psb_lpk_), allocatable :: gia(:), gja(:) -#endif - integer(psb_ipk_) :: n_row,n_col, nrow_a, nza, npr, npc - integer(psb_lpk_) :: nglob, nglobrec, nzt - integer(psb_ipk_) :: ifrst, ibcheck - integer(psb_ipk_) :: ictxt, ictxt1, icomm, np, iam, me, i, err_act, debug_unit, debug_level - character(len=20) :: name='s_mumps_solver_bld', ch_err - -#if defined(HAVE_MUMPS_) - - info=psb_success_ - - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, iam, np) - if (sv%ipar(1) == mld_local_solver_ ) then - call psb_init(ictxt1,np=1,basectxt=ictxt,ids=(/iam/)) - icomm = psb_get_mpi_comm(ictxt1) - allocate(sv%local_ictxt,stat=info) - sv%local_ictxt = ictxt1 - !write(*,*)iam,'mumps_bld: local +++++>',icomm,sv%local_ictxt - call psb_info(ictxt1, me, np) - npr = np - else if (sv%ipar(1) == mld_global_solver_ ) then - icomm = psb_get_mpi_comm(ictxt) - !write(*,*)iam,'mumps_bld: global +++++>',icomm,ictxt - call psb_info(ictxt, iam, np) - me = iam - npr = np - else - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid local/global solver in MUMPS') - goto 9999 - end if - npc = 1 - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - ! if (allocated(sv%id)) then - ! call sv%free(info) - - ! deallocate(sv%id) - ! end if - if(.not.allocated(sv%id)) then - allocate(sv%id,stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_dealloc_ - call psb_errpush(info,name,a_err='mld_smumps_default') - goto 9999 - end if - end if - - - sv%id%comm = icomm - sv%id%job = -1 - sv%id%par = 1 - if (sv%ipar(3) == 2) then - sv%id%sym = 2 - else - sv%id%sym = 0 - end if - - call smumps(sv%id) - !WARNING: CALLING smumps WITH JOB=-1 DESTROY THE SETTING OF DEFAULT:TO FIX - if (allocated(sv%icntl)) then - do i=1,mld_mumps_icntl_size - if (allocated(sv%icntl(i)%item)) then - !write(0,*) 'MUMPS_BLD: setting entry ',i,' to ', sv%icntl(i)%item - sv%id%icntl(i) = sv%icntl(i)%item - end if - end do - end if - if (allocated(sv%rcntl)) then - do i=1,mld_mumps_rcntl_size - if (allocated(sv%rcntl(i)%item)) sv%id%cntl(i) = sv%rcntl(i)%item - end do - end if - sv%id%icntl(3)=sv%ipar(2) - - nglob = desc_a%get_global_rows() - if (sv%ipar(1) == mld_local_solver_ ) then - nglobrec=desc_a%get_local_rows() - if (sv%ipar(3) == 2) then - ! Always pass the upper triangle to MUMPS - call a%triu(c,info,jmax=a%get_nrows()) - call c%set_symmetric() - else - call a%csclip(c,info,jmax=a%get_nrows()) - end if - call c%cp_to(acoo) - nglob = c%get_nrows() - if (nglobrec /= nglob) then - write(*,*)'WARNING: MUMPS solver does not allow overlap in AS yet. ' - write(*,*)'A zero-overlap is used instead' - end if - else - call a%cp_to(acoo) - end if - nza = acoo%get_nzeros() - - ! switch to global numbering - if (sv%ipar(1) == mld_global_solver_ ) then -#if defined(IPK4) && defined(LPK8) - ! - ! Strategy here is as follows: because a call to MUMPS - ! as a gobal solver is mostly done at the coarsest level, - ! even if we start from a problem requiring 8 bytes, chances - ! are that the global size will be suitable for 4 bytes - ! anyway, so we hope for the best, and throw an error - ! if something goes wrong. - ! - if (nglob > huge(1_psb_ipk_)) then - write(0,*) iam,' ',trim(name),': Error: overflow of local indices ' - info=psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - gia = acoo%ia(1:nza) - gja = acoo%ja(1:nza) - call psb_loc_to_glob(gia(1:nza), desc_a, info, iact='I') - call psb_loc_to_glob(gja(1:nza), desc_a, info, iact='I') - acoo%ia(1:nza) = gia(1:nza) - acoo%ja(1:nza) = gja(1:nza) -#else - ! - ! Here global and local numbers have the same size, so this must work. - ! - call psb_loc_to_glob(acoo%ja(1:nza), desc_a, info, iact='I') - call psb_loc_to_glob(acoo%ia(1:nza), desc_a, info, iact='I') -#endif - if (sv%ipar(3) == 2 ) then - ! Always pass the upper triangle to MUMPS - block - integer(psb_ipk_) :: j,nz - nz = 0 - do j=1,nza - if (acoo%ja(j) >= acoo%ia(j)) then - nz = nz + 1 - acoo%ia(nz) = acoo%ia(j) - acoo%ja(nz) = acoo%ja(j) - acoo%val(nz) = acoo%val(j) - end if - end do - call acoo%set_nzeros(nz) - call acoo%set_triangle() - call acoo%set_upper() - call acoo%set_symmetric() - end block - end if - end if - sv%id%irn_loc => acoo%ia - sv%id%jcn_loc => acoo%ja - sv%id%a_loc => acoo%val - sv%id%icntl(18) = 3 - sv%id%n = nglob - ! there should be a better way for this - sv%id%nnz_loc = acoo%get_nzeros() - sv%id%nnz = acoo%get_nzeros() - sv%id%job = 4 - if (sv%ipar(1) == mld_global_solver_ ) then - call psb_sum(ictxt,sv%id%nnz) - end if - !call psb_barrier(ictxt) - write(*,*)iam, ' calling mumps N,nz,nz_loc',sv%id%n,sv%id%nnz,sv%id%nnz_loc - call smumps(sv%id) - !call psb_barrier(ictxt) - info = sv%id%infog(1) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='mld_smumps_fact ' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - nullify(sv%id%irn) - nullify(sv%id%jcn) - nullify(sv%id%a) - - call acoo%free() - sv%built=.true. - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) iam,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -#else - write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " -#endif -end subroutine s_mumps_solver_bld - diff --git a/mlprec/impl/solver/mld_z_base_solver_apply.f90 b/mlprec/impl/solver/mld_z_base_solver_apply.f90 deleted file mode 100644 index 0c7a0f61..00000000 --- a/mlprec/impl/solver/mld_z_base_solver_apply.f90 +++ /dev/null @@ -1,71 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - - use psb_base_mod - use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_base_solver_type), intent(inout) :: sv - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_base_solver_apply diff --git a/mlprec/impl/solver/mld_z_base_solver_apply_vect.f90 b/mlprec/impl/solver/mld_z_base_solver_apply_vect.f90 deleted file mode 100644 index cc72e07d..00000000 --- a/mlprec/impl/solver/mld_z_base_solver_apply_vect.f90 +++ /dev/null @@ -1,72 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_base_solver_type), intent(inout) :: sv - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_solver_apply_vect' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_base_solver_apply_vect diff --git a/mlprec/impl/solver/mld_z_base_solver_bld.f90 b/mlprec/impl/solver/mld_z_base_solver_bld.f90 deleted file mode 100644 index 15736925..00000000 --- a/mlprec/impl/solver/mld_z_base_solver_bld.f90 +++ /dev/null @@ -1,68 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_bld - Implicit None - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_bld' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_solver_bld diff --git a/mlprec/impl/solver/mld_z_base_solver_check.f90 b/mlprec/impl/solver/mld_z_base_solver_check.f90 deleted file mode 100644 index 1fc6ccd8..00000000 --- a/mlprec/impl/solver/mld_z_base_solver_check.f90 +++ /dev/null @@ -1,61 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_solver_check(sv,info) - - use psb_base_mod - use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_check - Implicit None - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_solver_check diff --git a/mlprec/impl/solver/mld_z_base_solver_clear_data.f90 b/mlprec/impl/solver/mld_z_base_solver_clear_data.f90 deleted file mode 100644 index a28cee5c..00000000 --- a/mlprec/impl/solver/mld_z_base_solver_clear_data.f90 +++ /dev/null @@ -1,60 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_solver_clear_data(sv,info) - - use psb_base_mod - use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_clear_data - Implicit None - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_solver_clear_data' - - call psb_erractionsave(err_act) - info = 0 - - ! Do nothing - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_solver_clear_data diff --git a/mlprec/impl/solver/mld_z_base_solver_clone.f90 b/mlprec/impl/solver/mld_z_base_solver_clone.f90 deleted file mode 100644 index 8c73d112..00000000 --- a/mlprec/impl/solver/mld_z_base_solver_clone.f90 +++ /dev/null @@ -1,62 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_clone - Implicit None - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_solver_clone' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_solver_clone diff --git a/mlprec/impl/solver/mld_z_base_solver_clone_settings.f90 b/mlprec/impl/solver/mld_z_base_solver_clone_settings.f90 deleted file mode 100644 index 34b5dabd..00000000 --- a/mlprec/impl/solver/mld_z_base_solver_clone_settings.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_solver_clone_settings(sv,svout,info) - - use psb_base_mod - use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_clone_settings - Implicit None - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_solver_clone_settings' - - call psb_erractionsave(err_act) - - if (same_type_as(sv,svout)) then - ! Do nothing - else - - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_solver_clone_settings diff --git a/mlprec/impl/solver/mld_z_base_solver_cnv.f90 b/mlprec/impl/solver/mld_z_base_solver_cnv.f90 deleted file mode 100644 index bd62c83d..00000000 --- a/mlprec/impl/solver/mld_z_base_solver_cnv.f90 +++ /dev/null @@ -1,63 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_solver_cnv(sv,info,amold,vmold,imold) - - use psb_base_mod - use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_cnv - Implicit None - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_cnv' - - call psb_erractionsave(err_act) - - info = psb_success_ - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_solver_cnv diff --git a/mlprec/impl/solver/mld_z_base_solver_csetc.f90 b/mlprec/impl/solver/mld_z_base_solver_csetc.f90 deleted file mode 100644 index eb1231f8..00000000 --- a/mlprec/impl/solver/mld_z_base_solver_csetc.f90 +++ /dev/null @@ -1,63 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_solver_csetc(sv,what,val,info,idx) - - use psb_base_mod - use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_csetc - Implicit None - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - Integer(Psb_ipk_) :: err_act, ival - character(len=20) :: name='d_base_solver_csetc' - - call psb_erractionsave(err_act) - - info = psb_success_ - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_solver_csetc diff --git a/mlprec/impl/solver/mld_z_base_solver_cseti.f90 b/mlprec/impl/solver/mld_z_base_solver_cseti.f90 deleted file mode 100644 index 5cf357b8..00000000 --- a/mlprec/impl/solver/mld_z_base_solver_cseti.f90 +++ /dev/null @@ -1,56 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_solver_cseti(sv,what,val,info,idx) - - use psb_base_mod - use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_cseti - Implicit None - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_cseti' - - ! Correct action here is doing nothing. - info = 0 - - return -end subroutine mld_z_base_solver_cseti diff --git a/mlprec/impl/solver/mld_z_base_solver_csetr.f90 b/mlprec/impl/solver/mld_z_base_solver_csetr.f90 deleted file mode 100644 index 193fa789..00000000 --- a/mlprec/impl/solver/mld_z_base_solver_csetr.f90 +++ /dev/null @@ -1,57 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_solver_csetr(sv,what,val,info,idx) - - use psb_base_mod - use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_csetr - Implicit None - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_csetr' - - - ! Correct action here is doing nothing. - info = 0 - - return -end subroutine mld_z_base_solver_csetr diff --git a/mlprec/impl/solver/mld_z_base_solver_descr.f90 b/mlprec/impl/solver/mld_z_base_solver_descr.f90 deleted file mode 100644 index 01050fdd..00000000 --- a/mlprec/impl/solver/mld_z_base_solver_descr.f90 +++ /dev/null @@ -1,66 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_solver_descr(sv,info,iout,coarse) - - use psb_base_mod - use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_descr - Implicit None - ! Arguments - class(mld_z_base_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_z_base_solver_descr' - - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_solver_descr diff --git a/mlprec/impl/solver/mld_z_base_solver_dmp.f90 b/mlprec/impl/solver/mld_z_base_solver_dmp.f90 deleted file mode 100644 index 1d54ee84..00000000 --- a/mlprec/impl/solver/mld_z_base_solver_dmp.f90 +++ /dev/null @@ -1,78 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_dmp - implicit none - class(mld_z_base_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: solver_ - ! len of prefix_ - - info = 0 - - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_z" - end if - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - ! At base level do nothing for the solver - -end subroutine mld_z_base_solver_dmp diff --git a/mlprec/impl/solver/mld_z_base_solver_free.f90 b/mlprec/impl/solver/mld_z_base_solver_free.f90 deleted file mode 100644 index 84b03763..00000000 --- a/mlprec/impl/solver/mld_z_base_solver_free.f90 +++ /dev/null @@ -1,60 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_base_solver_free(sv,info) - - use psb_base_mod - use mld_z_base_solver_mod, mld_protect_name => mld_z_base_solver_free - Implicit None - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_solver_free' - - call psb_erractionsave(err_act) - - ! Do nothing - info = psb_success_ - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_base_solver_free diff --git a/mlprec/impl/solver/mld_z_bwgs_solver_apply.f90 b/mlprec/impl/solver/mld_z_bwgs_solver_apply.f90 deleted file mode 100644 index 89f870c8..00000000 --- a/mlprec/impl/solver/mld_z_bwgs_solver_apply.f90 +++ /dev/null @@ -1,216 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_bwgs_solver_apply(alpha,sv,x,beta,y,desc_data,& - &trans,work,info,init,initu) - - use psb_base_mod - use mld_z_gs_solver, mld_protect_name => mld_z_bwgs_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_bwgs_solver_type), intent(inout) :: sv - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col, itx, itxst - complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - complex(psb_dpk_), allocatable :: temp(:),wv(:),xit(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='z_bwgs_solver_apply' - - call psb_erractionsave(err_act) - ictxt = desc_data%get_ctxt() - call psb_info(ictxt,me,np) - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') -!!$ case('T') -!!$ case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - - call psb_geasb(wv,desc_data,info) - call psb_geasb(xit,desc_data,info) - itxst = 1 - select case (init_) - case('Z') - call psb_geaxpby(zone,x,zzero,wv,desc_data,info) - call psb_spsm(zone,sv%u,wv,zzero,xit,desc_data,info) - itxst = 2 - case('Y') - call psb_geaxpby(zone,y,zzero,xit,desc_data,info) - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(zone,initu,zzero,xit,desc_data,info) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - select case(trans_) - case('N') - if (sv%eps <=dzero) then - ! - ! Fixed number of iterations - ! - ! - do itx=itxst, sv%sweeps - call psb_geaxpby(zone,x,zzero,wv,desc_data,info) - ! Update with L. The off-diagonal block is taken care - ! from the Jacobi smoother, hence this is purely local. - call psb_spmm(-zone,sv%l,xit,zone,wv,desc_data,info,doswap=.false.) - call psb_spsm(zone,sv%u,wv,zzero,xit,desc_data,info) - end do - - call psb_geaxpby(alpha,xit,beta,y,desc_data,info) - - else - ! - ! Iterations to convergence, not implemented right now. - ! - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') - goto 9999 - - end if -!!$ case('T') -!!$ call psb_spsm(zone,sv%u,x,zzero,wv,desc_data,info,& -!!$ & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) -!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) -!!$ -!!$ case('C') -!!$ -!!$ call psb_spsm(zone,sv%u,x,zzero,wv,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) -!!$ -!!$ call wv1%mlt(zone,sv%dv,wv,zzero,info,conjgx=trans_) -!!$ -!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv1,beta,y,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid TRANS in GS subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_bwgs_solver_apply diff --git a/mlprec/impl/solver/mld_z_bwgs_solver_apply_vect.f90 b/mlprec/impl/solver/mld_z_bwgs_solver_apply_vect.f90 deleted file mode 100644 index 5e167ba4..00000000 --- a/mlprec/impl/solver/mld_z_bwgs_solver_apply_vect.f90 +++ /dev/null @@ -1,211 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_bwgs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_z_gs_solver, mld_protect_name => mld_z_bwgs_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_bwgs_solver_type), intent(inout) :: sv - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col, itx, itxst - complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - complex(psb_dpk_), allocatable :: temp(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='z_bwgs_solver_apply' - - call psb_erractionsave(err_act) - ictxt = desc_data%get_ctxt() - call psb_info(ictxt,me,np) - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') -!!$ case('T') -!!$ case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - - if (x%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/itwo,n_row,izero,izero,izero/)) - goto 9999 - end if - if (y%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/ithree,n_row,izero,izero,izero/)) - goto 9999 - end if - - - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - - if (size(wv) < 2) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size') - goto 9999 - end if - - associate(tw => wv(1), xit => wv(2)) - itxst = 1 - select case (init_) - case('Z') - call psb_geaxpby(zone,x,zzero,tw,desc_data,info) - call psb_spsm(zone,sv%u,tw,zzero,xit,desc_data,info) - itxst = 2 - case('Y') - call psb_geaxpby(zone,y,zzero,xit,desc_data,info) - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(zone,initu,zzero,xit,desc_data,info) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - select case(trans_) - case('N') - if (sv%eps <=dzero) then - ! - ! Fixed number of iterations - ! - ! - do itx=itxst,sv%sweeps - call psb_geaxpby(zone,x,zzero,tw,desc_data,info) - ! Update with L. The off-diagonal block is taken care - ! from the Jacobi smoother, hence this is purely local. - call psb_spmm(-zone,sv%l,xit,zone,tw,desc_data,info,doswap=.false.) - call psb_spsm(zone,sv%u,tw,zzero,xit,desc_data,info) - end do - - call psb_geaxpby(alpha,xit,beta,y,desc_data,info) - - else - ! - ! Iterations to convergence, not implemented right now. - ! - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') - goto 9999 - - end if - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid TRANS in GS subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - end associate - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_bwgs_solver_apply_vect diff --git a/mlprec/impl/solver/mld_z_bwgs_solver_bld.f90 b/mlprec/impl/solver/mld_z_bwgs_solver_bld.f90 deleted file mode 100644 index 28f9e404..00000000 --- a/mlprec/impl/solver/mld_z_bwgs_solver_bld.f90 +++ /dev/null @@ -1,110 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_bwgs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_z_gs_solver, mld_protect_name => mld_z_bwgs_solver_bld - - Implicit None - - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(in) :: desc_a - class(mld_z_bwgs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_bwgs_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - - if (sv%eps <= dzero) then - ! - ! This cuts out the off-diagonal part, because it's supposed to - ! be handled by the outer Jacobi smoother. - ! - call a%tril(sv%l,info,diag=-ione,jmax=nrow_a,u=sv%u) - - else - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end if - - - - call sv%l%set_asb() - call sv%l%trim() - call sv%u%set_asb() - call sv%u%trim() - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_bwgs_solver_bld diff --git a/mlprec/impl/solver/mld_z_diag_solver_apply.f90 b/mlprec/impl/solver/mld_z_diag_solver_apply.f90 deleted file mode 100644 index bdedc0f0..00000000 --- a/mlprec/impl/solver/mld_z_diag_solver_apply.f90 +++ /dev/null @@ -1,240 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_diag_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - - use psb_base_mod - use mld_z_diag_solver, mld_protect_name => mld_z_diag_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_diag_solver_type), intent(inout) :: sv - complex(psb_dpk_), intent(inout) :: x(:) - complex(psb_dpk_), intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col - complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='z_diag_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (trans_ == 'C') then - if (beta == zzero) then - - if (alpha == zzero) then - y(1:n_row) = zzero - else if (alpha == zone) then - do i=1, n_row - y(i) = conjg(sv%d(i)) * x(i) - end do - else if (alpha == -zone) then - do i=1, n_row - y(i) = -conjg(sv%d(i)) * x(i) - end do - else - do i=1, n_row - y(i) = alpha * conjg(sv%d(i)) * x(i) - end do - end if - - else if (beta == zone) then - - if (alpha == zzero) then - !y(1:n_row) = zzero - else if (alpha == zone) then - do i=1, n_row - y(i) = conjg(sv%d(i)) * x(i) + y(i) - end do - else if (alpha == -zone) then - do i=1, n_row - y(i) = -conjg(sv%d(i)) * x(i) + y(i) - end do - else - do i=1, n_row - y(i) = alpha * conjg(sv%d(i)) * x(i) + y(i) - end do - end if - - else if (beta == -zone) then - - if (alpha == zzero) then - y(1:n_row) = -y(1:n_row) - else if (alpha == zone) then - do i=1, n_row - y(i) = conjg(sv%d(i)) * x(i) - y(i) - end do - else if (alpha == -zone) then - do i=1, n_row - y(i) = -conjg(sv%d(i)) * x(i) - y(i) - end do - else - do i=1, n_row - y(i) = alpha * conjg(sv%d(i)) * x(i) - y(i) - end do - end if - - else - - if (alpha == zzero) then - y(1:n_row) = beta *y(1:n_row) - else if (alpha == zone) then - do i=1, n_row - y(i) = conjg(sv%d(i)) * x(i) + beta*y(i) - end do - else if (alpha == -zone) then - do i=1, n_row - y(i) = -conjg(sv%d(i)) * x(i) + beta*y(i) - end do - else - do i=1, n_row - y(i) = alpha * conjg(sv%d(i)) * x(i) + beta*y(i) - end do - end if - - end if - - else if (trans_ /= 'C') then - - if (beta == zzero) then - - if (alpha == zzero) then - y(1:n_row) = zzero - else if (alpha == zone) then - do i=1, n_row - y(i) = sv%d(i) * x(i) - end do - else if (alpha == -zone) then - do i=1, n_row - y(i) = -sv%d(i) * x(i) - end do - else - do i=1, n_row - y(i) = alpha * sv%d(i) * x(i) - end do - end if - - else if (beta == zone) then - - if (alpha == zzero) then - !y(1:n_row) = zzero - else if (alpha == zone) then - do i=1, n_row - y(i) = sv%d(i) * x(i) + y(i) - end do - else if (alpha == -zone) then - do i=1, n_row - y(i) = -sv%d(i) * x(i) + y(i) - end do - else - do i=1, n_row - y(i) = alpha * sv%d(i) * x(i) + y(i) - end do - end if - - else if (beta == -zone) then - - if (alpha == zzero) then - y(1:n_row) = -y(1:n_row) - else if (alpha == zone) then - do i=1, n_row - y(i) = sv%d(i) * x(i) - y(i) - end do - else if (alpha == -zone) then - do i=1, n_row - y(i) = -sv%d(i) * x(i) - y(i) - end do - else - do i=1, n_row - y(i) = alpha * sv%d(i) * x(i) - y(i) - end do - end if - - else - - if (alpha == zzero) then - y(1:n_row) = beta *y(1:n_row) - else if (alpha == zone) then - do i=1, n_row - y(i) = sv%d(i) * x(i) + beta*y(i) - end do - else if (alpha == -zone) then - do i=1, n_row - y(i) = -sv%d(i) * x(i) + beta*y(i) - end do - else - do i=1, n_row - y(i) = alpha * sv%d(i) * x(i) + beta*y(i) - end do - end if - - end if - - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_diag_solver_apply diff --git a/mlprec/impl/solver/mld_z_diag_solver_apply_vect.f90 b/mlprec/impl/solver/mld_z_diag_solver_apply_vect.f90 deleted file mode 100644 index 840e14a6..00000000 --- a/mlprec/impl/solver/mld_z_diag_solver_apply_vect.f90 +++ /dev/null @@ -1,117 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_diag_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_z_diag_solver, mld_protect_name => mld_z_diag_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_diag_solver_type), intent(inout) :: sv - type(psb_z_vect_type), intent(inout) :: x - type(psb_z_vect_type), intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col - complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='z_diag_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - if (x%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/itwo,n_row,izero,izero,izero/)) - goto 9999 - end if - if (y%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/ithree,n_row,izero,izero,izero/)) - goto 9999 - end if - if (.not.allocated(sv%dv)) then - info = 1124 - call psb_errpush(info,name,a_err="preconditioner: D") - goto 9999 - end if - if (sv%dv%get_nrows() < n_row) then - info = 1124 - call psb_errpush(info,name,a_err="preconditioner: D") - goto 9999 - end if - - call y%mlt(alpha,sv%dv,x,beta,info,conjgx=trans_) - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='vect%mlt') - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_diag_solver_apply_vect diff --git a/mlprec/impl/solver/mld_z_diag_solver_bld.f90 b/mlprec/impl/solver/mld_z_diag_solver_bld.f90 deleted file mode 100644 index a19a5a1f..00000000 --- a/mlprec/impl/solver/mld_z_diag_solver_bld.f90 +++ /dev/null @@ -1,191 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_z_diag_solver, mld_protect_name => mld_z_diag_solver_bld - - Implicit None - - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - complex(psb_dpk_), allocatable :: tdb(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='z_diag_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - nrow_a = a%get_nrows() - - sv%d = a%get_diag(info) - if (info == psb_success_) call psb_realloc(n_row,sv%d,info) - if (present(b)) then - tdb=b%get_diag(info) - if (size(tdb)+nrow_a > n_row) call psb_realloc(nrow_a+size(tdb),sv%d,info) - if (info == psb_success_) sv%d(nrow_a+1:nrow_a+size(tdb)) = tdb(:) - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='get_diag') - goto 9999 - end if - - do i=1,n_row - if (sv%d(i) == zzero) then - sv%d(i) = zone - else - sv%d(i) = zone/sv%d(i) - end if - end do - allocate(sv%dv,stat=info) - if (info == psb_success_) then - call sv%dv%bld(sv%d) - if (present(vmold)) call sv%dv%cnv(vmold) - call sv%dv%sync() - else - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='Allocate sv%dv') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_diag_solver_bld - - -subroutine mld_z_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_z_l1_diag_solver, mld_protect_name => mld_z_l1_diag_solver_bld - - Implicit None - - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_l1_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - complex(psb_dpk_), allocatable :: tdb(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='z_l1_diag_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - nrow_a = a%get_nrows() - - sv%d = a%arwsum(info) - if (info == psb_success_) call psb_realloc(n_row,sv%d,info) - if (present(b)) then - tdb=b%arwsum(info) - if (size(tdb)+nrow_a > n_row) call psb_realloc(nrow_a+size(tdb),sv%d,info) - if (info == psb_success_) sv%d(nrow_a+1:nrow_a+size(tdb)) = tdb(:) - end if - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='arwsum') - goto 9999 - end if - - do i=1,n_row - if (sv%d(i) == zzero) then - sv%d(i) = zone - else - sv%d(i) = zone/sv%d(i) - end if - end do - allocate(sv%dv,stat=info) - if (info == psb_success_) then - call sv%dv%bld(sv%d) - if (present(vmold)) call sv%dv%cnv(vmold) - call sv%dv%sync() - else - call psb_errpush(psb_err_from_subroutine_,name,& - & a_err='Allocate sv%dv') - goto 9999 - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_l1_diag_solver_bld diff --git a/mlprec/impl/solver/mld_z_diag_solver_clear_data.f90 b/mlprec/impl/solver/mld_z_diag_solver_clear_data.f90 deleted file mode 100644 index 59add192..00000000 --- a/mlprec/impl/solver/mld_z_diag_solver_clear_data.f90 +++ /dev/null @@ -1,65 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_diag_solver_clear_data(sv,info) - - use psb_base_mod - use mld_z_diag_solver, mld_protect_name => mld_z_diag_solver_clear_data - - Implicit None - - ! Arguments - class(mld_z_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - call sv%dv%free(info) - if ((info ==0).and.allocated(sv%d)) deallocate(sv%d,stat=info) - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_diag_solver_clear_data diff --git a/mlprec/impl/solver/mld_z_diag_solver_clone.f90 b/mlprec/impl/solver/mld_z_diag_solver_clone.f90 deleted file mode 100644 index a576d499..00000000 --- a/mlprec/impl/solver/mld_z_diag_solver_clone.f90 +++ /dev/null @@ -1,83 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_diag_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_z_diag_solver, mld_protect_name => mld_z_diag_solver_clone - - Implicit None - - ! Arguments - class(mld_z_diag_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(svout)) then - call svout%free(info) - if (info == psb_success_) deallocate(svout, stat=info) - end if - if (info == psb_success_) & - & allocate(svout, mold=sv, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(svo => svout) - class is (mld_z_diag_solver_type) - call psb_safe_ab_cpy(sv%d,svo%d,info) - if (info == psb_success_) & - & call sv%dv%clone(svo%dv,info) - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_diag_solver_clone diff --git a/mlprec/impl/solver/mld_z_diag_solver_cnv.f90 b/mlprec/impl/solver/mld_z_diag_solver_cnv.f90 deleted file mode 100644 index 1f432bc1..00000000 --- a/mlprec/impl/solver/mld_z_diag_solver_cnv.f90 +++ /dev/null @@ -1,76 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_diag_solver_cnv(sv,info,amold,vmold,imold) - - use psb_base_mod - use mld_z_diag_solver, mld_protect_name => mld_z_diag_solver_cnv - - Implicit None - - ! Arguments - class(mld_z_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: err_act, debug_unit, debug_level - character(len=20) :: name='d_diag_solver_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) trim(name),' start' - - - if (allocated(sv%dv)) then - call sv%dv%cnv(vmold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_z_diag_solver_cnv diff --git a/mlprec/impl/solver/mld_z_diag_solver_dmp.f90 b/mlprec/impl/solver/mld_z_diag_solver_dmp.f90 deleted file mode 100644 index 5f52b8ff..00000000 --- a/mlprec/impl/solver/mld_z_diag_solver_dmp.f90 +++ /dev/null @@ -1,133 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_z_diag_solver, mld_protect_name => mld_z_diag_solver_dmp - implicit none - class(mld_z_diag_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: solver_ - ! len of prefix_ - - info = 0 - - ictxt = desc%get_context() - - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - - if (solver_) then - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_z" - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' - if (allocated(sv%d)) & - & call psb_geprt(fname,sv%d,head=head) - - end if - -end subroutine mld_z_diag_solver_dmp -subroutine mld_z_l1_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_z_l1_diag_solver, mld_protect_name => mld_z_l1_diag_solver_dmp - implicit none - class(mld_z_l1_diag_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: solver_ - ! len of prefix_ - - info = 0 - - ictxt = desc%get_context() - - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - - if (solver_) then - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_z" - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_l1_diag.mtx' - if (allocated(sv%d)) & - & call psb_geprt(fname,sv%d,head=head) - - end if - -end subroutine mld_z_l1_diag_solver_dmp diff --git a/mlprec/impl/solver/mld_z_gs_solver_apply.f90 b/mlprec/impl/solver/mld_z_gs_solver_apply.f90 deleted file mode 100644 index 679a8867..00000000 --- a/mlprec/impl/solver/mld_z_gs_solver_apply.f90 +++ /dev/null @@ -1,216 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_gs_solver_apply(alpha,sv,x,beta,y,desc_data,& - &trans,work,info,init,initu) - - use psb_base_mod - use mld_z_gs_solver, mld_protect_name => mld_z_gs_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_gs_solver_type), intent(inout) :: sv - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col, itx, itxst - complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - complex(psb_dpk_), allocatable :: temp(:),wv(:),xit(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='z_gs_solver_apply' - - call psb_erractionsave(err_act) - ictxt = desc_data%get_ctxt() - call psb_info(ictxt,me,np) - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') -!!$ case('T') -!!$ case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - - call psb_geasb(wv,desc_data,info) - call psb_geasb(xit,desc_data,info) - itxst = 1 - select case (init_) - case('Z') - call psb_geaxpby(zone,x,zzero,wv,desc_data,info) - call psb_spsm(zone,sv%l,wv,zzero,xit,desc_data,info) - itxst = 2 - case('Y') - call psb_geaxpby(zone,y,zzero,xit,desc_data,info) - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(zone,initu,zzero,xit,desc_data,info) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - select case(trans_) - case('N') - if (sv%eps <=dzero) then - ! - ! Fixed number of iterations - ! - ! - do itx=itxst,sv%sweeps - call psb_geaxpby(zone,x,zzero,wv,desc_data,info) - ! Update with U. The off-diagonal block is taken care - ! from the Jacobi smoother, hence this is purely local. - call psb_spmm(-zone,sv%u,xit,zone,wv,desc_data,info,doswap=.false.) - call psb_spsm(zone,sv%l,wv,zzero,xit,desc_data,info) - end do - - call psb_geaxpby(alpha,xit,beta,y,desc_data,info) - - else - ! - ! Iterations to convergence, not implemented right now. - ! - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') - goto 9999 - - end if -!!$ case('T') -!!$ call psb_spsm(zone,sv%u,x,zzero,wv,desc_data,info,& -!!$ & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) -!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv,beta,y,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) -!!$ -!!$ case('C') -!!$ -!!$ call psb_spsm(zone,sv%u,x,zzero,wv,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) -!!$ -!!$ call wv1%mlt(zone,sv%dv,wv,zzero,info,conjgx=trans_) -!!$ -!!$ if (info == psb_success_) call psb_spsm(alpha,sv%l,wv1,beta,y,desc_data,info,& -!!$ & trans=trans_,scale='U',choice=psb_none_,work=aux) - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid TRANS in GS subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_gs_solver_apply diff --git a/mlprec/impl/solver/mld_z_gs_solver_apply_vect.f90 b/mlprec/impl/solver/mld_z_gs_solver_apply_vect.f90 deleted file mode 100644 index 905c2c66..00000000 --- a/mlprec/impl/solver/mld_z_gs_solver_apply_vect.f90 +++ /dev/null @@ -1,211 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_gs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_z_gs_solver, mld_protect_name => mld_z_gs_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_gs_solver_type), intent(inout) :: sv - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col, itx, itxst - complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - complex(psb_dpk_), allocatable :: temp(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_, init_ - character(len=20) :: name='z_gs_solver_apply' - - call psb_erractionsave(err_act) - ictxt = desc_data%get_ctxt() - call psb_info(ictxt,me,np) - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') -!!$ case('T') -!!$ case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - - if (present(init)) then - init_ = psb_toupper(init) - else - init_='Z' - end if - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - - if (x%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/itwo,n_row,izero,izero,izero/)) - goto 9999 - end if - if (y%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/ithree,n_row,izero,izero,izero/)) - goto 9999 - end if - - - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - - if (size(wv) < 2) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size') - goto 9999 - end if - - associate(tw => wv(1), xit => wv(2)) - itxst = 1 - select case (init_) - case('Z') - call psb_geaxpby(zone,x,zzero,tw,desc_data,info) - call psb_spsm(zone,sv%l,tw,zzero,xit,desc_data,info) - itxst = 2 - case('Y') - call psb_geaxpby(zone,y,zzero,xit,desc_data,info) - case('U') - if (.not.present(initu)) then - call psb_errpush(psb_err_internal_error_,name,& - & a_err='missing initu to smoother_apply') - goto 9999 - end if - call psb_geaxpby(zone,initu,zzero,xit,desc_data,info) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='wrong init to smoother_apply') - goto 9999 - end select - - select case(trans_) - case('N') - if (sv%eps <=dzero) then - ! - ! Fixed number of iterations - ! - ! - do itx=itxst,sv%sweeps - call psb_geaxpby(zone,x,zzero,tw,desc_data,info) - ! Update with U. The off-diagonal block is taken care - ! from the Jacobi smoother, hence this is purely local. - call psb_spmm(-zone,sv%u,xit,zone,tw,desc_data,info,doswap=.false.) - call psb_spsm(zone,sv%l,tw,zzero,xit,desc_data,info) - end do - - call psb_geaxpby(alpha,xit,beta,y,desc_data,info) - - else - ! - ! Iterations to convergence, not implemented right now. - ! - info = psb_err_internal_error_ - call psb_errpush(info,name,a_err='EPS>0 not implemented in GS subsolve') - goto 9999 - - end if - - case default - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid TRANS in GS subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - end associate - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_gs_solver_apply_vect diff --git a/mlprec/impl/solver/mld_z_gs_solver_bld.f90 b/mlprec/impl/solver/mld_z_gs_solver_bld.f90 deleted file mode 100644 index dad76c87..00000000 --- a/mlprec/impl/solver/mld_z_gs_solver_bld.f90 +++ /dev/null @@ -1,109 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_gs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_z_gs_solver, mld_protect_name => mld_z_gs_solver_bld - - Implicit None - - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='z_gs_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - - if (sv%eps <= dzero) then - ! - ! This cuts out the off-diagonal part, because it's supposed to - ! be handled by the outer Jacobi smoother. - ! - call a%tril(sv%l,info,diag=izero,jmax=nrow_a,u=sv%u) - - else - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end if - - - - call sv%l%set_asb() - call sv%l%trim() - call sv%u%set_asb() - call sv%u%trim() - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_gs_solver_bld diff --git a/mlprec/impl/solver/mld_z_gs_solver_clear_data.f90 b/mlprec/impl/solver/mld_z_gs_solver_clear_data.f90 deleted file mode 100644 index 9f44d559..00000000 --- a/mlprec/impl/solver/mld_z_gs_solver_clear_data.f90 +++ /dev/null @@ -1,65 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_gs_solver_clear_data(sv,info) - - use psb_base_mod - use mld_z_gs_solver, mld_protect_name => mld_z_gs_solver_clear_data - - Implicit None - - ! Arguments - class(mld_z_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - call sv%l%free() - call sv%u%free() - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_gs_solver_clear_data diff --git a/mlprec/impl/solver/mld_z_gs_solver_clone.f90 b/mlprec/impl/solver/mld_z_gs_solver_clone.f90 deleted file mode 100644 index 0691846b..00000000 --- a/mlprec/impl/solver/mld_z_gs_solver_clone.f90 +++ /dev/null @@ -1,87 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_gs_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_z_gs_solver, mld_protect_name => mld_z_gs_solver_clone - - Implicit None - - ! Arguments - class(mld_z_gs_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - if (allocated(svout)) then - call svout%free(info) - if (info == psb_success_) deallocate(svout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_z_gs_solver_type :: svout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(svo => svout) - type is (mld_z_gs_solver_type) - svo%sweeps = sv%sweeps - svo%eps = sv%eps - if (info == psb_success_) & - & call sv%l%clone(svo%l,info) - if (info == psb_success_) & - & call sv%u%clone(svo%u,info) - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_gs_solver_clone diff --git a/mlprec/impl/solver/mld_z_gs_solver_clone_settings.f90 b/mlprec/impl/solver/mld_z_gs_solver_clone_settings.f90 deleted file mode 100644 index f7bdf138..00000000 --- a/mlprec/impl/solver/mld_z_gs_solver_clone_settings.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_gs_solver_clone_settings(sv,svout,info) - - use psb_base_mod - use mld_z_gs_solver, mld_protect_name => mld_z_gs_solver_clone_settings - Implicit None - ! Arguments - class(mld_z_gs_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_gs_solver_clone_settings' - - call psb_erractionsave(err_act) - - select type(svout) - class is(mld_z_gs_solver_type) - svout%sweeps = sv%sweeps - svout%eps = sv%eps - - class default - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_gs_solver_clone_settings diff --git a/mlprec/impl/solver/mld_z_gs_solver_cnv.f90 b/mlprec/impl/solver/mld_z_gs_solver_cnv.f90 deleted file mode 100644 index 212a733d..00000000 --- a/mlprec/impl/solver/mld_z_gs_solver_cnv.f90 +++ /dev/null @@ -1,74 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_gs_solver_cnv(sv,info,amold,vmold,imold) - - use psb_base_mod - use mld_z_gs_solver, mld_protect_name => mld_z_gs_solver_cnv - - Implicit None - - ! Arguments - class(mld_z_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: err_act, debug_unit, debug_level - character(len=20) :: name='z_gs_solver_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_gs_solver_cnv diff --git a/mlprec/impl/solver/mld_z_gs_solver_dmp.f90 b/mlprec/impl/solver/mld_z_gs_solver_dmp.f90 deleted file mode 100644 index 3f5908a9..00000000 --- a/mlprec/impl/solver/mld_z_gs_solver_dmp.f90 +++ /dev/null @@ -1,102 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_gs_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_z_gs_solver, mld_protect_name => mld_z_gs_solver_dmp - implicit none - class(mld_z_gs_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - integer(psb_lpk_), allocatable :: iv(:) - logical :: solver_, global_num_ - ! len of prefix_ - - info = 0 - - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - - if (solver_) then - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_d" - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - if (global_num_) then - iv = desc%get_global_indices(owned=.false.) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' - if (sv%l%is_asb()) & - & call sv%l%print(fname,head=head,iv=iv) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' - if (sv%u%is_asb()) & - & call sv%u%print(fname,head=head,iv=iv) - else - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' - if (sv%l%is_asb()) & - & call sv%l%print(fname,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' - if (sv%u%is_asb()) & - & call sv%u%print(fname,head=head) - end if - end if - -end subroutine mld_z_gs_solver_dmp diff --git a/mlprec/impl/solver/mld_z_id_solver_apply.f90 b/mlprec/impl/solver/mld_z_id_solver_apply.f90 deleted file mode 100644 index ab728ab2..00000000 --- a/mlprec/impl/solver/mld_z_id_solver_apply.f90 +++ /dev/null @@ -1,86 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_id_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - - use psb_base_mod - use mld_z_id_solver, mld_protect_name => mld_z_id_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_id_solver_type), intent(inout) :: sv - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='z_id_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call psb_geaxpby(alpha,x,beta,y,desc_data,info) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_id_solver_apply diff --git a/mlprec/impl/solver/mld_z_id_solver_apply_vect.f90 b/mlprec/impl/solver/mld_z_id_solver_apply_vect.f90 deleted file mode 100644 index 43ef0442..00000000 --- a/mlprec/impl/solver/mld_z_id_solver_apply_vect.f90 +++ /dev/null @@ -1,87 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_id_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_z_id_solver, mld_protect_name => mld_z_id_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_id_solver_type), intent(inout) :: sv - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='z_id_solver_apply_vect' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call psb_geaxpby(alpha,x,beta,y,desc_data,info) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_id_solver_apply_vect diff --git a/mlprec/impl/solver/mld_z_id_solver_clone.f90 b/mlprec/impl/solver/mld_z_id_solver_clone.f90 deleted file mode 100644 index 3dafb3ff..00000000 --- a/mlprec/impl/solver/mld_z_id_solver_clone.f90 +++ /dev/null @@ -1,81 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_id_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_z_id_solver, mld_protect_name => mld_z_id_solver_clone - - Implicit None - - ! Arguments - class(mld_z_id_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - if (allocated(svout)) then - call svout%free(info) - if (info == psb_success_) deallocate(svout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_z_id_solver_type :: svout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(svo => svout) - type is (mld_z_id_solver_type) - ! Nothing to be done. - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_id_solver_clone diff --git a/mlprec/impl/solver/mld_z_ilu_solver_apply.f90 b/mlprec/impl/solver/mld_z_ilu_solver_apply.f90 deleted file mode 100644 index 5d70536d..00000000 --- a/mlprec/impl/solver/mld_z_ilu_solver_apply.f90 +++ /dev/null @@ -1,153 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - - use psb_base_mod - use mld_z_ilu_solver, mld_protect_name => mld_z_ilu_solver_apply - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_ilu_solver_type), intent(inout) :: sv - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row,n_col - complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='z_ilu_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/4*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - endif - - select case(trans_) - case('N') - call psb_spsm(zone,sv%l,x,zzero,ww,desc_data,info,& - & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) - - if (info == psb_success_) call psb_spsm(alpha,sv%u,ww,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_, work=aux) - - case('T') - call psb_spsm(zone,sv%u,x,zzero,ww,desc_data,info,& - & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) - if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - case('C') - call psb_spsm(zone,sv%u,x,zzero,ww,desc_data,info,& - & trans=trans_,scale='L',diag=sv%d,choice=psb_none_,work=aux) - if (info == psb_success_) call psb_spsm(alpha,sv%l,ww,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid TRANS in ILU subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_ilu_solver_apply diff --git a/mlprec/impl/solver/mld_z_ilu_solver_apply_vect.f90 b/mlprec/impl/solver/mld_z_ilu_solver_apply_vect.f90 deleted file mode 100644 index 5cf4d013..00000000 --- a/mlprec/impl/solver/mld_z_ilu_solver_apply_vect.f90 +++ /dev/null @@ -1,194 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - - use psb_base_mod - use mld_z_ilu_solver, mld_protect_name => mld_z_ilu_solver_apply_vect - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_ilu_solver_type), intent(inout) :: sv - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: n_row,n_col - type(psb_z_vect_type) :: tw, tw1 - complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='z_ilu_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case('C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - - if (x%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/itwo,n_row,izero,izero,izero/)) - goto 9999 - end if - if (y%get_nrows() < n_row) then - info = 36 - call psb_errpush(info,name,& - & i_err=(/ithree,n_row,izero,izero,izero/)) - goto 9999 - end if - if (.not.allocated(sv%dv%v)) then - info = 1124 - call psb_errpush(info,name,a_err="preconditioner: D") - goto 9999 - end if - if (sv%dv%get_nrows() < n_row) then - info = 1124 - call psb_errpush(info,name,a_err="preconditioner: DV") - goto 9999 - end if - - - - if (n_col <= size(work)) then - ww => work(1:n_col) - if ((4*n_col+n_col) <= size(work)) then - aux => work(n_col+1:) - else - allocate(aux(4*n_col),stat=info) - endif - else - allocate(ww(n_col),aux(4*n_col),stat=info) - endif - - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,& - & i_err=(/5*n_col,izero,izero,izero,izero/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - - - if (size(wv) < 2) then - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='invalid wv size') - goto 9999 - end if - - - associate(tw => wv(1), tw1 => wv(2)) - - select case(trans_) - case('N') - call psb_spsm(zone,sv%l,x,zzero,tw,desc_data,info,& - & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) - - if (info == psb_success_) call psb_spsm(alpha,sv%u,tw,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_, work=aux) - - case('T') - call psb_spsm(zone,sv%u,x,zzero,tw,desc_data,info,& - & trans=trans_,scale='L',diag=sv%dv,choice=psb_none_,work=aux) - if (info == psb_success_) call psb_spsm(alpha,sv%l,tw,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - - case('C') - - call psb_spsm(zone,sv%u,x,zzero,tw,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - - call tw1%mlt(zone,sv%dv,tw,zzero,info,conjgx=trans_) - - if (info == psb_success_) call psb_spsm(alpha,sv%l,tw1,beta,y,desc_data,info,& - & trans=trans_,scale='U',choice=psb_none_,work=aux) - - case default - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Invalid TRANS in ILU subsolve') - goto 9999 - end select - - - if (info /= psb_success_) then - - call psb_errpush(psb_err_internal_error_,name,& - & a_err='Error in subsolve') - goto 9999 - endif - end associate - - if (n_col <= size(work)) then - if ((4*n_col+n_col) <= size(work)) then - else - deallocate(aux) - endif - else - deallocate(ww,aux) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - -end subroutine mld_z_ilu_solver_apply_vect diff --git a/mlprec/impl/solver/mld_z_ilu_solver_bld.f90 b/mlprec/impl/solver/mld_z_ilu_solver_bld.f90 deleted file mode 100644 index 70f23af0..00000000 --- a/mlprec/impl/solver/mld_z_ilu_solver_bld.f90 +++ /dev/null @@ -1,191 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_ilu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_z_ilu_solver, mld_protect_name => mld_z_ilu_solver_bld - - Implicit None - - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota -!!$ complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='z_ilu_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - - nrow_a = a%get_nrows() - nztota = a%get_nzeros() - if (present(b)) then - nztota = nztota + b%get_nzeros() - end if - - call sv%l%csall(n_row,n_row,info,nztota) - if (info == psb_success_) call sv%u%csall(n_row,n_row,info,nztota) - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_sp_all' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if (allocated(sv%d)) then - if (size(sv%d) < n_row) then - deallocate(sv%d) - endif - endif - if (.not.allocated(sv%d)) allocate(sv%d(n_row),stat=info) - - if (info /= psb_success_) then - call psb_errpush(psb_err_from_subroutine_,name,a_err='Allocate') - goto 9999 - endif - - - select case(sv%fact_type) - - case (psb_ilu_t_) - ! - ! ILU(k,t) - ! - select case(sv%fill_in) - - case(:-1) - ! Error: fill-in <= -1 - call psb_errpush(psb_err_input_value_invalid_i_,& - & name,i_err=(/ithree,sv%fill_in,izero,izero,izero/)) - goto 9999 - - case(0:) - ! Fill-in >= 0 - call psb_ilut_fact(sv%fill_in,sv%thresh,& - & a, sv%l,sv%u,sv%d,info,blck=b) - end select - if(info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_ilut_fact' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - case(psb_ilu_n_,psb_milu_n_) - ! - ! ILU(k) and MILU(k) - ! - select case(sv%fill_in) - case(:-1) - ! Error: fill-in <= -1 - call psb_errpush(psb_err_input_value_invalid_i_,& - & name,i_err=(/ithree,sv%fill_in,izero,izero,izero/)) - goto 9999 - case(0) - ! Fill-in 0 - ! Separate implementation of ILU(0) for better performance. - ! There seems to be a problem with the separate implementation of MILU(0), - ! contained into psb_ilu0_fact. This must be investigated. For the time being, - ! resort to the implementation of MILU(k) with k=0. - if (sv%fact_type == psb_ilu_n_) then - call psb_ilu0_fact(sv%fact_type,a,sv%l,sv%u,& - & sv%d,info,blck=b) - else - call psb_iluk_fact(sv%fill_in,sv%fact_type,& - & a,sv%l,sv%u,sv%d,info,blck=b) - endif - case(1:) - ! Fill-in >= 1 - ! The same routine implements both ILU(k) and MILU(k) - call psb_iluk_fact(sv%fill_in,sv%fact_type,& - & a,sv%l,sv%u,sv%d,info,blck=b) - end select - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='psb_iluk_fact' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - case default - ! If we end up here, something was wrong up in the call chain. - info = psb_err_input_value_invalid_i_ - call psb_errpush(psb_err_input_value_invalid_i_,name,& - & i_err=(/ithree,sv%fact_type,izero,izero,izero/)) - goto 9999 - - end select - - call sv%l%set_asb() - call sv%l%trim() - call sv%u%set_asb() - call sv%u%trim() - call sv%dv%bld(sv%d,mold=vmold) - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_ilu_solver_bld diff --git a/mlprec/impl/solver/mld_z_ilu_solver_clear_data.f90 b/mlprec/impl/solver/mld_z_ilu_solver_clear_data.f90 deleted file mode 100644 index 7d5e91d3..00000000 --- a/mlprec/impl/solver/mld_z_ilu_solver_clear_data.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_ilu_solver_clear_data(sv,info) - - use psb_base_mod - use mld_z_ilu_solver, mld_protect_name => mld_z_ilu_solver_clear_data - - Implicit None - - ! Arguments - class(mld_z_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - info=psb_success_ - call psb_erractionsave(err_act) - - call sv%l%free() - call sv%u%free() - call sv%dv%free(info) - if ((info==0).and.allocated(sv%d)) deallocate(sv%d,stat=info) - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_ilu_solver_clear_data diff --git a/mlprec/impl/solver/mld_z_ilu_solver_clone.f90 b/mlprec/impl/solver/mld_z_ilu_solver_clone.f90 deleted file mode 100644 index a754b969..00000000 --- a/mlprec/impl/solver/mld_z_ilu_solver_clone.f90 +++ /dev/null @@ -1,91 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_ilu_solver_clone(sv,svout,info) - - use psb_base_mod - use mld_z_ilu_solver, mld_protect_name => mld_z_ilu_solver_clone - - Implicit None - - ! Arguments - class(mld_z_ilu_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - ! Local variables - integer(psb_ipk_) :: err_act - - - info=psb_success_ - call psb_erractionsave(err_act) - if (allocated(svout)) then - call svout%free(info) - if (info == psb_success_) deallocate(svout, stat=info) - end if - if (info == psb_success_) & - & allocate(mld_z_ilu_solver_type :: svout, stat=info) - if (info /= 0) then - info = psb_err_alloc_dealloc_ - goto 9999 - end if - - select type(svo => svout) - type is (mld_z_ilu_solver_type) - svo%fact_type = sv%fact_type - svo%fill_in = sv%fill_in - svo%thresh = sv%thresh - call psb_safe_ab_cpy(sv%d,svo%d,info) - if (info == psb_success_) & - & call sv%dv%clone(svo%dv,info) - if (info == psb_success_) & - & call sv%l%clone(svo%l,info) - if (info == psb_success_) & - & call sv%u%clone(svo%u,info) - - class default - info = psb_err_internal_error_ - end select - - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_ilu_solver_clone diff --git a/mlprec/impl/solver/mld_z_ilu_solver_clone_settings.f90 b/mlprec/impl/solver/mld_z_ilu_solver_clone_settings.f90 deleted file mode 100644 index 9ba84b60..00000000 --- a/mlprec/impl/solver/mld_z_ilu_solver_clone_settings.f90 +++ /dev/null @@ -1,70 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_ilu_solver_clone_settings(sv,svout,info) - - use psb_base_mod - use mld_z_ilu_solver, mld_protect_name => mld_z_ilu_solver_clone_settings - Implicit None - ! Arguments - class(mld_z_ilu_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_ilu_solver_clone_settings' - - call psb_erractionsave(err_act) - - select type(svout) - class is(mld_z_ilu_solver_type) - svout%fact_type = sv%fact_type - svout%fill_in = sv%fill_in - svout%thresh = sv%thresh - - class default - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_ilu_solver_clone_settings diff --git a/mlprec/impl/solver/mld_z_ilu_solver_cnv.f90 b/mlprec/impl/solver/mld_z_ilu_solver_cnv.f90 deleted file mode 100644 index bbfcca7f..00000000 --- a/mlprec/impl/solver/mld_z_ilu_solver_cnv.f90 +++ /dev/null @@ -1,76 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_ilu_solver_cnv(sv,info,amold,vmold,imold) - - use psb_base_mod - use mld_z_ilu_solver, mld_protect_name => mld_z_ilu_solver_cnv - - Implicit None - - ! Arguments - class(mld_z_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: err_act, debug_unit, debug_level - character(len=20) :: name='d_ilu_solver_cnv', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - - call sv%dv%cnv(mold=vmold) - - if (present(amold)) then - call sv%l%cscnv(info,mold=amold) - call sv%u%cscnv(info,mold=amold) - end if - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -end subroutine mld_z_ilu_solver_cnv diff --git a/mlprec/impl/solver/mld_z_ilu_solver_dmp.f90 b/mlprec/impl/solver/mld_z_ilu_solver_dmp.f90 deleted file mode 100644 index a9a10ca4..00000000 --- a/mlprec/impl/solver/mld_z_ilu_solver_dmp.f90 +++ /dev/null @@ -1,112 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -subroutine mld_z_ilu_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - - use psb_base_mod - use mld_z_ilu_solver, mld_protect_name => mld_z_ilu_solver_dmp - implicit none - class(mld_z_ilu_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - integer(psb_ipk_) :: i, j, il1, iln, lname, lev - integer(psb_ipk_) :: ictxt,iam, np - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - logical :: solver_, global_num_ - integer(psb_lpk_), allocatable :: iv(:) - ! len of prefix_ - - info = 0 - - ictxt = desc%get_context() - call psb_info(ictxt,iam,np) - - if (present(solver)) then - solver_ = solver - else - solver_ = .false. - end if - if (present(global_num)) then - global_num_ = global_num - else - global_num_ = .false. - end if - - - if (solver_) then - if (present(prefix)) then - prefix_ = trim(prefix(1:min(len(prefix),len(prefix_)))) - else - prefix_ = "dump_slv_z" - end if - lname = len_trim(prefix_) - fname = trim(prefix_) - write(fname(lname+1:lname+5),'(a,i3.3)') '_p',iam - lname = lname + 5 - - if (global_num_) then - iv = desc%get_global_indices(owned=.false.) - - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' - if (sv%l%is_asb()) & - & call sv%l%print(fname,head=head,iv=iv) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' - if (allocated(sv%d)) & - & call psb_geprt(fname,sv%d,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' - if (sv%u%is_asb()) & - & call sv%u%print(fname,head=head,iv=iv) - - else - - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_lower.mtx' - if (sv%l%is_asb()) & - & call sv%l%print(fname,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_diag.mtx' - if (allocated(sv%d)) & - & call psb_geprt(fname,sv%d,head=head) - write(fname(lname+1:),'(a,i3.3,a)')'_l',level,'_upper.mtx' - if (sv%u%is_asb()) & - & call sv%u%print(fname,head=head) - end if - end if - -end subroutine mld_z_ilu_solver_dmp diff --git a/mlprec/impl/solver/mld_z_mumps_solver_apply.F90 b/mlprec/impl/solver/mld_z_mumps_solver_apply.F90 deleted file mode 100644 index 94e6758e..00000000 --- a/mlprec/impl/solver/mld_z_mumps_solver_apply.F90 +++ /dev/null @@ -1,169 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.0) -! -! (C) Copyright 2008,2009,2010,2012,2013 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -subroutine z_mumps_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - use psb_base_mod - use mld_z_mumps_solver - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_mumps_solver_type), intent(inout) :: sv - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - - integer(psb_ipk_) :: n_row, n_col - integer(psb_lpk_) :: nglob - integer(psb_epk_) :: eng - complex(psb_dpk_), allocatable :: ww(:) - complex(psb_dpk_), allocatable, target :: gx(:) - integer(psb_ipk_) :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='z_mumps_solver_apply' - - call psb_erractionsave(err_act) - -#if defined(HAVE_MUMPS_) - info = psb_success_ - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - nglob = desc_data%get_global_rows() - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - ! Running in local mode? - if (sv%ipar(1) == mld_local_solver_ ) then - gx = x - else if (sv%ipar(1) == mld_global_solver_ ) then - - if (n_col <= size(work)) then - ww = work(1:n_col) - else - allocate(ww(n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/n_col/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - end if - allocate(gx(nglob),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_; eng = nglob - call psb_errpush(info,name,e_err=(/eng/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - call psb_gather(gx, x, desc_data, info, root=izero) - else - info=psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid local/global solver in MUMPS') - goto 9999 - end if - - select case(trans_) - case('N') - sv%id%icntl(9) = 1 - case('T') - sv%id%icntl(9) = 2 - case default - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Invalid TRANS in subsolve') - goto 9999 - end select - - sv%id%rhs => gx - sv%id%nrhs = 1 - sv%id%icntl(1)=-1 - sv%id%icntl(2)=-1 - sv%id%icntl(3)=-1 - sv%id%icntl(4)=-1 - sv%id%job = 3 - call zmumps(sv%id) - if (sv%ipar(1) == mld_local_solver_ ) then - call psb_geaxpby(alpha,gx,beta,y,desc_data,info) - else - call psb_scatter(gx, ww, desc_data, info, root=izero) - if (info == psb_success_) then - call psb_geaxpby(alpha,ww,beta,y,desc_data,info) - end if - end if - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in subsolve') - goto 9999 - endif - - if (allocated(ww)) deallocate(ww) - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return - -#else - write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " -#endif -end subroutine z_mumps_solver_apply - diff --git a/mlprec/impl/solver/mld_z_mumps_solver_apply_vect.F90 b/mlprec/impl/solver/mld_z_mumps_solver_apply_vect.F90 deleted file mode 100644 index 2a8a4e5c..00000000 --- a/mlprec/impl/solver/mld_z_mumps_solver_apply_vect.F90 +++ /dev/null @@ -1,93 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.0) -! -! (C) Copyright 2008,2009,2010,2012,2013 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -subroutine z_mumps_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - use psb_base_mod - use mld_z_mumps_solver - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_mumps_solver_type), intent(inout) :: sv - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_mumps_solver_apply_vect' - -#if defined(HAVE_MUMPS_) - - call psb_erractionsave(err_act) - - info = psb_success_ - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call x%v%sync() - call y%v%sync() - call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) - call y%v%set_host() - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return - -#else - write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " -#endif - -end subroutine z_mumps_solver_apply_vect - diff --git a/mlprec/impl/solver/mld_z_mumps_solver_bld.F90 b/mlprec/impl/solver/mld_z_mumps_solver_bld.F90 deleted file mode 100644 index bcc88493..00000000 --- a/mlprec/impl/solver/mld_z_mumps_solver_bld.F90 +++ /dev/null @@ -1,262 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.0) -! -! (C) Copyright 2008,2009,2010,2012,2013 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -subroutine z_mumps_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - use mld_z_mumps_solver - Implicit None - - ! Arguments - type(psb_zspmat_type) :: c - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - type(psb_zspmat_type) :: atmp - type(psb_z_coo_sparse_mat), target :: acoo -#if defined(IPK4) && defined(LPK8) - integer(psb_lpk_), allocatable :: gia(:), gja(:) -#endif - integer(psb_ipk_) :: n_row,n_col, nrow_a, nza, npr, npc - integer(psb_lpk_) :: nglob, nglobrec, nzt - integer(psb_ipk_) :: ifrst, ibcheck - integer(psb_ipk_) :: ictxt, ictxt1, icomm, np, iam, me, i, err_act, debug_unit, debug_level - character(len=20) :: name='z_mumps_solver_bld', ch_err - -#if defined(HAVE_MUMPS_) - - info=psb_success_ - - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, iam, np) - if (sv%ipar(1) == mld_local_solver_ ) then - call psb_init(ictxt1,np=1,basectxt=ictxt,ids=(/iam/)) - icomm = psb_get_mpi_comm(ictxt1) - allocate(sv%local_ictxt,stat=info) - sv%local_ictxt = ictxt1 - !write(*,*)iam,'mumps_bld: local +++++>',icomm,sv%local_ictxt - call psb_info(ictxt1, me, np) - npr = np - else if (sv%ipar(1) == mld_global_solver_ ) then - icomm = psb_get_mpi_comm(ictxt) - !write(*,*)iam,'mumps_bld: global +++++>',icomm,ictxt - call psb_info(ictxt, iam, np) - me = iam - npr = np - else - info = psb_err_internal_error_ - call psb_errpush(info,name,& - & a_err='Invalid local/global solver in MUMPS') - goto 9999 - end if - npc = 1 - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - ! if (allocated(sv%id)) then - ! call sv%free(info) - - ! deallocate(sv%id) - ! end if - if(.not.allocated(sv%id)) then - allocate(sv%id,stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_dealloc_ - call psb_errpush(info,name,a_err='mld_zmumps_default') - goto 9999 - end if - end if - - - sv%id%comm = icomm - sv%id%job = -1 - sv%id%par = 1 - if (sv%ipar(3) == 2) then - sv%id%sym = 2 - else - sv%id%sym = 0 - end if - - call zmumps(sv%id) - !WARNING: CALLING zmumps WITH JOB=-1 DESTROY THE SETTING OF DEFAULT:TO FIX - if (allocated(sv%icntl)) then - do i=1,mld_mumps_icntl_size - if (allocated(sv%icntl(i)%item)) then - !write(0,*) 'MUMPS_BLD: setting entry ',i,' to ', sv%icntl(i)%item - sv%id%icntl(i) = sv%icntl(i)%item - end if - end do - end if - if (allocated(sv%rcntl)) then - do i=1,mld_mumps_rcntl_size - if (allocated(sv%rcntl(i)%item)) sv%id%cntl(i) = sv%rcntl(i)%item - end do - end if - sv%id%icntl(3)=sv%ipar(2) - - nglob = desc_a%get_global_rows() - if (sv%ipar(1) == mld_local_solver_ ) then - nglobrec=desc_a%get_local_rows() - if (sv%ipar(3) == 2) then - ! Always pass the upper triangle to MUMPS - call a%triu(c,info,jmax=a%get_nrows()) - call c%set_symmetric() - else - call a%csclip(c,info,jmax=a%get_nrows()) - end if - call c%cp_to(acoo) - nglob = c%get_nrows() - if (nglobrec /= nglob) then - write(*,*)'WARNING: MUMPS solver does not allow overlap in AS yet. ' - write(*,*)'A zero-overlap is used instead' - end if - else - call a%cp_to(acoo) - end if - nza = acoo%get_nzeros() - - ! switch to global numbering - if (sv%ipar(1) == mld_global_solver_ ) then -#if defined(IPK4) && defined(LPK8) - ! - ! Strategy here is as follows: because a call to MUMPS - ! as a gobal solver is mostly done at the coarsest level, - ! even if we start from a problem requiring 8 bytes, chances - ! are that the global size will be suitable for 4 bytes - ! anyway, so we hope for the best, and throw an error - ! if something goes wrong. - ! - if (nglob > huge(1_psb_ipk_)) then - write(0,*) iam,' ',trim(name),': Error: overflow of local indices ' - info=psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end if - - gia = acoo%ia(1:nza) - gja = acoo%ja(1:nza) - call psb_loc_to_glob(gia(1:nza), desc_a, info, iact='I') - call psb_loc_to_glob(gja(1:nza), desc_a, info, iact='I') - acoo%ia(1:nza) = gia(1:nza) - acoo%ja(1:nza) = gja(1:nza) -#else - ! - ! Here global and local numbers have the same size, so this must work. - ! - call psb_loc_to_glob(acoo%ja(1:nza), desc_a, info, iact='I') - call psb_loc_to_glob(acoo%ia(1:nza), desc_a, info, iact='I') -#endif - if (sv%ipar(3) == 2 ) then - ! Always pass the upper triangle to MUMPS - block - integer(psb_ipk_) :: j,nz - nz = 0 - do j=1,nza - if (acoo%ja(j) >= acoo%ia(j)) then - nz = nz + 1 - acoo%ia(nz) = acoo%ia(j) - acoo%ja(nz) = acoo%ja(j) - acoo%val(nz) = acoo%val(j) - end if - end do - call acoo%set_nzeros(nz) - call acoo%set_triangle() - call acoo%set_upper() - call acoo%set_symmetric() - end block - end if - end if - sv%id%irn_loc => acoo%ia - sv%id%jcn_loc => acoo%ja - sv%id%a_loc => acoo%val - sv%id%icntl(18) = 3 - sv%id%n = nglob - ! there should be a better way for this - sv%id%nnz_loc = acoo%get_nzeros() - sv%id%nnz = acoo%get_nzeros() - sv%id%job = 4 - if (sv%ipar(1) == mld_global_solver_ ) then - call psb_sum(ictxt,sv%id%nnz) - end if - !call psb_barrier(ictxt) - write(*,*)iam, ' calling mumps N,nz,nz_loc',sv%id%n,sv%id%nnz,sv%id%nnz_loc - call zmumps(sv%id) - !call psb_barrier(ictxt) - info = sv%id%infog(1) - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='mld_zmumps_fact ' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - nullify(sv%id%irn) - nullify(sv%id%jcn) - nullify(sv%id%a) - - call acoo%free() - sv%built=.true. - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) iam,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -#else - write(psb_err_unit,*) "MUMPS Not Configured, fix make.inc and recompile " -#endif -end subroutine z_mumps_solver_bld - diff --git a/mlprec/mld_base_prec_type.F90 b/mlprec/mld_base_prec_type.F90 deleted file mode 100644 index 691611c7..00000000 --- a/mlprec/mld_base_prec_type.F90 +++ /dev/null @@ -1,1210 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_base_prec_type.F90 -! -! Module: mld_base_prec_type -! -! Constants and utilities in common to all type variants of MLD preconditioners. -! - integer constants defining the preconditioner; -! - character constants describing the preconditioner (used by the routines -! printing out a preconditioner description); -! - the interfaces to the routines for the management of the preconditioner -! data structure (see below); -! - The data type encapsulating the parameters defining the ML preconditioner -! - The data type encapsulating the basic aggregation map. -! -! It contains routines for -! - converting character constants defining the preconditioner into integer -! constants; -! - checking if the preconditioner is correctly defined; -! - printing a description of the preconditioner; -! - deallocating the preconditioner data structure. -! - -module mld_base_prec_type - - ! - ! This reduces the size of .mod file. Without the ONLY clause compilation - ! blows up on some systems. - ! - use psb_const_mod - use psb_base_mod, only :& - & psb_desc_type, psb_i_vect_type, psb_i_base_vect_type,& - & psb_ipk_, psb_dpk_, psb_spk_, psb_epk_, & - & psb_cdfree, psb_halo_, psb_none_, psb_sum_, psb_avg_, & - & psb_nohalo_, psb_square_root_, psb_toupper, psb_root_,& - & psb_sizeof_ip, psb_sizeof_lp, psb_sizeof_sp, & - & psb_sizeof_dp, psb_sizeof,& - & psb_cd_get_context, psb_info, psb_min, psb_sum, psb_bcast,& - & psb_sizeof, psb_free, psb_cdfree, & - & psb_errpush, psb_act_abort_, psb_act_ret_,& - & psb_erractionsave, psb_erractionrestore, psb_error, psb_get_errstatus, & - & psb_get_erraction, psb_success_, psb_err_alloc_dealloc_,& - & psb_err_from_subroutine_, psb_err_missing_override_method_, & - & psb_error_handler, psb_out_unit, psb_err_unit - - ! - ! Version numbers - ! - character(len=*), parameter :: mld_version_string_ = "2.3.0" - integer(psb_ipk_), parameter :: mld_version_major_ = 2 - integer(psb_ipk_), parameter :: mld_version_minor_ = 3 - integer(psb_ipk_), parameter :: mld_patchlevel_ = 0 - - type mld_ml_parms - integer(psb_ipk_) :: sweeps_pre, sweeps_post - integer(psb_ipk_) :: ml_cycle - integer(psb_ipk_) :: aggr_type, par_aggr_alg - integer(psb_ipk_) :: aggr_ord, aggr_prol - integer(psb_ipk_) :: aggr_omega_alg, aggr_eig, aggr_filter - integer(psb_ipk_) :: coarse_mat, coarse_solve - contains - procedure, pass(pm) :: get_coarse => ml_parms_get_coarse - procedure, pass(pm) :: clone => ml_parms_clone - procedure, pass(pm) :: descr => ml_parms_descr - procedure, pass(pm) :: mlcycledsc => ml_parms_mlcycledsc - procedure, pass(pm) :: mldescr => ml_parms_mldescr - procedure, pass(pm) :: coarsedescr => ml_parms_coarsedescr - procedure, pass(pm) :: printout => ml_parms_printout - end type mld_ml_parms - - - type, extends(mld_ml_parms) :: mld_sml_parms - real(psb_spk_) :: aggr_omega_val, aggr_thresh - contains - procedure, pass(pm) :: clone => s_ml_parms_clone - procedure, pass(pm) :: descr => s_ml_parms_descr - procedure, pass(pm) :: printout => s_ml_parms_printout - end type mld_sml_parms - - type, extends(mld_ml_parms) :: mld_dml_parms - real(psb_dpk_) :: aggr_omega_val, aggr_thresh - contains - procedure, pass(pm) :: clone => d_ml_parms_clone - procedure, pass(pm) :: descr => d_ml_parms_descr - procedure, pass(pm) :: printout => d_ml_parms_printout - end type mld_dml_parms - - type mld_saggr_data - ! - ! Aggregation data and defaults: - ! - ! 1. min_coarse_size = 0 Default target size will be computed as - ! 40*(N_fine)**(1./3.) - ! We are assuming that the coarse size fits in - ! integer range of psb_ipk_, but this is - ! not very restrictive - integer(psb_ipk_) :: min_coarse_size = izero - ! 2. maximum number of levels. Defaults to 20 - integer(psb_ipk_) :: max_levs = 20_psb_ipk_ - ! 3. min_cr_ratio = 1.5 - real(psb_spk_) :: min_cr_ratio = 1.5_psb_spk_ - real(psb_spk_) :: op_complexity = szero - real(psb_spk_) :: avg_cr = szero - end type mld_saggr_data - - type mld_daggr_data - ! - ! Aggregation data and defaults: - ! - ! - ! 1. min_coarse_size = 0 Default target size will be computed as - ! 40*(N_fine)**(1./3.) - ! We are assuming that the coarse size fits in - ! integer range of psb_ipk_, but this is - ! not very restrictive - integer(psb_ipk_) :: min_coarse_size = izero - ! 2. maximum number of levels. Defaults to 20 - integer(psb_ipk_) :: max_levs = 20_psb_ipk_ - ! 3. min_cr_ratio = 1.5 - real(psb_dpk_) :: min_cr_ratio = 1.5_psb_dpk_ - real(psb_dpk_) :: op_complexity = dzero - real(psb_dpk_) :: avg_cr = dzero - end type mld_daggr_data - - - - ! - ! Entries in iprcparm - ! - ! These are in baseprec - ! - integer(psb_ipk_), parameter :: mld_smoother_type_ = 1 - integer(psb_ipk_), parameter :: mld_sub_solve_ = 2 - integer(psb_ipk_), parameter :: mld_sub_restr_ = 3 - integer(psb_ipk_), parameter :: mld_sub_prol_ = 4 - integer(psb_ipk_), parameter :: mld_sub_ovr_ = 6 - integer(psb_ipk_), parameter :: mld_sub_fillin_ = 7 - integer(psb_ipk_), parameter :: mld_ilu_scale_ = 8 - - ! - ! These are in onelev - ! - integer(psb_ipk_), parameter :: mld_ml_cycle_ = 20 - integer(psb_ipk_), parameter :: mld_smoother_sweeps_pre_ = 21 - integer(psb_ipk_), parameter :: mld_smoother_sweeps_post_ = 22 - integer(psb_ipk_), parameter :: mld_aggr_type_ = 23 - integer(psb_ipk_), parameter :: mld_aggr_prol_ = 24 - integer(psb_ipk_), parameter :: mld_par_aggr_alg_ = 25 - integer(psb_ipk_), parameter :: mld_aggr_ord_ = 26 - integer(psb_ipk_), parameter :: mld_aggr_omega_alg_ = 27 - integer(psb_ipk_), parameter :: mld_aggr_eig_ = 28 - integer(psb_ipk_), parameter :: mld_aggr_filter_ = 29 - integer(psb_ipk_), parameter :: mld_coarse_mat_ = 30 - integer(psb_ipk_), parameter :: mld_coarse_solve_ = 31 - integer(psb_ipk_), parameter :: mld_coarse_sweeps_ = 32 - integer(psb_ipk_), parameter :: mld_coarse_fillin_ = 33 - integer(psb_ipk_), parameter :: mld_coarse_subsolve_ = 34 - integer(psb_ipk_), parameter :: mld_smoother_sweeps_ = 36 - integer(psb_ipk_), parameter :: mld_solver_sweeps_ = 37 - integer(psb_ipk_), parameter :: mld_min_coarse_size_ = 38 - integer(psb_ipk_), parameter :: mld_n_prec_levs_ = 39 - integer(psb_ipk_), parameter :: mld_max_levs_ = 40 - integer(psb_ipk_), parameter :: mld_min_cr_ratio_ = 41 - integer(psb_ipk_), parameter :: mld_outer_sweeps_ = 42 - integer(psb_ipk_), parameter :: mld_ifpsz_ = 43 - - ! - ! Legal values for entry: mld_smoother_type_ - ! - integer(psb_ipk_), parameter :: mld_min_prec_ = 0 - integer(psb_ipk_), parameter :: mld_noprec_ = 0 - integer(psb_ipk_), parameter :: mld_base_smooth_ = 0 - integer(psb_ipk_), parameter :: mld_jac_ = 1 - integer(psb_ipk_), parameter :: mld_l1_jac_ = 2 - integer(psb_ipk_), parameter :: mld_bjac_ = 3 - integer(psb_ipk_), parameter :: mld_l1_bjac_ = 4 - integer(psb_ipk_), parameter :: mld_as_ = 5 - integer(psb_ipk_), parameter :: mld_fbgs_ = 6 - integer(psb_ipk_), parameter :: mld_l1_gs_ = 7 - integer(psb_ipk_), parameter :: mld_l1_fbgs_ = 8 - integer(psb_ipk_), parameter :: mld_max_prec_ = 8 - ! - ! Constants for pre/post signaling. Now only used internally - ! - integer(psb_ipk_), parameter :: mld_smooth_pre_ = 1 - integer(psb_ipk_), parameter :: mld_smooth_post_ = 2 - integer(psb_ipk_), parameter :: mld_smooth_both_ = 3 - - ! - ! This is a quick&dirty fix, but I have nothing better now... - ! - ! Legal values for entry: mld_sub_solve_ - ! - integer(psb_ipk_), parameter :: mld_slv_delta_ = mld_max_prec_+1 - integer(psb_ipk_), parameter :: mld_f_none_ = mld_slv_delta_+0 - integer(psb_ipk_), parameter :: mld_diag_scale_ = mld_slv_delta_+1 - integer(psb_ipk_), parameter :: mld_l1_diag_scale_ = mld_slv_delta_+2 - integer(psb_ipk_), parameter :: mld_gs_ = mld_slv_delta_+3 - ! !$ integer(psb_ipk_), parameter :: mld_ilu_n_ = mld_slv_delta_+4 - ! !$ integer(psb_ipk_), parameter :: mld_milu_n_ = mld_slv_delta_+5 - ! !$ integer(psb_ipk_), parameter :: mld_ilu_t_ = mld_slv_delta_+6 - integer(psb_ipk_), parameter :: mld_slu_ = mld_slv_delta_+7 - integer(psb_ipk_), parameter :: mld_umf_ = mld_slv_delta_+8 - integer(psb_ipk_), parameter :: mld_sludist_ = mld_slv_delta_+9 - integer(psb_ipk_), parameter :: mld_mumps_ = mld_slv_delta_+10 - integer(psb_ipk_), parameter :: mld_bwgs_ = mld_slv_delta_+11 - integer(psb_ipk_), parameter :: mld_max_sub_solve_ = mld_slv_delta_+11 - integer(psb_ipk_), parameter :: mld_min_sub_solve_ = mld_diag_scale_ - - ! - ! Legal values for entry: mld_ilu_scale_ - ! - integer(psb_ipk_), parameter :: mld_ilu_scale_none_ = 0 - integer(psb_ipk_), parameter :: mld_ilu_scale_maxval_ = 1 - integer(psb_ipk_), parameter :: mld_ilu_scale_diag_ = 2 - integer(psb_ipk_), parameter :: mld_ilu_scale_arwsum_ = 3 - integer(psb_ipk_), parameter :: mld_ilu_scale_aclsum_ = 4 - integer(psb_ipk_), parameter :: mld_ilu_scale_arcsum_ = 5 - ! For the time being enable only maxval scale - integer(psb_ipk_), parameter :: mld_max_ilu_scale_ = 1 - ! - ! Legal values for entry: mld_ml_cycle_ - ! - integer(psb_ipk_), parameter :: mld_no_ml_ = 0 - integer(psb_ipk_), parameter :: mld_add_ml_ = 1 - integer(psb_ipk_), parameter :: mld_mult_ml_ = 2 - integer(psb_ipk_), parameter :: mld_vcycle_ml_ = 3 - integer(psb_ipk_), parameter :: mld_wcycle_ml_ = 4 - integer(psb_ipk_), parameter :: mld_kcycle_ml_ = 5 - integer(psb_ipk_), parameter :: mld_kcyclesym_ml_ = 6 - integer(psb_ipk_), parameter :: mld_new_ml_prec_ = 7 - integer(psb_ipk_), parameter :: mld_mult_dev_ml_ = 7 - integer(psb_ipk_), parameter :: mld_max_ml_cycle_ = 8 - ! - ! Legal values for entry: mld_par_aggr_alg_ - ! - integer(psb_ipk_), parameter :: mld_dec_aggr_ = 0 - integer(psb_ipk_), parameter :: mld_sym_dec_aggr_ = 1 - integer(psb_ipk_), parameter :: mld_ext_aggr_ = 2 - integer(psb_ipk_), parameter :: mld_max_par_aggr_alg_ = mld_ext_aggr_ - ! - ! Legal values for entry: mld_aggr_type_ - ! - integer(psb_ipk_), parameter :: mld_noalg_ = 0 - integer(psb_ipk_), parameter :: mld_soc1_ = 1 - integer(psb_ipk_), parameter :: mld_soc2_ = 2 - ! - ! Legal values for entry: mld_aggr_prol_ - ! - integer(psb_ipk_), parameter :: mld_no_smooth_ = 0 - integer(psb_ipk_), parameter :: mld_smooth_prol_ = 1 - integer(psb_ipk_), parameter :: mld_min_energy_ = 2 - ! Disabling min_energy for the time being. - integer(psb_ipk_), parameter :: mld_max_aggr_prol_=mld_smooth_prol_ - ! - ! Legal values for entry: mld_aggr_filter_ - ! - integer(psb_ipk_), parameter :: mld_no_filter_mat_ = 0 - integer(psb_ipk_), parameter :: mld_filter_mat_ = 1 - integer(psb_ipk_), parameter :: mld_max_filter_mat_ = mld_filter_mat_ - ! - ! Legal values for entry: mld_aggr_ord_ - ! - integer(psb_ipk_), parameter :: mld_aggr_ord_nat_ = 0 - integer(psb_ipk_), parameter :: mld_aggr_ord_desc_deg_ = 1 - integer(psb_ipk_), parameter :: mld_max_aggr_ord_ = mld_aggr_ord_desc_deg_ - ! - ! Legal values for entry: mld_aggr_omega_alg_ - ! - integer(psb_ipk_), parameter :: mld_eig_est_ = 0 - integer(psb_ipk_), parameter :: mld_user_choice_ = 999 - ! - ! Legal values for entry: mld_aggr_eig_ - ! - integer(psb_ipk_), parameter :: mld_max_norm_ = 0 - ! - ! Legal values for entry: mld_coarse_mat_ - ! - integer(psb_ipk_), parameter :: mld_distr_mat_ = 0 - integer(psb_ipk_), parameter :: mld_repl_mat_ = 1 - integer(psb_ipk_), parameter :: mld_max_coarse_mat_ = mld_repl_mat_ - ! - ! Legal values for entry: mld_prec_status_ - ! - integer(psb_ipk_), parameter :: mld_prec_built_ = 98765 - - ! - ! Entries in rprcparm: ILU(k,t) threshold, smoothed aggregation omega - ! - integer(psb_ipk_), parameter :: mld_sub_iluthrs_ = 1 - integer(psb_ipk_), parameter :: mld_aggr_omega_val_ = 2 - integer(psb_ipk_), parameter :: mld_aggr_thresh_ = 3 - integer(psb_ipk_), parameter :: mld_coarse_iluthrs_ = 4 - integer(psb_ipk_), parameter :: mld_solver_eps_ = 6 - integer(psb_ipk_), parameter :: mld_rfpsz_ = 8 - ! - ! Is the current solver local or global - ! - integer(psb_ipk_), parameter :: mld_local_solver_ = 0 - integer(psb_ipk_), parameter :: mld_global_solver_ = 1 - - ! - ! Entries for mumps - ! - ! Size of the control vectors - integer, parameter :: mld_mumps_icntl_size=40 - integer, parameter :: mld_mumps_rcntl_size=15 - - ! - ! Fields for sparse matrices ensembles stored in av() - ! - integer(psb_ipk_), parameter :: mld_l_pr_ = 1 - integer(psb_ipk_), parameter :: mld_u_pr_ = 2 - integer(psb_ipk_), parameter :: mld_bp_ilu_avsz_ = 2 - integer(psb_ipk_), parameter :: mld_ap_nd_ = 3 - integer(psb_ipk_), parameter :: mld_ac_ = 4 - integer(psb_ipk_), parameter :: mld_sm_pr_t_ = 5 - integer(psb_ipk_), parameter :: mld_sm_pr_ = 6 - integer(psb_ipk_), parameter :: mld_smth_avsz_ = 6 - integer(psb_ipk_), parameter :: mld_max_avsz_ = mld_smth_avsz_ - - ! - ! Character constants used by mld_file_prec_descr - ! - character(len=19), parameter, private :: & - & eigen_estimates(0:0)=(/'infinity norm '/) - character(len=15), parameter, private :: & - & aggr_prols(0:3)=(/'unsmoothed ','smoothed ',& - & 'min energy ','bizr. smoothed'/) - character(len=15), parameter, private :: & - & aggr_filters(0:1)=(/'no filtering ','filtering '/) - character(len=15), parameter, private :: & - & matrix_names(0:1)=(/'distributed ','replicated '/) - character(len=18), parameter, private :: & - & aggr_type_names(0:2)=(/'None ',& - & 'SOC measure 1 ', 'SOC Measure 2 '/) - character(len=18), parameter, private :: & - & par_aggr_alg_names(0:2)=(/& - & 'decoupled aggr. ', 'sym. dec. aggr. ',& - & 'user defined aggr.'/) - character(len=18), parameter, private :: & - & ord_names(0:1)=(/'Natural ordering ','Desc. degree ord. '/) - character(len=6), parameter, private :: & - & restrict_names(0:4)=(/'none ','halo ',' ',' ',' '/) - character(len=12), parameter, private :: & - & prolong_names(0:3)=(/'none ','sum ', & - & 'average ','square root'/) - character(len=15), parameter, private :: & - & ml_names(0:7)=(/'none ','additive ',& - & 'multiplicative', 'VCycle ','WCycle ',& - & 'KCycle ','KCycleSym ','new ML '/) - character(len=15), parameter :: & - & mld_fact_names(0:mld_max_sub_solve_)=(/& - & 'none ','Jacobi ',& - & 'L1-Jacobi ','none ','none ',& - & 'none ','none ','L1-GS ',& - & 'L1-FBGS ','none ','Point Jacobi ',& - & 'L1-Jacobi ','Gauss-Seidel ','ILU(n) ',& - & 'MILU(n) ','ILU(t,n) ',& - & 'SuperLU ','UMFPACK LU ',& - & 'SuperLU_Dist ','MUMPS ',& - & 'Backward GS '/) - - interface mld_check_def - module procedure mld_icheck_def, mld_scheck_def, mld_dcheck_def - end interface - - interface psb_bcast - module procedure mld_ml_bcast, mld_sml_bcast, mld_dml_bcast - end interface psb_bcast - - interface mld_equal_aggregation - module procedure mld_d_equal_aggregation, mld_s_equal_aggregation - end interface mld_equal_aggregation - -contains - - ! - ! Function: mld_stringval - ! - ! This routine converts the string contained into string into the corresponding - ! integer value. - ! - ! Arguments: - ! string - character(len=*), input. - ! The string to be converted. - ! val - integer, output. - ! The integer value corresponding to the string - ! - function mld_stringval(string) result(val) - use psb_prec_const_mod - implicit none - ! Arguments - character(len=*), intent(in) :: string - integer(psb_ipk_) :: val - character(len=*), parameter :: name='mld_stringval' - ! Local variable - integer :: index_tab - character(len=15) ::string2 - index_tab=index(string,char(9)) - if (index_tab.NE.0) then - string2=string(1:index_tab-1) - else - string2=string - endif - select case(psb_toupper(trim(string2))) - case('NONE') - val = 0 - case('HALO') - val = psb_halo_ - case('SUM') - val = psb_sum_ - case('AVG') - val = psb_avg_ - case('FACT_NONE') - val = mld_f_none_ - case('FBGS') - val = mld_fbgs_ - case('GS','FGS','FWGS') - val = mld_gs_ - case('BGS','BWGS') - val = mld_bwgs_ - case('ILU') - val = psb_ilu_n_ - case('MILU') - val = psb_milu_n_ - case('ILUT') - val = psb_ilu_t_ - case('MUMPS') - val = mld_mumps_ - case('UMF') - val = mld_umf_ - case('SLU') - val = mld_slu_ - case('SLUDIST') - val = mld_sludist_ - case('DIAG') - val = mld_diag_scale_ - case('L1-DIAG') - val = mld_l1_diag_scale_ - case('ADD') - val = mld_add_ml_ - case('MULT_DEV') - val = mld_mult_dev_ml_ - case('MULT') - val = mld_mult_ml_ - case('VCYCLE') - val = mld_vcycle_ml_ - case('WCYCLE') - val = mld_wcycle_ml_ - case('KCYCLE') - val = mld_kcycle_ml_ - case('KCYCLESYM') - val = mld_kcyclesym_ml_ - case('SOC2') - val = mld_soc2_ - case('SOC1') - val = mld_soc1_ - case('DEC') - val = mld_dec_aggr_ - case('SYMDEC') - val = mld_sym_dec_aggr_ - case('NAT','NATURAL') - val = mld_aggr_ord_nat_ - case('DESC','RDEGREE','DEGREE') - val = mld_aggr_ord_desc_deg_ - case('REPL') - val = mld_repl_mat_ - case('DIST') - val = mld_distr_mat_ - case('UNSMOOTHED','NONSMOOTHED') - val = mld_no_smooth_ - case('SMOOTHED') - val = mld_smooth_prol_ - case('MINENERGY') - val = mld_min_energy_ - case('NOPREC') - val = mld_noprec_ - case('BJAC') - val = mld_bjac_ - case('L1-GS') - val = mld_l1_gs_ - case('L1-FBGS') - val = mld_l1_fbgs_ - case('L1-BJAC') - val = mld_l1_bjac_ - case('JAC','JACOBI') - val = mld_jac_ - case('L1-JACOBI') - val = mld_l1_jac_ - case('AS') - val = mld_as_ - case('A_NORMI') - val = mld_max_norm_ - case('USER_CHOICE') - val = mld_user_choice_ - case('EIG_EST') - val = mld_eig_est_ - case('FILTER') - val = mld_filter_mat_ - case('NOFILTER','NO_FILTER') - val = mld_no_filter_mat_ - case('OUTER_SWEEPS') - val = mld_outer_sweeps_ - case('LOCAL_SOLVER') - val = mld_local_solver_ - case('GLOBAL_SOLVER') - val = mld_global_solver_ - case default - val = -1 - end select - end function mld_stringval - - subroutine ml_parms_get_coarse(pm,pmin) - implicit none - class(mld_ml_parms), intent(inout) :: pm - class(mld_ml_parms), intent(in) :: pmin - pm%coarse_mat = pmin%coarse_mat - pm%coarse_solve = pmin%coarse_solve - end subroutine ml_parms_get_coarse - - - - subroutine ml_parms_printout(pm,iout) - implicit none - class(mld_ml_parms), intent(in) :: pm - integer(psb_ipk_), intent(in) :: iout - - write(iout,*) 'ML : ',pm%ml_cycle - write(iout,*) 'Sweeps: ',pm%sweeps_pre,pm%sweeps_post - write(iout,*) 'AGGR : ',pm%par_aggr_alg,pm%aggr_prol, pm%aggr_ord - write(iout,*) ' : ',pm%aggr_omega_alg,pm%aggr_eig,pm%aggr_filter - write(iout,*) 'COARSE: ',pm%coarse_mat,pm%coarse_solve - end subroutine ml_parms_printout - - - subroutine s_ml_parms_printout(pm,iout) - implicit none - class(mld_sml_parms), intent(in) :: pm - integer(psb_ipk_), intent(in) :: iout - - call pm%mld_ml_parms%printout(iout) - write(iout,*) 'REAL : ',pm%aggr_omega_val,pm%aggr_thresh - end subroutine s_ml_parms_printout - - - subroutine d_ml_parms_printout(pm,iout) - implicit none - class(mld_dml_parms), intent(in) :: pm - integer(psb_ipk_), intent(in) :: iout - - call pm%mld_ml_parms%printout(iout) - write(iout,*) 'REAL : ',pm%aggr_omega_val,pm%aggr_thresh - end subroutine d_ml_parms_printout - - - ! - ! Routines printing out a description of the preconditioner - ! - subroutine ml_parms_mlcycledsc(pm,iout,info) - - Implicit None - - ! Arguments - class(mld_ml_parms), intent(in) :: pm - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - info = psb_success_ - if ((pm%ml_cycle>=mld_no_ml_).and.(pm%ml_cycle<=mld_max_ml_cycle_)) then - - - write(iout,*) ' Multilevel cycle: ',& - & ml_names(pm%ml_cycle) - select case (pm%ml_cycle) - case (mld_add_ml_) - write(iout,*) ' Number of smoother sweeps : ',& - & pm%sweeps_pre - case (mld_mult_ml_,mld_vcycle_ml_, mld_wcycle_ml_, mld_kcycle_ml_, mld_kcyclesym_ml_) - write(iout,*) ' Number of smoother sweeps : pre: ',& - & pm%sweeps_pre ,' post: ', pm%sweeps_post - end select - - end if - end subroutine ml_parms_mlcycledsc - - subroutine ml_parms_mldescr(pm,iout,info) - - Implicit None - - ! Arguments - class(mld_ml_parms), intent(in) :: pm - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - info = psb_success_ - if ((pm%ml_cycle>=mld_no_ml_).and.(pm%ml_cycle<=mld_max_ml_cycle_)) then - - - write(iout,*) ' Parallel aggregation algorithm: ',& - & par_aggr_alg_names(pm%par_aggr_alg) - if (pm%aggr_type>0) write(iout,*) ' Aggregation type: ',& - & aggr_type_names(pm%aggr_type) - !if (pm%par_aggr_alg /= mld_ext_aggr_) then - if ( pm%aggr_ord /= mld_aggr_ord_nat_) & - & write(iout,*) ' with initial ordering: ',& - & ord_names(pm%aggr_ord) - write(iout,*) ' Aggregation prolongator: ', & - & aggr_prols(pm%aggr_prol) - if (pm%aggr_prol /= mld_no_smooth_) then - write(iout,*) ' with: ', aggr_filters(pm%aggr_filter) - if (pm%aggr_omega_alg == mld_eig_est_) then - write(iout,*) ' Damping omega computation: spectral radius estimate' - write(iout,*) ' Spectral radius estimate: ', & - & eigen_estimates(pm%aggr_eig) - else if (pm%aggr_omega_alg == mld_user_choice_) then - write(iout,*) ' Damping omega computation: user defined value.' - else - write(iout,*) ' Damping omega computation: unknown value in iprcparm!!' - end if - end if - !end if - else - write(iout,*) ' Multilevel type: Unkonwn value. Something is amiss....',& - & pm%ml_cycle - end if - - return - - end subroutine ml_parms_mldescr - - subroutine ml_parms_descr(pm,iout,info,coarse) - - Implicit None - - ! Arguments - class(mld_ml_parms), intent(in) :: pm - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - logical, intent(in), optional :: coarse - logical :: coarse_ - - info = psb_success_ - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - - if (coarse_) then - call pm%coarsedescr(iout,info) - end if - - return - - end subroutine ml_parms_descr - - - subroutine ml_parms_coarsedescr(pm,iout,info) - - - Implicit None - - ! Arguments - class(mld_ml_parms), intent(in) :: pm - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - - info = psb_success_ - write(iout,*) ' Coarse matrix: ',& - & matrix_names(pm%coarse_mat) - select case(pm%coarse_solve) - case (mld_bjac_,mld_as_) - write(iout,*) ' Number of sweeps : ',& - & pm%sweeps_pre - write(iout,*) ' Coarse solver: ',& - & 'Block Jacobi' - case (mld_l1_bjac_) - write(iout,*) ' Number of sweeps : ',& - & pm%sweeps_pre - write(iout,*) ' Coarse solver: ',& - & 'L1-Block Jacobi' - case (mld_jac_) - write(iout,*) ' Number of sweeps : ',& - & pm%sweeps_pre - write(iout,*) ' Coarse solver: ',& - & 'Point Jacobi' - case default - write(iout,*) ' Coarse solver: ',& - & mld_fact_names(pm%coarse_solve) - end select - - end subroutine ml_parms_coarsedescr - - subroutine s_ml_parms_descr(pm,iout,info,coarse) - - Implicit None - - ! Arguments - class(mld_sml_parms), intent(in) :: pm - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - logical, intent(in), optional :: coarse - - info = psb_success_ - - call pm%mld_ml_parms%descr(iout,info,coarse) - if (pm%aggr_prol /= mld_no_smooth_) then - write(iout,*) ' Damping omega value :',pm%aggr_omega_val - end if - write(iout,*) ' Aggregation threshold:',pm%aggr_thresh - - return - - end subroutine s_ml_parms_descr - - subroutine d_ml_parms_descr(pm,iout,info,coarse) - - Implicit None - - ! Arguments - class(mld_dml_parms), intent(in) :: pm - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - logical, intent(in), optional :: coarse - - info = psb_success_ - - call pm%mld_ml_parms%descr(iout,info,coarse) - if (pm%aggr_prol /= mld_no_smooth_) then - write(iout,*) ' Damping omega value :',pm%aggr_omega_val - end if - write(iout,*) ' Aggregation threshold:',pm%aggr_thresh - - return - - end subroutine d_ml_parms_descr - - - ! - ! Functions/subroutines checking if the preconditioner is correctly defined - ! - - function is_legal_base_prec(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_legal_base_prec - - is_legal_base_prec = ((ip>=mld_noprec_).and.(ip<=mld_max_prec_)) - return - end function is_legal_base_prec - function is_int_non_negative(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_int_non_negative - - is_int_non_negative = (ip >= 0) - return - end function is_int_non_negative - function is_legal_ilu_scale(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_legal_ilu_scale - is_legal_ilu_scale = ((ip >= mld_ilu_scale_none_).and.(ip <= mld_max_ilu_scale_)) - return - end function is_legal_ilu_scale - function is_int_positive(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_int_positive - - is_int_positive = (ip >= 1) - return - end function is_int_positive - function is_legal_prolong(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_legal_prolong - is_legal_prolong = ((ip>=psb_none_).and.(ip<=psb_square_root_)) - return - end function is_legal_prolong - function is_legal_restrict(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_legal_restrict - is_legal_restrict = ((ip == psb_nohalo_).or.(ip==psb_halo_)) - return - end function is_legal_restrict - function is_legal_ml_cycle(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_legal_ml_cycle - - is_legal_ml_cycle = ((ip>=mld_no_ml_).and.(ip<=mld_max_ml_cycle_)) - return - end function is_legal_ml_cycle - function is_legal_ml_par_aggr_alg(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_legal_ml_par_aggr_alg - - is_legal_ml_par_aggr_alg = ((ip>=mld_dec_aggr_).and.(ip<=mld_max_par_aggr_alg_)) - return - end function is_legal_ml_par_aggr_alg - function is_legal_ml_aggr_type(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_legal_ml_aggr_type - - is_legal_ml_aggr_type = (ip >= mld_soc1_) .and. (ip <= mld_soc2_) - return - end function is_legal_ml_aggr_type - function is_legal_ml_aggr_ord(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_legal_ml_aggr_ord - - is_legal_ml_aggr_ord = ((mld_aggr_ord_nat_<=ip).and.(ip<=mld_max_aggr_ord_)) - return - end function is_legal_ml_aggr_ord - function is_legal_ml_aggr_omega_alg(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_legal_ml_aggr_omega_alg - - is_legal_ml_aggr_omega_alg = ((ip == mld_eig_est_).or.(ip==mld_user_choice_)) - return - end function is_legal_ml_aggr_omega_alg - function is_legal_ml_aggr_eig(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_legal_ml_aggr_eig - - is_legal_ml_aggr_eig = (ip == mld_max_norm_) - return - end function is_legal_ml_aggr_eig - function is_legal_ml_aggr_prol(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_legal_ml_aggr_prol - - is_legal_ml_aggr_prol = ((ip>=0).and.(ip<=mld_max_aggr_prol_)) - return - end function is_legal_ml_aggr_prol - function is_legal_ml_coarse_mat(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_legal_ml_coarse_mat - - is_legal_ml_coarse_mat = ((ip>=0).and.(ip<=mld_max_coarse_mat_)) - return - end function is_legal_ml_coarse_mat - function is_legal_aggr_filter(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_legal_aggr_filter - - is_legal_aggr_filter = ((ip>=0).and.(ip<=mld_max_filter_mat_)) - return - end function is_legal_aggr_filter - function is_distr_ml_coarse_mat(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_distr_ml_coarse_mat - - is_distr_ml_coarse_mat = (ip == mld_distr_mat_) - return - end function is_distr_ml_coarse_mat - function is_legal_ml_fact(ip) - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_legal_ml_fact - ! Here the minimum is really 1, mld_fact_none_ is not acceptable. - is_legal_ml_fact = ((ip>=mld_min_sub_solve_)& - & .and.(ip<=mld_max_sub_solve_)) - return - end function is_legal_ml_fact - function is_legal_ilu_fact(ip) - use psb_prec_const_mod - implicit none - integer(psb_ipk_), intent(in) :: ip - logical :: is_legal_ilu_fact - - is_legal_ilu_fact = ((ip==psb_ilu_n_).or.& - & (ip==psb_milu_n_).or.(ip==psb_ilu_t_)) - return - end function is_legal_ilu_fact - function is_legal_d_omega(ip) - implicit none - real(psb_dpk_), intent(in) :: ip - logical :: is_legal_d_omega - is_legal_d_omega = ((ip>=0.0d0).and.(ip<=2.0d0)) - return - end function is_legal_d_omega - function is_legal_d_fact_thrs(ip) - implicit none - real(psb_dpk_), intent(in) :: ip - logical :: is_legal_d_fact_thrs - - is_legal_d_fact_thrs = (ip>=0.0d0) - return - end function is_legal_d_fact_thrs - function is_legal_d_aggr_thrs(ip) - implicit none - real(psb_dpk_), intent(in) :: ip - logical :: is_legal_d_aggr_thrs - - is_legal_d_aggr_thrs = (ip>=0.0d0) - return - end function is_legal_d_aggr_thrs - - function is_legal_s_omega(ip) - implicit none - real(psb_spk_), intent(in) :: ip - logical :: is_legal_s_omega - is_legal_s_omega = ((ip>=0.0).and.(ip<=2.0)) - return - end function is_legal_s_omega - function is_legal_s_fact_thrs(ip) - implicit none - real(psb_spk_), intent(in) :: ip - logical :: is_legal_s_fact_thrs - - is_legal_s_fact_thrs = (ip>=0.0) - return - end function is_legal_s_fact_thrs - function is_legal_s_aggr_thrs(ip) - implicit none - real(psb_spk_), intent(in) :: ip - logical :: is_legal_s_aggr_thrs - - is_legal_s_aggr_thrs = (ip>=0.0) - return - end function is_legal_s_aggr_thrs - - - subroutine mld_icheck_def(ip,name,id,is_legal) - implicit none - integer(psb_ipk_), intent(inout) :: ip - integer(psb_ipk_), intent(in) :: id - character(len=*), intent(in) :: name - interface - function is_legal(i) - import :: psb_ipk_ - integer(psb_ipk_), intent(in) :: i - logical :: is_legal - end function is_legal - end interface - character(len=20), parameter :: rname='mld_check_def' - - if (.not.is_legal(ip)) then - write(0,*)trim(rname),': Error: Illegal value for ',& - & name,' :',ip, '. defaulting to ',id - ip = id - end if - end subroutine mld_icheck_def - - subroutine mld_scheck_def(ip,name,id,is_legal) - implicit none - real(psb_spk_), intent(inout) :: ip - real(psb_spk_), intent(in) :: id - character(len=*), intent(in) :: name - interface - function is_legal(i) - use psb_base_mod, only : psb_spk_ - real(psb_spk_), intent(in) :: i - logical :: is_legal - end function is_legal - end interface - character(len=20), parameter :: rname='mld_check_def' - - if (.not.is_legal(ip)) then - write(0,*)trim(rname),': Error: Illegal value for ',& - & name,' :',ip, '. defaulting to ',id - ip = id - end if - end subroutine mld_scheck_def - - subroutine mld_dcheck_def(ip,name,id,is_legal) - implicit none - real(psb_dpk_), intent(inout) :: ip - real(psb_dpk_), intent(in) :: id - character(len=*), intent(in) :: name - interface - function is_legal(i) - use psb_base_mod, only : psb_dpk_ - real(psb_dpk_), intent(in) :: i - logical :: is_legal - end function is_legal - end interface - character(len=20), parameter :: rname='mld_check_def' - - if (.not.is_legal(ip)) then - write(0,*)trim(rname),': Error: Illegal value for ',& - & name,' :',ip, '. defaulting to ',id - ip = id - end if - end subroutine mld_dcheck_def - - - function pr_to_str(iprec) - implicit none - - integer(psb_ipk_), intent(in) :: iprec - character(len=10) :: pr_to_str - - select case(iprec) - case(mld_noprec_) - pr_to_str='NOPREC' - case(mld_jac_) - pr_to_str='JAC' - case(mld_bjac_) - pr_to_str='BJAC' - case(mld_as_) - pr_to_str='AS' - end select - - end function pr_to_str - - subroutine mld_ml_bcast(ictxt,dat,root) - - implicit none - integer(psb_ipk_), intent(in) :: ictxt - type(mld_ml_parms), intent(inout) :: dat - integer(psb_ipk_), intent(in), optional :: root - - call psb_bcast(ictxt,dat%sweeps_pre,root) - call psb_bcast(ictxt,dat%sweeps_post,root) - call psb_bcast(ictxt,dat%ml_cycle,root) - call psb_bcast(ictxt,dat%aggr_type,root) - call psb_bcast(ictxt,dat%par_aggr_alg,root) - call psb_bcast(ictxt,dat%aggr_ord,root) - call psb_bcast(ictxt,dat%aggr_prol,root) - call psb_bcast(ictxt,dat%aggr_omega_alg,root) - call psb_bcast(ictxt,dat%aggr_eig,root) - call psb_bcast(ictxt,dat%aggr_filter,root) - call psb_bcast(ictxt,dat%coarse_mat,root) - call psb_bcast(ictxt,dat%coarse_solve,root) - - end subroutine mld_ml_bcast - - subroutine mld_sml_bcast(ictxt,dat,root) - - implicit none - integer(psb_ipk_), intent(in) :: ictxt - type(mld_sml_parms), intent(inout) :: dat - integer(psb_ipk_), intent(in), optional :: root - - call psb_bcast(ictxt,dat%mld_ml_parms,root) - call psb_bcast(ictxt,dat%aggr_omega_val,root) - call psb_bcast(ictxt,dat%aggr_thresh,root) - end subroutine mld_sml_bcast - - subroutine mld_dml_bcast(ictxt,dat,root) - implicit none - integer(psb_ipk_), intent(in) :: ictxt - type(mld_dml_parms), intent(inout) :: dat - integer(psb_ipk_), intent(in), optional :: root - - call psb_bcast(ictxt,dat%mld_ml_parms,root) - call psb_bcast(ictxt,dat%aggr_omega_val,root) - call psb_bcast(ictxt,dat%aggr_thresh,root) - end subroutine mld_dml_bcast - - subroutine ml_parms_clone(pm,pmout,info) - - implicit none - class(mld_ml_parms), intent(inout) :: pm - class(mld_ml_parms), intent(out) :: pmout - integer(psb_ipk_), intent(out) :: info - - info = psb_success_ - pmout%sweeps_pre = pm%sweeps_pre - pmout%sweeps_post = pm%sweeps_post - pmout%ml_cycle = pm%ml_cycle - pmout%aggr_type = pm%aggr_type - pmout%par_aggr_alg = pm%par_aggr_alg - pmout%aggr_ord = pm%aggr_ord - pmout%aggr_prol = pm%aggr_prol - pmout%aggr_omega_alg = pm%aggr_omega_alg - pmout%aggr_eig = pm%aggr_eig - pmout%aggr_filter = pm%aggr_filter - pmout%coarse_mat = pm%coarse_mat - pmout%coarse_solve = pm%coarse_solve - - end subroutine ml_parms_clone - - subroutine s_ml_parms_clone(pm,pmout,info) - - implicit none - class(mld_sml_parms), intent(inout) :: pm - class(mld_ml_parms), intent(out) :: pmout - integer(psb_ipk_), intent(out) :: info - - - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ierr(5) - character(len=20) :: name='clone' - - info = 0 - select type(pout => pmout) - class is (mld_sml_parms) - call pm%mld_ml_parms%clone(pout%mld_ml_parms,info) - pout%aggr_omega_val = pm%aggr_omega_val - pout%aggr_thresh = pm%aggr_thresh - class default - info = psb_err_invalid_dynamic_type_ - ierr(1) = 2 - info = psb_err_missing_override_method_ - call psb_errpush(info,name,i_err=ierr) - call psb_get_erraction(err_act) - call psb_error_handler(err_act) - end select - - end subroutine s_ml_parms_clone - - subroutine d_ml_parms_clone(pm,pmout,info) - - implicit none - class(mld_dml_parms), intent(inout) :: pm - class(mld_ml_parms), intent(out) :: pmout - integer(psb_ipk_), intent(out) :: info - - - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ierr(5) - character(len=20) :: name='clone' - - info = 0 - select type(pout => pmout) - class is (mld_dml_parms) - call pm%mld_ml_parms%clone(pout%mld_ml_parms,info) - pout%aggr_omega_val = pm%aggr_omega_val - pout%aggr_thresh = pm%aggr_thresh - class default - info = psb_err_invalid_dynamic_type_ - ierr(1) = 2 - info = psb_err_missing_override_method_ - call psb_errpush(info,name,i_err=ierr) - call psb_get_erraction(err_act) - call psb_error_handler(err_act) - return - end select - - end subroutine d_ml_parms_clone - - function mld_s_equal_aggregation(parms1, parms2) result(val) - type(mld_sml_parms), intent(in) :: parms1, parms2 - logical :: val - - val = (parms1%par_aggr_alg == parms2%par_aggr_alg ) .and. & - & (parms1%aggr_type == parms2%aggr_type ) .and. & - & (parms1%aggr_ord == parms2%aggr_ord ) .and. & - & (parms1%aggr_prol == parms2%aggr_prol ) .and. & - & (parms1%aggr_omega_alg == parms2%aggr_omega_alg ) .and. & - & (parms1%aggr_eig == parms2%aggr_eig ) .and. & - & (parms1%aggr_filter == parms2%aggr_filter ) .and. & - & (parms1%aggr_omega_val == parms2%aggr_omega_val ) .and. & - & (parms1%aggr_thresh == parms2%aggr_thresh ) - end function mld_s_equal_aggregation - - function mld_d_equal_aggregation(parms1, parms2) result(val) - type(mld_dml_parms), intent(in) :: parms1, parms2 - logical :: val - - val = (parms1%par_aggr_alg == parms2%par_aggr_alg ) .and. & - & (parms1%aggr_type == parms2%aggr_type ) .and. & - & (parms1%aggr_ord == parms2%aggr_ord ) .and. & - & (parms1%aggr_prol == parms2%aggr_prol ) .and. & - & (parms1%aggr_omega_alg == parms2%aggr_omega_alg ) .and. & - & (parms1%aggr_eig == parms2%aggr_eig ) .and. & - & (parms1%aggr_filter == parms2%aggr_filter ) .and. & - & (parms1%aggr_omega_val == parms2%aggr_omega_val ) .and. & - & (parms1%aggr_thresh == parms2%aggr_thresh ) - end function mld_d_equal_aggregation - -end module mld_base_prec_type diff --git a/mlprec/mld_c_as_smoother.f90 b/mlprec/mld_c_as_smoother.f90 deleted file mode 100644 index 017e1520..00000000 --- a/mlprec/mld_c_as_smoother.f90 +++ /dev/null @@ -1,471 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_c_as_smoother_mod.f90 -! -! Module: mld_c_as_smoother_mod -! -! This module defines: -! the mld_c_as_smoother_type data structure containing the -! smoother for an Additive Schwarz smoother. -! -! To begin with, the build procedure constructs the extended -! matrix A and its corresponding descriptor (this has multiple -! halo layers duplicated across different processes); it then -! stores in ND the block off-diagonal matrix, and builds the solver -! on the (extended) block diagonal matrix. -! -! The code allows for the variations of Additive Schwartz, Restricted -! Additive Schwartz and Additive Schwartz with Harmonic Extensions. -! From an implementation point of view, these are handled by -! combining application/non-application of the prolongator/restrictor -! operators. -! -module mld_c_as_smoother - - use mld_c_base_smoother_mod - - type, extends(mld_c_base_smoother_type) :: mld_c_as_smoother_type - ! The local solver component is inherited from the - ! parent type. - ! class(mld_c_base_solver_type), allocatable :: sv - ! - type(psb_cspmat_type) :: nd - type(psb_desc_type) :: desc_data - integer(psb_ipk_) :: novr, restr, prol - integer(psb_lpk_) :: nd_nnz_tot - contains - procedure, pass(sm) :: apply_v => mld_c_as_smoother_apply_vect - procedure, pass(sm) :: apply_a => mld_c_as_smoother_apply - procedure, pass(sm) :: check => mld_c_as_smoother_check - procedure, pass(sm) :: dump => mld_c_as_smoother_dmp - procedure, pass(sm) :: build => mld_c_as_smoother_bld - procedure, pass(sm) :: cnv => mld_c_as_smoother_cnv - procedure, pass(sm) :: clone => mld_c_as_smoother_clone - procedure, pass(sm) :: clone_settings => mld_c_as_smoother_clone_settings - procedure, pass(sm) :: clear_data => mld_c_as_smoother_clear_data - procedure, pass(sm) :: restr_a => mld_c_as_smoother_restr_a - procedure, pass(sm) :: prol_a => mld_c_as_smoother_prol_a - procedure, pass(sm) :: restr_v => mld_c_as_smoother_restr_v - procedure, pass(sm) :: prol_v => mld_c_as_smoother_prol_v - generic, public :: apply_restr => restr_v, restr_a - generic, public :: apply_prol => prol_v, prol_a - procedure, pass(sm) :: free => mld_c_as_smoother_free - procedure, pass(sm) :: cseti => mld_c_as_smoother_cseti - procedure, pass(sm) :: csetc => mld_c_as_smoother_csetc - procedure, pass(sm) :: descr => c_as_smoother_descr - procedure, pass(sm) :: sizeof => c_as_smoother_sizeof - procedure, pass(sm) :: default => c_as_smoother_default - procedure, pass(sm) :: get_nzeros => c_as_smoother_get_nzeros - procedure, pass(sm) :: get_wrksz => c_as_smoother_get_wrksize - procedure, nopass :: get_fmt => c_as_smoother_get_fmt - procedure, nopass :: get_id => c_as_smoother_get_id - end type mld_c_as_smoother_type - - - private :: c_as_smoother_descr, c_as_smoother_sizeof, & - & c_as_smoother_default, c_as_smoother_get_nzeros, & - & c_as_smoother_get_fmt, c_as_smoother_get_id, & - & c_as_smoother_get_wrksize - - character(len=6), parameter, private :: & - & restrict_names(0:4)=(/'none ','halo ',' ',' ',' '/) - character(len=12), parameter, private :: & - & prolong_names(0:3)=(/'none ','sum ','average ','square root'/) - - - interface - subroutine mld_c_as_smoother_check(sm,info) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_spk_, mld_c_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_c_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_as_smoother_check - end interface - - interface - subroutine mld_c_as_smoother_restr_v(sm,x,trans,work,info,data) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_spk_, mld_c_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - class(mld_c_as_smoother_type), intent(inout) :: sm - type(psb_c_vect_type),intent(inout) :: x - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - end subroutine mld_c_as_smoother_restr_v - end interface - - interface - subroutine mld_c_as_smoother_restr_a(sm,x,trans,work,info,data) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_spk_, mld_c_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - class(mld_c_as_smoother_type), intent(inout) :: sm - complex(psb_spk_), intent(inout) :: x(:) - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - end subroutine mld_c_as_smoother_restr_a - end interface - - interface - subroutine mld_c_as_smoother_prol_v(sm,x,trans,work,info,data) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_spk_, mld_c_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - class(mld_c_as_smoother_type), intent(inout) :: sm - type(psb_c_vect_type),intent(inout) :: x - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - end subroutine mld_c_as_smoother_prol_v - end interface - - interface - subroutine mld_c_as_smoother_prol_a(sm,x,trans,work,info,data) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_spk_, mld_c_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - class(mld_c_as_smoother_type), intent(inout) :: sm - complex(psb_spk_), intent(inout) :: x(:) - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - end subroutine mld_c_as_smoother_prol_a - end interface - - - interface - subroutine mld_c_as_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,wv,info,init,initu) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_spk_, mld_c_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_as_smoother_type), intent(inout) :: sm - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - end subroutine mld_c_as_smoother_apply_vect - end interface - - interface - subroutine mld_c_as_smoother_apply(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,info,init,initu) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_spk_, mld_c_as_smoother_type, psb_epk_,& - & psb_desc_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_as_smoother_type), intent(inout) :: sm - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_c_as_smoother_apply - end interface - - interface - subroutine mld_c_as_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_spk_, mld_c_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_c_base_sparse_mat, psb_ipk_,& - & psb_i_base_vect_type - implicit none - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_as_smoother_bld - end interface - - interface - subroutine mld_c_as_smoother_cnv(sm,info,amold,vmold,imold) - import :: psb_c_base_vect_type, & - & psb_spk_, mld_c_as_smoother_type, psb_epk_, & - & psb_c_base_sparse_mat, psb_ipk_, psb_i_base_vect_type - implicit none - class(mld_c_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_as_smoother_cnv - end interface - - interface - subroutine mld_c_as_smoother_cseti(sm,what,val,info,idx) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_spk_, mld_c_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_c_as_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_c_as_smoother_cseti - end interface - - interface - subroutine mld_c_as_smoother_csetc(sm,what,val,info,idx) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_spk_, mld_c_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_c_as_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_c_as_smoother_csetc - end interface - - interface - subroutine mld_c_as_smoother_free(sm,info) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_spk_, mld_c_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_c_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_as_smoother_free - end interface - - interface - subroutine mld_c_as_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_spk_, mld_c_as_smoother_type, psb_epk_, psb_desc_type, & - & psb_ipk_ - implicit none - class(mld_c_as_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - end subroutine mld_c_as_smoother_dmp - end interface - - interface - subroutine mld_c_as_smoother_clone(sm,smout,info) - import :: mld_c_as_smoother_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_ - class(mld_c_as_smoother_type), intent(inout) :: sm - class(mld_c_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_as_smoother_clone - end interface - - - interface - subroutine mld_c_as_smoother_clone_settings(sm,smout,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_smoother_type, mld_c_as_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_as_smoother_type), intent(inout) :: sm - class(mld_c_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_as_smoother_clone_settings - end interface - - interface - subroutine mld_c_as_smoother_clear_data(sm,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_as_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_as_smoother_clear_data - end interface - - -contains - - function c_as_smoother_sizeof(sm) result(val) - implicit none - ! Arguments - class(mld_c_as_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 3*psb_sizeof_ip + psb_sizeof_lp - if (allocated(sm%sv)) val = val + sm%sv%sizeof() - val = val + sm%nd%sizeof() - - return - end function c_as_smoother_sizeof - - function c_as_smoother_get_nzeros(sm) result(val) - implicit none - class(mld_c_as_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - if (allocated(sm%sv)) & - & val = sm%sv%get_nzeros() - val = val + sm%nd%get_nzeros() - - end function c_as_smoother_get_nzeros - - subroutine c_as_smoother_default(sm) - - use psb_base_mod, only : psb_halo_, psb_none_ - - Implicit None - - ! Arguments - class(mld_c_as_smoother_type), intent(inout) :: sm - - ! - ! Default: AS with 1 overlap layer - ! - sm%restr = psb_halo_ - sm%prol = psb_sum_ - sm%novr = 1 - - if (allocated(sm%sv)) then - call sm%sv%default() - end if - - return - end subroutine c_as_smoother_default - - - subroutine c_as_smoother_descr(sm,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_c_as_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_c_as_smoother_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (.not.coarse_) then - write(iout_,*) ' Additive Schwarz with ',& - & sm%novr, ' overlap layers.' - write(iout_,*) ' Restrictor: ',restrict_names(sm%restr) - write(iout_,*) ' Prolongator: ',prolong_names(sm%prol) - write(iout_,*) ' Local solver:' - endif - if (allocated(sm%sv)) then - call sm%sv%descr(info,iout_,coarse=coarse) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine c_as_smoother_descr - - function c_as_smoother_get_wrksize(sm) result(val) - implicit none - class(mld_c_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_) :: val - - val = 3 - if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() - - end function c_as_smoother_get_wrksize - - function c_as_smoother_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Additive Schwarz" - end function c_as_smoother_get_fmt - - function c_as_smoother_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_as_ - end function c_as_smoother_get_id - -end module mld_c_as_smoother diff --git a/mlprec/mld_c_base_aggregator_mod.f90 b/mlprec/mld_c_base_aggregator_mod.f90 deleted file mode 100644 index c51cc83a..00000000 --- a/mlprec/mld_c_base_aggregator_mod.f90 +++ /dev/null @@ -1,519 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! The aggregator object hosts the aggregation method for building -! the multilevel hierarchy. -! -module mld_c_base_aggregator_mod - - use mld_base_prec_type, only : mld_sml_parms, mld_saggr_data - use psb_base_mod, only : psb_cspmat_type, psb_lcspmat_type, psb_c_vect_type, & - & psb_c_base_vect_type, psb_clinmap_type, psb_spk_, & - & psb_lc_csr_sparse_mat, psb_lc_coo_sparse_mat, & - & psb_c_csr_sparse_mat, psb_c_coo_sparse_mat, & - & psb_ipk_, psb_epk_, psb_lpk_, psb_desc_type, psb_i_base_vect_type, & - & psb_erractionsave, psb_error_handler, psb_success_, psb_toupper - ! - ! - ! - !> \class mld_c_base_aggregator_type - !! - !! It is the data type containing the basic interface definition for - !! building a multigrid hierarchy by aggregation. The base object has no attributes, - !! it is intended to be essentially an abstract type. - !! - !! - !! type mld_c_base_aggregator_type - !! end type - !! - !! - !! Methods: - !! - !! bld_tprol - Build a tentative prolongator - !! - !! mat_bld - Build prolongator/restrictor and coarse matrix ac - !! - !! mat_asb - Convert prolongator/restrictor/coarse matrix - !! and fix their descriptor(s) - !! - !! update_next - Transfer information to the next level; default is - !! to do nothing, i.e. aggregators at different - !! levels are independent. - !! - !! default - Apply defaults - !! set_aggr_type - For aggregator that have internal options. - !! fmt - Return a short string description - !! descr - Print a more detailed description - !! - !! cseti, csetr, csetc - Set internal parameters, if any - ! - type mld_c_base_aggregator_type - ! Do we want to purge explicit zeros when aggregating? - logical :: do_clean_zeros - contains - procedure, pass(ag) :: bld_tprol => mld_c_base_aggregator_build_tprol - procedure, pass(ag) :: mat_bld => mld_c_base_aggregator_mat_bld - procedure, pass(ag) :: mat_asb => mld_c_base_aggregator_mat_asb - procedure, pass(ag) :: bld_map => mld_c_base_aggregator_bld_map - procedure, pass(ag) :: update_next => mld_c_base_aggregator_update_next - procedure, pass(ag) :: clone => mld_c_base_aggregator_clone - procedure, pass(ag) :: free => mld_c_base_aggregator_free - procedure, pass(ag) :: default => mld_c_base_aggregator_default - procedure, pass(ag) :: descr => mld_c_base_aggregator_descr - procedure, pass(ag) :: sizeof => mld_c_base_aggregator_sizeof - procedure, pass(ag) :: set_aggr_type => mld_c_base_aggregator_set_aggr_type - procedure, nopass :: fmt => mld_c_base_aggregator_fmt - procedure, pass(ag) :: cseti => mld_c_base_aggregator_cseti - procedure, pass(ag) :: csetr => mld_c_base_aggregator_csetr - procedure, pass(ag) :: csetc => mld_c_base_aggregator_csetc - generic, public :: set => cseti, csetr, csetc - procedure, nopass :: xt_desc => mld_c_base_aggregator_xt_desc - end type mld_c_base_aggregator_type - - abstract interface - subroutine mld_c_soc_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, psb_ipk_, psb_lpk_ - implicit none - integer(psb_ipk_), intent(in) :: iorder - logical, intent(in) :: clean_zeros - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - real(psb_spk_), intent(in) :: theta - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_soc_map_bld - end interface - - interface mld_ptap - subroutine mld_c_ptap(a_csr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_cprol,coo_restr,info,desc_ax) - import :: psb_c_csr_sparse_mat, psb_cspmat_type, psb_desc_type, & - & psb_c_coo_sparse_mat, mld_sml_parms, psb_spk_, psb_ipk_, psb_lpk_ - implicit none - type(psb_c_csr_sparse_mat), intent(inout) :: a_csr - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - type(mld_sml_parms), intent(inout) :: parms - type(psb_c_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr - type(psb_desc_type), intent(inout) :: desc_cprol - type(psb_cspmat_type), intent(out) :: ac - integer(psb_ipk_), intent(out) :: info - type(psb_desc_type), intent(inout), optional :: desc_ax - end subroutine mld_c_ptap -!!$ subroutine mld_c_lc_ptap(a_csr,desc_a,nlaggr,parms,ac,& -!!$ & coo_prol,desc_cprol,coo_restr,info,desc_ax) -!!$ import :: psb_c_csr_sparse_mat, psb_lcspmat_type, psb_desc_type, & -!!$ & psb_lc_coo_sparse_mat, mld_sml_parms, psb_spk_, psb_ipk_, psb_lpk_ -!!$ implicit none -!!$ type(psb_c_csr_sparse_mat), intent(inout) :: a_csr -!!$ type(psb_desc_type), intent(in) :: desc_a -!!$ integer(psb_lpk_), intent(inout) :: nlaggr(:) -!!$ type(mld_sml_parms), intent(inout) :: parms -!!$ type(psb_lc_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr -!!$ type(psb_desc_type), intent(inout) :: desc_cprol -!!$ type(psb_lcspmat_type), intent(out) :: ac -!!$ integer(psb_ipk_), intent(out) :: info -!!$ type(psb_desc_type), intent(inout), optional :: desc_ax -!!$ end subroutine mld_c_lc_ptap -!!$ subroutine mld_lc_ptap(a_csr,desc_a,nlaggr,parms,ac,& -!!$ & coo_prol,desc_cprol,coo_restr,info,desc_ax) -!!$ import :: psb_lc_csr_sparse_mat, psb_lcspmat_type, psb_desc_type, & -!!$ & psb_lc_coo_sparse_mat, mld_sml_parms, psb_spk_, psb_ipk_, psb_lpk_ -!!$ implicit none -!!$ type(psb_lc_csr_sparse_mat), intent(inout) :: a_csr -!!$ type(psb_desc_type), intent(in) :: desc_a -!!$ integer(psb_lpk_), intent(inout) :: nlaggr(:) -!!$ type(mld_sml_parms), intent(inout) :: parms -!!$ type(psb_lc_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr -!!$ type(psb_desc_type), intent(inout) :: desc_cprol -!!$ type(psb_lcspmat_type), intent(out) :: ac -!!$ integer(psb_ipk_), intent(out) :: info -!!$ type(psb_desc_type), intent(inout), optional :: desc_ax -!!$ end subroutine mld_lc_ptap - end interface mld_ptap - -contains - - subroutine mld_c_base_aggregator_cseti(ag,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_c_base_aggregator_type), intent(inout) :: ag - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - ! Do nothing - info = 0 - end subroutine mld_c_base_aggregator_cseti - - subroutine mld_c_base_aggregator_csetr(ag,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_c_base_aggregator_type), intent(inout) :: ag - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - ! Do nothing - info = 0 - end subroutine mld_c_base_aggregator_csetr - - subroutine mld_c_base_aggregator_csetc(ag,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_c_base_aggregator_type), intent(inout) :: ag - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - ! Set clean zeros, or do nothing. - select case (psb_toupper(trim(what))) - case('AGGR_CLEAN_ZEROS') - select case (psb_toupper(trim(val))) - case('TRUE','T') - ag%do_clean_zeros = .true. - case('FALSE','F') - ag%do_clean_zeros = .false. - end select - end select - info = 0 - end subroutine mld_c_base_aggregator_csetc - - - subroutine mld_c_base_aggregator_update_next(ag,agnext,info) - implicit none - class(mld_c_base_aggregator_type), target, intent(inout) :: ag, agnext - integer(psb_ipk_), intent(out) :: info - - ! - ! Base version does nothing. - ! - info = 0 - end subroutine mld_c_base_aggregator_update_next - - subroutine mld_c_base_aggregator_clone(ag,agnext,info) - implicit none - class(mld_c_base_aggregator_type), intent(inout) :: ag - class(mld_c_base_aggregator_type), allocatable, intent(inout) :: agnext - integer(psb_ipk_), intent(out) :: info - - info = 0 - if (allocated(agnext)) then - call agnext%free(info) - if (info == 0) deallocate(agnext,stat=info) - end if - if (info /= 0) return - allocate(agnext,source=ag,stat=info) - - end subroutine mld_c_base_aggregator_clone - - subroutine mld_c_base_aggregator_free(ag,info) - implicit none - class(mld_c_base_aggregator_type), intent(inout) :: ag - integer(psb_ipk_), intent(out) :: info - - info = psb_success_ - return - end subroutine mld_c_base_aggregator_free - - subroutine mld_c_base_aggregator_default(ag) - implicit none - class(mld_c_base_aggregator_type), intent(inout) :: ag - ! Only one default setting - ag%do_clean_zeros = .true. - - return - end subroutine mld_c_base_aggregator_default - - function mld_c_base_aggregator_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Default aggregator " - end function mld_c_base_aggregator_fmt - - function mld_c_base_aggregator_sizeof(ag) result(val) - implicit none - class(mld_c_base_aggregator_type), intent(in) :: ag - integer(psb_epk_) :: val - - val = 1 - end function mld_c_base_aggregator_sizeof - - function mld_c_base_aggregator_xt_desc() result(val) - implicit none - logical :: val - - val = .false. - end function mld_c_base_aggregator_xt_desc - - subroutine mld_c_base_aggregator_descr(ag,parms,iout,info) - implicit none - class(mld_c_base_aggregator_type), intent(in) :: ag - type(mld_sml_parms), intent(in) :: parms - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - - write(iout,*) 'Aggregator object type: ',ag%fmt() - call parms%mldescr(iout,info) - - return - end subroutine mld_c_base_aggregator_descr - - subroutine mld_c_base_aggregator_set_aggr_type(ag,parms,info) - implicit none - class(mld_c_base_aggregator_type), intent(inout) :: ag - type(mld_sml_parms), intent(in) :: parms - integer(psb_ipk_), intent(out) :: info - - ! Do nothing - - return - end subroutine mld_c_base_aggregator_set_aggr_type - - ! - !> Function bld_tprol: - !! \memberof mld_c_base_aggregator_type - !! \brief Build a tentative prolongator. - !! The routine will map the local matrix entries to aggregates. - !! The mapping is store in ILAGGR; for each local row index I, - !! ILAGGR(I) contains the index of the aggregate to which index I - !! will contribute, in global numbering. - !! Many aggregations produce a binary tentative prolongator, but some - !! do not, hence we also need the OP_PROL output. - !! AG_DATA is passed here just in case some of the - !! aggregators need it internally, most of them will ignore. - !! - !! \param ag The input aggregator object - !! \param parms The auxiliary parameters object - !! \param ag_data Auxiliary global aggregation info - !! \param a The local matrix part - !! \param desc_a The descriptor - !! \param ilaggr Output aggregation map - !! \param nlaggr Sizes of ilaggr on all processes - !! \param op_prol The tentative prolongator operator - !! \param info Return code - !! - ! - subroutine mld_c_base_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,t_prol,info) - use psb_base_mod - implicit none - class(mld_c_base_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(mld_saggr_data), intent(in) :: ag_data - type(psb_cspmat_type), intent(inout) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lcspmat_type), intent(out) :: t_prol - integer(psb_ipk_), intent(out) :: info - - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_aggregator_build_tprol' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - - end subroutine mld_c_base_aggregator_build_tprol - - ! - !> Function mat_bld - !! \memberof mld_c_base_aggregator_type - !! \brief Build prolongator/restrictor/coarse matrix. - !! - !! - !! \param ag The input aggregator object - !! \param parms The auxiliary parameters object - !! \param a The local matrix part - !! \param desc_a The descriptor - !! \param ilaggr Aggregation map - !! \param nlaggr Sizes of ilaggr on all processes - !! \param ac On output the coarse matrix - !! \param op_prol On input, the tentative prolongator operator, on output - !! the final prolongator - !! \param op_restr On output, the restrictor operator; - !! in many cases it is the transpose of the prolongator. - !! \param info Return code - !! - subroutine mld_c_base_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - use psb_base_mod - implicit none - class(mld_c_base_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(psb_lcspmat_type), intent(inout) :: t_prol - type(psb_cspmat_type), intent(out) :: op_prol, ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_aggregator_mat_bld' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - end subroutine mld_c_base_aggregator_mat_bld - - ! - !> Function mat_asb - !! \memberof mld_c_base_aggregator_type - !! \brief Build prolongator/restrictor/coarse matrix. - !! - !! - !! \param ag The input aggregator object - !! \param parms The auxiliary parameters object - !! \param a The local matrix part - !! \param desc_a The descriptor - !! \param ilaggr Aggregation map - !! \param nlaggr Sizes of ilaggr on all processes - !! \param ac On output the coarse matrix - !! \param op_prol On input, the tentative prolongator operator, on output - !! the final prolongator - !! \param op_restr On output, the restrictor operator; - !! in many cases it is the transpose of the prolongator. - !! \param info Return code - !! - subroutine mld_c_base_aggregator_mat_asb(ag,parms,a,desc_a,& - & ac,desc_ac, op_prol,op_restr,info) - use psb_base_mod - implicit none - class(mld_c_base_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - type(psb_cspmat_type), intent(inout) :: op_prol,ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_aggregator_mat_asb' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - end subroutine mld_c_base_aggregator_mat_asb - - ! - !> Function bld_map - !! \memberof mld_c_base_aggregator_type - !! \brief Build linear map between hierarchy levels - !! - !! - !! \param ag The input aggregator object - !! \param desc_a The fine space descriptor - !! \param desc_ac The coarse space descriptor - !! \param ilaggr Aggregation map vector - !! \param nlaggr Sizes of ilaggr on all processes - !! \param op_prol The prolongator operator - !! \param op_restr The restrictor operator - !! \param map The output map - !! \param info Return code - !! - subroutine mld_c_base_aggregator_bld_map(ag,desc_a,desc_ac,ilaggr,nlaggr,& - & op_restr,op_prol,map,info) - use psb_base_mod - implicit none - class(mld_c_base_aggregator_type), target, intent(inout) :: ag - type(psb_desc_type), intent(in), target :: desc_a, desc_ac - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(psb_cspmat_type), intent(inout) :: op_restr, op_prol - type(psb_clinmap_type), intent(out) :: map - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_base_aggregator_bld_map' - - call psb_erractionsave(err_act) - ! - ! Copy the prolongation/restriction matrices into the descriptor map. - ! op_restr => PR^T i.e. restriction operator - ! op_prol => PR i.e. prolongation operator - ! - ! WARNING: need to check whether the copy into IOP_RESTR/IOP_PROL - ! is safe or not. - ! - ! This default implementation reuses desc_a/desc_ac through - ! pointers in the map structure. - ! - map = psb_linmap(psb_map_aggr_,desc_a,& - & desc_ac,op_restr,op_prol,ilaggr,nlaggr) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - end subroutine mld_c_base_aggregator_bld_map - - -end module mld_c_base_aggregator_mod diff --git a/mlprec/mld_c_base_smoother_mod.f90 b/mlprec/mld_c_base_smoother_mod.f90 deleted file mode 100644 index b7c8cd0a..00000000 --- a/mlprec/mld_c_base_smoother_mod.f90 +++ /dev/null @@ -1,412 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_c_base_smoother_mod.f90 -! -! Module: mld_c_base_smoother_mod -! -! This module defines: -! - the mld_c_base_smoother_type data structure containing the -! smoother and related data structures; -! -! It contains routines for -! - Building and applying; -! - checking if the smoother is correctly defined; -! - printing a description of the preconditioner; -! - deallocating the preconditioner data structure. -! -! What is the difference between a smoother and a solver? -! In the mathematics literature the two concepts are treated -! essentially as synonymous, but here we are using them in a more -! computer-science oriented fashion. In particular, a SMOOTHER object -! contains a SOLVER object: the SOLVER operates locally within the -! current process, whereas the SMOOTHER object accounts for (possible) -! interactions between processes. -! Some solvers (MUMPS and SuperLU_DIST) can also operate on the entire -! distributed matrix, in which case the smoother object essentially -! becomes transparent. -! -module mld_c_base_smoother_mod - - use mld_c_base_solver_mod - use psb_base_mod, only : psb_desc_type, psb_cspmat_type, psb_epk_,& - & psb_c_vect_type, psb_c_base_vect_type, psb_c_base_sparse_mat, & - & psb_spk_, psb_i_base_vect_type, psb_erractionsave, psb_error_handler - - ! - ! - ! - ! Type: mld_T_base_smoother_type. - ! - ! It holds the smoother a single level. Its only mandatory component is a solver - ! object which holds a local solver; this decoupling allows to have the same solver - ! e.g ILU to work with Jacobi with multiple sweeps as well as with any AS variant. - ! - ! type mld_T_base_smoother_type - ! class(mld_T_base_solver_type), allocatable :: sv - ! end type mld_T_base_smoother_type - ! - ! Methods: - ! - ! build - Compute the actual contents of the smoother; includes - ! invocation of the build method on the solver component. - ! free - Release memory - ! apply - Apply the smoother to a vector (or to an array); includes - ! invocation of the apply method on the solver component. - ! descr - Prints a description of the object. - ! default - Set default values - ! dump - Dump to file object contents - ! set - Sets various parameters; when a request is unknown - ! it is passed to the solver object for further processing. - ! check - Sanity checks. - ! sizeof - Total memory occupation in bytes - ! get_nzeros - Number of nonzeros - ! stringval - convert string to val for internal parms - ! get_fmt - short string descriptor - ! get_id - numeric id descriptro - ! get_wrksz - How many workspace vector does apply_vect need - ! - ! - ! - - type mld_c_base_smoother_type - class(mld_c_base_solver_type), allocatable :: sv - contains - procedure, pass(sm) :: apply_v => mld_c_base_smoother_apply_vect - procedure, pass(sm) :: apply_a => mld_c_base_smoother_apply - generic, public :: apply => apply_a, apply_v - procedure, pass(sm) :: check => mld_c_base_smoother_check - procedure, pass(sm) :: dump => mld_c_base_smoother_dmp - procedure, pass(sm) :: clone => mld_c_base_smoother_clone - procedure, pass(sm) :: build => mld_c_base_smoother_bld - procedure, pass(sm) :: cnv => mld_c_base_smoother_cnv - procedure, pass(sm) :: free => mld_c_base_smoother_free - procedure, pass(sm) :: clone_settings => mld_c_base_smoother_clone_settings - procedure, pass(sm) :: clear_data => mld_c_base_smoother_clear_data - procedure, pass(sm) :: cseti => mld_c_base_smoother_cseti - procedure, pass(sm) :: csetc => mld_c_base_smoother_csetc - procedure, pass(sm) :: csetr => mld_c_base_smoother_csetr - generic, public :: set => cseti, csetc, csetr - procedure, pass(sm) :: default => c_base_smoother_default - procedure, pass(sm) :: descr => mld_c_base_smoother_descr - procedure, pass(sm) :: sizeof => c_base_smoother_sizeof - procedure, pass(sm) :: get_nzeros => c_base_smoother_get_nzeros - procedure, pass(sm) :: get_wrksz => c_base_smoother_get_wrksize - procedure, nopass :: stringval => mld_stringval - procedure, nopass :: get_fmt => c_base_smoother_get_fmt - procedure, nopass :: get_id => c_base_smoother_get_id - end type mld_c_base_smoother_type - - - private :: c_base_smoother_sizeof, c_base_smoother_get_fmt, & - & c_base_smoother_default, c_base_smoother_get_nzeros, & - & c_base_smoother_get_id, c_base_smoother_get_wrksize - - - - interface - subroutine mld_c_base_smoother_apply(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,info,init,initu) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_base_smoother_type), intent(inout) :: sm - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_c_base_smoother_apply - end interface - - interface - subroutine mld_c_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,wv,info,init,initu) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_base_smoother_type), intent(inout) :: sm - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - end subroutine mld_c_base_smoother_apply_vect - end interface - - interface - subroutine mld_c_base_smoother_check(sm,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_base_smoother_check - end interface - - interface - subroutine mld_c_base_smoother_cseti(sm,what,val,info,idx) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_c_base_smoother_cseti - end interface - - interface - subroutine mld_c_base_smoother_csetc(sm,what,val,info,idx) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_ - class(mld_c_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_c_base_smoother_csetc - end interface - - interface - subroutine mld_c_base_smoother_csetr(sm,what,val,info,idx) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_c_base_smoother_csetr - end interface - - interface - subroutine mld_c_base_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_, psb_i_base_vect_type - ! Arguments - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_base_smoother_bld - end interface - - interface - subroutine mld_c_base_smoother_cnv(sm,info,amold,vmold,imold) - import :: psb_c_base_sparse_mat, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_, psb_i_base_vect_type - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_base_smoother_cnv - end interface - - interface - subroutine mld_c_base_smoother_free(sm,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_base_smoother_free - end interface - - interface - subroutine mld_c_base_smoother_descr(sm,info,iout,coarse) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_c_base_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - end subroutine mld_c_base_smoother_descr - end interface - - interface - subroutine mld_c_base_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_ - class(mld_c_base_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - end subroutine mld_c_base_smoother_dmp - end interface - - interface - subroutine mld_c_base_smoother_clone(sm,smout,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - class(mld_c_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_base_smoother_clone - end interface - - interface - subroutine mld_c_base_smoother_clone_settings(sm,smout,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - class(mld_c_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_base_smoother_clone_settings - end interface - - interface - subroutine mld_c_base_smoother_clear_data(sm,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_base_smoother_clear_data - end interface - -contains - ! - ! Function returning the size of the mld_prec_type data structure - ! in bytes or in number of nonzeros of the operator(s) involved. - ! - - function c_base_smoother_get_nzeros(sm) result(val) - implicit none - class(mld_c_base_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - if (allocated(sm%sv)) & - & val = sm%sv%get_nzeros() - end function c_base_smoother_get_nzeros - - function c_base_smoother_sizeof(sm) result(val) - implicit none - ! Arguments - class(mld_c_base_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - if (allocated(sm%sv)) then - val = sm%sv%sizeof() - end if - - return - end function c_base_smoother_sizeof - - ! - ! Set sensible defaults. - ! To be called immediately after allocation - ! - subroutine c_base_smoother_default(sm) - implicit none - ! Arguments - class(mld_c_base_smoother_type), intent(inout) :: sm - ! Do nothing for base version - - if (allocated(sm%sv)) call sm%sv%default() - - return - end subroutine c_base_smoother_default - - function c_base_smoother_get_wrksize(sm) result(val) - implicit none - class(mld_c_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_) :: val - - val = 0 - if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() - - end function c_base_smoother_get_wrksize - - function c_base_smoother_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Base smoother" - end function c_base_smoother_get_fmt - - function c_base_smoother_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_base_smooth_ - end function c_base_smoother_get_id - -end module mld_c_base_smoother_mod diff --git a/mlprec/mld_c_base_solver_mod.f90 b/mlprec/mld_c_base_solver_mod.f90 deleted file mode 100644 index fe0a1b07..00000000 --- a/mlprec/mld_c_base_solver_mod.f90 +++ /dev/null @@ -1,421 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_c_base_solver_mod.f90 -! -! Module: mld_c_base_solver_mod -! -! This module defines: -! - the mld_c_base_solver_type data structure containing the -! basic solver type acting on a subdomain -! -! It contains routines for -! - Building and applying; -! - checking if the solver is correctly defined; -! - printing a description of the solver; -! - deallocating the data structure. -! - -module mld_c_base_solver_mod - - use mld_base_prec_type - use psb_base_mod, only : psb_cspmat_type, & - & psb_c_vect_type, psb_c_base_vect_type, psb_c_base_sparse_mat, & - & psb_spk_, psb_i_base_vect_type, psb_erractionsave, psb_error_handler - ! - ! - ! Type: mld_T_base_solver_type. - ! - ! It holds the local solver; it has no mandatory components. - ! - ! type mld_T_base_solver_type - ! end type mld_T_base_solver_type - ! - ! build - Compute the actual contents of the smoother; includes - ! invocation of the build method on the solver component. - ! free - Release memory - ! apply - Apply the smoother to a vector (or to an array); includes - ! invocation of the apply method on the solver component. - ! descr - Prints a description of the object. - ! default - Set default values - ! dump - Dump to file object contents - ! set - Sets various parameters; when a request is unknown - ! it is passed to the smoother object for further processing. - ! check - Sanity checks. - ! sizeof - Total memory occupation in bytes - ! get_nzeros - Number of nonzeros - ! stringval - convert string to val for internal parms - ! get_fmt - short string descriptor - ! get_id - numeric id descriptro - ! get_wrksz - How many workspace vector does apply_vect need - ! - ! - - type mld_c_base_solver_type - contains - procedure, pass(sv) :: apply_v => mld_c_base_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_c_base_solver_apply - generic, public :: apply => apply_a, apply_v - procedure, pass(sv) :: check => mld_c_base_solver_check - procedure, pass(sv) :: dump => mld_c_base_solver_dmp - procedure, pass(sv) :: clone => mld_c_base_solver_clone - procedure, pass(sv) :: clone_settings => mld_c_base_solver_clone_settings - procedure, pass(sv) :: clear_data => mld_c_base_solver_clear_data - procedure, pass(sv) :: build => mld_c_base_solver_bld - procedure, pass(sv) :: cnv => mld_c_base_solver_cnv - procedure, pass(sv) :: free => mld_c_base_solver_free - procedure, pass(sv) :: cseti => mld_c_base_solver_cseti - procedure, pass(sv) :: csetc => mld_c_base_solver_csetc - procedure, pass(sv) :: csetr => mld_c_base_solver_csetr - generic, public :: set => cseti, csetc, csetr - procedure, pass(sv) :: default => c_base_solver_default - procedure, pass(sv) :: descr => mld_c_base_solver_descr - procedure, pass(sv) :: sizeof => c_base_solver_sizeof - procedure, pass(sv) :: get_nzeros => c_base_solver_get_nzeros - procedure, nopass :: get_wrksz => c_base_solver_get_wrksize - procedure, nopass :: stringval => mld_stringval - procedure, nopass :: get_fmt => c_base_solver_get_fmt - procedure, nopass :: get_id => c_base_solver_get_id - procedure, nopass :: is_iterative => c_base_solver_is_iterative - procedure, pass(sv) :: is_global => c_base_solver_is_global - end type mld_c_base_solver_type - - private :: c_base_solver_sizeof, c_base_solver_default,& - & c_base_solver_get_nzeros, c_base_solver_get_fmt, & - & c_base_solver_is_iterative, c_base_solver_get_id, & - & c_base_solver_get_wrksize, c_base_solver_is_global - - - interface - subroutine mld_c_base_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_base_solver_type), intent(inout) :: sv - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_c_base_solver_apply - end interface - - - interface - subroutine mld_c_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_base_solver_type), intent(inout) :: sv - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - end subroutine mld_c_base_solver_apply_vect - end interface - - interface - subroutine mld_c_base_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, psb_ipk_, psb_i_base_vect_type - Implicit None - - ! Arguments - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type), intent(in), target, optional :: b - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_base_solver_bld - end interface - - interface - subroutine mld_c_base_solver_cnv(sv,info,amold,vmold,imold) - import :: psb_c_base_sparse_mat, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, psb_ipk_, psb_i_base_vect_type - Implicit None - - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_base_solver_cnv - end interface - - interface - subroutine mld_c_base_solver_check(sv,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_base_solver_check - end interface - - interface - subroutine mld_c_base_solver_cseti(sv,what,val,info,idx) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_c_base_solver_cseti - end interface - - interface - subroutine mld_c_base_solver_csetc(sv,what,val,info,idx) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_c_base_solver_csetc - end interface - - interface - subroutine mld_c_base_solver_csetr(sv,what,val,info,idx) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, psb_ipk_ - Implicit None - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_c_base_solver_csetr - end interface - - interface - subroutine mld_c_base_solver_free(sv,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_base_solver_free - end interface - - interface - subroutine mld_c_base_solver_descr(sv,info,iout,coarse) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_base_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - end subroutine mld_c_base_solver_descr - end interface - - interface - subroutine mld_c_base_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, psb_ipk_ - implicit none - class(mld_c_base_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_c_base_solver_dmp - end interface - - interface - subroutine mld_c_base_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_base_solver_clone - end interface - - interface - subroutine mld_c_base_solver_clone_settings(sv,svout,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_base_solver_clone_settings - end interface - - interface - subroutine mld_c_base_solver_clear_data(sv,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_base_solver_clear_data - end interface - -contains - ! - ! Function returning the size of the data structure - ! in bytes or in number of nonzeros of the operator(s) involved. - ! - - function c_base_solver_sizeof(sv) result(val) - implicit none - ! Arguments - class(mld_c_base_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - - return - end function c_base_solver_sizeof - - function c_base_solver_get_nzeros(sv) result(val) - implicit none - class(mld_c_base_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - end function c_base_solver_get_nzeros - - subroutine c_base_solver_default(sv) - implicit none - ! Arguments - class(mld_c_base_solver_type), intent(inout) :: sv - ! Do nothing for base version - - return - end subroutine c_base_solver_default - - function c_base_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Base solver" - end function c_base_solver_get_fmt - - ! - ! If this is true, then the solver needs a starting - ! guess. Currently only handled in JAC smoother. - ! - function c_base_solver_is_iterative() result(val) - implicit none - logical :: val - - val = .false. - end function c_base_solver_is_iterative - ! - ! Is the solver acting globally? In most cases - ! not, SuperLU_Dist does, MUMPS can do either. - ! - function c_base_solver_is_global(sv) result(val) - implicit none - class(mld_c_base_solver_type), intent(in) :: sv - logical :: val - - val = .false. - end function c_base_solver_is_global - - function c_base_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_f_none_ - end function c_base_solver_get_id - - function c_base_solver_get_wrksize() result(val) - implicit none - integer(psb_ipk_) :: val - - val = 0 - end function c_base_solver_get_wrksize - -end module mld_c_base_solver_mod diff --git a/mlprec/mld_c_dec_aggregator_mod.f90 b/mlprec/mld_c_dec_aggregator_mod.f90 deleted file mode 100644 index 4af836c7..00000000 --- a/mlprec/mld_c_dec_aggregator_mod.f90 +++ /dev/null @@ -1,201 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! Basic (decoupled) aggregation algorithm. Based on the ideas in -! M. Brezina and P. Vanek, A black-box iterative solver based on a -! two-level Schwarz method, Computing, 63 (1999), 233-263. -! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed -! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 -! (1996), 179-196. -! -module mld_c_dec_aggregator_mod - - use mld_c_base_aggregator_mod - !> \namespace mld_c_dec_aggregator_mod \class mld_c_dec_aggregator_type - !! \extends mld_c_base_aggregator_mod::mld_c_base_aggregator_type - !! - !! type, extends(mld_c_base_aggregator_type) :: mld_c_dec_aggregator_type - !! procedure(mld_c_soc_map_bld), nopass, pointer :: soc_map_bld => null() - !! end type - !! - !! This is the simplest aggregation method: starting from the - !! strength-of-connection measure for defining the aggregation - !! presented in - !! - !! M. Brezina and P. Vanek, A black-box iterative solver based on a - !! two-level Schwarz method, Computing, 63 (1999), 233-263. - !! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed - !! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 - !! (1996), 179-196. - !! - !! it achieves parallelization by simply acting on the local matrix, - !! i.e. by "decoupling" the subdomains. - !! The data structure hosts a "map_bld" function pointer which allows to - !! choose other ways to measure "strength-of-connection", of which the - !! Vanek-Brezina-Mandel is the default. More details are available in - !! - !! P. D'Ambra, D. di Serafino and S. Filippone, On the development of - !! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math. - !! 57 (2007), 1181-1196. - !! - !! The soc_map_bld method is used inside the implementation of build_tprol - !! - ! - ! - type, extends(mld_c_base_aggregator_type) :: mld_c_dec_aggregator_type - procedure(mld_c_soc_map_bld), nopass, pointer :: soc_map_bld => null() - - contains - procedure, pass(ag) :: bld_tprol => mld_c_dec_aggregator_build_tprol - procedure, pass(ag) :: mat_bld => mld_c_dec_aggregator_mat_bld - procedure, pass(ag) :: mat_asb => mld_c_dec_aggregator_mat_asb - procedure, pass(ag) :: default => mld_c_dec_aggregator_default - procedure, pass(ag) :: set_aggr_type => mld_c_dec_aggregator_set_aggr_type - procedure, pass(ag) :: descr => mld_c_dec_aggregator_descr - procedure, nopass :: fmt => mld_c_dec_aggregator_fmt - end type mld_c_dec_aggregator_type - - - procedure(mld_c_soc_map_bld) :: mld_c_soc1_map_bld, mld_c_soc2_map_bld - - interface - subroutine mld_c_dec_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,t_prol,info) - import :: mld_c_dec_aggregator_type, psb_desc_type, psb_cspmat_type, psb_spk_, & - & psb_ipk_, psb_lpk_, psb_lcspmat_type, mld_sml_parms, mld_saggr_data - implicit none - class(mld_c_dec_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(mld_saggr_data), intent(in) :: ag_data - type(psb_cspmat_type), intent(inout) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lcspmat_type), intent(out) :: t_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_dec_aggregator_build_tprol - end interface - - interface - subroutine mld_c_dec_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - import :: mld_c_dec_aggregator_type, psb_desc_type, psb_cspmat_type, psb_spk_, & - & psb_ipk_, psb_lpk_, psb_lcspmat_type, mld_sml_parms - implicit none - class(mld_c_dec_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(psb_lcspmat_type), intent(inout) :: t_prol - type(psb_cspmat_type), intent(out) :: op_prol, ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_dec_aggregator_mat_bld - end interface - - interface - subroutine mld_c_dec_aggregator_mat_asb(ag,parms,a,desc_a,& - & ac,desc_ac,op_prol,op_restr,info) - import :: mld_c_dec_aggregator_type, psb_desc_type, psb_cspmat_type, psb_spk_, & - & psb_ipk_, psb_lpk_, psb_lcspmat_type, mld_sml_parms - implicit none - class(mld_c_dec_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - type(psb_cspmat_type), intent(inout) :: op_prol,ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_dec_aggregator_mat_asb - end interface - -contains - - subroutine mld_c_dec_aggregator_set_aggr_type(ag,parms,info) - use mld_base_prec_type - implicit none - class(mld_c_dec_aggregator_type), intent(inout) :: ag - type(mld_sml_parms), intent(in) :: parms - integer(psb_ipk_), intent(out) :: info - - select case(parms%aggr_type) - case (mld_noalg_) - ag%soc_map_bld => null() - case (mld_soc1_) - ag%soc_map_bld => mld_c_soc1_map_bld - case (mld_soc2_) - ag%soc_map_bld => mld_c_soc2_map_bld - case default - write(0,*) 'Unknown aggregation type, defaulting to SOC1' - ag%soc_map_bld => mld_c_soc1_map_bld - end select - - return - end subroutine mld_c_dec_aggregator_set_aggr_type - - - subroutine mld_c_dec_aggregator_default(ag) - implicit none - class(mld_c_dec_aggregator_type), intent(inout) :: ag - - call ag%mld_c_base_aggregator_type%default() - ag%soc_map_bld => mld_c_soc1_map_bld - - return - end subroutine mld_c_dec_aggregator_default - - function mld_c_dec_aggregator_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Decoupled aggregation" - end function mld_c_dec_aggregator_fmt - - subroutine mld_c_dec_aggregator_descr(ag,parms,iout,info) - implicit none - class(mld_c_dec_aggregator_type), intent(in) :: ag - type(mld_sml_parms), intent(in) :: parms - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - - write(iout,*) 'Decoupled Aggregator' - write(iout,*) 'Aggregator object type: ',ag%fmt() - call parms%mldescr(iout,info) - - return - end subroutine mld_c_dec_aggregator_descr - -end module mld_c_dec_aggregator_mod diff --git a/mlprec/mld_c_diag_solver.f90 b/mlprec/mld_c_diag_solver.f90 deleted file mode 100644 index e5212b63..00000000 --- a/mlprec/mld_c_diag_solver.f90 +++ /dev/null @@ -1,398 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_c_diag_solver_mod.f90 -! -! Module: mld_c_diag_solver_mod -! -! This module defines: -! - the mld_c_diag_solver_type data structure containing the -! simple diagonal solver. This extracts the main diagonal of a matrix -! and precomputes its inverse. Combined with a Jacobi "smoother" generates -! what are commonly known as the classic Jacobi iterations -! -module mld_c_diag_solver - - use mld_c_base_solver_mod - - type, extends(mld_c_base_solver_type) :: mld_c_diag_solver_type - type(psb_c_vect_type), allocatable :: dv - complex(psb_spk_), allocatable :: d(:) - contains - procedure, pass(sv) :: dump => mld_c_diag_solver_dmp - procedure, pass(sv) :: build => mld_c_diag_solver_bld - procedure, pass(sv) :: cnv => mld_c_diag_solver_cnv - procedure, pass(sv) :: clone => mld_c_diag_solver_clone - procedure, pass(sv) :: clear_data => mld_c_diag_solver_clear_data - procedure, pass(sv) :: apply_v => mld_c_diag_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_c_diag_solver_apply - procedure, pass(sv) :: free => c_diag_solver_free - procedure, pass(sv) :: descr => c_diag_solver_descr - procedure, pass(sv) :: sizeof => c_diag_solver_sizeof - procedure, pass(sv) :: get_nzeros => c_diag_solver_get_nzeros - procedure, nopass :: get_fmt => c_diag_solver_get_fmt - procedure, nopass :: get_id => c_diag_solver_get_id - end type mld_c_diag_solver_type - - - private :: c_diag_solver_free, c_diag_solver_descr, & - & c_diag_solver_sizeof, c_diag_solver_get_nzeros, & - & c_diag_solver_get_fmt, c_diag_solver_get_id - - - interface - subroutine mld_c_diag_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_diag_solver_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_diag_solver_type), intent(inout) :: sv - type(psb_c_vect_type), intent(inout) :: x - type(psb_c_vect_type), intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - end subroutine mld_c_diag_solver_apply_vect - end interface - - interface - subroutine mld_c_diag_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_diag_solver_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_diag_solver_type), intent(inout) :: sv - complex(psb_spk_), intent(inout) :: x(:) - complex(psb_spk_), intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_c_diag_solver_apply - end interface - - interface - subroutine mld_c_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_diag_solver_type, psb_ipk_, psb_i_base_vect_type - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type), intent(in), target, optional :: b - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_diag_solver_bld - end interface - - interface - subroutine mld_c_diag_solver_cnv(sv,info,amold,vmold,imold) - import :: psb_c_base_sparse_mat, psb_c_base_vect_type, psb_spk_, & - & mld_c_diag_solver_type, psb_ipk_, psb_i_base_vect_type - class(mld_c_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_diag_solver_cnv - end interface - - interface - subroutine mld_c_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, mld_c_diag_solver_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, & - & psb_ipk_ - implicit none - class(mld_c_diag_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_c_diag_solver_dmp - end interface - - interface - subroutine mld_c_diag_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, mld_c_diag_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_diag_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_diag_solver_clone - end interface - - interface - subroutine mld_c_diag_solver_clear_data(sv,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_diag_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_diag_solver_clear_data - end interface - - -contains - - subroutine c_diag_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_c_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_diag_solver_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sv%dv)) call sv%dv%free(info) - - if (allocated(sv%d)) then - deallocate(sv%d,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine c_diag_solver_free - - subroutine c_diag_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_c_diag_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_c_diag_solver_descr' - integer(psb_ipk_) :: iout_ - - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' Diagonal local solver ' - - return - - end subroutine c_diag_solver_descr - - function c_diag_solver_sizeof(sv) result(val) - implicit none - ! Arguments - class(mld_c_diag_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - if (allocated(sv%dv)) val = val + sv%dv%sizeof() - - return - end function c_diag_solver_sizeof - - function c_diag_solver_get_nzeros(sv) result(val) - implicit none - ! Arguments - class(mld_c_diag_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - if (allocated(sv%dv)) val = val + sv%dv%get_nrows() - - return - end function c_diag_solver_get_nzeros - - function c_diag_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Diag solver" - end function c_diag_solver_get_fmt - - function c_diag_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_diag_scale_ - end function c_diag_solver_get_id - -end module mld_c_diag_solver - -! -! Module: mld_c_l1_diag_solver_mod -! -! This module defines: -! - the mld_c_l1_diag_solver_type data structure containing the -! L1 diagonal solver. -! The solver is defined as a diagonal containing in each element the -! inverse of the sum of the absolute values of the matrix entries -! along the corresponding row. -! Combined with a Jacobi "smoother" generates -! what are commonly known as the L1-Jacobi iterations -! - -module mld_c_l1_diag_solver - - use mld_c_diag_solver - - type, extends(mld_c_diag_solver_type) :: mld_c_l1_diag_solver_type - contains - procedure, pass(sv) :: dump => mld_c_l1_diag_solver_dmp - procedure, pass(sv) :: build => mld_c_l1_diag_solver_bld - procedure, pass(sv) :: descr => c_l1_diag_solver_descr - procedure, nopass :: get_fmt => c_l1_diag_solver_get_fmt - procedure, nopass :: get_id => c_l1_diag_solver_get_id - end type mld_c_l1_diag_solver_type - - - private :: c_l1_diag_solver_descr, & - & c_l1_diag_solver_get_fmt, c_l1_diag_solver_get_id - - interface - subroutine mld_c_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_l1_diag_solver_type, psb_ipk_, psb_i_base_vect_type - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_l1_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type), intent(in), target, optional :: b - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_l1_diag_solver_bld - end interface - - interface - subroutine mld_c_l1_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, mld_c_l1_diag_solver_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, & - & psb_ipk_ - implicit none - class(mld_c_l1_diag_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_c_l1_diag_solver_dmp - end interface - -contains - - subroutine c_l1_diag_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_c_l1_diag_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_c_l1_diag_solver_descr' - integer(psb_ipk_) :: iout_ - - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' L1 Diagonal solver ' - - return - - end subroutine c_l1_diag_solver_descr - - function c_l1_diag_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "L1 Diag solver" - end function c_l1_diag_solver_get_fmt - - function c_l1_diag_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_l1_diag_scale_ - end function c_l1_diag_solver_get_id - -end module mld_c_l1_diag_solver - diff --git a/mlprec/mld_c_gs_solver.f90 b/mlprec/mld_c_gs_solver.f90 deleted file mode 100644 index 8bb92e83..00000000 --- a/mlprec/mld_c_gs_solver.f90 +++ /dev/null @@ -1,588 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! File: mld_c_gs_solver_mod.f90 -! -! Module: mld_c_gs_solver_mod -! -! This module defines: -! - the mld_c_gs_solver_type data structure containing the ingredients -! for a local Gauss-Seidel iteration. We provide Forward GS (FWGS) and -! backward GS (BWGS). The iterations are local to a process (they operate -! on the block diagonal). Combined with a Jacobi smoother will generate a -! hybrid-Gauss-Seidel solver, i.e. Gauss-Seidel within each process, Jacobi -! among the processes. -! With two objects as pre- and post-smoothers it is possible to build a -! Forward-Backward smoother, suitable for symmetric iterations. -! -module mld_c_gs_solver - - use mld_c_base_solver_mod - - type, extends(mld_c_base_solver_type) :: mld_c_gs_solver_type - type(psb_cspmat_type) :: l, u - integer(psb_ipk_) :: sweeps - real(psb_spk_) :: eps - contains - procedure, pass(sv) :: dump => mld_c_gs_solver_dmp - procedure, pass(sv) :: check => c_gs_solver_check - procedure, pass(sv) :: clone => mld_c_gs_solver_clone - procedure, pass(sv) :: clone_settings => mld_c_gs_solver_clone_settings - procedure, pass(sv) :: clear_data => mld_c_gs_solver_clear_data - procedure, pass(sv) :: build => mld_c_gs_solver_bld - procedure, pass(sv) :: cnv => mld_c_gs_solver_cnv - procedure, pass(sv) :: apply_v => mld_c_gs_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_c_gs_solver_apply - procedure, pass(sv) :: free => c_gs_solver_free - procedure, pass(sv) :: cseti => c_gs_solver_cseti - procedure, pass(sv) :: csetc => c_gs_solver_csetc - procedure, pass(sv) :: csetr => c_gs_solver_csetr - procedure, pass(sv) :: descr => c_gs_solver_descr - procedure, pass(sv) :: default => c_gs_solver_default - procedure, pass(sv) :: sizeof => c_gs_solver_sizeof - procedure, pass(sv) :: get_nzeros => c_gs_solver_get_nzeros - procedure, nopass :: get_wrksz => c_gs_solver_get_wrksize - procedure, nopass :: get_fmt => c_gs_solver_get_fmt - procedure, nopass :: get_id => c_gs_solver_get_id - procedure, nopass :: is_iterative => c_gs_solver_is_iterative - end type mld_c_gs_solver_type - - type, extends(mld_c_gs_solver_type) :: mld_c_bwgs_solver_type - contains - procedure, pass(sv) :: build => mld_c_bwgs_solver_bld - procedure, pass(sv) :: apply_v => mld_c_bwgs_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_c_bwgs_solver_apply - procedure, nopass :: get_fmt => c_bwgs_solver_get_fmt - procedure, nopass :: get_id => c_bwgs_solver_get_id - procedure, pass(sv) :: descr => c_bwgs_solver_descr - end type mld_c_bwgs_solver_type - - - private :: c_gs_solver_bld, c_gs_solver_apply, & - & c_gs_solver_free, & - & c_gs_solver_descr, c_gs_solver_sizeof, & - & c_gs_solver_default, c_gs_solver_dmp, & - & c_gs_solver_apply_vect, c_gs_solver_get_nzeros, & - & c_gs_solver_get_fmt, c_gs_solver_check,& - & c_gs_solver_is_iterative, & - & c_bwgs_solver_get_fmt, c_bwgs_solver_descr, & - & c_gs_solver_get_id, c_bwgs_solver_get_id, c_gs_solver_get_wrksize - - interface - subroutine mld_c_gs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, mld_c_gs_solver_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_gs_solver_type), intent(inout) :: sv - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - end subroutine mld_c_gs_solver_apply_vect - subroutine mld_c_bwgs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, mld_c_bwgs_solver_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_bwgs_solver_type), intent(inout) :: sv - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - end subroutine mld_c_bwgs_solver_apply_vect - end interface - - interface - subroutine mld_c_gs_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info,init,initu) - import :: psb_desc_type, mld_c_gs_solver_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_gs_solver_type), intent(inout) :: sv - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_c_gs_solver_apply - subroutine mld_c_bwgs_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, mld_c_bwgs_solver_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_bwgs_solver_type), intent(inout) :: sv - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_c_bwgs_solver_apply - end interface - - interface - subroutine mld_c_gs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, mld_c_gs_solver_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type), intent(in), target, optional :: b - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_gs_solver_bld - subroutine mld_c_bwgs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, mld_c_bwgs_solver_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_bwgs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type), intent(in), target, optional :: b - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_bwgs_solver_bld - end interface - - interface - subroutine mld_c_gs_solver_cnv(sv,info,amold,vmold,imold) - import :: mld_c_gs_solver_type, psb_spk_, & - & psb_c_base_sparse_mat, psb_c_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - class(mld_c_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_gs_solver_cnv - end interface - - interface - subroutine mld_c_gs_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, mld_c_gs_solver_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, & - & psb_ipk_ - implicit none - class(mld_c_gs_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_c_gs_solver_dmp - end interface - - interface - subroutine mld_c_gs_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, mld_c_gs_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_gs_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_gs_solver_clone - end interface - - interface - subroutine mld_c_gs_solver_clone_settings(sv,svout,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, mld_c_gs_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_gs_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_gs_solver_clone_settings - end interface - - interface - subroutine mld_c_gs_solver_clear_data(sv,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_gs_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_gs_solver_clear_data - end interface - -contains - - subroutine c_gs_solver_default(sv) - - Implicit None - - ! Arguments - class(mld_c_gs_solver_type), intent(inout) :: sv - - sv%sweeps = ione - sv%eps = dzero - - return - end subroutine c_gs_solver_default - - subroutine c_gs_solver_check(sv,info) - - Implicit None - - ! Arguments - class(mld_c_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_gs_solver_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - call mld_check_def(sv%sweeps,& - & 'GS Sweeps',ione,is_int_positive) - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine c_gs_solver_check - - subroutine c_gs_solver_cseti(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_c_gs_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_gs_solver_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) - case('SOLVER_SWEEPS') - sv%sweeps = val - case default - call sv%mld_c_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine c_gs_solver_cseti - - subroutine c_gs_solver_csetc(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_c_gs_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='c_gs_solver_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - - - call sv%mld_c_base_solver_type%set(what,val,info,idx=idx) - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info, name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine c_gs_solver_csetc - - subroutine c_gs_solver_csetr(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_c_gs_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_gs_solver_csetr' - - call psb_erractionsave(err_act) - info = psb_success_ - - select case(psb_toupper(what)) - case('SOLVER_EPS') - sv%eps = val - case default - call sv%mld_c_base_solver_type%set(what,val,info,idx=idx) - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine c_gs_solver_csetr - - subroutine c_gs_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_c_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_gs_solver_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - call sv%l%free() - call sv%u%free() - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine c_gs_solver_free - - subroutine c_gs_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_c_gs_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_c_gs_solver_descr' - integer(psb_ipk_) :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (sv%eps<=dzero) then - write(iout_,*) ' Forward Gauss-Seidel iterative solver with ',& - & sv%sweeps,' sweeps' - else - write(iout_,*) ' Forward Gauss-Seidel iterative solver with tolerance',& - & sv%eps,' and maxit', sv%sweeps - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine c_gs_solver_descr - - function c_gs_solver_get_nzeros(sv) result(val) - - implicit none - ! Arguments - class(mld_c_gs_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - val = val + sv%l%get_nzeros() - val = val + sv%u%get_nzeros() - - return - end function c_gs_solver_get_nzeros - - function c_gs_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_c_gs_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = psb_sizeof_ip - val = val + sv%l%sizeof() - val = val + sv%u%sizeof() - - return - end function c_gs_solver_sizeof - - function c_gs_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Forward Gauss-Seidel solver" - end function c_gs_solver_get_fmt - - function c_gs_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_gs_ - end function c_gs_solver_get_id - - ! - ! If this is true, then the solver needs a starting - ! guess. Currently only handled in JAC smoother. - ! - function c_gs_solver_is_iterative() result(val) - implicit none - logical :: val - - val = .true. - end function c_gs_solver_is_iterative - - subroutine c_bwgs_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_c_bwgs_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_c_bwgs_solver_descr' - integer(psb_ipk_) :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (sv%eps<=dzero) then - write(iout_,*) ' Backward Gauss-Seidel iterative solver with ',& - & sv%sweeps,' sweeps' - else - write(iout_,*) ' Backward Gauss-Seidel iterative solver with tolerance',& - & sv%eps,' and maxit', sv%sweeps - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine c_bwgs_solver_descr - - function c_bwgs_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Backward Gauss-Seidel solver" - end function c_bwgs_solver_get_fmt - - function c_bwgs_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_bwgs_ - end function c_bwgs_solver_get_id - - function c_gs_solver_get_wrksize() result(val) - implicit none - integer(psb_ipk_) :: val - - val = 2 - end function c_gs_solver_get_wrksize - -end module mld_c_gs_solver diff --git a/mlprec/mld_c_hybrid_aggregator_mod.F90 b/mlprec/mld_c_hybrid_aggregator_mod.F90 deleted file mode 100644 index e616eb87..00000000 --- a/mlprec/mld_c_hybrid_aggregator_mod.F90 +++ /dev/null @@ -1,125 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! The aggregator object hosts the aggregation method for building -! the multilevel hierarchy. This variant is based on the hybrid method -! presented in -! -! S. Gratton, P. Henon, P. Jiranek and X. Vasseur: -! Reducing complexity of algebraic multigrid by aggregation -! Numerical Lin. Algebra with Applications, 2016, 23:501-518 -! -module mld_c_hybrid_aggregator_mod - - use mld_c_dec_aggregator_mod - ! - ! sm - class(mld_T_base_smoother_type), allocatable - ! The current level preconditioner (aka smoother). - ! parms - type(mld_RTml_parms) - ! The parameters defining the multilevel strategy. - ! ac - The local part of the current-level matrix, built by - ! coarsening the previous-level matrix. - ! desc_ac - type(psb_desc_type). - ! The communication descriptor associated to the matrix - ! stored in ac. - ! base_a - type(psb_Tspmat_type), pointer. - ! Pointer (really a pointer!) to the local part of the current - ! matrix (so we have a unified treatment of residuals). - ! We need this to avoid passing explicitly the current matrix - ! to the routine which applies the preconditioner. - ! base_desc - type(psb_desc_type), pointer. - ! Pointer to the communication descriptor associated to the - ! matrix pointed by base_a. - ! map - Stores the maps (restriction and prolongation) between the - ! vector spaces associated to the index spaces of the previous - ! and current levels. - ! - ! Methods: - ! Most methods follow the encapsulation hierarchy: they take whatever action - ! is appropriate for the current object, then call the corresponding method for - ! the contained object. - ! As an example: the descr() method prints out a description of the - ! level. It starts by invoking the descr() method of the parms object, - ! then calls the descr() method of the smoother object. - ! - ! descr - Prints a description of the object. - ! default - Set default values - ! dump - Dump to file object contents - ! set - Sets various parameters; when a request is unknown - ! it is passed to the smoother object for further processing. - ! check - Sanity checks. - ! sizeof - Total memory occupation in bytes - ! get_nzeros - Number of nonzeros - ! - ! - type, extends(mld_c_dec_aggregator_type) :: mld_c_hybrid_aggregator_type - - contains - procedure, pass(ag) :: bld_tprol => mld_c_hybrid_aggregator_build_tprol - procedure, nopass :: fmt => mld_c_hybrid_aggregator_fmt - end type mld_c_hybrid_aggregator_type - - - interface - subroutine mld_c_hybrid_aggregator_build_tprol(ag,parms,a,desc_a,ilaggr,nlaggr,op_prol,info) - import :: mld_c_hybrid_aggregator_type, psb_desc_type, psb_cspmat_type, psb_spk_, & - & psb_ipk_, psb_long_int_k_, mld_sml_parms - implicit none - class(mld_c_hybrid_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - integer(psb_ipk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_cspmat_type), intent(out) :: op_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_hybrid_aggregator_build_tprol - end interface - -contains - - - function mld_c_hybrid_aggregator_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Hybrid Decoupled aggregation" - end function mld_c_hybrid_aggregator_fmt - - -end module mld_c_hybrid_aggregator_mod diff --git a/mlprec/mld_c_id_solver.f90 b/mlprec/mld_c_id_solver.f90 deleted file mode 100644 index 010604ae..00000000 --- a/mlprec/mld_c_id_solver.f90 +++ /dev/null @@ -1,202 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! -! Identity solver. Reference for nullprec. -! -! -module mld_c_id_solver - - use mld_c_base_solver_mod - - type, extends(mld_c_base_solver_type) :: mld_c_id_solver_type - contains - procedure, pass(sv) :: build => c_id_solver_bld - procedure, pass(sv) :: clone => mld_c_id_solver_clone - procedure, pass(sv) :: apply_v => mld_c_id_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_c_id_solver_apply - procedure, pass(sv) :: free => c_id_solver_free - procedure, pass(sv) :: descr => c_id_solver_descr - procedure, nopass :: get_fmt => c_id_solver_get_fmt - procedure, nopass :: get_id => c_id_solver_get_id - end type mld_c_id_solver_type - - - private :: c_id_solver_bld, & - & c_id_solver_free, c_id_solver_get_fmt, & - & c_id_solver_descr, c_id_solver_get_id - - interface - subroutine mld_c_id_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_id_solver_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_id_solver_type), intent(inout) :: sv - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - end subroutine mld_c_id_solver_apply_vect - end interface - - interface - subroutine mld_c_id_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_id_solver_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_id_solver_type), intent(inout) :: sv - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_c_id_solver_apply - end interface - - interface - subroutine mld_c_id_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, mld_c_id_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_id_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_id_solver_clone - end interface - -contains - - - subroutine c_id_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - Implicit None - - ! Arguments - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_id_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type), intent(in), target, optional :: b - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - complex(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: i, err_act, debug_unit, debug_level - character(len=20) :: name='c_id_solver_bld', ch_err - - info=psb_success_ - - return - end subroutine c_id_solver_bld - - subroutine c_id_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_c_id_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_id_solver_free' - - info = psb_success_ - - return - end subroutine c_id_solver_free - - subroutine c_id_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_c_id_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_c_id_solver_descr' - integer(psb_ipk_) :: iout_ - - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' Identity local solver ' - - return - - end subroutine c_id_solver_descr - - function c_id_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Identity solver" - end function c_id_solver_get_fmt - - function c_id_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_f_none_ - end function c_id_solver_get_id - -end module mld_c_id_solver diff --git a/mlprec/mld_c_ilu_fact_mod.f90 b/mlprec/mld_c_ilu_fact_mod.f90 deleted file mode 100644 index 1cb53d59..00000000 --- a/mlprec/mld_c_ilu_fact_mod.f90 +++ /dev/null @@ -1,91 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! File: mld_c_ilu_fact_mod.f90 -! -! Module: mld_c_ilu_fact_mod -! -! This module defines some interfaces used internally by the implementation of -! mld_c_ilu_solver, but not visible to the end user. -! -! -module mld_c_ilu_fact_mod - - use mld_c_base_solver_mod - - interface mld_ilu0_fact - subroutine mld_cilu0_fact(ialg,a,l,u,d,info,blck,upd) - import psb_cspmat_type, psb_spk_, psb_ipk_ - integer(psb_ipk_), intent(in) :: ialg - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type),intent(in) :: a - type(psb_cspmat_type),intent(inout) :: l,u - type(psb_cspmat_type),intent(in), optional, target :: blck - character, intent(in), optional :: upd - complex(psb_spk_), intent(inout) :: d(:) - end subroutine mld_cilu0_fact - end interface - - interface mld_iluk_fact - subroutine mld_ciluk_fact(fill_in,ialg,a,l,u,d,info,blck) - import psb_cspmat_type, psb_spk_, psb_ipk_ - integer(psb_ipk_), intent(in) :: fill_in,ialg - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type),intent(in) :: a - type(psb_cspmat_type),intent(inout) :: l,u - type(psb_cspmat_type),intent(in), optional, target :: blck - complex(psb_spk_), intent(inout) :: d(:) - end subroutine mld_ciluk_fact - end interface - - interface mld_ilut_fact - subroutine mld_cilut_fact(fill_in,thres,a,l,u,d,info,blck,iscale) - import psb_cspmat_type, psb_spk_, psb_ipk_ - integer(psb_ipk_), intent(in) :: fill_in - real(psb_spk_), intent(in) :: thres - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type),intent(in) :: a - type(psb_cspmat_type),intent(inout) :: l,u - complex(psb_spk_), intent(inout) :: d(:) - type(psb_cspmat_type),intent(in), optional, target :: blck - integer(psb_ipk_), intent(in), optional :: iscale - end subroutine mld_cilut_fact - end interface - -end module mld_c_ilu_fact_mod diff --git a/mlprec/mld_c_ilu_solver.f90 b/mlprec/mld_c_ilu_solver.f90 deleted file mode 100644 index 2d2056a9..00000000 --- a/mlprec/mld_c_ilu_solver.f90 +++ /dev/null @@ -1,502 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! File: mld_c_ilu_solver_mod.f90 -! -! Module: mld_c_ilu_solver_mod -! -! This module defines: -! - the mld_c_ilu_solver_type data structure containing the ingredients -! for a local Incomplete LU factorization. -! 1. The factorization is always restricted to the diagonal block of the -! current image (coherently with the definition of a SOLVER as a local -! object) -! 2. The code provides support for both pattern-based ILU(K) and -! threshold base ILU(T,L) -! 3. The diagonal is stored separately, so strictly speaking this is -! an incomplete LDU factorization; -! 4. The application phase is shared among all variants; -! -! -module mld_c_ilu_solver - - use mld_base_prec_type, only : mld_fact_names - use mld_c_base_solver_mod - use psb_c_ilu_fact_mod - - type, extends(mld_c_base_solver_type) :: mld_c_ilu_solver_type - type(psb_cspmat_type) :: l, u - complex(psb_spk_), allocatable :: d(:) - type(psb_c_vect_type) :: dv - integer(psb_ipk_) :: fact_type, fill_in - real(psb_spk_) :: thresh - contains - procedure, pass(sv) :: dump => mld_c_ilu_solver_dmp - procedure, pass(sv) :: check => c_ilu_solver_check - procedure, pass(sv) :: clone => mld_c_ilu_solver_clone - procedure, pass(sv) :: clone_settings => mld_c_ilu_solver_clone_settings - procedure, pass(sv) :: clear_data => mld_c_ilu_solver_clear_data - procedure, pass(sv) :: build => mld_c_ilu_solver_bld - procedure, pass(sv) :: cnv => mld_c_ilu_solver_cnv - procedure, pass(sv) :: apply_v => mld_c_ilu_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_c_ilu_solver_apply - procedure, pass(sv) :: free => c_ilu_solver_free - procedure, pass(sv) :: cseti => c_ilu_solver_cseti - procedure, pass(sv) :: csetc => c_ilu_solver_csetc - procedure, pass(sv) :: csetr => c_ilu_solver_csetr - procedure, pass(sv) :: descr => c_ilu_solver_descr - procedure, pass(sv) :: default => c_ilu_solver_default - procedure, pass(sv) :: sizeof => c_ilu_solver_sizeof - procedure, pass(sv) :: get_nzeros => c_ilu_solver_get_nzeros - procedure, nopass :: get_wrksz => c_ilu_solver_get_wrksize - procedure, nopass :: get_fmt => c_ilu_solver_get_fmt - procedure, nopass :: get_id => c_ilu_solver_get_id - end type mld_c_ilu_solver_type - - - private :: c_ilu_solver_bld, c_ilu_solver_apply, & - & c_ilu_solver_free, & - & c_ilu_solver_descr, c_ilu_solver_sizeof, & - & c_ilu_solver_default, c_ilu_solver_dmp, & - & c_ilu_solver_apply_vect, c_ilu_solver_get_nzeros, & - & c_ilu_solver_get_fmt, c_ilu_solver_check, & - & c_ilu_solver_get_id, c_ilu_solver_get_wrksize - - - interface - subroutine mld_c_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, mld_c_ilu_solver_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_ilu_solver_type), intent(inout) :: sv - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - end subroutine mld_c_ilu_solver_apply_vect - end interface - - interface - subroutine mld_c_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, mld_c_ilu_solver_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_ilu_solver_type), intent(inout) :: sv - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_c_ilu_solver_apply - end interface - - interface - subroutine mld_c_ilu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, mld_c_ilu_solver_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type), intent(in), target, optional :: b - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_ilu_solver_bld - end interface - - interface - subroutine mld_c_ilu_solver_cnv(sv,info,amold,vmold,imold) - import :: mld_c_ilu_solver_type, psb_spk_, & - & psb_c_base_sparse_mat, psb_c_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - class(mld_c_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_ilu_solver_cnv - end interface - - interface - subroutine mld_c_ilu_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, mld_c_ilu_solver_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, & - & psb_ipk_ - implicit none - class(mld_c_ilu_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_c_ilu_solver_dmp - end interface - - interface - subroutine mld_c_ilu_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, mld_c_ilu_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_ilu_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_ilu_solver_clone - end interface - - interface - subroutine mld_c_ilu_solver_clone_settings(sv,svout,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_base_solver_type, mld_c_ilu_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_ilu_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_ilu_solver_clone_settings - end interface - - interface - subroutine mld_c_ilu_solver_clear_data(sv,info) - import :: psb_desc_type, psb_cspmat_type, psb_c_base_sparse_mat, & - & psb_c_vect_type, psb_c_base_vect_type, psb_spk_, & - & mld_c_ilu_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_c_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_ilu_solver_clear_data - end interface - -contains - - subroutine c_ilu_solver_default(sv) - - Implicit None - - ! Arguments - class(mld_c_ilu_solver_type), intent(inout) :: sv - - sv%fact_type = psb_ilu_n_ - sv%fill_in = 0 - sv%thresh = szero - - return - end subroutine c_ilu_solver_default - - subroutine c_ilu_solver_check(sv,info) - - Implicit None - - ! Arguments - class(mld_c_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_ilu_solver_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - call mld_check_def(sv%fact_type,& - & 'Factorization',psb_ilu_n_,is_legal_ilu_fact) - - select case(sv%fact_type) - case(psb_ilu_n_,psb_milu_n_) - call mld_check_def(sv%fill_in,& - & 'Level',izero,is_int_non_negative) - case(psb_ilu_t_) - call mld_check_def(sv%thresh,& - & 'Eps',szero,is_legal_s_fact_thrs) - end select - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine c_ilu_solver_check - - subroutine c_ilu_solver_cseti(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_c_ilu_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_ilu_solver_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(trim((what)))) - case('SUB_SOLVE') - sv%fact_type = val - case('SUB_FILLIN') - sv%fill_in = val - case default - call sv%mld_c_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine c_ilu_solver_cseti - - subroutine c_ilu_solver_csetc(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_c_ilu_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='c_ilu_solver_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - ival = mld_stringval(val) - select case(psb_toupper(trim((what)))) - case('SUB_SOLVE') - sv%fact_type = ival - case default - call sv%mld_c_base_solver_type%set(what,val,info,idx=idx) - end select - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info, name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine c_ilu_solver_csetc - - subroutine c_ilu_solver_csetr(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_c_ilu_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_ilu_solver_csetr' - - call psb_erractionsave(err_act) - info = psb_success_ - - select case(psb_toupper(what)) - case('SUB_ILUTHRS') - sv%thresh = val - case default - call sv%mld_c_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine c_ilu_solver_csetr - - subroutine c_ilu_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_c_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_ilu_solver_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sv%d)) then - deallocate(sv%d,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - end if - call sv%l%free() - call sv%u%free() - call sv%dv%free(info) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine c_ilu_solver_free - - subroutine c_ilu_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_c_ilu_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_c_ilu_solver_descr' - integer(psb_ipk_) :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' Incomplete factorization solver: ',& - & mld_fact_names(sv%fact_type) - select case(sv%fact_type) - case(psb_ilu_n_,psb_milu_n_) - write(iout_,*) ' Fill level:',sv%fill_in - case(psb_ilu_t_) - write(iout_,*) ' Fill level:',sv%fill_in - write(iout_,*) ' Fill threshold :',sv%thresh - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine c_ilu_solver_descr - - function c_ilu_solver_get_nzeros(sv) result(val) - - implicit none - ! Arguments - class(mld_c_ilu_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - val = val + sv%dv%get_nrows() - val = val + sv%l%get_nzeros() - val = val + sv%u%get_nzeros() - - return - end function c_ilu_solver_get_nzeros - - function c_ilu_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_c_ilu_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 2*psb_sizeof_ip + (2*psb_sizeof_sp) - val = val + sv%dv%sizeof() - val = val + sv%l%sizeof() - val = val + sv%u%sizeof() - - return - end function c_ilu_solver_sizeof - - function c_ilu_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "ILU solver" - end function c_ilu_solver_get_fmt - - function c_ilu_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = psb_ilu_n_ - end function c_ilu_solver_get_id - - function c_ilu_solver_get_wrksize() result(val) - implicit none - integer(psb_ipk_) :: val - - val = 2 - end function c_ilu_solver_get_wrksize - -end module mld_c_ilu_solver diff --git a/mlprec/mld_c_inner_mod.f90 b/mlprec/mld_c_inner_mod.f90 deleted file mode 100644 index cca84a1a..00000000 --- a/mlprec/mld_c_inner_mod.f90 +++ /dev/null @@ -1,131 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_inner_mod.f90 -! -! Module: mld_inner_mod -! -! This module defines the interfaces to inner MLD2P4 routines. -! The interfaces of the user level routines are defined in mld_prec_mod.f90. -! -module mld_c_inner_mod - - use psb_base_mod, only : psb_cspmat_type, psb_desc_type, psb_i_base_vect_type, & - & psb_spk_, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_, & - & psb_c_vect_type, psb_lpk_, psb_lcspmat_type - use mld_c_prec_type, only : mld_cprec_type, mld_sml_parms, & - & mld_c_onelev_type, mld_cmlprec_wrk_type - - interface mld_mlprec_bld - subroutine mld_cmlprec_bld(a,desc_a,prec,info, amold, vmold,imold) - import :: psb_cspmat_type, psb_desc_type, psb_i_base_vect_type, & - & psb_spk_, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ - import :: mld_cprec_type - implicit none - type(psb_cspmat_type), intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - type(mld_cprec_type), intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_cmlprec_bld - end interface mld_mlprec_bld - - interface mld_mlprec_aply - subroutine mld_cmlprec_aply(alpha,p,x,beta,y,desc_data,trans,work,info) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, psb_ipk_ - import :: mld_cprec_type - implicit none - type(psb_desc_type),intent(in) :: desc_data - type(mld_cprec_type), intent(inout) :: p - complex(psb_spk_),intent(in) :: alpha,beta - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - character,intent(in) :: trans - complex(psb_spk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - end subroutine mld_cmlprec_aply - subroutine mld_cmlprec_aply_vect(alpha,p,x,beta,y,desc_data,trans,work,info) - import :: psb_cspmat_type, psb_desc_type, & - & psb_spk_, psb_c_vect_type, psb_ipk_ - import :: mld_cprec_type - implicit none - type(psb_desc_type),intent(in) :: desc_data - type(mld_cprec_type), intent(inout) :: p - complex(psb_spk_),intent(in) :: alpha,beta - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - character,intent(in) :: trans - complex(psb_spk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - end subroutine mld_cmlprec_aply_vect - end interface mld_mlprec_aply - - interface mld_map_to_tprol - subroutine mld_c_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, psb_ipk_, psb_lpk_, psb_lcspmat_type - import :: mld_c_onelev_type - implicit none - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), allocatable, intent(inout) :: ilaggr(:),nlaggr(:) - type(psb_lcspmat_type), intent(out) :: op_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_map_to_tprol - end interface mld_map_to_tprol - - abstract interface - subroutine mld_caggrmat_var_bld(a,desc_a,ilaggr,nlaggr,parms,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, psb_ipk_, psb_lpk_, psb_lcspmat_type - import :: mld_c_onelev_type, mld_sml_parms - implicit none - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(mld_sml_parms), intent(inout) :: parms - type(psb_cspmat_type), intent(inout) :: op_prol,ac,op_restr - type(psb_lcspmat_type), intent(inout) :: t_prol - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - end subroutine mld_caggrmat_var_bld - end interface - - procedure(mld_caggrmat_var_bld) :: mld_caggrmat_nosmth_bld, & - & mld_caggrmat_smth_bld, mld_caggrmat_minnrg_bld - -end module mld_c_inner_mod diff --git a/mlprec/mld_c_jac_smoother.f90 b/mlprec/mld_c_jac_smoother.f90 deleted file mode 100644 index c9303889..00000000 --- a/mlprec/mld_c_jac_smoother.f90 +++ /dev/null @@ -1,454 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_c_jac_smoother_mod.f90 -! -! Module: mld_c_jac_smoother_mod -! -! This module defines: -! the mld_c_jac_smoother_type data structure containing the -! smoother for a Jacobi/block Jacobi smoother. -! The smoother stores in ND the block off-diagonal matrix. -! One special case is treated separately, when the solver is DIAG or L1-DIAG -! then the ND is the entire off-diagonal part of the matrix (including the -! main diagonal block), so that it becomes possible to implement -! a pure Jacobi or L1-Jacobi global solver. -! -module mld_c_jac_smoother - - use mld_c_base_smoother_mod - - type, extends(mld_c_base_smoother_type) :: mld_c_jac_smoother_type - ! The local solver component is inherited from the - ! parent type. - ! class(mld_c_base_solver_type), allocatable :: sv - ! - type(psb_cspmat_type), pointer :: pa => null() - type(psb_cspmat_type) :: nd - integer(psb_lpk_) :: nd_nnz_tot - logical :: checkres - logical :: printres - integer(psb_ipk_) :: checkiter - integer(psb_ipk_) :: printiter - real(psb_dpk_) :: tol - contains - procedure, pass(sm) :: apply_v => mld_c_jac_smoother_apply_vect - procedure, pass(sm) :: apply_a => mld_c_jac_smoother_apply - procedure, pass(sm) :: dump => mld_c_jac_smoother_dmp - procedure, pass(sm) :: build => mld_c_jac_smoother_bld - procedure, pass(sm) :: cnv => mld_c_jac_smoother_cnv - procedure, pass(sm) :: clone => mld_c_jac_smoother_clone - procedure, pass(sm) :: clone_settings => mld_c_jac_smoother_clone_settings - procedure, pass(sm) :: clear_data => mld_c_jac_smoother_clear_data - procedure, pass(sm) :: free => c_jac_smoother_free - procedure, pass(sm) :: cseti => mld_c_jac_smoother_cseti - procedure, pass(sm) :: csetc => mld_c_jac_smoother_csetc - procedure, pass(sm) :: csetr => mld_c_jac_smoother_csetr - procedure, pass(sm) :: descr => mld_c_jac_smoother_descr - procedure, pass(sm) :: sizeof => c_jac_smoother_sizeof - procedure, pass(sm) :: default => c_jac_smoother_default - procedure, pass(sm) :: get_nzeros => c_jac_smoother_get_nzeros - procedure, pass(sm) :: get_wrksz => c_jac_smoother_get_wrksize - procedure, nopass :: get_fmt => c_jac_smoother_get_fmt - procedure, nopass :: get_id => c_jac_smoother_get_id - end type mld_c_jac_smoother_type - - type, extends(mld_c_jac_smoother_type) :: mld_c_l1_jac_smoother_type - contains - procedure, pass(sm) :: build => mld_c_l1_jac_smoother_bld - procedure, pass(sm) :: clone => mld_c_l1_jac_smoother_clone - procedure, pass(sm) :: descr => mld_c_l1_jac_smoother_descr - procedure, nopass :: get_fmt => c_l1_jac_smoother_get_fmt - procedure, nopass :: get_id => c_l1_jac_smoother_get_id - end type mld_c_l1_jac_smoother_type - - private :: c_jac_smoother_free, & - & c_jac_smoother_sizeof, c_jac_smoother_get_nzeros, & - & c_jac_smoother_get_fmt, c_jac_smoother_get_id, & - & c_jac_smoother_get_wrksize - private :: c_l1_jac_smoother_get_fmt, c_l1_jac_smoother_get_id - - - interface - subroutine mld_c_jac_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,wv,info,init,initu) - import :: psb_desc_type, mld_c_jac_smoother_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type,& - & psb_ipk_ - - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_jac_smoother_type), intent(inout) :: sm - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - end subroutine mld_c_jac_smoother_apply_vect - end interface - - interface - subroutine mld_c_jac_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,info,init,initu) - import :: psb_desc_type, mld_c_jac_smoother_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, & - & psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_jac_smoother_type), intent(inout) :: sm - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_c_jac_smoother_apply - end interface - - interface - subroutine mld_c_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - import :: psb_desc_type, mld_c_jac_smoother_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_jac_smoother_bld - end interface - - interface - subroutine mld_c_jac_smoother_cnv(sm,info,amold,vmold,imold) - import :: mld_c_jac_smoother_type, psb_spk_, & - & psb_c_base_sparse_mat, psb_c_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - class(mld_c_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_jac_smoother_cnv - end interface - - interface - subroutine mld_c_jac_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_spk_, mld_c_jac_smoother_type, psb_epk_, psb_desc_type, & - & psb_ipk_ - implicit none - class(mld_c_jac_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - end subroutine mld_c_jac_smoother_dmp - end interface - - interface - subroutine mld_c_jac_smoother_clone(sm,smout,info) - import :: mld_c_jac_smoother_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_ - class(mld_c_jac_smoother_type), intent(inout) :: sm - class(mld_c_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_jac_smoother_clone - end interface - - interface - subroutine mld_c_jac_smoother_clone_settings(sm,smout,info) - import :: mld_c_jac_smoother_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_ - class(mld_c_jac_smoother_type), intent(inout) :: sm - class(mld_c_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_jac_smoother_clone_settings - end interface - - interface - subroutine mld_c_jac_smoother_clear_data(sm,info) - import :: mld_c_jac_smoother_type, psb_spk_, & - & mld_c_base_smoother_type, psb_ipk_ - class(mld_c_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_jac_smoother_clear_data - end interface - - interface - subroutine mld_c_jac_smoother_descr(sm,info,iout,coarse) - import :: mld_c_jac_smoother_type, psb_ipk_ - class(mld_c_jac_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - end subroutine mld_c_jac_smoother_descr - end interface - - interface - subroutine mld_c_jac_smoother_cseti(sm,what,val,info,idx) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_spk_, mld_c_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_c_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_c_jac_smoother_cseti - end interface - - interface - subroutine mld_c_jac_smoother_csetc(sm,what,val,info,idx) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_spk_, mld_c_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_c_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_c_jac_smoother_csetc - end interface - - interface - subroutine mld_c_jac_smoother_csetr(sm,what,val,info,idx) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_spk_, mld_c_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_c_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_c_jac_smoother_csetr - end interface - - - interface - subroutine mld_c_l1_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - import :: psb_desc_type, mld_c_l1_jac_smoother_type, psb_c_vect_type, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_l1_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_l1_jac_smoother_bld - end interface - - interface - subroutine mld_c_l1_jac_smoother_clone(sm,smout,info) - import :: mld_c_l1_jac_smoother_type, & - & mld_c_base_smoother_type, psb_ipk_ - class(mld_c_l1_jac_smoother_type), intent(inout) :: sm - class(mld_c_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_l1_jac_smoother_clone - end interface - - interface - subroutine mld_c_l1_jac_smoother_clone_settings(sm,smout,info) - import :: mld_c_l1_jac_smoother_type, & - & mld_c_base_smoother_type, psb_ipk_ - class(mld_c_l1_jac_smoother_type), intent(inout) :: sm - class(mld_c_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_l1_jac_smoother_clone_settings - end interface - - interface - subroutine mld_c_l1_jac_smoother_clear_data(sm,info) - import :: mld_c_l1_jac_smoother_type, & - & mld_c_base_smoother_type, psb_ipk_ - class(mld_c_l1_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_l1_jac_smoother_clear_data - end interface - - interface - subroutine mld_c_l1_jac_smoother_descr(sm,info,iout,coarse) - import :: mld_c_l1_jac_smoother_type, psb_ipk_ - class(mld_c_l1_jac_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - end subroutine mld_c_l1_jac_smoother_descr - end interface - -contains - - - subroutine c_jac_smoother_free(sm,info) - - - Implicit None - - ! Arguments - class(mld_c_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_jac_smoother_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - - - if (allocated(sm%sv)) then - call sm%sv%free(info) - if (info == psb_success_) deallocate(sm%sv,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - end if - call sm%nd%free() - sm%pa => null() - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine c_jac_smoother_free - - function c_jac_smoother_sizeof(sm) result(val) - - implicit none - ! Arguments - class(mld_c_jac_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = psb_sizeof_lp - if (allocated(sm%sv)) val = val + sm%sv%sizeof() - val = val + sm%nd%sizeof() - - return - end function c_jac_smoother_sizeof - - subroutine c_jac_smoother_default(sm) - - Implicit None - - ! Arguments - class(mld_c_jac_smoother_type), intent(inout) :: sm - - ! - ! Default: BJAC with no residual check - ! - sm%checkres = .false. - sm%printres = .false. - sm%checkiter = -1 - sm%printiter = -1 - sm%tol = 0 - - if (allocated(sm%sv)) then - call sm%sv%default() - end if - - return - end subroutine c_jac_smoother_default - - function c_jac_smoother_get_nzeros(sm) result(val) - - implicit none - ! Arguments - class(mld_c_jac_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - if (allocated(sm%sv)) val = val + sm%sv%get_nzeros() - val = val + sm%nd%get_nzeros() - - return - end function c_jac_smoother_get_nzeros - - function c_jac_smoother_get_wrksize(sm) result(val) - implicit none - class(mld_c_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_) :: val - - val = 2 - if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() - - end function c_jac_smoother_get_wrksize - - function c_jac_smoother_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Jacobi smoother" - end function c_jac_smoother_get_fmt - - function c_jac_smoother_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_jac_ - end function c_jac_smoother_get_id - - function c_l1_jac_smoother_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "L1-Jacobi smoother" - end function c_l1_jac_smoother_get_fmt - - function c_l1_jac_smoother_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_l1_jac_ - end function c_l1_jac_smoother_get_id - -end module mld_c_jac_smoother diff --git a/mlprec/mld_c_mumps_solver.F90 b/mlprec/mld_c_mumps_solver.F90 deleted file mode 100644 index 61439dd4..00000000 --- a/mlprec/mld_c_mumps_solver.F90 +++ /dev/null @@ -1,590 +0,0 @@ - -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -! File: mld_c_mumps_solver_mod.f90 -! -! Module: mld_c_mumps_solver_mod -! -! This module defines: -! - the mld_c_mumps_solver_type data structure containing the ingredients -! to interface with the MUMPS package. -! 1. The factorization can be either restricted to the diagonal block of the -! current image or distributed (and thus exact). -! -module mld_c_mumps_solver - use mld_c_base_solver_mod -#if defined(HAVE_MUMPS_) && defined(HAVE_MUMPS_MODULES_) - use cmumps_struc_def -#endif -#if defined(HAVE_MUMPS_) && defined(HAVE_MUMPS_INCLUDES_) - include 'cmumps_struc.h' -#endif - - - type :: mld_c_mumps_icntl_item - integer(psb_ipk_), allocatable :: item - end type mld_c_mumps_icntl_item - type :: mld_c_mumps_rcntl_item - real(psb_spk_), allocatable :: item - end type mld_c_mumps_rcntl_item - - type, extends(mld_c_base_solver_type) :: mld_c_mumps_solver_type -#if defined(HAVE_MUMPS_) - type(cmumps_struc), allocatable :: id -#else - integer, allocatable :: id -#endif - type(mld_c_mumps_icntl_item), allocatable :: icntl(:) - type(mld_c_mumps_rcntl_item), allocatable :: rcntl(:) - ! - ! Controls to be set before MUMPS instantiation: - ! - ! IPAR(1) : MUMPS_LOC_GLOB 0==mld_local_solver_: LOCAL 1==mld_global_solver_: GLOBAL - ! IPAR(2) : MUMPS_PRINT_ERR print verbosity (see MUMPS) - ! IPAR(3) : MUMPS_SYM 0: non-symmetric 2: symmetric - integer(psb_ipk_), dimension(3) :: ipar - integer(psb_ipk_), allocatable :: local_ictxt - logical :: built = .false. - contains - procedure, pass(sv) :: build => c_mumps_solver_bld - procedure, pass(sv) :: apply_a => c_mumps_solver_apply - procedure, pass(sv) :: apply_v => c_mumps_solver_apply_vect - procedure, pass(sv) :: clone_settings => c_mumps_solver_clone_settings - procedure, pass(sv) :: clear_data => c_mumps_solver_clear_data - procedure, pass(sv) :: free => c_mumps_solver_free - procedure, pass(sv) :: descr => c_mumps_solver_descr - procedure, pass(sv) :: sizeof => c_mumps_solver_sizeof - procedure, pass(sv) :: csetc => c_mumps_solver_csetc - procedure, pass(sv) :: cseti => c_mumps_solver_cseti - procedure, pass(sv) :: csetr => c_mumps_solver_csetr - procedure, pass(sv) :: default => c_mumps_solver_default - procedure, nopass :: get_fmt => c_mumps_solver_get_fmt - procedure, nopass :: get_id => c_mumps_solver_get_id - procedure, pass(sv) :: is_global => c_mumps_solver_is_global - final :: c_mumps_solver_finalize - end type mld_c_mumps_solver_type - - - private :: c_mumps_solver_bld, c_mumps_solver_apply, & - & c_mumps_solver_free, c_mumps_solver_descr, & - & c_mumps_solver_sizeof, c_mumps_solver_apply_vect,& - & c_mumps_solver_cseti, c_mumps_solver_csetr, & - & c_mumps_solver_csetc, c_mumps_solver_clear_data, & - & c_mumps_solver_default, c_mumps_solver_get_fmt, & - & c_mumps_solver_clone_settings, & - & c_mumps_solver_get_id, c_mumps_solver_is_global - private :: c_mumps_solver_finalize - - interface - subroutine c_mumps_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, mld_c_mumps_solver_type, psb_c_vect_type, psb_dpk_, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_mumps_solver_type), intent(inout) :: sv - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - end subroutine c_mumps_solver_apply_vect - end interface - - interface - subroutine c_mumps_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info,init,initu) - import :: psb_desc_type, mld_c_mumps_solver_type, psb_c_vect_type, psb_dpk_, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_mumps_solver_type), intent(inout) :: sv - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - end subroutine c_mumps_solver_apply - end interface - - interface - subroutine c_mumps_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - import :: psb_desc_type, mld_c_mumps_solver_type, psb_c_vect_type, psb_spk_, & - & psb_cspmat_type, psb_c_base_sparse_mat, psb_c_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - - Implicit None - - ! Arguments - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_cspmat_type), intent(in), target, optional :: b - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine c_mumps_solver_bld - end interface - -contains - - subroutine c_mumps_solver_clone_settings(sv,svout,info) - - use psb_base_mod - Implicit None - ! Arguments - class(mld_c_mumps_solver_type), intent(inout) :: sv - class(mld_c_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: k,err_act - character(len=20) :: name='c_mumps_solver_clone_settings' - - info = 0 - -#if defined(HAVE_MUMPS_) - - call psb_erractionsave(err_act) - - select type(svout) - class is(mld_c_mumps_solver_type) - svout%ipar(:) = sv%ipar(:) - svout%built = .false. - if (allocated(svout%icntl)) deallocate(svout%icntl,stat=info) - if (info == 0) allocate(svout%icntl(mld_mumps_icntl_size),stat=info) - if (info == 0) then - do k=1,mld_mumps_icntl_size - call psb_safe_ab_cpy(sv%icntl(k)%item,svout%icntl(k)%item,info) - end do - end if - - if (allocated(svout%rcntl)) deallocate(svout%rcntl,stat=info) - if (info == 0) allocate(svout%rcntl(mld_mumps_rcntl_size),stat=info) - if (info == 0) then - do k=1,mld_mumps_rcntl_size - call psb_safe_ab_cpy(sv%rcntl(k)%item,svout%rcntl(k)%item,info) - end do - end if - - class default - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -#endif - end subroutine c_mumps_solver_clone_settings - - subroutine c_mumps_solver_clear_data(sv,info) - use psb_base_mod, only : psb_exit - Implicit None - - ! Arguments - class(mld_c_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - Integer(psb_ipk_) :: err_act - character(len=20) :: name='c_mumps_solver_clear_data' - - info = 0 -#if defined(HAVE_MUMPS_) - call psb_erractionsave(err_act) - if (allocated(sv%id)) then - if (sv%built) then - sv%id%job = -2 - call cmumps(sv%id) - info = sv%id%infog(1) - if (info /= psb_success_) goto 9999 - end if - deallocate(sv%id, stat=info) - if (allocated(sv%local_ictxt)) then - call psb_exit(sv%local_ictxt,close=.false.) - deallocate(sv%local_ictxt,stat=info) - end if - sv%built=.false. - end if - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -#endif - end subroutine c_mumps_solver_clear_data - - subroutine c_mumps_solver_free(sv,info) - use psb_base_mod, only : psb_exit - Implicit None - - ! Arguments - class(mld_c_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - Integer(psb_ipk_) :: err_act - character(len=20) :: name='c_mumps_solver_free' - - info = 0 -#if defined(HAVE_MUMPS_) - call psb_erractionsave(err_act) - call sv%clear_data(info) - if ((info == 0).and.allocated(sv%icntl)) deallocate(sv%icntl,stat=info) - if ((info == 0).and.allocated(sv%rcntl)) deallocate(sv%rcntl,stat=info) - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -#endif - end subroutine c_mumps_solver_free - -subroutine c_mumps_solver_finalize(sv) - - Implicit None - - ! Arguments - type(mld_c_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_) :: info - Integer(psb_ipk_) :: err_act - character(len=20) :: name='c_mumps_solver_finalize' - - call sv%free(info) - - return - -end subroutine c_mumps_solver_finalize - -subroutine c_mumps_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_c_mumps_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt, me, np - character(len=20), parameter :: name='mld_z_mumps_solver_descr' - integer(psb_ipk_) :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' MUMPS Solver. ' - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -end subroutine c_mumps_solver_descr - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! WARNING: OTHER PARAMETERS OF MUMPS COULD BE ADDED. !! -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - -subroutine c_mumps_solver_csetc(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_c_mumps_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_mumps_solver_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - - - select case(psb_toupper(trim(what))) -#if defined(HAVE_MUMPS_) - case('MUMPS_LOC_GLOB') - sv%ipar(1) = sv%stringval(psb_toupper(trim(val))) -#endif - case default - call sv%mld_c_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -end subroutine c_mumps_solver_csetc - - -subroutine c_mumps_solver_cseti(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_c_mumps_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_mumps_solver_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) -#if defined(HAVE_MUMPS_) - case('MUMPS_LOC_GLOB') - sv%ipar(1) = val - case('MUMPS_PRINT_ERR') - sv%ipar(2) = val - case('MUMPS_SYM') - sv%ipar(3) = val - case('MUMPS_IPAR_ENTRY') - if(present(idx)) then - ! Note: this will allocate %item - sv%icntl(idx)%item = val - end if -#endif - case default - call sv%mld_c_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -end subroutine c_mumps_solver_cseti - -subroutine c_mumps_solver_csetr(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_c_mumps_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='c_mumps_solver_csetr' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) -#if defined(HAVE_MUMPS_) - case('MUMPS_RPAR_ENTRY') - if(present(idx)) then - ! Note: this will allocate %item - sv%rcntl(idx)%item = val - end if -#endif - case default - call sv%mld_c_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -end subroutine c_mumps_solver_csetr - -!!NOTE: BY DEFAULT BLR is activated with a dropping parameter to 1d-4 !! -subroutine c_mumps_solver_default(sv) - - Implicit none - - !Argument - class(mld_c_mumps_solver_type),intent(inout) :: sv - integer(psb_ipk_) :: info - integer(psb_ipk_) :: err_act,ictx,icomm - character(len=20) :: name='c_mumps_default' - - info = psb_success_ - call psb_erractionsave(err_act) - -#if defined(HAVE_MUMPS_) - if (.not.allocated(sv%id)) then - allocate(sv%id,stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_dealloc_ - call psb_errpush(info,name,a_err='mld_cmumps_default') - goto 9999 - end if - sv%built=.false. - end if - if (.not.allocated(sv%icntl)) then - allocate(sv%icntl(mld_mumps_icntl_size),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_dealloc_ - call psb_errpush(info,name,a_err='mld_cmumps_default') - goto 9999 - end if - end if - if (.not.allocated(sv%rcntl)) then - allocate(sv%rcntl(mld_mumps_rcntl_size),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_dealloc_ - call psb_errpush(info,name,a_err='mld_cmumps_default') - goto 9999 - end if - end if - ! INSTANTIATION OF sv%id needed to set parmater but mpi communicator needed - ! sv%id%job = -1 - ! sv%id%par=1 - ! call dmumps(sv%id) - sv%ipar = 0 - sv%ipar(1) = mld_global_solver_ - !sv%ipar(10)=6 - !sv%ipar(11)=0 - !sv%ipar(12)=6 - -#endif - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return - -end subroutine c_mumps_solver_default - -function c_mumps_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_c_mumps_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer :: i -#if defined(HAVE_MUMPS_) - val = (sv%id%INFOG(22)+sv%id%INFOG(32))*1d+6 -#else - val = 0 -#endif - ! val = 2*psb_sizeof_ip + psb_sizeof_dp - ! val = val + sv%symbsize - ! val = val + sv%numsize - return -end function c_mumps_solver_sizeof - -function c_mumps_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "MUMPS solver" -end function c_mumps_solver_get_fmt - -function c_mumps_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_mumps_ -end function c_mumps_solver_get_id - - -function c_mumps_solver_is_global(sv) result(val) - implicit none - class(mld_c_mumps_solver_type), intent(in) :: sv - logical :: val - - val = (sv%ipar(1) == mld_global_solver_ ) -end function c_mumps_solver_is_global - -end module mld_c_mumps_solver - diff --git a/mlprec/mld_c_onelev_mod.f90 b/mlprec/mld_c_onelev_mod.f90 deleted file mode 100644 index 121e89bc..00000000 --- a/mlprec/mld_c_onelev_mod.f90 +++ /dev/null @@ -1,824 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_c_onelev_mod.f90 -! -! Module: mld_c_onelev_mod -! -! This module defines: -! - the mld_c_onelev_type data structure containing one level -! of a multilevel preconditioner and related -! data structures; -! -! It contains routines for -! - Building and applying; -! - checking if the preconditioner is correctly defined; -! - printing a description of the preconditioner; -! - deallocating the preconditioner data structure. -! - -module mld_c_onelev_mod - - use mld_base_prec_type - use mld_c_base_smoother_mod - use mld_c_dec_aggregator_mod - use psb_base_mod, only : psb_cspmat_type, psb_c_vect_type, & - & psb_c_base_vect_type, psb_lcspmat_type, psb_clinmap_type, psb_spk_, & - & psb_ipk_, psb_epk_, psb_lpk_, psb_desc_type, psb_i_base_vect_type, & - & psb_erractionsave, psb_error_handler - ! - ! - ! Type: mld_conelev_type. - ! - ! It is the data type containing the necessary items for the current - ! level (essentially, the smoother, the current-level matrix - ! and the restriction and prolongation operators). - ! - ! type mld_conelev_type - ! class(mld_c_base_smoother_type), allocatable :: sm, sm2a - ! class(mld_c_base_smoother_type), pointer :: sm2 => null() - ! class(mld_cmlprec_wrk_type), allocatable :: wrk - ! class(mld_c_base_aggregator_type), allocatable :: aggr - ! type(mld_sml_parms) :: parms - ! type(psb_cspmat_type) :: ac - ! type(psb_cesc_type) :: desc_ac - ! type(psb_cspmat_type), pointer :: base_a => null() - ! type(psb_desc_type), pointer :: base_desc => null() - ! type(psb_clinmap_type) :: map - ! end type mld_conelev_type - ! - ! Note that s denotes the kind of the real data type to be chosen - ! according to single/double precision version of MLD2P4. - ! - ! sm,sm2a - class(mld_c_base_smoother_type), allocatable - ! The current level pre- and post-smooother. - ! sm2 - class(mld_c_base_smoother_type), pointer - ! The current level post-smooother; if sm2a is allocated - ! explicitly, then sm2 => sm2a, otherwise sm2 => sm. - ! wrk - class(mld_cmlprec_wrk_type), allocatable - ! Workspace for application of preconditioner; may be - ! pre-allocated to save time in the application within a - ! Krylov solver. - ! aggr - class(mld_c_base_aggregator_type), allocatable - ! The aggregator object: holds the algorithmic choices and - ! (possibly) additional data for building the aggregation. - ! parms - type(mld_sml_parms) - ! The parameters defining the multilevel strategy. - ! ac - The local part of the current-level matrix, built by - ! coarsening the previous-level matrix. - ! desc_ac - type(psb_desc_type). - ! The communication descriptor associated to the matrix - ! stored in ac. - ! base_a - type(psb_cspmat_type), pointer. - ! Pointer (really a pointer!) to the local part of the current - ! matrix (so we have a unified treatment of residuals). - ! We need this to avoid passing explicitly the current matrix - ! to the routine which applies the preconditioner. - ! base_desc - type(psb_desc_type), pointer. - ! Pointer to the communication descriptor associated to the - ! matrix pointed by base_a. - ! map - Stores the maps (restriction and prolongation) between the - ! vector spaces associated to the index spaces of the previous - ! and current levels. - ! - ! Methods: - ! Most methods follow the encapsulation hierarchy: they take whatever action - ! is appropriate for the current object, then call the corresponding method for - ! the contained object. - ! As an example: the descr() method prints out a description of the - ! level. It starts by invoking the descr() method of the parms object, - ! then calls the descr() method of the smoother object. - ! - ! descr - Prints a description of the object. - ! default - Set default values - ! dump - Dump to file object contents - ! set - Sets various parameters; when a request is unknown - ! it is passed to the smoother object for further processing. - ! check - Sanity checks. - ! sizeof - Total memory occupation in bytes - ! get_nzeros - Number of nonzeros - ! get_wrksz - How many workspace vector does apply_vect need - ! allocate_wrk - Allocate auxiliary workspace - ! free_wrk - Free auxiliary workspace - ! bld_tprol - Invoke the aggr method to build the tentative prolongator - ! mat_asb - Build the final (possibly smoothed) prolongator and coarse matrix. - ! - ! - type mld_cmlprec_wrk_type - complex(psb_spk_), allocatable :: tx(:), ty(:), x2l(:), y2l(:) - type(psb_c_vect_type) :: vtx, vty, vx2l, vy2l - type(psb_c_vect_type), allocatable :: wv(:) - contains - procedure, pass(wk) :: alloc => c_wrk_alloc - procedure, pass(wk) :: free => c_wrk_free - procedure, pass(wk) :: clone => c_wrk_clone - procedure, pass(wk) :: move_alloc => c_wrk_move_alloc - procedure, pass(wk) :: cnv => c_wrk_cnv - procedure, pass(wk) :: sizeof => c_wrk_sizeof - end type mld_cmlprec_wrk_type - private :: c_wrk_alloc, c_wrk_free, & - & c_wrk_clone, c_wrk_move_alloc, c_wrk_cnv, c_wrk_sizeof - - type mld_c_onelev_type - class(mld_c_base_smoother_type), allocatable :: sm, sm2a - class(mld_c_base_smoother_type), pointer :: sm2 => null() - class(mld_cmlprec_wrk_type), allocatable :: wrk - class(mld_c_base_aggregator_type), allocatable :: aggr - type(mld_sml_parms) :: parms - type(psb_cspmat_type) :: ac - integer(psb_ipk_) :: ac_nz_loc - integer(psb_lpk_) :: ac_nz_tot - type(psb_desc_type) :: desc_ac - type(psb_cspmat_type), pointer :: base_a => null() - type(psb_desc_type), pointer :: base_desc => null() - type(psb_lcspmat_type) :: tprol - type(psb_clinmap_type) :: map - real(psb_spk_) :: szratio - contains - procedure, pass(lv) :: bld_tprol => c_base_onelev_bld_tprol - procedure, pass(lv) :: mat_asb => mld_c_base_onelev_mat_asb - procedure, pass(lv) :: update_aggr => c_base_onelev_update_aggr - procedure, pass(lv) :: bld => mld_c_base_onelev_build - procedure, pass(lv) :: clone => c_base_onelev_clone - procedure, pass(lv) :: cnv => mld_c_base_onelev_cnv - procedure, pass(lv) :: descr => mld_c_base_onelev_descr - procedure, pass(lv) :: default => c_base_onelev_default - procedure, pass(lv) :: free => mld_c_base_onelev_free - procedure, pass(lv) :: nullify => c_base_onelev_nullify - procedure, pass(lv) :: check => mld_c_base_onelev_check - procedure, pass(lv) :: dump => mld_c_base_onelev_dump - procedure, pass(lv) :: cseti => mld_c_base_onelev_cseti - procedure, pass(lv) :: csetr => mld_c_base_onelev_csetr - procedure, pass(lv) :: csetc => mld_c_base_onelev_csetc - procedure, pass(lv) :: setsm => mld_c_base_onelev_setsm - procedure, pass(lv) :: setsv => mld_c_base_onelev_setsv - procedure, pass(lv) :: setag => mld_c_base_onelev_setag - generic, public :: set => cseti, csetr, csetc, setsm, setsv, setag - procedure, pass(lv) :: sizeof => c_base_onelev_sizeof - procedure, pass(lv) :: get_nzeros => c_base_onelev_get_nzeros - procedure, pass(lv) :: get_wrksz => c_base_onelev_get_wrksize - procedure, pass(lv) :: allocate_wrk => c_base_onelev_allocate_wrk - procedure, pass(lv) :: free_wrk => c_base_onelev_free_wrk - procedure, nopass :: stringval => mld_stringval - procedure, pass(lv) :: move_alloc => c_base_onelev_move_alloc - - end type mld_c_onelev_type - - type mld_c_onelev_node - type(mld_c_onelev_type) :: item - type(mld_c_onelev_node), pointer :: prev=>null(), next=>null() - end type mld_c_onelev_node - - private :: c_base_onelev_default, c_base_onelev_sizeof, & - & c_base_onelev_nullify, c_base_onelev_get_nzeros, & - & c_base_onelev_clone, c_base_onelev_move_alloc, & - & c_base_onelev_get_wrksize, c_base_onelev_allocate_wrk, & - & c_base_onelev_free_wrk - - interface - subroutine mld_c_base_onelev_mat_asb(lv,a,desc_a,ilaggr,nlaggr,t_prol,info) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, psb_ipk_, psb_lcspmat_type, psb_lpk_ - import :: mld_c_onelev_type - implicit none - class(mld_c_onelev_type), intent(inout), target :: lv - type(psb_cspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:),nlaggr(:) - type(psb_lcspmat_type), intent(inout) :: t_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_base_onelev_mat_asb - end interface - - interface - subroutine mld_c_base_onelev_build(lv,info,amold,vmold,imold,ilv) - import :: psb_c_base_sparse_mat, psb_c_base_vect_type, & - & psb_i_base_vect_type, psb_spk_, mld_c_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - implicit none - class(mld_c_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - integer(psb_ipk_), intent(in), optional :: ilv - end subroutine mld_c_base_onelev_build - end interface - - interface - subroutine mld_c_base_onelev_descr(lv,il,nl,ilmin,info,iout) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_clinmap_type, psb_spk_, mld_c_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - ! Arguments - class(mld_c_onelev_type), intent(in) :: lv - integer(psb_ipk_), intent(in) :: il,nl,ilmin - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - end subroutine mld_c_base_onelev_descr - end interface - - interface - subroutine mld_c_base_onelev_cnv(lv,info,amold,vmold,imold) - import :: mld_c_onelev_type, psb_c_base_vect_type, psb_spk_, & - & psb_c_base_sparse_mat, psb_ipk_, psb_i_base_vect_type - ! Arguments - class(mld_c_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_c_base_onelev_cnv - end interface - -interface - subroutine mld_c_base_onelev_free(lv,info) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_clinmap_type, psb_spk_, mld_c_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - implicit none - - class(mld_c_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_base_onelev_free - end interface - - interface - subroutine mld_c_base_onelev_check(lv,info) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_clinmap_type, psb_spk_, mld_c_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - ! Arguments - class(mld_c_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_base_onelev_check - end interface - - interface - subroutine mld_c_base_onelev_setsm(lv,val,info,pos) - import :: psb_spk_, mld_c_onelev_type, mld_c_base_smoother_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - ! Arguments - class(mld_c_onelev_type), target, intent(inout) :: lv - class(mld_c_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - end subroutine mld_c_base_onelev_setsm - end interface - - interface - subroutine mld_c_base_onelev_setsv(lv,val,info,pos) - import :: psb_spk_, mld_c_onelev_type, mld_c_base_solver_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - ! Arguments - class(mld_c_onelev_type), target, intent(inout) :: lv - class(mld_c_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - end subroutine mld_c_base_onelev_setsv - end interface - - interface - subroutine mld_c_base_onelev_setag(lv,val,info,pos) - import :: psb_spk_, mld_c_onelev_type, mld_c_base_aggregator_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - ! Arguments - class(mld_c_onelev_type), target, intent(inout) :: lv - class(mld_c_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - end subroutine mld_c_base_onelev_setag - end interface - - interface - subroutine mld_c_base_onelev_cseti(lv,what,val,info,pos,idx) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_clinmap_type, psb_spk_, mld_c_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - ! Arguments - class(mld_c_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_c_base_onelev_cseti - end interface - - interface - subroutine mld_c_base_onelev_csetc(lv,what,val,info,pos,idx) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_clinmap_type, psb_spk_, mld_c_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - ! Arguments - class(mld_c_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_c_base_onelev_csetc - end interface - - interface - subroutine mld_c_base_onelev_csetr(lv,what,val,info,pos,idx) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_clinmap_type, psb_spk_, mld_c_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - class(mld_c_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_c_base_onelev_csetr - end interface - - interface - subroutine mld_c_base_onelev_dump(lv,level,info,prefix,head,ac,rp,smoother,& - & solver,tprol,global_num) - import :: psb_cspmat_type, psb_c_vect_type, psb_c_base_vect_type, & - & psb_clinmap_type, psb_spk_, mld_c_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - implicit none - class(mld_c_onelev_type), intent(in) :: lv - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: ac, rp, smoother, solver, tprol, global_num - end subroutine mld_c_base_onelev_dump - end interface - -contains - ! - ! Function returning the size of the mld_prec_type data structure - ! in bytes or in number of nonzeros of the operator(s) involved. - ! - - function c_base_onelev_get_nzeros(lv) result(val) - implicit none - class(mld_c_onelev_type), intent(in) :: lv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - if (allocated(lv%sm)) & - & val = lv%sm%get_nzeros() - if (allocated(lv%sm2a)) & - & val = val + lv%sm2a%get_nzeros() - end function c_base_onelev_get_nzeros - - function c_base_onelev_sizeof(lv) result(val) - implicit none - class(mld_c_onelev_type), intent(in) :: lv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = psb_sizeof_ip+psb_sizeof_lp - val = val + lv%desc_ac%sizeof() - val = val + lv%ac%sizeof() - val = val + lv%tprol%sizeof() - val = val + lv%map%sizeof() - if (allocated(lv%sm)) val = val + lv%sm%sizeof() - if (allocated(lv%sm2a)) val = val + lv%sm2a%sizeof() - if (allocated(lv%aggr)) val = val + lv%aggr%sizeof() - if (allocated(lv%wrk)) val = val + lv%wrk%sizeof() - end function c_base_onelev_sizeof - - - subroutine c_base_onelev_nullify(lv) - implicit none - - class(mld_c_onelev_type), intent(inout) :: lv - - nullify(lv%base_a) - nullify(lv%base_desc) - nullify(lv%sm2) - end subroutine c_base_onelev_nullify - - ! - ! Multilevel defaults: - ! multiplicative vs. additive ML framework; - ! Smoothed decoupled aggregation with zero threshold; - ! distributed coarse matrix; - ! damping omega computed with the max-norm estimate of the - ! dominant eigenvalue; - ! two-sided smoothing (i.e. V-cycle) with 1 smoothing sweep; - ! - - subroutine c_base_onelev_default(lv) - - Implicit None - - ! Arguments - class(mld_c_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_) :: info - - lv%parms%sweeps_pre = 1 - lv%parms%sweeps_post = 1 - lv%parms%ml_cycle = mld_vcycle_ml_ - lv%parms%aggr_type = mld_soc1_ - lv%parms%par_aggr_alg = mld_dec_aggr_ - lv%parms%aggr_ord = mld_aggr_ord_nat_ - lv%parms%aggr_prol = mld_smooth_prol_ - lv%parms%coarse_mat = mld_distr_mat_ - lv%parms%aggr_omega_alg = mld_eig_est_ - lv%parms%aggr_eig = mld_max_norm_ - lv%parms%aggr_filter = mld_no_filter_mat_ - lv%parms%aggr_omega_val = szero - lv%parms%aggr_thresh = 0.01_psb_spk_ - - if (allocated(lv%sm)) call lv%sm%default() - if (allocated(lv%sm2a)) then - call lv%sm2a%default() - lv%sm2 => lv%sm2a - else - lv%sm2 => lv%sm - end if - if (.not.allocated(lv%aggr)) allocate(mld_c_dec_aggregator_type :: lv%aggr,stat=info) - if (allocated(lv%aggr)) call lv%aggr%default() - - return - - end subroutine c_base_onelev_default - - subroutine c_base_onelev_bld_tprol(lv,a,desc_a,& - & ilaggr,nlaggr,t_prol,ag_data,info) - implicit none - class(mld_c_onelev_type), intent(inout), target :: lv - type(psb_cspmat_type), intent(inout) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lcspmat_type), intent(out) :: t_prol - type(mld_saggr_data), intent(in) :: ag_data - integer(psb_ipk_), intent(out) :: info - - call lv%aggr%bld_tprol(lv%parms,ag_data,a,desc_a,ilaggr,nlaggr,t_prol,info) - - end subroutine c_base_onelev_bld_tprol - - - subroutine c_base_onelev_update_aggr(lv,lvnext,info) - implicit none - class(mld_c_onelev_type), intent(inout), target :: lv, lvnext - integer(psb_ipk_), intent(out) :: info - - call lv%aggr%update_next(lvnext%aggr,info) - - end subroutine c_base_onelev_update_aggr - - - subroutine c_base_onelev_clone(lv,lvout,info) - - Implicit None - - ! Arguments - class(mld_c_onelev_type), target, intent(inout) :: lv - class(mld_c_onelev_type), target, intent(inout) :: lvout - integer(psb_ipk_), intent(out) :: info - - info = psb_success_ - if (allocated(lv%sm)) then - call lv%sm%clone(lvout%sm,info) - else - if (allocated(lvout%sm)) then - call lvout%sm%free(info) - if (info==psb_success_) deallocate(lvout%sm,stat=info) - end if - end if - if (allocated(lv%sm2a)) then - call lv%sm%clone(lvout%sm2a,info) - lvout%sm2 => lvout%sm2a - else - if (allocated(lvout%sm2a)) then - call lvout%sm2a%free(info) - if (info==psb_success_) deallocate(lvout%sm2a,stat=info) - end if - lvout%sm2 => lvout%sm - end if - if (allocated(lv%aggr)) then - call lv%aggr%clone(lvout%aggr,info) - else - if (allocated(lvout%aggr)) then - call lvout%aggr%free(info) - if (info==psb_success_) deallocate(lvout%aggr,stat=info) - end if - end if - if (info == psb_success_) call lv%parms%clone(lvout%parms,info) - if (info == psb_success_) call lv%ac%clone(lvout%ac,info) - if (info == psb_success_) call lv%tprol%clone(lvout%tprol,info) - if (info == psb_success_) call lv%desc_ac%clone(lvout%desc_ac,info) - if (info == psb_success_) call lv%map%clone(lvout%map,info) - lvout%base_a => lv%base_a - lvout%base_desc => lv%base_desc - - return - - end subroutine c_base_onelev_clone - - subroutine c_base_onelev_move_alloc(lv, b,info) - use psb_base_mod - implicit none - class(mld_c_onelev_type), target, intent(inout) :: lv, b - integer(psb_ipk_), intent(out) :: info - - call b%free(info) - b%parms = lv%parms - b%szratio = lv%szratio - if (associated(lv%sm2,lv%sm2a)) then - call move_alloc(lv%sm,b%sm) - call move_alloc(lv%sm2a,b%sm2a) - b%sm2 =>b%sm2a - else - call move_alloc(lv%sm,b%sm) - call move_alloc(lv%sm2a,b%sm2a) - b%sm2 =>b%sm - end if - - call move_alloc(lv%aggr,b%aggr) - if (info == psb_success_) call psb_move_alloc(lv%ac,b%ac,info) - if (info == psb_success_) call psb_move_alloc(lv%tprol,b%tprol,info) - if (info == psb_success_) call psb_move_alloc(lv%desc_ac,b%desc_ac,info) - if (info == psb_success_) call psb_move_alloc(lv%map,b%map,info) - b%base_a => lv%base_a - b%base_desc => lv%base_desc - - end subroutine c_base_onelev_move_alloc - - - function c_base_onelev_get_wrksize(lv) result(val) - implicit none - class(mld_c_onelev_type), intent(inout) :: lv - integer(psb_ipk_) :: val - - val = 0 - ! SM and SM2A can share work vectors - if (allocated(lv%sm)) val = val + lv%sm%get_wrksz() - if (allocated(lv%sm2a)) val = max(val,lv%sm2a%get_wrksz()) - ! - ! Now for the ML application itself - ! - - ! VTX/VTY/VX2L/VY2L are stored explicitly - ! - - ! - ! additions for specific ML/cycles - ! - select case(lv%parms%ml_cycle) - case(mld_add_ml_,mld_mult_ml_,mld_vcycle_ml_, mld_wcycle_ml_) - ! We're good - - case(mld_kcycle_ml_, mld_kcyclesym_ml_) - ! - ! We need 7 in inneritkcycle. - ! Can we reuse vtx? - ! - val = val + 7 - - case default - ! Need a better error signaling ? - val = -1 - end select - - end function c_base_onelev_get_wrksize - - subroutine c_base_onelev_allocate_wrk(lv,info,vmold) - use psb_base_mod - implicit none - class(mld_c_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_vect_type), intent(in), optional :: vmold - ! - integer(psb_ipk_) :: nwv, i - info = psb_success_ - nwv = lv%get_wrksz() - if (.not.allocated(lv%wrk)) allocate(lv%wrk,stat=info) - if (info == 0) call lv%wrk%alloc(nwv,lv%base_desc,info,vmold=vmold) - - end subroutine c_base_onelev_allocate_wrk - - - subroutine c_base_onelev_free_wrk(lv,info) - use psb_base_mod - implicit none - class(mld_c_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: nwv,i - info = psb_success_ - - if (allocated(lv%wrk)) then - call lv%wrk%free(info) - if (info == 0) deallocate(lv%wrk,stat=info) - end if - end subroutine c_base_onelev_free_wrk - - subroutine c_wrk_alloc(wk,nwv,desc,info,vmold) - use psb_base_mod - - Implicit None - - ! Arguments - class(mld_cmlprec_wrk_type), target, intent(inout) :: wk - integer(psb_ipk_), intent(in) :: nwv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_vect_type), intent(in), optional :: vmold - ! - integer(psb_ipk_) :: i - - info = psb_success_ - call wk%free(info) - call psb_geasb(wk%vx2l,desc,info,& - & scratch=.true.,mold=vmold) - call psb_geasb(wk%vy2l,desc,info,& - & scratch=.true.,mold=vmold) - call psb_geasb(wk%vtx,desc,info,& - & scratch=.true.,mold=vmold) - call psb_geasb(wk%vty,desc,info,& - & scratch=.true.,mold=vmold) - allocate(wk%wv(nwv),stat=info) - do i=1,nwv - call psb_geasb(wk%wv(i),desc,info,& - & scratch=.true.,mold=vmold) - end do - - end subroutine c_wrk_alloc - - subroutine c_wrk_free(wk,info) - - Implicit None - - ! Arguments - class(mld_cmlprec_wrk_type), target, intent(inout) :: wk - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: i - info = psb_success_ - - if (allocated(wk%tx)) deallocate(wk%tx, stat=info) - if (allocated(wk%ty)) deallocate(wk%ty, stat=info) - if (allocated(wk%x2l)) deallocate(wk%x2l, stat=info) - if (allocated(wk%y2l)) deallocate(wk%y2l, stat=info) - call wk%vtx%free(info) - call wk%vty%free(info) - call wk%vx2l%free(info) - call wk%vy2l%free(info) - if (allocated(wk%wv)) then - do i=1,size(wk%wv) - call wk%wv(i)%free(info) - end do - deallocate(wk%wv, stat=info) - end if - - end subroutine c_wrk_free - - subroutine c_wrk_clone(wk,wkout,info) - use psb_base_mod - Implicit None - - ! Arguments - class(mld_cmlprec_wrk_type), target, intent(inout) :: wk - class(mld_cmlprec_wrk_type), target, intent(inout) :: wkout - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: i - info = psb_success_ - - call psb_safe_ab_cpy(wk%tx,wkout%tx,info) - call psb_safe_ab_cpy(wk%ty,wkout%ty,info) - call psb_safe_ab_cpy(wk%x2l,wkout%x2l,info) - call psb_safe_ab_cpy(wk%y2l,wkout%y2l,info) - call wk%vtx%clone(wkout%vtx,info) - call wk%vty%clone(wkout%vty,info) - call wk%vx2l%clone(wkout%vx2l,info) - call wk%vy2l%clone(wkout%vy2l,info) - if (allocated(wkout%wv)) then - do i=1,size(wkout%wv) - call wkout%wv(i)%free(info) - end do - deallocate( wkout%wv) - end if - allocate(wkout%wv(size(wk%wv)),stat=info) - do i=1,size(wk%wv) - call wk%wv(i)%clone(wkout%wv(i),info) - end do - return - - end subroutine c_wrk_clone - - subroutine c_wrk_move_alloc(wk, b,info) - implicit none - class(mld_cmlprec_wrk_type), target, intent(inout) :: wk, b - integer(psb_ipk_), intent(out) :: info - - call b%free(info) - call move_alloc(wk%tx,b%tx) - call move_alloc(wk%ty,b%ty) - call move_alloc(wk%x2l,b%x2l) - call move_alloc(wk%y2l,b%y2l) - ! - ! Should define V%move_alloc.... - call move_alloc(wk%vtx%v,b%vtx%v) - call move_alloc(wk%vty%v,b%vty%v) - call move_alloc(wk%vx2l%v,b%vx2l%v) - call move_alloc(wk%vy2l%v,b%vy2l%v) - call move_alloc(wk%wv,b%wv) - - end subroutine c_wrk_move_alloc - - subroutine c_wrk_cnv(wk,info,vmold) - use psb_base_mod - - Implicit None - - ! Arguments - class(mld_cmlprec_wrk_type), target, intent(inout) :: wk - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_vect_type), intent(in), optional :: vmold - ! - integer(psb_ipk_) :: i - - info = psb_success_ - if (present(vmold)) then - call wk%vtx%cnv(vmold) - call wk%vty%cnv(vmold) - call wk%vx2l%cnv(vmold) - call wk%vy2l%cnv(vmold) - if (allocated(wk%wv)) then - do i=1,size(wk%wv) - call wk%wv(i)%cnv(vmold) - end do - end if - end if - end subroutine c_wrk_cnv - - function c_wrk_sizeof(wk) result(val) - use psb_realloc_mod - implicit none - class(mld_cmlprec_wrk_type), intent(in) :: wk - integer(psb_epk_) :: val - integer :: i - val = 0 - val = val + (1_psb_epk_ * (2*psb_sizeof_sp)) * psb_size(wk%tx) - val = val + (1_psb_epk_ * (2*psb_sizeof_sp)) * psb_size(wk%ty) - val = val + (1_psb_epk_ * (2*psb_sizeof_sp)) * psb_size(wk%x2l) - val = val + (1_psb_epk_ * (2*psb_sizeof_sp)) * psb_size(wk%y2l) - val = val + wk%vtx%sizeof() - val = val + wk%vty%sizeof() - val = val + wk%vx2l%sizeof() - val = val + wk%vy2l%sizeof() - if (allocated(wk%wv)) then - do i=1, size(wk%wv) - val = val + wk%wv(i)%sizeof() - end do - end if - end function c_wrk_sizeof - -end module mld_c_onelev_mod diff --git a/mlprec/mld_c_prec_mod.f90 b/mlprec/mld_c_prec_mod.f90 deleted file mode 100644 index 5b2768b5..00000000 --- a/mlprec/mld_c_prec_mod.f90 +++ /dev/null @@ -1,139 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_c_prec_mod.f90 -! -! Module: mld_c_prec_mod -! -! This module defines the user interfaces to the real/complex, single/double -! precision versions of the user-level MLD2P4 routines. -! -module mld_c_prec_mod - - use mld_c_prec_type - use mld_c_jac_smoother - use mld_c_as_smoother - use mld_c_id_solver - use mld_c_diag_solver - use mld_c_l1_diag_solver - use mld_c_ilu_solver - use mld_c_gs_solver - - interface mld_precset - module procedure mld_c_iprecsetsm, mld_c_iprecsetsv, & - & mld_c_cprecseti, mld_c_cprecsetc, mld_c_cprecsetr, & - & mld_c_iprecsetag - end interface mld_precset - - interface mld_extprol_bld - subroutine mld_c_extprol_bld(a,desc_a,p,prolv,restrv,info,amold,vmold,imold) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, & - & psb_c_base_sparse_mat, psb_c_base_vect_type, & - & psb_i_base_vect_type, mld_cprec_type, psb_ipk_ - - ! Arguments - type(psb_cspmat_type),intent(in), target :: a - type(psb_cspmat_type),intent(inout), target :: prolv(:) - type(psb_cspmat_type),intent(inout), target :: restrv(:) - type(psb_desc_type), intent(inout), target :: desc_a - type(mld_cprec_type),intent(inout),target :: p - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! !$ character, intent(in), optional :: upd - end subroutine mld_c_extprol_bld - end interface mld_extprol_bld - -contains - - subroutine mld_c_iprecsetsm(p,val,info,pos) - type(mld_cprec_type), intent(inout) :: p - class(mld_c_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - call p%set(val,info,pos=pos) - end subroutine mld_c_iprecsetsm - - subroutine mld_c_iprecsetsv(p,val,info,pos) - type(mld_cprec_type), intent(inout) :: p - class(mld_c_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - call p%set(val,info, pos=pos) - end subroutine mld_c_iprecsetsv - - subroutine mld_c_iprecsetag(p,val,info,pos) - type(mld_cprec_type), intent(inout) :: p - class(mld_c_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - call p%set(val,info, pos=pos) - end subroutine mld_c_iprecsetag - - subroutine mld_c_cprecseti(p,what,val,info,pos) - type(mld_cprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - call p%set(what,val,info,pos=pos) - end subroutine mld_c_cprecseti - - subroutine mld_c_cprecsetr(p,what,val,info,pos) - type(mld_cprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - call p%set(what,val,info,pos=pos) - end subroutine mld_c_cprecsetr - - subroutine mld_c_cprecsetc(p,what,val,info,pos) - type(mld_cprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - call p%set(what,val,info,pos=pos) - end subroutine mld_c_cprecsetc - -end module mld_c_prec_mod diff --git a/mlprec/mld_c_prec_type.f90 b/mlprec/mld_c_prec_type.f90 deleted file mode 100644 index d2cdf170..00000000 --- a/mlprec/mld_c_prec_type.f90 +++ /dev/null @@ -1,964 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_c_prec_type.f90 -! -! Module: mld_c_prec_type -! -! This module defines: -! - the mld_c_prec_type data structure containing the preconditioner and related -! data structures; -! -! It contains routines for -! - Building and applying; -! - checking if the preconditioner is correctly defined; -! - printing a description of the preconditioner; -! - deallocating the preconditioner data structure. -! - -module mld_c_prec_type - - use mld_base_prec_type - use mld_c_base_solver_mod - use mld_c_base_smoother_mod - use mld_c_base_aggregator_mod - use mld_c_onelev_mod - use psb_base_mod, only : psb_erractionsave, psb_erractionrestore, psb_errstatus_fatal - use psb_prec_mod, only : psb_cprec_type - - ! - ! Type: mld_cprec_type. - ! - ! This is the data type containing all the information about the multilevel - ! preconditioner ('d', 's', 'c' and 'z', according to the real/complex, - ! single/double precision version of MLD2P4). - ! It consists of an array of 'one-level' intermediate data structures - ! of type mld_conelev_type, each containing the information needed to apply - ! the smoothing and the coarse-space correction at a generic level. RT is the - ! real data type, i.e. S for both S and C, and D for both D and Z. - ! - ! type mld_cprec_type - ! type(mld_conelev_type), allocatable :: precv(:) - ! end type mld_cprec_type - ! - ! Note that the levels are numbered in increasing order starting from - ! the level 1 as the finest one, and the number of levels is given by - ! size(precv(:)) which is the id of the coarsest level. - ! In the multigrid literature many authors number the levels in the opposite - ! order, with level 0 being the id of the coarsest level. - ! - ! - integer, parameter, private :: wv_size_=4 - - type, extends(psb_cprec_type) :: mld_cprec_type - ! integer(psb_ipk_) :: ictxt ! Now it's in the PSBLAS prec. - type(mld_saggr_data) :: ag_data - ! - ! Number of outer sweeps. Sometimes 2 V-cycles may be better than 1 W-cycle. - ! - integer(psb_ipk_) :: outer_sweeps = 1 - ! - ! Coarse solver requires some tricky checks, and for this we need to - ! record the choice in the format given by the user, - ! to keep track against what is put later in the multilevel array - ! - integer(psb_ipk_) :: coarse_solver = -1 - - ! - ! The multilevel hierarchy - ! - type(mld_c_onelev_type), allocatable :: precv(:) - contains - procedure, pass(prec) :: psb_c_apply2_vect => mld_c_apply2_vect - procedure, pass(prec) :: psb_c_apply1_vect => mld_c_apply1_vect - procedure, pass(prec) :: psb_c_apply2v => mld_c_apply2v - procedure, pass(prec) :: psb_c_apply1v => mld_c_apply1v - procedure, pass(prec) :: dump => mld_c_dump - procedure, pass(prec) :: cnv => mld_c_cnv - procedure, pass(prec) :: clone => mld_c_clone - procedure, pass(prec) :: free => mld_c_prec_free - procedure, pass(prec) :: allocate_wrk => mld_c_allocate_wrk - procedure, pass(prec) :: free_wrk => mld_c_free_wrk - procedure, pass(prec) :: is_allocated_wrk => mld_c_is_allocated_wrk - procedure, pass(prec) :: get_complexity => mld_c_get_compl - procedure, pass(prec) :: cmp_complexity => mld_c_cmp_compl - procedure, pass(prec) :: get_avg_cr => mld_c_get_avg_cr - procedure, pass(prec) :: cmp_avg_cr => mld_c_cmp_avg_cr - procedure, pass(prec) :: get_nlevs => mld_c_get_nlevs - procedure, pass(prec) :: get_nzeros => mld_c_get_nzeros - procedure, pass(prec) :: sizeof => mld_cprec_sizeof - procedure, pass(prec) :: setsm => mld_cprecsetsm - procedure, pass(prec) :: setsv => mld_cprecsetsv - procedure, pass(prec) :: setag => mld_cprecsetag - procedure, pass(prec) :: cseti => mld_ccprecseti - procedure, pass(prec) :: csetc => mld_ccprecsetc - procedure, pass(prec) :: csetr => mld_ccprecsetr - generic, public :: set => cseti, csetc, csetr, setsm, setsv, setag - procedure, pass(prec) :: get_smoother => mld_c_get_smootherp - procedure, pass(prec) :: get_solver => mld_c_get_solverp - procedure, pass(prec) :: move_alloc => c_prec_move_alloc - procedure, pass(prec) :: init => mld_cprecinit - procedure, pass(prec) :: build => mld_cprecbld - procedure, pass(prec) :: hierarchy_build => mld_c_hierarchy_bld - procedure, pass(prec) :: smoothers_build => mld_c_smoothers_bld - procedure, pass(prec) :: descr => mld_cfile_prec_descr - end type mld_cprec_type - - private :: mld_c_dump, mld_c_get_compl, mld_c_cmp_compl,& - & mld_c_get_avg_cr, mld_c_cmp_avg_cr,& - & mld_c_get_nzeros, mld_c_get_nlevs, c_prec_move_alloc - - - ! - ! Interfaces to routines for checking the definition of the preconditioner, - ! for printing its description and for deallocating its data structure - ! - - interface mld_precfree - module procedure mld_cprecfree - end interface - - - interface mld_precdescr - subroutine mld_cfile_prec_descr(prec,iout,root) - import :: mld_cprec_type, psb_ipk_ - implicit none - ! Arguments - class(mld_cprec_type), intent(in) :: prec - integer(psb_ipk_), intent(in), optional :: iout - integer(psb_ipk_), intent(in), optional :: root - end subroutine mld_cfile_prec_descr - end interface - - interface mld_sizeof - module procedure mld_cprec_sizeof - end interface - - interface mld_precapply - subroutine mld_cprecaply2_vect(prec,x,y,desc_data,info,trans,work) - import :: psb_cspmat_type, psb_desc_type, & - & psb_spk_, psb_c_vect_type, mld_cprec_type, psb_ipk_ - type(psb_desc_type),intent(in) :: desc_data - type(mld_cprec_type), intent(inout) :: prec - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_spk_),intent(inout), optional, target :: work(:) - end subroutine mld_cprecaply2_vect - subroutine mld_cprecaply1_vect(prec,x,desc_data,info,trans,work) - import :: psb_cspmat_type, psb_desc_type, & - & psb_spk_, psb_c_vect_type, mld_cprec_type, psb_ipk_ - type(psb_desc_type),intent(in) :: desc_data - type(mld_cprec_type), intent(inout) :: prec - type(psb_c_vect_type),intent(inout) :: x - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_spk_),intent(inout), optional, target :: work(:) - end subroutine mld_cprecaply1_vect - subroutine mld_cprecaply(prec,x,y,desc_data,info,trans,work) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, mld_cprec_type, psb_ipk_ - type(psb_desc_type),intent(in) :: desc_data - type(mld_cprec_type), intent(inout) :: prec - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_spk_),intent(inout), optional, target :: work(:) - end subroutine mld_cprecaply - subroutine mld_cprecaply1(prec,x,desc_data,info,trans) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, mld_cprec_type, psb_ipk_ - type(psb_desc_type),intent(in) :: desc_data - type(mld_cprec_type), intent(inout) :: prec - complex(psb_spk_),intent(inout) :: x(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - end subroutine mld_cprecaply1 - end interface - - interface - subroutine mld_cprecsetsm(prec,val,info,ilev,ilmax,pos) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, & - & mld_cprec_type, mld_c_base_smoother_type, psb_ipk_ - class(mld_cprec_type), target, intent(inout):: prec - class(mld_c_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - end subroutine mld_cprecsetsm - subroutine mld_cprecsetsv(prec,val,info,ilev,ilmax,pos) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, & - & mld_cprec_type, mld_c_base_solver_type, psb_ipk_ - class(mld_cprec_type), intent(inout) :: prec - class(mld_c_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - end subroutine mld_cprecsetsv - subroutine mld_cprecsetag(prec,val,info,ilev,ilmax,pos) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, & - & mld_cprec_type, mld_c_base_aggregator_type, psb_ipk_ - class(mld_cprec_type), intent(inout) :: prec - class(mld_c_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - end subroutine mld_cprecsetag - subroutine mld_ccprecseti(prec,what,val,info,ilev,ilmax,pos,idx) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, & - & mld_cprec_type, psb_ipk_ - class(mld_cprec_type), intent(inout) :: prec - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx - character(len=*), optional, intent(in) :: pos - end subroutine mld_ccprecseti - subroutine mld_ccprecsetr(prec,what,val,info,ilev,ilmax,pos,idx) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, & - & mld_cprec_type, psb_ipk_ - class(mld_cprec_type), intent(inout) :: prec - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx - character(len=*), optional, intent(in) :: pos - end subroutine mld_ccprecsetr - subroutine mld_ccprecsetc(prec,what,string,info,ilev,ilmax,pos,idx) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, & - & mld_cprec_type, psb_ipk_ - class(mld_cprec_type), intent(inout) :: prec - character(len=*), intent(in) :: what - character(len=*), intent(in) :: string - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx - character(len=*), optional, intent(in) :: pos - end subroutine mld_ccprecsetc - end interface - - interface mld_precinit - subroutine mld_cprecinit(ictxt,prec,ptype,info) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, & - & mld_cprec_type, psb_ipk_ - integer(psb_ipk_), intent(in) :: ictxt - class(mld_cprec_type), intent(inout) :: prec - character(len=*), intent(in) :: ptype - integer(psb_ipk_), intent(out) :: info - end subroutine mld_cprecinit - end interface mld_precinit - - interface mld_precbld - subroutine mld_cprecbld(a,desc_a,prec,info,amold,vmold,imold) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, & - & psb_c_base_sparse_mat, psb_c_base_vect_type, & - & psb_i_base_vect_type, mld_cprec_type, psb_ipk_ - implicit none - type(psb_cspmat_type), intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_cprec_type), intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! character, intent(in),optional :: upd - end subroutine mld_cprecbld - end interface mld_precbld - - interface mld_hierarchy_bld - subroutine mld_c_hierarchy_bld(a,desc_a,prec,info) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, & - & mld_cprec_type, psb_ipk_ - implicit none - type(psb_cspmat_type), intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_cprec_type), intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - ! character, intent(in),optional :: upd - end subroutine mld_c_hierarchy_bld - end interface mld_hierarchy_bld - - interface mld_smoothers_bld - subroutine mld_c_smoothers_bld(a,desc_a,prec,info,amold,vmold,imold) - import :: psb_cspmat_type, psb_desc_type, psb_spk_, & - & psb_c_base_sparse_mat, psb_c_base_vect_type, & - & psb_i_base_vect_type, mld_cprec_type, psb_ipk_ - implicit none - type(psb_cspmat_type), intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_cprec_type), intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! character, intent(in),optional :: upd - end subroutine mld_c_smoothers_bld - end interface mld_smoothers_bld - -contains - ! - ! Function returning a pointer to the smoother - ! - function mld_c_get_smootherp(prec,ilev) result(val) - implicit none - class(mld_cprec_type), target, intent(in) :: prec - integer(psb_ipk_), optional :: ilev - class(mld_c_base_smoother_type), pointer :: val - integer(psb_ipk_) :: ilev_ - - val => null() - if (present(ilev)) then - ilev_ = ilev - else - ! What is a good default? - ilev_ = 1 - end if - if (allocated(prec%precv)) then - if ((1<=ilev_).and.(ilev_<=size(prec%precv))) then - if (allocated(prec%precv(ilev_)%sm)) then - val => prec%precv(ilev_)%sm - end if - end if - end if - end function mld_c_get_smootherp - ! - ! Function returning a pointer to the solver - ! - function mld_c_get_solverp(prec,ilev) result(val) - implicit none - class(mld_cprec_type), target, intent(in) :: prec - integer(psb_ipk_), optional :: ilev - class(mld_c_base_solver_type), pointer :: val - integer(psb_ipk_) :: ilev_ - - val => null() - if (present(ilev)) then - ilev_ = ilev - else - ! What is a good default? - ilev_ = 1 - end if - if (allocated(prec%precv)) then - if ((1<=ilev_).and.(ilev_<=size(prec%precv))) then - if (allocated(prec%precv(ilev_)%sm)) then - if (allocated(prec%precv(ilev_)%sm%sv)) then - val => prec%precv(ilev_)%sm%sv - end if - end if - end if - end if - end function mld_c_get_solverp - ! - ! Function returning the size of the precv(:) array - ! - function mld_c_get_nlevs(prec) result(val) - implicit none - class(mld_cprec_type), intent(in) :: prec - integer(psb_ipk_) :: val - val = 0 - if (allocated(prec%precv)) then - val = size(prec%precv) - end if - end function mld_c_get_nlevs - ! - ! Function returning the size of the mld_prec_type data structure - ! in bytes or in number of nonzeros of the operator(s) involved. - ! - function mld_c_get_nzeros(prec) result(val) - implicit none - class(mld_cprec_type), intent(in) :: prec - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - if (allocated(prec%precv)) then - do i=1, size(prec%precv) - val = val + prec%precv(i)%get_nzeros() - end do - end if - end function mld_c_get_nzeros - - function mld_cprec_sizeof(prec) result(val) - implicit none - class(mld_cprec_type), intent(in) :: prec - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - val = val + psb_sizeof_ip - if (allocated(prec%precv)) then - do i=1, size(prec%precv) - val = val + prec%precv(i)%sizeof() - end do - end if - end function mld_cprec_sizeof - - ! - ! Operator complexity: ratio of total number - ! of nonzeros in the aggregated matrices at the - ! various level to the nonzeroes at the fine level - ! (original matrix) - ! - - function mld_c_get_compl(prec) result(val) - implicit none - class(mld_cprec_type), intent(in) :: prec - complex(psb_spk_) :: val - - val = prec%ag_data%op_complexity - - end function mld_c_get_compl - - subroutine mld_c_cmp_compl(prec) - - implicit none - class(mld_cprec_type), intent(inout) :: prec - - real(psb_spk_) :: num, den, nmin - integer(psb_ipk_) :: ictxt - integer(psb_ipk_) :: il - - num = -sone - den = sone - ictxt = prec%ictxt - if (allocated(prec%precv)) then - il = 1 - num = prec%precv(il)%base_a%get_nzeros() - if (num >= szero) then - den = num - do il=2,size(prec%precv) - num = num + max(0,prec%precv(il)%base_a%get_nzeros()) - end do - end if - end if - nmin = num - call psb_min(ictxt,nmin) - if (nmin < szero) then - num = szero - den = sone - else - call psb_sum(ictxt,num) - call psb_sum(ictxt,den) - end if - prec%ag_data%op_complexity = num/den - end subroutine mld_c_cmp_compl - - ! - ! Average coarsening ratio - ! - - function mld_c_get_avg_cr(prec) result(val) - implicit none - class(mld_cprec_type), intent(in) :: prec - complex(psb_spk_) :: val - - val = prec%ag_data%avg_cr - - end function mld_c_get_avg_cr - - subroutine mld_c_cmp_avg_cr(prec) - - implicit none - class(mld_cprec_type), intent(inout) :: prec - - real(psb_spk_) :: avgcr - integer(psb_ipk_) :: ictxt - integer(psb_ipk_) :: il, nl, iam, np - - - avgcr = szero - ictxt = prec%ictxt - call psb_info(ictxt,iam,np) - if (allocated(prec%precv)) then - nl = size(prec%precv) - do il=2,nl - avgcr = avgcr + max(szero,prec%precv(il)%szratio) - end do - avgcr = avgcr / (nl-1) - end if - call psb_sum(ictxt,avgcr) - prec%ag_data%avg_cr = avgcr/np - end subroutine mld_c_cmp_avg_cr - - ! - ! Subroutines: mld_Tprec_free - ! Version: complex - ! - ! These routines deallocate the mld_Tprec_type data structures. - ! - ! Arguments: - ! p - type(mld_Tprec_type), input. - ! The data structure to be deallocated. - ! info - integer, output. - ! error code. - ! - subroutine mld_cprecfree(p,info) - - implicit none - - ! Arguments - type(mld_cprec_type), intent(inout) :: p - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: me,err_act,i - character(len=20) :: name - - info=psb_success_ - name = 'mld_cprecfree' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; return - end if - - me=-1 - - call p%free(info) - - - return - - end subroutine mld_cprecfree - - subroutine mld_c_prec_free(prec,info) - - implicit none - - ! Arguments - class(mld_cprec_type), intent(inout) :: prec - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: me,err_act,i - character(len=20) :: name - - info=psb_success_ - name = 'mld_cprecfree' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - - me=-1 - if (allocated(prec%precv)) then - do i=1,size(prec%precv) - call prec%precv(i)%free(info) - end do - deallocate(prec%precv,stat=info) - end if - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_c_prec_free - - - - ! - ! Top level methods. - ! - subroutine mld_c_apply2_vect(prec,x,y,desc_data,info,trans,work) - implicit none - type(psb_desc_type),intent(in) :: desc_data - class(mld_cprec_type), intent(inout) :: prec - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_spk_),intent(inout), optional, target :: work(:) - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_prec_apply' - - call psb_erractionsave(err_act) - - select type(prec) - type is (mld_cprec_type) - call mld_precapply(prec,x,y,desc_data,info,trans,work) - class default - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_c_apply2_vect - - subroutine mld_c_apply1_vect(prec,x,desc_data,info,trans,work) - implicit none - type(psb_desc_type),intent(in) :: desc_data - class(mld_cprec_type), intent(inout) :: prec - type(psb_c_vect_type),intent(inout) :: x - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_spk_),intent(inout), optional, target :: work(:) - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_prec_apply' - - call psb_erractionsave(err_act) - - select type(prec) - type is (mld_cprec_type) - call mld_precapply(prec,x,desc_data,info,trans,work) - class default - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_c_apply1_vect - - - subroutine mld_c_apply2v(prec,x,y,desc_data,info,trans,work) - implicit none - type(psb_desc_type),intent(in) :: desc_data - class(mld_cprec_type), intent(inout) :: prec - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_spk_),intent(inout), optional, target :: work(:) - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_prec_apply' - - call psb_erractionsave(err_act) - - select type(prec) - type is (mld_cprec_type) - call mld_precapply(prec,x,y,desc_data,info,trans,work) - class default - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_c_apply2v - - subroutine mld_c_apply1v(prec,x,desc_data,info,trans) - implicit none - type(psb_desc_type),intent(in) :: desc_data - class(mld_cprec_type), intent(inout) :: prec - complex(psb_spk_),intent(inout) :: x(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_prec_apply' - - call psb_erractionsave(err_act) - - select type(prec) - type is (mld_cprec_type) - call mld_precapply(prec,x,desc_data,info,trans) - class default - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_c_apply1v - - - subroutine mld_c_dump(prec,info,istart,iend,iproc,prefix,head,& - & ac,rp,smoother,solver,tprol,& - & global_num) - - implicit none - class(mld_cprec_type), intent(in) :: prec - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: istart, iend, iproc - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver,ac, rp, tprol, global_num - integer(psb_ipk_) :: i, j, il1, iln, lev - integer(psb_ipk_) :: icontxt, iam, np, iproc_ - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - ! len of prefix_ - - info = 0 - icontxt = prec%ictxt - call psb_info(icontxt,iam,np) - - iln = size(prec%precv) - if (present(istart)) then - il1 = max(1,istart) - else - il1 = min(2,iln) - end if - if (present(iend)) then - iln = min(iln, iend) - end if - iproc_ = -1 - if (present(iproc)) then - iproc_ = iproc - end if - - if ((iproc_ == -1).or.(iproc_==iam)) then - do lev=il1, iln - call prec%precv(lev)%dump(lev,info,prefix=prefix,head=head,& - & ac=ac,smoother=smoother,solver=solver,rp=rp,tprol=tprol, & - & global_num=global_num) - end do - end if - end subroutine mld_c_dump - - subroutine mld_c_cnv(prec,info,amold,vmold,imold) - - implicit none - class(mld_cprec_type), intent(inout) :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - integer(psb_ipk_) :: i - - info = psb_success_ - if (allocated(prec%precv)) then - do i=1,size(prec%precv) - if (info == psb_success_ ) & - & call prec%precv(i)%cnv(info,amold=amold,vmold=vmold,imold=imold) - end do - end if - - end subroutine mld_c_cnv - - subroutine mld_c_clone(prec,precout,info) - - implicit none - class(mld_cprec_type), intent(inout) :: prec - class(psb_cprec_type), intent(inout) :: precout - integer(psb_ipk_), intent(out) :: info - - call precout%free(info) - if (info == 0) call mld_c_inner_clone(prec,precout,info) - - end subroutine mld_c_clone - - subroutine mld_c_inner_clone(prec,precout,info) - - implicit none - class(mld_cprec_type), intent(inout) :: prec - class(psb_cprec_type), target, intent(inout) :: precout - integer(psb_ipk_), intent(out) :: info - ! Local vars - integer(psb_ipk_) :: i, j, ln, lev - integer(psb_ipk_) :: icontxt,iam, np - - info = psb_success_ - select type(pout => precout) - class is (mld_cprec_type) - pout%ictxt = prec%ictxt - pout%ag_data = prec%ag_data - pout%outer_sweeps = prec%outer_sweeps - if (allocated(prec%precv)) then - ln = size(prec%precv) - allocate(pout%precv(ln),stat=info) - if (info /= psb_success_) goto 9999 - if (ln >= 1) then - call prec%precv(1)%clone(pout%precv(1),info) - end if - do lev=2, ln - if (info /= psb_success_) exit - call prec%precv(lev)%clone(pout%precv(lev),info) - if (info == psb_success_) then - pout%precv(lev)%base_a => pout%precv(lev)%ac - pout%precv(lev)%base_desc => pout%precv(lev)%desc_ac - pout%precv(lev)%map%p_desc_U => pout%precv(lev-1)%base_desc - pout%precv(lev)%map%p_desc_V => pout%precv(lev)%base_desc - end if - end do - end if - if (allocated(prec%precv(1)%wrk)) & - & call pout%allocate_wrk(info,vmold=prec%precv(1)%wrk%vx2l%v) - - class default - write(0,*) 'Error: wrong out type' - info = psb_err_invalid_input_ - end select -9999 continue - end subroutine mld_c_inner_clone - - subroutine c_prec_move_alloc(prec, b,info) - use psb_base_mod - implicit none - class(mld_cprec_type), intent(inout) :: prec - class(mld_cprec_type), intent(inout), target :: b - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: i - - if (same_type_as(prec,b)) then - if (allocated(b%precv)) then - ! This might not be required if FINAL procedures are available. - call b%free(info) - if (info /= psb_success_) then - !????? -!!$ return - endif - end if - b%ictxt = prec%ictxt - b%ag_data = prec%ag_data - b%outer_sweeps = prec%outer_sweeps - - call move_alloc(prec%precv,b%precv) - ! Fix the pointers except on level 1. - do i=2, size(b%precv) - b%precv(i)%base_a => b%precv(i)%ac - b%precv(i)%base_desc => b%precv(i)%desc_ac - b%precv(i)%map%p_desc_U => b%precv(i-1)%base_desc - b%precv(i)%map%p_desc_V => b%precv(i)%base_desc - end do - - else - write(0,*) 'Warning: PREC%move_alloc onto different type?' - info = psb_err_internal_error_ - end if - end subroutine c_prec_move_alloc - - subroutine mld_c_allocate_wrk(prec,info,vmold,desc) - use psb_base_mod - implicit none - - ! Arguments - class(mld_cprec_type), intent(inout) :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_c_base_vect_type), intent(in), optional :: vmold - ! - ! In MLD the DESC optional argument is ignored, since - ! the necessary info is contained in the various entries of the - ! PRECV component. - type(psb_desc_type), intent(in), optional :: desc - - ! Local variables - integer(psb_ipk_) :: me,err_act,i,j,level,nlev, nc2l - character(len=20) :: name - - info=psb_success_ - name = 'mld_c_allocate_wrk' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - nlev = size(prec%precv) - level = 1 - do level = 1, nlev - call prec%precv(level)%allocate_wrk(info,vmold=vmold) - if (psb_errstatus_fatal()) then - nc2l = prec%precv(level)%base_desc%get_local_cols() - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nc2l/), a_err='complex(psb_spk_)') - goto 9999 - end if - end do - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_c_allocate_wrk - - subroutine mld_c_free_wrk(prec,info) - use psb_base_mod - implicit none - - ! Arguments - class(mld_cprec_type), intent(inout) :: prec - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: me,err_act,i,j,level, nlev, nc2l - character(len=20) :: name - - info=psb_success_ - name = 'mld_c_free_wrk' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - - if (allocated(prec%precv)) then - nlev = size(prec%precv) - do level = 1, nlev - call prec%precv(level)%free_wrk(info) - end do - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_c_free_wrk - - function mld_c_is_allocated_wrk(prec) result(res) - use psb_base_mod - implicit none - - ! Arguments - class(mld_cprec_type), intent(in) :: prec - logical :: res - - res = .false. - if (.not.allocated(prec%precv)) return - res = allocated(prec%precv(1)%wrk) - - end function mld_c_is_allocated_wrk - -end module mld_c_prec_type diff --git a/mlprec/mld_c_slu_solver.F90 b/mlprec/mld_c_slu_solver.F90 deleted file mode 100644 index 48780b82..00000000 --- a/mlprec/mld_c_slu_solver.F90 +++ /dev/null @@ -1,447 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_c_slu_solver_mod.f90 -! -! Module: mld_c_slu_solver_mod -! -! This module defines: -! - the mld_c_slu_solver_type data structure containing the ingredients -! to interface with the SuperLU package. -! 1. The factorization is restricted to the diagonal block of the -! current image. -! -module mld_c_slu_solver - - use iso_c_binding - use mld_c_base_solver_mod - -#if defined(IPK8) - - type, extends(mld_c_base_solver_type) :: mld_c_slu_solver_type - - end type mld_c_slu_solver_type - -#else - - type, extends(mld_c_base_solver_type) :: mld_c_slu_solver_type - type(c_ptr) :: lufactors=c_null_ptr - integer(c_long_long) :: symbsize=0, numsize=0 - contains - procedure, pass(sv) :: build => c_slu_solver_bld - procedure, pass(sv) :: apply_a => c_slu_solver_apply - procedure, pass(sv) :: apply_v => c_slu_solver_apply_vect - procedure, pass(sv) :: free => c_slu_solver_free - procedure, pass(sv) :: clear_data => c_slu_solver_clear_data - procedure, pass(sv) :: descr => c_slu_solver_descr - procedure, pass(sv) :: sizeof => c_slu_solver_sizeof - procedure, nopass :: get_fmt => c_slu_solver_get_fmt - procedure, nopass :: get_id => c_slu_solver_get_id - final :: c_slu_solver_finalize - end type mld_c_slu_solver_type - - - private :: c_slu_solver_bld, c_slu_solver_apply, & - & c_slu_solver_free, c_slu_solver_descr, & - & c_slu_solver_sizeof, c_slu_solver_apply_vect, & - & c_slu_solver_get_fmt, c_slu_solver_get_id, & - & c_slu_solver_clear_data - private :: c_slu_solver_finalize - - - - interface - function mld_cslu_fact(n,nnz,values,rowptr,colind,& - & lufactors)& - & bind(c,name='mld_cslu_fact') result(info) - use iso_c_binding - integer(c_int), value :: n,nnz - integer(c_int) :: info - integer(c_int) :: rowptr(*),colind(*) - complex(c_float_complex) :: values(*) - type(c_ptr) :: lufactors - end function mld_cslu_fact - end interface - - interface - function mld_cslu_solve(itrans,n,nrhs,b,ldb,lufactors)& - & bind(c,name='mld_cslu_solve') result(info) - use iso_c_binding - integer(c_int) :: info - integer(c_int), value :: itrans,n,nrhs,ldb - complex(c_float_complex) :: b(ldb,*) - type(c_ptr), value :: lufactors - end function mld_cslu_solve - end interface - - interface - function mld_cslu_free(lufactors)& - & bind(c,name='mld_cslu_free') result(info) - use iso_c_binding - integer(c_int) :: info - type(c_ptr), value :: lufactors - end function mld_cslu_free - end interface - -contains - - subroutine c_slu_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - use psb_base_mod - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_slu_solver_type), intent(inout) :: sv - complex(psb_spk_),intent(inout) :: x(:) - complex(psb_spk_),intent(inout) :: y(:) - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - integer, intent(out) :: info - character, intent(in), optional :: init - complex(psb_spk_),intent(inout), optional :: initu(:) - - integer :: n_row,n_col - complex(psb_spk_), pointer :: ww(:) - integer :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='c_slu_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - else - allocate(ww(n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/n_col,0,0,0,0/),& - & a_err='complex(psb_spk_)') - goto 9999 - end if - endif - - ww(1:n_row) = x(1:n_row) - select case(trans_) - case('N') - info = mld_cslu_solve(0,n_row,1,ww,n_row,sv%lufactors) - case('T') - info = mld_cslu_solve(1,n_row,1,ww,n_row,sv%lufactors) - case('C') - info = mld_cslu_solve(2,n_row,1,ww,n_row,sv%lufactors) - case default - call psb_errpush(psb_err_internal_error_, & - & name,a_err='Invalid TRANS in ILU subsolve') - goto 9999 - end select - - if (info == psb_success_) & - & call psb_geaxpby(alpha,ww,beta,y,desc_data,info) - - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in subsolve') - goto 9999 - endif - - if (n_col > size(work)) then - deallocate(ww) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine c_slu_solver_apply - - subroutine c_slu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - use psb_base_mod - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_c_slu_solver_type), intent(inout) :: sv - type(psb_c_vect_type),intent(inout) :: x - type(psb_c_vect_type),intent(inout) :: y - complex(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_spk_),target, intent(inout) :: work(:) - type(psb_c_vect_type),intent(inout) :: wv(:) - integer, intent(out) :: info - character, intent(in), optional :: init - type(psb_c_vect_type),intent(inout), optional :: initu - - integer :: err_act - character(len=20) :: name='c_slu_solver_apply_vect' - - call psb_erractionsave(err_act) - - info = psb_success_ - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call x%v%sync() - call y%v%sync() - call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) - call y%v%set_host() - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine c_slu_solver_apply_vect - - subroutine c_slu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - - Implicit None - - ! Arguments - type(psb_cspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_c_slu_solver_type), intent(inout) :: sv - integer, intent(out) :: info - type(psb_cspmat_type), intent(in), target, optional :: b - class(psb_c_base_sparse_mat), intent(in), optional :: amold - class(psb_c_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - type(psb_cspmat_type) :: atmp - type(psb_c_csc_sparse_mat) :: acsc - type(psb_c_coo_sparse_mat) :: acoo - integer :: n_row,n_col, nrow_a, nztota - integer :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='c_slu_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - n_col = desc_a%get_local_cols() - - - call a%cscnv(atmp,info,type='coo') - call psb_rwextd(n_row,atmp,info,b=b) - call atmp%cscnv(info,type='coo',dupl=psb_dupl_add_) - nrow_a = atmp%get_nrows() - call atmp%a%csclip(acoo,info,jmax=nrow_a) - call acsc%mv_from_coo(acoo,info) - nztota = acsc%get_nzeros() - ! Fix the entries to call C-base SuperLU - acsc%ia(:) = acsc%ia(:) - 1 - acsc%icp(:) = acsc%icp(:) - 1 - info = mld_cslu_fact(nrow_a,nztota,acsc%val,& - & acsc%icp,acsc%ia,sv%lufactors) - - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='mld_cslu_fact' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - call acsc%free() - call atmp%free() - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine c_slu_solver_bld - - subroutine c_slu_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_c_slu_solver_type), intent(inout) :: sv - integer, intent(out) :: info - Integer :: err_act - character(len=20) :: name='c_slu_solver_free' - - call psb_erractionsave(err_act) - - info = psb_success_ - - call sv%clear_data(info) - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine c_slu_solver_free - - subroutine c_slu_solver_clear_data(sv,info) - - Implicit None - - ! Arguments - class(mld_c_slu_solver_type), intent(inout) :: sv - integer, intent(out) :: info - Integer :: err_act - character(len=20) :: name='c_slu_solver_clear_data' - - call psb_erractionsave(err_act) - - info = psb_success_ - if (c_associated(sv%lufactors)) info = mld_cslu_free(sv%lufactors) - sv%lufactors = c_null_ptr - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine c_slu_solver_clear_data - - subroutine c_slu_solver_finalize(sv) - - Implicit None - - ! Arguments - type(mld_c_slu_solver_type), intent(inout) :: sv - integer :: info - Integer :: err_act - character(len=20) :: name='c_slu_solver_finalize' - - call sv%free(info) - - return - - end subroutine c_slu_solver_finalize - - subroutine c_slu_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_c_slu_solver_type), intent(in) :: sv - integer, intent(out) :: info - integer, intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer :: err_act - integer :: ictxt, me, np - character(len=20), parameter :: name='mld_c_slu_solver_descr' - integer :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' SuperLU Sparse Factorization Solver. ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine c_slu_solver_descr - - function c_slu_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_c_slu_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer :: i - - val = 2*psb_sizeof_ip + psb_sizeof_dp - val = val + sv%symbsize - val = val + sv%numsize - return - end function c_slu_solver_sizeof - - function c_slu_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "SuperLU solver" - end function c_slu_solver_get_fmt - - function c_slu_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_slu_ - end function c_slu_solver_get_id -#endif -end module mld_c_slu_solver diff --git a/mlprec/mld_c_symdec_aggregator_mod.f90 b/mlprec/mld_c_symdec_aggregator_mod.f90 deleted file mode 100644 index 078c7ebc..00000000 --- a/mlprec/mld_c_symdec_aggregator_mod.f90 +++ /dev/null @@ -1,105 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! Locally symmetrized (decoupled) aggregation algorithm. -! This version differs from the basic decoupled aggregation algorithm -! only because it works on (the pattern of) A+A^T instead of A. -! -! -module mld_c_symdec_aggregator_mod - - use mld_c_dec_aggregator_mod - !> \namespace mld_c_symdec_aggregator_mod \class mld_c_symdec_aggregator_type - !! \extends mld_c_dec_aggregator_mod::mld_c_dec_aggregator_type - !! - !! This version differs from the basic decoupled aggregation algorithm - !! only because it works on (the pattern of) A+A^T instead of A. - !! - ! - type, extends(mld_c_dec_aggregator_type) :: mld_c_symdec_aggregator_type - - contains - procedure, pass(ag) :: bld_tprol => mld_c_symdec_aggregator_build_tprol - procedure, pass(ag) :: descr => mld_c_symdec_aggregator_descr - procedure, nopass :: fmt => mld_c_symdec_aggregator_fmt - end type mld_c_symdec_aggregator_type - - - interface - subroutine mld_c_symdec_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,t_prol,info) - import :: mld_c_symdec_aggregator_type, psb_desc_type, psb_cspmat_type, psb_spk_, & - & psb_ipk_, psb_lpk_, psb_lcspmat_type, mld_sml_parms, mld_saggr_data - implicit none - class(mld_c_symdec_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(mld_saggr_data), intent(in) :: ag_data - type(psb_cspmat_type), intent(inout) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lcspmat_type), intent(out) :: t_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_c_symdec_aggregator_build_tprol - end interface - - -contains - - function mld_c_symdec_aggregator_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Symmetric Decoupled aggregation" - end function mld_c_symdec_aggregator_fmt - - subroutine mld_c_symdec_aggregator_descr(ag,parms,iout,info) - implicit none - class(mld_c_symdec_aggregator_type), intent(in) :: ag - type(mld_sml_parms), intent(in) :: parms - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - - write(iout,*) 'Decoupled Aggregator locally-symmetrized' - write(iout,*) 'Aggregator object type: ',ag%fmt() - call parms%mldescr(iout,info) - - return - end subroutine mld_c_symdec_aggregator_descr - -end module mld_c_symdec_aggregator_mod diff --git a/mlprec/mld_d_as_smoother.f90 b/mlprec/mld_d_as_smoother.f90 deleted file mode 100644 index a560706a..00000000 --- a/mlprec/mld_d_as_smoother.f90 +++ /dev/null @@ -1,471 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_d_as_smoother_mod.f90 -! -! Module: mld_d_as_smoother_mod -! -! This module defines: -! the mld_d_as_smoother_type data structure containing the -! smoother for an Additive Schwarz smoother. -! -! To begin with, the build procedure constructs the extended -! matrix A and its corresponding descriptor (this has multiple -! halo layers duplicated across different processes); it then -! stores in ND the block off-diagonal matrix, and builds the solver -! on the (extended) block diagonal matrix. -! -! The code allows for the variations of Additive Schwartz, Restricted -! Additive Schwartz and Additive Schwartz with Harmonic Extensions. -! From an implementation point of view, these are handled by -! combining application/non-application of the prolongator/restrictor -! operators. -! -module mld_d_as_smoother - - use mld_d_base_smoother_mod - - type, extends(mld_d_base_smoother_type) :: mld_d_as_smoother_type - ! The local solver component is inherited from the - ! parent type. - ! class(mld_d_base_solver_type), allocatable :: sv - ! - type(psb_dspmat_type) :: nd - type(psb_desc_type) :: desc_data - integer(psb_ipk_) :: novr, restr, prol - integer(psb_lpk_) :: nd_nnz_tot - contains - procedure, pass(sm) :: apply_v => mld_d_as_smoother_apply_vect - procedure, pass(sm) :: apply_a => mld_d_as_smoother_apply - procedure, pass(sm) :: check => mld_d_as_smoother_check - procedure, pass(sm) :: dump => mld_d_as_smoother_dmp - procedure, pass(sm) :: build => mld_d_as_smoother_bld - procedure, pass(sm) :: cnv => mld_d_as_smoother_cnv - procedure, pass(sm) :: clone => mld_d_as_smoother_clone - procedure, pass(sm) :: clone_settings => mld_d_as_smoother_clone_settings - procedure, pass(sm) :: clear_data => mld_d_as_smoother_clear_data - procedure, pass(sm) :: restr_a => mld_d_as_smoother_restr_a - procedure, pass(sm) :: prol_a => mld_d_as_smoother_prol_a - procedure, pass(sm) :: restr_v => mld_d_as_smoother_restr_v - procedure, pass(sm) :: prol_v => mld_d_as_smoother_prol_v - generic, public :: apply_restr => restr_v, restr_a - generic, public :: apply_prol => prol_v, prol_a - procedure, pass(sm) :: free => mld_d_as_smoother_free - procedure, pass(sm) :: cseti => mld_d_as_smoother_cseti - procedure, pass(sm) :: csetc => mld_d_as_smoother_csetc - procedure, pass(sm) :: descr => d_as_smoother_descr - procedure, pass(sm) :: sizeof => d_as_smoother_sizeof - procedure, pass(sm) :: default => d_as_smoother_default - procedure, pass(sm) :: get_nzeros => d_as_smoother_get_nzeros - procedure, pass(sm) :: get_wrksz => d_as_smoother_get_wrksize - procedure, nopass :: get_fmt => d_as_smoother_get_fmt - procedure, nopass :: get_id => d_as_smoother_get_id - end type mld_d_as_smoother_type - - - private :: d_as_smoother_descr, d_as_smoother_sizeof, & - & d_as_smoother_default, d_as_smoother_get_nzeros, & - & d_as_smoother_get_fmt, d_as_smoother_get_id, & - & d_as_smoother_get_wrksize - - character(len=6), parameter, private :: & - & restrict_names(0:4)=(/'none ','halo ',' ',' ',' '/) - character(len=12), parameter, private :: & - & prolong_names(0:3)=(/'none ','sum ','average ','square root'/) - - - interface - subroutine mld_d_as_smoother_check(sm,info) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dpk_, mld_d_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_d_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_as_smoother_check - end interface - - interface - subroutine mld_d_as_smoother_restr_v(sm,x,trans,work,info,data) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dpk_, mld_d_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - class(mld_d_as_smoother_type), intent(inout) :: sm - type(psb_d_vect_type),intent(inout) :: x - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - end subroutine mld_d_as_smoother_restr_v - end interface - - interface - subroutine mld_d_as_smoother_restr_a(sm,x,trans,work,info,data) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dpk_, mld_d_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - class(mld_d_as_smoother_type), intent(inout) :: sm - real(psb_dpk_), intent(inout) :: x(:) - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - end subroutine mld_d_as_smoother_restr_a - end interface - - interface - subroutine mld_d_as_smoother_prol_v(sm,x,trans,work,info,data) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dpk_, mld_d_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - class(mld_d_as_smoother_type), intent(inout) :: sm - type(psb_d_vect_type),intent(inout) :: x - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - end subroutine mld_d_as_smoother_prol_v - end interface - - interface - subroutine mld_d_as_smoother_prol_a(sm,x,trans,work,info,data) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dpk_, mld_d_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - class(mld_d_as_smoother_type), intent(inout) :: sm - real(psb_dpk_), intent(inout) :: x(:) - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - end subroutine mld_d_as_smoother_prol_a - end interface - - - interface - subroutine mld_d_as_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,wv,info,init,initu) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dpk_, mld_d_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_as_smoother_type), intent(inout) :: sm - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - end subroutine mld_d_as_smoother_apply_vect - end interface - - interface - subroutine mld_d_as_smoother_apply(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,info,init,initu) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dpk_, mld_d_as_smoother_type, psb_epk_,& - & psb_desc_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_as_smoother_type), intent(inout) :: sm - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_d_as_smoother_apply - end interface - - interface - subroutine mld_d_as_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dpk_, mld_d_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_d_base_sparse_mat, psb_ipk_,& - & psb_i_base_vect_type - implicit none - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_as_smoother_bld - end interface - - interface - subroutine mld_d_as_smoother_cnv(sm,info,amold,vmold,imold) - import :: psb_d_base_vect_type, & - & psb_dpk_, mld_d_as_smoother_type, psb_epk_, & - & psb_d_base_sparse_mat, psb_ipk_, psb_i_base_vect_type - implicit none - class(mld_d_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_as_smoother_cnv - end interface - - interface - subroutine mld_d_as_smoother_cseti(sm,what,val,info,idx) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dpk_, mld_d_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_d_as_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_d_as_smoother_cseti - end interface - - interface - subroutine mld_d_as_smoother_csetc(sm,what,val,info,idx) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dpk_, mld_d_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_d_as_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_d_as_smoother_csetc - end interface - - interface - subroutine mld_d_as_smoother_free(sm,info) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dpk_, mld_d_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_d_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_as_smoother_free - end interface - - interface - subroutine mld_d_as_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dpk_, mld_d_as_smoother_type, psb_epk_, psb_desc_type, & - & psb_ipk_ - implicit none - class(mld_d_as_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - end subroutine mld_d_as_smoother_dmp - end interface - - interface - subroutine mld_d_as_smoother_clone(sm,smout,info) - import :: mld_d_as_smoother_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_ - class(mld_d_as_smoother_type), intent(inout) :: sm - class(mld_d_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_as_smoother_clone - end interface - - - interface - subroutine mld_d_as_smoother_clone_settings(sm,smout,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_smoother_type, mld_d_as_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_as_smoother_type), intent(inout) :: sm - class(mld_d_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_as_smoother_clone_settings - end interface - - interface - subroutine mld_d_as_smoother_clear_data(sm,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_as_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_as_smoother_clear_data - end interface - - -contains - - function d_as_smoother_sizeof(sm) result(val) - implicit none - ! Arguments - class(mld_d_as_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 3*psb_sizeof_ip + psb_sizeof_lp - if (allocated(sm%sv)) val = val + sm%sv%sizeof() - val = val + sm%nd%sizeof() - - return - end function d_as_smoother_sizeof - - function d_as_smoother_get_nzeros(sm) result(val) - implicit none - class(mld_d_as_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - if (allocated(sm%sv)) & - & val = sm%sv%get_nzeros() - val = val + sm%nd%get_nzeros() - - end function d_as_smoother_get_nzeros - - subroutine d_as_smoother_default(sm) - - use psb_base_mod, only : psb_halo_, psb_none_ - - Implicit None - - ! Arguments - class(mld_d_as_smoother_type), intent(inout) :: sm - - ! - ! Default: AS with 1 overlap layer - ! - sm%restr = psb_halo_ - sm%prol = psb_sum_ - sm%novr = 1 - - if (allocated(sm%sv)) then - call sm%sv%default() - end if - - return - end subroutine d_as_smoother_default - - - subroutine d_as_smoother_descr(sm,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_d_as_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_d_as_smoother_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (.not.coarse_) then - write(iout_,*) ' Additive Schwarz with ',& - & sm%novr, ' overlap layers.' - write(iout_,*) ' Restrictor: ',restrict_names(sm%restr) - write(iout_,*) ' Prolongator: ',prolong_names(sm%prol) - write(iout_,*) ' Local solver:' - endif - if (allocated(sm%sv)) then - call sm%sv%descr(info,iout_,coarse=coarse) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine d_as_smoother_descr - - function d_as_smoother_get_wrksize(sm) result(val) - implicit none - class(mld_d_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_) :: val - - val = 3 - if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() - - end function d_as_smoother_get_wrksize - - function d_as_smoother_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Additive Schwarz" - end function d_as_smoother_get_fmt - - function d_as_smoother_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_as_ - end function d_as_smoother_get_id - -end module mld_d_as_smoother diff --git a/mlprec/mld_d_base_aggregator_mod.f90 b/mlprec/mld_d_base_aggregator_mod.f90 deleted file mode 100644 index 5179d3c7..00000000 --- a/mlprec/mld_d_base_aggregator_mod.f90 +++ /dev/null @@ -1,519 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! The aggregator object hosts the aggregation method for building -! the multilevel hierarchy. -! -module mld_d_base_aggregator_mod - - use mld_base_prec_type, only : mld_dml_parms, mld_daggr_data - use psb_base_mod, only : psb_dspmat_type, psb_ldspmat_type, psb_d_vect_type, & - & psb_d_base_vect_type, psb_dlinmap_type, psb_dpk_, & - & psb_ld_csr_sparse_mat, psb_ld_coo_sparse_mat, & - & psb_d_csr_sparse_mat, psb_d_coo_sparse_mat, & - & psb_ipk_, psb_epk_, psb_lpk_, psb_desc_type, psb_i_base_vect_type, & - & psb_erractionsave, psb_error_handler, psb_success_, psb_toupper - ! - ! - ! - !> \class mld_d_base_aggregator_type - !! - !! It is the data type containing the basic interface definition for - !! building a multigrid hierarchy by aggregation. The base object has no attributes, - !! it is intended to be essentially an abstract type. - !! - !! - !! type mld_d_base_aggregator_type - !! end type - !! - !! - !! Methods: - !! - !! bld_tprol - Build a tentative prolongator - !! - !! mat_bld - Build prolongator/restrictor and coarse matrix ac - !! - !! mat_asb - Convert prolongator/restrictor/coarse matrix - !! and fix their descriptor(s) - !! - !! update_next - Transfer information to the next level; default is - !! to do nothing, i.e. aggregators at different - !! levels are independent. - !! - !! default - Apply defaults - !! set_aggr_type - For aggregator that have internal options. - !! fmt - Return a short string description - !! descr - Print a more detailed description - !! - !! cseti, csetr, csetc - Set internal parameters, if any - ! - type mld_d_base_aggregator_type - ! Do we want to purge explicit zeros when aggregating? - logical :: do_clean_zeros - contains - procedure, pass(ag) :: bld_tprol => mld_d_base_aggregator_build_tprol - procedure, pass(ag) :: mat_bld => mld_d_base_aggregator_mat_bld - procedure, pass(ag) :: mat_asb => mld_d_base_aggregator_mat_asb - procedure, pass(ag) :: bld_map => mld_d_base_aggregator_bld_map - procedure, pass(ag) :: update_next => mld_d_base_aggregator_update_next - procedure, pass(ag) :: clone => mld_d_base_aggregator_clone - procedure, pass(ag) :: free => mld_d_base_aggregator_free - procedure, pass(ag) :: default => mld_d_base_aggregator_default - procedure, pass(ag) :: descr => mld_d_base_aggregator_descr - procedure, pass(ag) :: sizeof => mld_d_base_aggregator_sizeof - procedure, pass(ag) :: set_aggr_type => mld_d_base_aggregator_set_aggr_type - procedure, nopass :: fmt => mld_d_base_aggregator_fmt - procedure, pass(ag) :: cseti => mld_d_base_aggregator_cseti - procedure, pass(ag) :: csetr => mld_d_base_aggregator_csetr - procedure, pass(ag) :: csetc => mld_d_base_aggregator_csetc - generic, public :: set => cseti, csetr, csetc - procedure, nopass :: xt_desc => mld_d_base_aggregator_xt_desc - end type mld_d_base_aggregator_type - - abstract interface - subroutine mld_d_soc_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, psb_ipk_, psb_lpk_ - implicit none - integer(psb_ipk_), intent(in) :: iorder - logical, intent(in) :: clean_zeros - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - real(psb_dpk_), intent(in) :: theta - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_soc_map_bld - end interface - - interface mld_ptap - subroutine mld_d_ptap(a_csr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_cprol,coo_restr,info,desc_ax) - import :: psb_d_csr_sparse_mat, psb_dspmat_type, psb_desc_type, & - & psb_d_coo_sparse_mat, mld_dml_parms, psb_dpk_, psb_ipk_, psb_lpk_ - implicit none - type(psb_d_csr_sparse_mat), intent(inout) :: a_csr - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - type(mld_dml_parms), intent(inout) :: parms - type(psb_d_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr - type(psb_desc_type), intent(inout) :: desc_cprol - type(psb_dspmat_type), intent(out) :: ac - integer(psb_ipk_), intent(out) :: info - type(psb_desc_type), intent(inout), optional :: desc_ax - end subroutine mld_d_ptap -!!$ subroutine mld_d_ld_ptap(a_csr,desc_a,nlaggr,parms,ac,& -!!$ & coo_prol,desc_cprol,coo_restr,info,desc_ax) -!!$ import :: psb_d_csr_sparse_mat, psb_ldspmat_type, psb_desc_type, & -!!$ & psb_ld_coo_sparse_mat, mld_dml_parms, psb_dpk_, psb_ipk_, psb_lpk_ -!!$ implicit none -!!$ type(psb_d_csr_sparse_mat), intent(inout) :: a_csr -!!$ type(psb_desc_type), intent(in) :: desc_a -!!$ integer(psb_lpk_), intent(inout) :: nlaggr(:) -!!$ type(mld_dml_parms), intent(inout) :: parms -!!$ type(psb_ld_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr -!!$ type(psb_desc_type), intent(inout) :: desc_cprol -!!$ type(psb_ldspmat_type), intent(out) :: ac -!!$ integer(psb_ipk_), intent(out) :: info -!!$ type(psb_desc_type), intent(inout), optional :: desc_ax -!!$ end subroutine mld_d_ld_ptap -!!$ subroutine mld_ld_ptap(a_csr,desc_a,nlaggr,parms,ac,& -!!$ & coo_prol,desc_cprol,coo_restr,info,desc_ax) -!!$ import :: psb_ld_csr_sparse_mat, psb_ldspmat_type, psb_desc_type, & -!!$ & psb_ld_coo_sparse_mat, mld_dml_parms, psb_dpk_, psb_ipk_, psb_lpk_ -!!$ implicit none -!!$ type(psb_ld_csr_sparse_mat), intent(inout) :: a_csr -!!$ type(psb_desc_type), intent(in) :: desc_a -!!$ integer(psb_lpk_), intent(inout) :: nlaggr(:) -!!$ type(mld_dml_parms), intent(inout) :: parms -!!$ type(psb_ld_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr -!!$ type(psb_desc_type), intent(inout) :: desc_cprol -!!$ type(psb_ldspmat_type), intent(out) :: ac -!!$ integer(psb_ipk_), intent(out) :: info -!!$ type(psb_desc_type), intent(inout), optional :: desc_ax -!!$ end subroutine mld_ld_ptap - end interface mld_ptap - -contains - - subroutine mld_d_base_aggregator_cseti(ag,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_d_base_aggregator_type), intent(inout) :: ag - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - ! Do nothing - info = 0 - end subroutine mld_d_base_aggregator_cseti - - subroutine mld_d_base_aggregator_csetr(ag,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_d_base_aggregator_type), intent(inout) :: ag - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - ! Do nothing - info = 0 - end subroutine mld_d_base_aggregator_csetr - - subroutine mld_d_base_aggregator_csetc(ag,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_d_base_aggregator_type), intent(inout) :: ag - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - ! Set clean zeros, or do nothing. - select case (psb_toupper(trim(what))) - case('AGGR_CLEAN_ZEROS') - select case (psb_toupper(trim(val))) - case('TRUE','T') - ag%do_clean_zeros = .true. - case('FALSE','F') - ag%do_clean_zeros = .false. - end select - end select - info = 0 - end subroutine mld_d_base_aggregator_csetc - - - subroutine mld_d_base_aggregator_update_next(ag,agnext,info) - implicit none - class(mld_d_base_aggregator_type), target, intent(inout) :: ag, agnext - integer(psb_ipk_), intent(out) :: info - - ! - ! Base version does nothing. - ! - info = 0 - end subroutine mld_d_base_aggregator_update_next - - subroutine mld_d_base_aggregator_clone(ag,agnext,info) - implicit none - class(mld_d_base_aggregator_type), intent(inout) :: ag - class(mld_d_base_aggregator_type), allocatable, intent(inout) :: agnext - integer(psb_ipk_), intent(out) :: info - - info = 0 - if (allocated(agnext)) then - call agnext%free(info) - if (info == 0) deallocate(agnext,stat=info) - end if - if (info /= 0) return - allocate(agnext,source=ag,stat=info) - - end subroutine mld_d_base_aggregator_clone - - subroutine mld_d_base_aggregator_free(ag,info) - implicit none - class(mld_d_base_aggregator_type), intent(inout) :: ag - integer(psb_ipk_), intent(out) :: info - - info = psb_success_ - return - end subroutine mld_d_base_aggregator_free - - subroutine mld_d_base_aggregator_default(ag) - implicit none - class(mld_d_base_aggregator_type), intent(inout) :: ag - ! Only one default setting - ag%do_clean_zeros = .true. - - return - end subroutine mld_d_base_aggregator_default - - function mld_d_base_aggregator_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Default aggregator " - end function mld_d_base_aggregator_fmt - - function mld_d_base_aggregator_sizeof(ag) result(val) - implicit none - class(mld_d_base_aggregator_type), intent(in) :: ag - integer(psb_epk_) :: val - - val = 1 - end function mld_d_base_aggregator_sizeof - - function mld_d_base_aggregator_xt_desc() result(val) - implicit none - logical :: val - - val = .false. - end function mld_d_base_aggregator_xt_desc - - subroutine mld_d_base_aggregator_descr(ag,parms,iout,info) - implicit none - class(mld_d_base_aggregator_type), intent(in) :: ag - type(mld_dml_parms), intent(in) :: parms - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - - write(iout,*) 'Aggregator object type: ',ag%fmt() - call parms%mldescr(iout,info) - - return - end subroutine mld_d_base_aggregator_descr - - subroutine mld_d_base_aggregator_set_aggr_type(ag,parms,info) - implicit none - class(mld_d_base_aggregator_type), intent(inout) :: ag - type(mld_dml_parms), intent(in) :: parms - integer(psb_ipk_), intent(out) :: info - - ! Do nothing - - return - end subroutine mld_d_base_aggregator_set_aggr_type - - ! - !> Function bld_tprol: - !! \memberof mld_d_base_aggregator_type - !! \brief Build a tentative prolongator. - !! The routine will map the local matrix entries to aggregates. - !! The mapping is store in ILAGGR; for each local row index I, - !! ILAGGR(I) contains the index of the aggregate to which index I - !! will contribute, in global numbering. - !! Many aggregations produce a binary tentative prolongator, but some - !! do not, hence we also need the OP_PROL output. - !! AG_DATA is passed here just in case some of the - !! aggregators need it internally, most of them will ignore. - !! - !! \param ag The input aggregator object - !! \param parms The auxiliary parameters object - !! \param ag_data Auxiliary global aggregation info - !! \param a The local matrix part - !! \param desc_a The descriptor - !! \param ilaggr Output aggregation map - !! \param nlaggr Sizes of ilaggr on all processes - !! \param op_prol The tentative prolongator operator - !! \param info Return code - !! - ! - subroutine mld_d_base_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,t_prol,info) - use psb_base_mod - implicit none - class(mld_d_base_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(mld_daggr_data), intent(in) :: ag_data - type(psb_dspmat_type), intent(inout) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_ldspmat_type), intent(out) :: t_prol - integer(psb_ipk_), intent(out) :: info - - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_aggregator_build_tprol' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - - end subroutine mld_d_base_aggregator_build_tprol - - ! - !> Function mat_bld - !! \memberof mld_d_base_aggregator_type - !! \brief Build prolongator/restrictor/coarse matrix. - !! - !! - !! \param ag The input aggregator object - !! \param parms The auxiliary parameters object - !! \param a The local matrix part - !! \param desc_a The descriptor - !! \param ilaggr Aggregation map - !! \param nlaggr Sizes of ilaggr on all processes - !! \param ac On output the coarse matrix - !! \param op_prol On input, the tentative prolongator operator, on output - !! the final prolongator - !! \param op_restr On output, the restrictor operator; - !! in many cases it is the transpose of the prolongator. - !! \param info Return code - !! - subroutine mld_d_base_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - use psb_base_mod - implicit none - class(mld_d_base_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(psb_ldspmat_type), intent(inout) :: t_prol - type(psb_dspmat_type), intent(out) :: op_prol, ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_aggregator_mat_bld' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - end subroutine mld_d_base_aggregator_mat_bld - - ! - !> Function mat_asb - !! \memberof mld_d_base_aggregator_type - !! \brief Build prolongator/restrictor/coarse matrix. - !! - !! - !! \param ag The input aggregator object - !! \param parms The auxiliary parameters object - !! \param a The local matrix part - !! \param desc_a The descriptor - !! \param ilaggr Aggregation map - !! \param nlaggr Sizes of ilaggr on all processes - !! \param ac On output the coarse matrix - !! \param op_prol On input, the tentative prolongator operator, on output - !! the final prolongator - !! \param op_restr On output, the restrictor operator; - !! in many cases it is the transpose of the prolongator. - !! \param info Return code - !! - subroutine mld_d_base_aggregator_mat_asb(ag,parms,a,desc_a,& - & ac,desc_ac, op_prol,op_restr,info) - use psb_base_mod - implicit none - class(mld_d_base_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - type(psb_dspmat_type), intent(inout) :: op_prol,ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_aggregator_mat_asb' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - end subroutine mld_d_base_aggregator_mat_asb - - ! - !> Function bld_map - !! \memberof mld_d_base_aggregator_type - !! \brief Build linear map between hierarchy levels - !! - !! - !! \param ag The input aggregator object - !! \param desc_a The fine space descriptor - !! \param desc_ac The coarse space descriptor - !! \param ilaggr Aggregation map vector - !! \param nlaggr Sizes of ilaggr on all processes - !! \param op_prol The prolongator operator - !! \param op_restr The restrictor operator - !! \param map The output map - !! \param info Return code - !! - subroutine mld_d_base_aggregator_bld_map(ag,desc_a,desc_ac,ilaggr,nlaggr,& - & op_restr,op_prol,map,info) - use psb_base_mod - implicit none - class(mld_d_base_aggregator_type), target, intent(inout) :: ag - type(psb_desc_type), intent(in), target :: desc_a, desc_ac - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(psb_dspmat_type), intent(inout) :: op_restr, op_prol - type(psb_dlinmap_type), intent(out) :: map - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_base_aggregator_bld_map' - - call psb_erractionsave(err_act) - ! - ! Copy the prolongation/restriction matrices into the descriptor map. - ! op_restr => PR^T i.e. restriction operator - ! op_prol => PR i.e. prolongation operator - ! - ! WARNING: need to check whether the copy into IOP_RESTR/IOP_PROL - ! is safe or not. - ! - ! This default implementation reuses desc_a/desc_ac through - ! pointers in the map structure. - ! - map = psb_linmap(psb_map_aggr_,desc_a,& - & desc_ac,op_restr,op_prol,ilaggr,nlaggr) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - end subroutine mld_d_base_aggregator_bld_map - - -end module mld_d_base_aggregator_mod diff --git a/mlprec/mld_d_base_smoother_mod.f90 b/mlprec/mld_d_base_smoother_mod.f90 deleted file mode 100644 index 1db243a2..00000000 --- a/mlprec/mld_d_base_smoother_mod.f90 +++ /dev/null @@ -1,412 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_d_base_smoother_mod.f90 -! -! Module: mld_d_base_smoother_mod -! -! This module defines: -! - the mld_d_base_smoother_type data structure containing the -! smoother and related data structures; -! -! It contains routines for -! - Building and applying; -! - checking if the smoother is correctly defined; -! - printing a description of the preconditioner; -! - deallocating the preconditioner data structure. -! -! What is the difference between a smoother and a solver? -! In the mathematics literature the two concepts are treated -! essentially as synonymous, but here we are using them in a more -! computer-science oriented fashion. In particular, a SMOOTHER object -! contains a SOLVER object: the SOLVER operates locally within the -! current process, whereas the SMOOTHER object accounts for (possible) -! interactions between processes. -! Some solvers (MUMPS and SuperLU_DIST) can also operate on the entire -! distributed matrix, in which case the smoother object essentially -! becomes transparent. -! -module mld_d_base_smoother_mod - - use mld_d_base_solver_mod - use psb_base_mod, only : psb_desc_type, psb_dspmat_type, psb_epk_,& - & psb_d_vect_type, psb_d_base_vect_type, psb_d_base_sparse_mat, & - & psb_dpk_, psb_i_base_vect_type, psb_erractionsave, psb_error_handler - - ! - ! - ! - ! Type: mld_T_base_smoother_type. - ! - ! It holds the smoother a single level. Its only mandatory component is a solver - ! object which holds a local solver; this decoupling allows to have the same solver - ! e.g ILU to work with Jacobi with multiple sweeps as well as with any AS variant. - ! - ! type mld_T_base_smoother_type - ! class(mld_T_base_solver_type), allocatable :: sv - ! end type mld_T_base_smoother_type - ! - ! Methods: - ! - ! build - Compute the actual contents of the smoother; includes - ! invocation of the build method on the solver component. - ! free - Release memory - ! apply - Apply the smoother to a vector (or to an array); includes - ! invocation of the apply method on the solver component. - ! descr - Prints a description of the object. - ! default - Set default values - ! dump - Dump to file object contents - ! set - Sets various parameters; when a request is unknown - ! it is passed to the solver object for further processing. - ! check - Sanity checks. - ! sizeof - Total memory occupation in bytes - ! get_nzeros - Number of nonzeros - ! stringval - convert string to val for internal parms - ! get_fmt - short string descriptor - ! get_id - numeric id descriptro - ! get_wrksz - How many workspace vector does apply_vect need - ! - ! - ! - - type mld_d_base_smoother_type - class(mld_d_base_solver_type), allocatable :: sv - contains - procedure, pass(sm) :: apply_v => mld_d_base_smoother_apply_vect - procedure, pass(sm) :: apply_a => mld_d_base_smoother_apply - generic, public :: apply => apply_a, apply_v - procedure, pass(sm) :: check => mld_d_base_smoother_check - procedure, pass(sm) :: dump => mld_d_base_smoother_dmp - procedure, pass(sm) :: clone => mld_d_base_smoother_clone - procedure, pass(sm) :: build => mld_d_base_smoother_bld - procedure, pass(sm) :: cnv => mld_d_base_smoother_cnv - procedure, pass(sm) :: free => mld_d_base_smoother_free - procedure, pass(sm) :: clone_settings => mld_d_base_smoother_clone_settings - procedure, pass(sm) :: clear_data => mld_d_base_smoother_clear_data - procedure, pass(sm) :: cseti => mld_d_base_smoother_cseti - procedure, pass(sm) :: csetc => mld_d_base_smoother_csetc - procedure, pass(sm) :: csetr => mld_d_base_smoother_csetr - generic, public :: set => cseti, csetc, csetr - procedure, pass(sm) :: default => d_base_smoother_default - procedure, pass(sm) :: descr => mld_d_base_smoother_descr - procedure, pass(sm) :: sizeof => d_base_smoother_sizeof - procedure, pass(sm) :: get_nzeros => d_base_smoother_get_nzeros - procedure, pass(sm) :: get_wrksz => d_base_smoother_get_wrksize - procedure, nopass :: stringval => mld_stringval - procedure, nopass :: get_fmt => d_base_smoother_get_fmt - procedure, nopass :: get_id => d_base_smoother_get_id - end type mld_d_base_smoother_type - - - private :: d_base_smoother_sizeof, d_base_smoother_get_fmt, & - & d_base_smoother_default, d_base_smoother_get_nzeros, & - & d_base_smoother_get_id, d_base_smoother_get_wrksize - - - - interface - subroutine mld_d_base_smoother_apply(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,info,init,initu) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_base_smoother_type), intent(inout) :: sm - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_d_base_smoother_apply - end interface - - interface - subroutine mld_d_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,wv,info,init,initu) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_base_smoother_type), intent(inout) :: sm - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - end subroutine mld_d_base_smoother_apply_vect - end interface - - interface - subroutine mld_d_base_smoother_check(sm,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_base_smoother_check - end interface - - interface - subroutine mld_d_base_smoother_cseti(sm,what,val,info,idx) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_d_base_smoother_cseti - end interface - - interface - subroutine mld_d_base_smoother_csetc(sm,what,val,info,idx) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_ - class(mld_d_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_d_base_smoother_csetc - end interface - - interface - subroutine mld_d_base_smoother_csetr(sm,what,val,info,idx) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_d_base_smoother_csetr - end interface - - interface - subroutine mld_d_base_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_, psb_i_base_vect_type - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_base_smoother_bld - end interface - - interface - subroutine mld_d_base_smoother_cnv(sm,info,amold,vmold,imold) - import :: psb_d_base_sparse_mat, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_, psb_i_base_vect_type - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_base_smoother_cnv - end interface - - interface - subroutine mld_d_base_smoother_free(sm,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_base_smoother_free - end interface - - interface - subroutine mld_d_base_smoother_descr(sm,info,iout,coarse) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_d_base_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - end subroutine mld_d_base_smoother_descr - end interface - - interface - subroutine mld_d_base_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_ - class(mld_d_base_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - end subroutine mld_d_base_smoother_dmp - end interface - - interface - subroutine mld_d_base_smoother_clone(sm,smout,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - class(mld_d_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_base_smoother_clone - end interface - - interface - subroutine mld_d_base_smoother_clone_settings(sm,smout,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - class(mld_d_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_base_smoother_clone_settings - end interface - - interface - subroutine mld_d_base_smoother_clear_data(sm,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_base_smoother_clear_data - end interface - -contains - ! - ! Function returning the size of the mld_prec_type data structure - ! in bytes or in number of nonzeros of the operator(s) involved. - ! - - function d_base_smoother_get_nzeros(sm) result(val) - implicit none - class(mld_d_base_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - if (allocated(sm%sv)) & - & val = sm%sv%get_nzeros() - end function d_base_smoother_get_nzeros - - function d_base_smoother_sizeof(sm) result(val) - implicit none - ! Arguments - class(mld_d_base_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - if (allocated(sm%sv)) then - val = sm%sv%sizeof() - end if - - return - end function d_base_smoother_sizeof - - ! - ! Set sensible defaults. - ! To be called immediately after allocation - ! - subroutine d_base_smoother_default(sm) - implicit none - ! Arguments - class(mld_d_base_smoother_type), intent(inout) :: sm - ! Do nothing for base version - - if (allocated(sm%sv)) call sm%sv%default() - - return - end subroutine d_base_smoother_default - - function d_base_smoother_get_wrksize(sm) result(val) - implicit none - class(mld_d_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_) :: val - - val = 0 - if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() - - end function d_base_smoother_get_wrksize - - function d_base_smoother_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Base smoother" - end function d_base_smoother_get_fmt - - function d_base_smoother_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_base_smooth_ - end function d_base_smoother_get_id - -end module mld_d_base_smoother_mod diff --git a/mlprec/mld_d_base_solver_mod.f90 b/mlprec/mld_d_base_solver_mod.f90 deleted file mode 100644 index 1db63184..00000000 --- a/mlprec/mld_d_base_solver_mod.f90 +++ /dev/null @@ -1,421 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_d_base_solver_mod.f90 -! -! Module: mld_d_base_solver_mod -! -! This module defines: -! - the mld_d_base_solver_type data structure containing the -! basic solver type acting on a subdomain -! -! It contains routines for -! - Building and applying; -! - checking if the solver is correctly defined; -! - printing a description of the solver; -! - deallocating the data structure. -! - -module mld_d_base_solver_mod - - use mld_base_prec_type - use psb_base_mod, only : psb_dspmat_type, & - & psb_d_vect_type, psb_d_base_vect_type, psb_d_base_sparse_mat, & - & psb_dpk_, psb_i_base_vect_type, psb_erractionsave, psb_error_handler - ! - ! - ! Type: mld_T_base_solver_type. - ! - ! It holds the local solver; it has no mandatory components. - ! - ! type mld_T_base_solver_type - ! end type mld_T_base_solver_type - ! - ! build - Compute the actual contents of the smoother; includes - ! invocation of the build method on the solver component. - ! free - Release memory - ! apply - Apply the smoother to a vector (or to an array); includes - ! invocation of the apply method on the solver component. - ! descr - Prints a description of the object. - ! default - Set default values - ! dump - Dump to file object contents - ! set - Sets various parameters; when a request is unknown - ! it is passed to the smoother object for further processing. - ! check - Sanity checks. - ! sizeof - Total memory occupation in bytes - ! get_nzeros - Number of nonzeros - ! stringval - convert string to val for internal parms - ! get_fmt - short string descriptor - ! get_id - numeric id descriptro - ! get_wrksz - How many workspace vector does apply_vect need - ! - ! - - type mld_d_base_solver_type - contains - procedure, pass(sv) :: apply_v => mld_d_base_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_d_base_solver_apply - generic, public :: apply => apply_a, apply_v - procedure, pass(sv) :: check => mld_d_base_solver_check - procedure, pass(sv) :: dump => mld_d_base_solver_dmp - procedure, pass(sv) :: clone => mld_d_base_solver_clone - procedure, pass(sv) :: clone_settings => mld_d_base_solver_clone_settings - procedure, pass(sv) :: clear_data => mld_d_base_solver_clear_data - procedure, pass(sv) :: build => mld_d_base_solver_bld - procedure, pass(sv) :: cnv => mld_d_base_solver_cnv - procedure, pass(sv) :: free => mld_d_base_solver_free - procedure, pass(sv) :: cseti => mld_d_base_solver_cseti - procedure, pass(sv) :: csetc => mld_d_base_solver_csetc - procedure, pass(sv) :: csetr => mld_d_base_solver_csetr - generic, public :: set => cseti, csetc, csetr - procedure, pass(sv) :: default => d_base_solver_default - procedure, pass(sv) :: descr => mld_d_base_solver_descr - procedure, pass(sv) :: sizeof => d_base_solver_sizeof - procedure, pass(sv) :: get_nzeros => d_base_solver_get_nzeros - procedure, nopass :: get_wrksz => d_base_solver_get_wrksize - procedure, nopass :: stringval => mld_stringval - procedure, nopass :: get_fmt => d_base_solver_get_fmt - procedure, nopass :: get_id => d_base_solver_get_id - procedure, nopass :: is_iterative => d_base_solver_is_iterative - procedure, pass(sv) :: is_global => d_base_solver_is_global - end type mld_d_base_solver_type - - private :: d_base_solver_sizeof, d_base_solver_default,& - & d_base_solver_get_nzeros, d_base_solver_get_fmt, & - & d_base_solver_is_iterative, d_base_solver_get_id, & - & d_base_solver_get_wrksize, d_base_solver_is_global - - - interface - subroutine mld_d_base_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_base_solver_type), intent(inout) :: sv - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_d_base_solver_apply - end interface - - - interface - subroutine mld_d_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_base_solver_type), intent(inout) :: sv - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - end subroutine mld_d_base_solver_apply_vect - end interface - - interface - subroutine mld_d_base_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, psb_ipk_, psb_i_base_vect_type - Implicit None - - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_base_solver_bld - end interface - - interface - subroutine mld_d_base_solver_cnv(sv,info,amold,vmold,imold) - import :: psb_d_base_sparse_mat, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, psb_ipk_, psb_i_base_vect_type - Implicit None - - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_base_solver_cnv - end interface - - interface - subroutine mld_d_base_solver_check(sv,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_base_solver_check - end interface - - interface - subroutine mld_d_base_solver_cseti(sv,what,val,info,idx) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_d_base_solver_cseti - end interface - - interface - subroutine mld_d_base_solver_csetc(sv,what,val,info,idx) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_d_base_solver_csetc - end interface - - interface - subroutine mld_d_base_solver_csetr(sv,what,val,info,idx) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, psb_ipk_ - Implicit None - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_d_base_solver_csetr - end interface - - interface - subroutine mld_d_base_solver_free(sv,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_base_solver_free - end interface - - interface - subroutine mld_d_base_solver_descr(sv,info,iout,coarse) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_base_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - end subroutine mld_d_base_solver_descr - end interface - - interface - subroutine mld_d_base_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, psb_ipk_ - implicit none - class(mld_d_base_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_d_base_solver_dmp - end interface - - interface - subroutine mld_d_base_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_base_solver_clone - end interface - - interface - subroutine mld_d_base_solver_clone_settings(sv,svout,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_base_solver_clone_settings - end interface - - interface - subroutine mld_d_base_solver_clear_data(sv,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_base_solver_clear_data - end interface - -contains - ! - ! Function returning the size of the data structure - ! in bytes or in number of nonzeros of the operator(s) involved. - ! - - function d_base_solver_sizeof(sv) result(val) - implicit none - ! Arguments - class(mld_d_base_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - - return - end function d_base_solver_sizeof - - function d_base_solver_get_nzeros(sv) result(val) - implicit none - class(mld_d_base_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - end function d_base_solver_get_nzeros - - subroutine d_base_solver_default(sv) - implicit none - ! Arguments - class(mld_d_base_solver_type), intent(inout) :: sv - ! Do nothing for base version - - return - end subroutine d_base_solver_default - - function d_base_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Base solver" - end function d_base_solver_get_fmt - - ! - ! If this is true, then the solver needs a starting - ! guess. Currently only handled in JAC smoother. - ! - function d_base_solver_is_iterative() result(val) - implicit none - logical :: val - - val = .false. - end function d_base_solver_is_iterative - ! - ! Is the solver acting globally? In most cases - ! not, SuperLU_Dist does, MUMPS can do either. - ! - function d_base_solver_is_global(sv) result(val) - implicit none - class(mld_d_base_solver_type), intent(in) :: sv - logical :: val - - val = .false. - end function d_base_solver_is_global - - function d_base_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_f_none_ - end function d_base_solver_get_id - - function d_base_solver_get_wrksize() result(val) - implicit none - integer(psb_ipk_) :: val - - val = 0 - end function d_base_solver_get_wrksize - -end module mld_d_base_solver_mod diff --git a/mlprec/mld_d_dec_aggregator_mod.f90 b/mlprec/mld_d_dec_aggregator_mod.f90 deleted file mode 100644 index feaef7bd..00000000 --- a/mlprec/mld_d_dec_aggregator_mod.f90 +++ /dev/null @@ -1,201 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! Basic (decoupled) aggregation algorithm. Based on the ideas in -! M. Brezina and P. Vanek, A black-box iterative solver based on a -! two-level Schwarz method, Computing, 63 (1999), 233-263. -! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed -! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 -! (1996), 179-196. -! -module mld_d_dec_aggregator_mod - - use mld_d_base_aggregator_mod - !> \namespace mld_d_dec_aggregator_mod \class mld_d_dec_aggregator_type - !! \extends mld_d_base_aggregator_mod::mld_d_base_aggregator_type - !! - !! type, extends(mld_d_base_aggregator_type) :: mld_d_dec_aggregator_type - !! procedure(mld_d_soc_map_bld), nopass, pointer :: soc_map_bld => null() - !! end type - !! - !! This is the simplest aggregation method: starting from the - !! strength-of-connection measure for defining the aggregation - !! presented in - !! - !! M. Brezina and P. Vanek, A black-box iterative solver based on a - !! two-level Schwarz method, Computing, 63 (1999), 233-263. - !! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed - !! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 - !! (1996), 179-196. - !! - !! it achieves parallelization by simply acting on the local matrix, - !! i.e. by "decoupling" the subdomains. - !! The data structure hosts a "map_bld" function pointer which allows to - !! choose other ways to measure "strength-of-connection", of which the - !! Vanek-Brezina-Mandel is the default. More details are available in - !! - !! P. D'Ambra, D. di Serafino and S. Filippone, On the development of - !! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math. - !! 57 (2007), 1181-1196. - !! - !! The soc_map_bld method is used inside the implementation of build_tprol - !! - ! - ! - type, extends(mld_d_base_aggregator_type) :: mld_d_dec_aggregator_type - procedure(mld_d_soc_map_bld), nopass, pointer :: soc_map_bld => null() - - contains - procedure, pass(ag) :: bld_tprol => mld_d_dec_aggregator_build_tprol - procedure, pass(ag) :: mat_bld => mld_d_dec_aggregator_mat_bld - procedure, pass(ag) :: mat_asb => mld_d_dec_aggregator_mat_asb - procedure, pass(ag) :: default => mld_d_dec_aggregator_default - procedure, pass(ag) :: set_aggr_type => mld_d_dec_aggregator_set_aggr_type - procedure, pass(ag) :: descr => mld_d_dec_aggregator_descr - procedure, nopass :: fmt => mld_d_dec_aggregator_fmt - end type mld_d_dec_aggregator_type - - - procedure(mld_d_soc_map_bld) :: mld_d_soc1_map_bld, mld_d_soc2_map_bld - - interface - subroutine mld_d_dec_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,t_prol,info) - import :: mld_d_dec_aggregator_type, psb_desc_type, psb_dspmat_type, psb_dpk_, & - & psb_ipk_, psb_lpk_, psb_ldspmat_type, mld_dml_parms, mld_daggr_data - implicit none - class(mld_d_dec_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(mld_daggr_data), intent(in) :: ag_data - type(psb_dspmat_type), intent(inout) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_ldspmat_type), intent(out) :: t_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_dec_aggregator_build_tprol - end interface - - interface - subroutine mld_d_dec_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - import :: mld_d_dec_aggregator_type, psb_desc_type, psb_dspmat_type, psb_dpk_, & - & psb_ipk_, psb_lpk_, psb_ldspmat_type, mld_dml_parms - implicit none - class(mld_d_dec_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(psb_ldspmat_type), intent(inout) :: t_prol - type(psb_dspmat_type), intent(out) :: op_prol, ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_dec_aggregator_mat_bld - end interface - - interface - subroutine mld_d_dec_aggregator_mat_asb(ag,parms,a,desc_a,& - & ac,desc_ac,op_prol,op_restr,info) - import :: mld_d_dec_aggregator_type, psb_desc_type, psb_dspmat_type, psb_dpk_, & - & psb_ipk_, psb_lpk_, psb_ldspmat_type, mld_dml_parms - implicit none - class(mld_d_dec_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - type(psb_dspmat_type), intent(inout) :: op_prol,ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_dec_aggregator_mat_asb - end interface - -contains - - subroutine mld_d_dec_aggregator_set_aggr_type(ag,parms,info) - use mld_base_prec_type - implicit none - class(mld_d_dec_aggregator_type), intent(inout) :: ag - type(mld_dml_parms), intent(in) :: parms - integer(psb_ipk_), intent(out) :: info - - select case(parms%aggr_type) - case (mld_noalg_) - ag%soc_map_bld => null() - case (mld_soc1_) - ag%soc_map_bld => mld_d_soc1_map_bld - case (mld_soc2_) - ag%soc_map_bld => mld_d_soc2_map_bld - case default - write(0,*) 'Unknown aggregation type, defaulting to SOC1' - ag%soc_map_bld => mld_d_soc1_map_bld - end select - - return - end subroutine mld_d_dec_aggregator_set_aggr_type - - - subroutine mld_d_dec_aggregator_default(ag) - implicit none - class(mld_d_dec_aggregator_type), intent(inout) :: ag - - call ag%mld_d_base_aggregator_type%default() - ag%soc_map_bld => mld_d_soc1_map_bld - - return - end subroutine mld_d_dec_aggregator_default - - function mld_d_dec_aggregator_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Decoupled aggregation" - end function mld_d_dec_aggregator_fmt - - subroutine mld_d_dec_aggregator_descr(ag,parms,iout,info) - implicit none - class(mld_d_dec_aggregator_type), intent(in) :: ag - type(mld_dml_parms), intent(in) :: parms - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - - write(iout,*) 'Decoupled Aggregator' - write(iout,*) 'Aggregator object type: ',ag%fmt() - call parms%mldescr(iout,info) - - return - end subroutine mld_d_dec_aggregator_descr - -end module mld_d_dec_aggregator_mod diff --git a/mlprec/mld_d_diag_solver.f90 b/mlprec/mld_d_diag_solver.f90 deleted file mode 100644 index f73ef0ce..00000000 --- a/mlprec/mld_d_diag_solver.f90 +++ /dev/null @@ -1,398 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_d_diag_solver_mod.f90 -! -! Module: mld_d_diag_solver_mod -! -! This module defines: -! - the mld_d_diag_solver_type data structure containing the -! simple diagonal solver. This extracts the main diagonal of a matrix -! and precomputes its inverse. Combined with a Jacobi "smoother" generates -! what are commonly known as the classic Jacobi iterations -! -module mld_d_diag_solver - - use mld_d_base_solver_mod - - type, extends(mld_d_base_solver_type) :: mld_d_diag_solver_type - type(psb_d_vect_type), allocatable :: dv - real(psb_dpk_), allocatable :: d(:) - contains - procedure, pass(sv) :: dump => mld_d_diag_solver_dmp - procedure, pass(sv) :: build => mld_d_diag_solver_bld - procedure, pass(sv) :: cnv => mld_d_diag_solver_cnv - procedure, pass(sv) :: clone => mld_d_diag_solver_clone - procedure, pass(sv) :: clear_data => mld_d_diag_solver_clear_data - procedure, pass(sv) :: apply_v => mld_d_diag_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_d_diag_solver_apply - procedure, pass(sv) :: free => d_diag_solver_free - procedure, pass(sv) :: descr => d_diag_solver_descr - procedure, pass(sv) :: sizeof => d_diag_solver_sizeof - procedure, pass(sv) :: get_nzeros => d_diag_solver_get_nzeros - procedure, nopass :: get_fmt => d_diag_solver_get_fmt - procedure, nopass :: get_id => d_diag_solver_get_id - end type mld_d_diag_solver_type - - - private :: d_diag_solver_free, d_diag_solver_descr, & - & d_diag_solver_sizeof, d_diag_solver_get_nzeros, & - & d_diag_solver_get_fmt, d_diag_solver_get_id - - - interface - subroutine mld_d_diag_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_diag_solver_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_diag_solver_type), intent(inout) :: sv - type(psb_d_vect_type), intent(inout) :: x - type(psb_d_vect_type), intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - end subroutine mld_d_diag_solver_apply_vect - end interface - - interface - subroutine mld_d_diag_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_diag_solver_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_diag_solver_type), intent(inout) :: sv - real(psb_dpk_), intent(inout) :: x(:) - real(psb_dpk_), intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_d_diag_solver_apply - end interface - - interface - subroutine mld_d_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_diag_solver_type, psb_ipk_, psb_i_base_vect_type - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_diag_solver_bld - end interface - - interface - subroutine mld_d_diag_solver_cnv(sv,info,amold,vmold,imold) - import :: psb_d_base_sparse_mat, psb_d_base_vect_type, psb_dpk_, & - & mld_d_diag_solver_type, psb_ipk_, psb_i_base_vect_type - class(mld_d_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_diag_solver_cnv - end interface - - interface - subroutine mld_d_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, mld_d_diag_solver_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, & - & psb_ipk_ - implicit none - class(mld_d_diag_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_d_diag_solver_dmp - end interface - - interface - subroutine mld_d_diag_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, mld_d_diag_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_diag_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_diag_solver_clone - end interface - - interface - subroutine mld_d_diag_solver_clear_data(sv,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_diag_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_diag_solver_clear_data - end interface - - -contains - - subroutine d_diag_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_d_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_diag_solver_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sv%dv)) call sv%dv%free(info) - - if (allocated(sv%d)) then - deallocate(sv%d,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine d_diag_solver_free - - subroutine d_diag_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_d_diag_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_d_diag_solver_descr' - integer(psb_ipk_) :: iout_ - - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' Diagonal local solver ' - - return - - end subroutine d_diag_solver_descr - - function d_diag_solver_sizeof(sv) result(val) - implicit none - ! Arguments - class(mld_d_diag_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - if (allocated(sv%dv)) val = val + sv%dv%sizeof() - - return - end function d_diag_solver_sizeof - - function d_diag_solver_get_nzeros(sv) result(val) - implicit none - ! Arguments - class(mld_d_diag_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - if (allocated(sv%dv)) val = val + sv%dv%get_nrows() - - return - end function d_diag_solver_get_nzeros - - function d_diag_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Diag solver" - end function d_diag_solver_get_fmt - - function d_diag_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_diag_scale_ - end function d_diag_solver_get_id - -end module mld_d_diag_solver - -! -! Module: mld_d_l1_diag_solver_mod -! -! This module defines: -! - the mld_d_l1_diag_solver_type data structure containing the -! L1 diagonal solver. -! The solver is defined as a diagonal containing in each element the -! inverse of the sum of the absolute values of the matrix entries -! along the corresponding row. -! Combined with a Jacobi "smoother" generates -! what are commonly known as the L1-Jacobi iterations -! - -module mld_d_l1_diag_solver - - use mld_d_diag_solver - - type, extends(mld_d_diag_solver_type) :: mld_d_l1_diag_solver_type - contains - procedure, pass(sv) :: dump => mld_d_l1_diag_solver_dmp - procedure, pass(sv) :: build => mld_d_l1_diag_solver_bld - procedure, pass(sv) :: descr => d_l1_diag_solver_descr - procedure, nopass :: get_fmt => d_l1_diag_solver_get_fmt - procedure, nopass :: get_id => d_l1_diag_solver_get_id - end type mld_d_l1_diag_solver_type - - - private :: d_l1_diag_solver_descr, & - & d_l1_diag_solver_get_fmt, d_l1_diag_solver_get_id - - interface - subroutine mld_d_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_l1_diag_solver_type, psb_ipk_, psb_i_base_vect_type - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_l1_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_l1_diag_solver_bld - end interface - - interface - subroutine mld_d_l1_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, mld_d_l1_diag_solver_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, & - & psb_ipk_ - implicit none - class(mld_d_l1_diag_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_d_l1_diag_solver_dmp - end interface - -contains - - subroutine d_l1_diag_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_d_l1_diag_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_d_l1_diag_solver_descr' - integer(psb_ipk_) :: iout_ - - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' L1 Diagonal solver ' - - return - - end subroutine d_l1_diag_solver_descr - - function d_l1_diag_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "L1 Diag solver" - end function d_l1_diag_solver_get_fmt - - function d_l1_diag_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_l1_diag_scale_ - end function d_l1_diag_solver_get_id - -end module mld_d_l1_diag_solver - diff --git a/mlprec/mld_d_gs_solver.f90 b/mlprec/mld_d_gs_solver.f90 deleted file mode 100644 index ed89ce0f..00000000 --- a/mlprec/mld_d_gs_solver.f90 +++ /dev/null @@ -1,588 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! File: mld_d_gs_solver_mod.f90 -! -! Module: mld_d_gs_solver_mod -! -! This module defines: -! - the mld_d_gs_solver_type data structure containing the ingredients -! for a local Gauss-Seidel iteration. We provide Forward GS (FWGS) and -! backward GS (BWGS). The iterations are local to a process (they operate -! on the block diagonal). Combined with a Jacobi smoother will generate a -! hybrid-Gauss-Seidel solver, i.e. Gauss-Seidel within each process, Jacobi -! among the processes. -! With two objects as pre- and post-smoothers it is possible to build a -! Forward-Backward smoother, suitable for symmetric iterations. -! -module mld_d_gs_solver - - use mld_d_base_solver_mod - - type, extends(mld_d_base_solver_type) :: mld_d_gs_solver_type - type(psb_dspmat_type) :: l, u - integer(psb_ipk_) :: sweeps - real(psb_dpk_) :: eps - contains - procedure, pass(sv) :: dump => mld_d_gs_solver_dmp - procedure, pass(sv) :: check => d_gs_solver_check - procedure, pass(sv) :: clone => mld_d_gs_solver_clone - procedure, pass(sv) :: clone_settings => mld_d_gs_solver_clone_settings - procedure, pass(sv) :: clear_data => mld_d_gs_solver_clear_data - procedure, pass(sv) :: build => mld_d_gs_solver_bld - procedure, pass(sv) :: cnv => mld_d_gs_solver_cnv - procedure, pass(sv) :: apply_v => mld_d_gs_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_d_gs_solver_apply - procedure, pass(sv) :: free => d_gs_solver_free - procedure, pass(sv) :: cseti => d_gs_solver_cseti - procedure, pass(sv) :: csetc => d_gs_solver_csetc - procedure, pass(sv) :: csetr => d_gs_solver_csetr - procedure, pass(sv) :: descr => d_gs_solver_descr - procedure, pass(sv) :: default => d_gs_solver_default - procedure, pass(sv) :: sizeof => d_gs_solver_sizeof - procedure, pass(sv) :: get_nzeros => d_gs_solver_get_nzeros - procedure, nopass :: get_wrksz => d_gs_solver_get_wrksize - procedure, nopass :: get_fmt => d_gs_solver_get_fmt - procedure, nopass :: get_id => d_gs_solver_get_id - procedure, nopass :: is_iterative => d_gs_solver_is_iterative - end type mld_d_gs_solver_type - - type, extends(mld_d_gs_solver_type) :: mld_d_bwgs_solver_type - contains - procedure, pass(sv) :: build => mld_d_bwgs_solver_bld - procedure, pass(sv) :: apply_v => mld_d_bwgs_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_d_bwgs_solver_apply - procedure, nopass :: get_fmt => d_bwgs_solver_get_fmt - procedure, nopass :: get_id => d_bwgs_solver_get_id - procedure, pass(sv) :: descr => d_bwgs_solver_descr - end type mld_d_bwgs_solver_type - - - private :: d_gs_solver_bld, d_gs_solver_apply, & - & d_gs_solver_free, & - & d_gs_solver_descr, d_gs_solver_sizeof, & - & d_gs_solver_default, d_gs_solver_dmp, & - & d_gs_solver_apply_vect, d_gs_solver_get_nzeros, & - & d_gs_solver_get_fmt, d_gs_solver_check,& - & d_gs_solver_is_iterative, & - & d_bwgs_solver_get_fmt, d_bwgs_solver_descr, & - & d_gs_solver_get_id, d_bwgs_solver_get_id, d_gs_solver_get_wrksize - - interface - subroutine mld_d_gs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, mld_d_gs_solver_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_gs_solver_type), intent(inout) :: sv - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - end subroutine mld_d_gs_solver_apply_vect - subroutine mld_d_bwgs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, mld_d_bwgs_solver_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_bwgs_solver_type), intent(inout) :: sv - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - end subroutine mld_d_bwgs_solver_apply_vect - end interface - - interface - subroutine mld_d_gs_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info,init,initu) - import :: psb_desc_type, mld_d_gs_solver_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_gs_solver_type), intent(inout) :: sv - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_d_gs_solver_apply - subroutine mld_d_bwgs_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, mld_d_bwgs_solver_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_bwgs_solver_type), intent(inout) :: sv - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_d_bwgs_solver_apply - end interface - - interface - subroutine mld_d_gs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, mld_d_gs_solver_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_gs_solver_bld - subroutine mld_d_bwgs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, mld_d_bwgs_solver_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_bwgs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_bwgs_solver_bld - end interface - - interface - subroutine mld_d_gs_solver_cnv(sv,info,amold,vmold,imold) - import :: mld_d_gs_solver_type, psb_dpk_, & - & psb_d_base_sparse_mat, psb_d_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - class(mld_d_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_gs_solver_cnv - end interface - - interface - subroutine mld_d_gs_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, mld_d_gs_solver_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, & - & psb_ipk_ - implicit none - class(mld_d_gs_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_d_gs_solver_dmp - end interface - - interface - subroutine mld_d_gs_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, mld_d_gs_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_gs_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_gs_solver_clone - end interface - - interface - subroutine mld_d_gs_solver_clone_settings(sv,svout,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, mld_d_gs_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_gs_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_gs_solver_clone_settings - end interface - - interface - subroutine mld_d_gs_solver_clear_data(sv,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_gs_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_gs_solver_clear_data - end interface - -contains - - subroutine d_gs_solver_default(sv) - - Implicit None - - ! Arguments - class(mld_d_gs_solver_type), intent(inout) :: sv - - sv%sweeps = ione - sv%eps = dzero - - return - end subroutine d_gs_solver_default - - subroutine d_gs_solver_check(sv,info) - - Implicit None - - ! Arguments - class(mld_d_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_gs_solver_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - call mld_check_def(sv%sweeps,& - & 'GS Sweeps',ione,is_int_positive) - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine d_gs_solver_check - - subroutine d_gs_solver_cseti(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_d_gs_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_gs_solver_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) - case('SOLVER_SWEEPS') - sv%sweeps = val - case default - call sv%mld_d_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_gs_solver_cseti - - subroutine d_gs_solver_csetc(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_d_gs_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='d_gs_solver_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - - - call sv%mld_d_base_solver_type%set(what,val,info,idx=idx) - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info, name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_gs_solver_csetc - - subroutine d_gs_solver_csetr(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_d_gs_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_gs_solver_csetr' - - call psb_erractionsave(err_act) - info = psb_success_ - - select case(psb_toupper(what)) - case('SOLVER_EPS') - sv%eps = val - case default - call sv%mld_d_base_solver_type%set(what,val,info,idx=idx) - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_gs_solver_csetr - - subroutine d_gs_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_d_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_gs_solver_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - call sv%l%free() - call sv%u%free() - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_gs_solver_free - - subroutine d_gs_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_d_gs_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_d_gs_solver_descr' - integer(psb_ipk_) :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (sv%eps<=dzero) then - write(iout_,*) ' Forward Gauss-Seidel iterative solver with ',& - & sv%sweeps,' sweeps' - else - write(iout_,*) ' Forward Gauss-Seidel iterative solver with tolerance',& - & sv%eps,' and maxit', sv%sweeps - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_gs_solver_descr - - function d_gs_solver_get_nzeros(sv) result(val) - - implicit none - ! Arguments - class(mld_d_gs_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - val = val + sv%l%get_nzeros() - val = val + sv%u%get_nzeros() - - return - end function d_gs_solver_get_nzeros - - function d_gs_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_d_gs_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = psb_sizeof_ip - val = val + sv%l%sizeof() - val = val + sv%u%sizeof() - - return - end function d_gs_solver_sizeof - - function d_gs_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Forward Gauss-Seidel solver" - end function d_gs_solver_get_fmt - - function d_gs_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_gs_ - end function d_gs_solver_get_id - - ! - ! If this is true, then the solver needs a starting - ! guess. Currently only handled in JAC smoother. - ! - function d_gs_solver_is_iterative() result(val) - implicit none - logical :: val - - val = .true. - end function d_gs_solver_is_iterative - - subroutine d_bwgs_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_d_bwgs_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_d_bwgs_solver_descr' - integer(psb_ipk_) :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (sv%eps<=dzero) then - write(iout_,*) ' Backward Gauss-Seidel iterative solver with ',& - & sv%sweeps,' sweeps' - else - write(iout_,*) ' Backward Gauss-Seidel iterative solver with tolerance',& - & sv%eps,' and maxit', sv%sweeps - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_bwgs_solver_descr - - function d_bwgs_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Backward Gauss-Seidel solver" - end function d_bwgs_solver_get_fmt - - function d_bwgs_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_bwgs_ - end function d_bwgs_solver_get_id - - function d_gs_solver_get_wrksize() result(val) - implicit none - integer(psb_ipk_) :: val - - val = 2 - end function d_gs_solver_get_wrksize - -end module mld_d_gs_solver diff --git a/mlprec/mld_d_hybrid_aggregator_mod.F90 b/mlprec/mld_d_hybrid_aggregator_mod.F90 deleted file mode 100644 index 7acb7942..00000000 --- a/mlprec/mld_d_hybrid_aggregator_mod.F90 +++ /dev/null @@ -1,125 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! The aggregator object hosts the aggregation method for building -! the multilevel hierarchy. This variant is based on the hybrid method -! presented in -! -! S. Gratton, P. Henon, P. Jiranek and X. Vasseur: -! Reducing complexity of algebraic multigrid by aggregation -! Numerical Lin. Algebra with Applications, 2016, 23:501-518 -! -module mld_d_hybrid_aggregator_mod - - use mld_d_dec_aggregator_mod - ! - ! sm - class(mld_T_base_smoother_type), allocatable - ! The current level preconditioner (aka smoother). - ! parms - type(mld_RTml_parms) - ! The parameters defining the multilevel strategy. - ! ac - The local part of the current-level matrix, built by - ! coarsening the previous-level matrix. - ! desc_ac - type(psb_desc_type). - ! The communication descriptor associated to the matrix - ! stored in ac. - ! base_a - type(psb_Tspmat_type), pointer. - ! Pointer (really a pointer!) to the local part of the current - ! matrix (so we have a unified treatment of residuals). - ! We need this to avoid passing explicitly the current matrix - ! to the routine which applies the preconditioner. - ! base_desc - type(psb_desc_type), pointer. - ! Pointer to the communication descriptor associated to the - ! matrix pointed by base_a. - ! map - Stores the maps (restriction and prolongation) between the - ! vector spaces associated to the index spaces of the previous - ! and current levels. - ! - ! Methods: - ! Most methods follow the encapsulation hierarchy: they take whatever action - ! is appropriate for the current object, then call the corresponding method for - ! the contained object. - ! As an example: the descr() method prints out a description of the - ! level. It starts by invoking the descr() method of the parms object, - ! then calls the descr() method of the smoother object. - ! - ! descr - Prints a description of the object. - ! default - Set default values - ! dump - Dump to file object contents - ! set - Sets various parameters; when a request is unknown - ! it is passed to the smoother object for further processing. - ! check - Sanity checks. - ! sizeof - Total memory occupation in bytes - ! get_nzeros - Number of nonzeros - ! - ! - type, extends(mld_d_dec_aggregator_type) :: mld_d_hybrid_aggregator_type - - contains - procedure, pass(ag) :: bld_tprol => mld_d_hybrid_aggregator_build_tprol - procedure, nopass :: fmt => mld_d_hybrid_aggregator_fmt - end type mld_d_hybrid_aggregator_type - - - interface - subroutine mld_d_hybrid_aggregator_build_tprol(ag,parms,a,desc_a,ilaggr,nlaggr,op_prol,info) - import :: mld_d_hybrid_aggregator_type, psb_desc_type, psb_dspmat_type, psb_dpk_, & - & psb_ipk_, psb_long_int_k_, mld_dml_parms - implicit none - class(mld_d_hybrid_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - integer(psb_ipk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_dspmat_type), intent(out) :: op_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_hybrid_aggregator_build_tprol - end interface - -contains - - - function mld_d_hybrid_aggregator_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Hybrid Decoupled aggregation" - end function mld_d_hybrid_aggregator_fmt - - -end module mld_d_hybrid_aggregator_mod diff --git a/mlprec/mld_d_id_solver.f90 b/mlprec/mld_d_id_solver.f90 deleted file mode 100644 index 10505233..00000000 --- a/mlprec/mld_d_id_solver.f90 +++ /dev/null @@ -1,202 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! -! Identity solver. Reference for nullprec. -! -! -module mld_d_id_solver - - use mld_d_base_solver_mod - - type, extends(mld_d_base_solver_type) :: mld_d_id_solver_type - contains - procedure, pass(sv) :: build => d_id_solver_bld - procedure, pass(sv) :: clone => mld_d_id_solver_clone - procedure, pass(sv) :: apply_v => mld_d_id_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_d_id_solver_apply - procedure, pass(sv) :: free => d_id_solver_free - procedure, pass(sv) :: descr => d_id_solver_descr - procedure, nopass :: get_fmt => d_id_solver_get_fmt - procedure, nopass :: get_id => d_id_solver_get_id - end type mld_d_id_solver_type - - - private :: d_id_solver_bld, & - & d_id_solver_free, d_id_solver_get_fmt, & - & d_id_solver_descr, d_id_solver_get_id - - interface - subroutine mld_d_id_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_id_solver_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_id_solver_type), intent(inout) :: sv - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - end subroutine mld_d_id_solver_apply_vect - end interface - - interface - subroutine mld_d_id_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_id_solver_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_id_solver_type), intent(inout) :: sv - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_d_id_solver_apply - end interface - - interface - subroutine mld_d_id_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, mld_d_id_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_id_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_id_solver_clone - end interface - -contains - - - subroutine d_id_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - Implicit None - - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_id_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - real(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: i, err_act, debug_unit, debug_level - character(len=20) :: name='d_id_solver_bld', ch_err - - info=psb_success_ - - return - end subroutine d_id_solver_bld - - subroutine d_id_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_d_id_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_id_solver_free' - - info = psb_success_ - - return - end subroutine d_id_solver_free - - subroutine d_id_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_d_id_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_d_id_solver_descr' - integer(psb_ipk_) :: iout_ - - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' Identity local solver ' - - return - - end subroutine d_id_solver_descr - - function d_id_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Identity solver" - end function d_id_solver_get_fmt - - function d_id_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_f_none_ - end function d_id_solver_get_id - -end module mld_d_id_solver diff --git a/mlprec/mld_d_ilu_fact_mod.f90 b/mlprec/mld_d_ilu_fact_mod.f90 deleted file mode 100644 index 20bbe28f..00000000 --- a/mlprec/mld_d_ilu_fact_mod.f90 +++ /dev/null @@ -1,91 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! File: mld_d_ilu_fact_mod.f90 -! -! Module: mld_d_ilu_fact_mod -! -! This module defines some interfaces used internally by the implementation of -! mld_d_ilu_solver, but not visible to the end user. -! -! -module mld_d_ilu_fact_mod - - use mld_d_base_solver_mod - - interface mld_ilu0_fact - subroutine mld_dilu0_fact(ialg,a,l,u,d,info,blck,upd) - import psb_dspmat_type, psb_dpk_, psb_ipk_ - integer(psb_ipk_), intent(in) :: ialg - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type),intent(in) :: a - type(psb_dspmat_type),intent(inout) :: l,u - type(psb_dspmat_type),intent(in), optional, target :: blck - character, intent(in), optional :: upd - real(psb_dpk_), intent(inout) :: d(:) - end subroutine mld_dilu0_fact - end interface - - interface mld_iluk_fact - subroutine mld_diluk_fact(fill_in,ialg,a,l,u,d,info,blck) - import psb_dspmat_type, psb_dpk_, psb_ipk_ - integer(psb_ipk_), intent(in) :: fill_in,ialg - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type),intent(in) :: a - type(psb_dspmat_type),intent(inout) :: l,u - type(psb_dspmat_type),intent(in), optional, target :: blck - real(psb_dpk_), intent(inout) :: d(:) - end subroutine mld_diluk_fact - end interface - - interface mld_ilut_fact - subroutine mld_dilut_fact(fill_in,thres,a,l,u,d,info,blck,iscale) - import psb_dspmat_type, psb_dpk_, psb_ipk_ - integer(psb_ipk_), intent(in) :: fill_in - real(psb_dpk_), intent(in) :: thres - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type),intent(in) :: a - type(psb_dspmat_type),intent(inout) :: l,u - real(psb_dpk_), intent(inout) :: d(:) - type(psb_dspmat_type),intent(in), optional, target :: blck - integer(psb_ipk_), intent(in), optional :: iscale - end subroutine mld_dilut_fact - end interface - -end module mld_d_ilu_fact_mod diff --git a/mlprec/mld_d_ilu_solver.f90 b/mlprec/mld_d_ilu_solver.f90 deleted file mode 100644 index 2ef71e30..00000000 --- a/mlprec/mld_d_ilu_solver.f90 +++ /dev/null @@ -1,502 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! File: mld_d_ilu_solver_mod.f90 -! -! Module: mld_d_ilu_solver_mod -! -! This module defines: -! - the mld_d_ilu_solver_type data structure containing the ingredients -! for a local Incomplete LU factorization. -! 1. The factorization is always restricted to the diagonal block of the -! current image (coherently with the definition of a SOLVER as a local -! object) -! 2. The code provides support for both pattern-based ILU(K) and -! threshold base ILU(T,L) -! 3. The diagonal is stored separately, so strictly speaking this is -! an incomplete LDU factorization; -! 4. The application phase is shared among all variants; -! -! -module mld_d_ilu_solver - - use mld_base_prec_type, only : mld_fact_names - use mld_d_base_solver_mod - use psb_d_ilu_fact_mod - - type, extends(mld_d_base_solver_type) :: mld_d_ilu_solver_type - type(psb_dspmat_type) :: l, u - real(psb_dpk_), allocatable :: d(:) - type(psb_d_vect_type) :: dv - integer(psb_ipk_) :: fact_type, fill_in - real(psb_dpk_) :: thresh - contains - procedure, pass(sv) :: dump => mld_d_ilu_solver_dmp - procedure, pass(sv) :: check => d_ilu_solver_check - procedure, pass(sv) :: clone => mld_d_ilu_solver_clone - procedure, pass(sv) :: clone_settings => mld_d_ilu_solver_clone_settings - procedure, pass(sv) :: clear_data => mld_d_ilu_solver_clear_data - procedure, pass(sv) :: build => mld_d_ilu_solver_bld - procedure, pass(sv) :: cnv => mld_d_ilu_solver_cnv - procedure, pass(sv) :: apply_v => mld_d_ilu_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_d_ilu_solver_apply - procedure, pass(sv) :: free => d_ilu_solver_free - procedure, pass(sv) :: cseti => d_ilu_solver_cseti - procedure, pass(sv) :: csetc => d_ilu_solver_csetc - procedure, pass(sv) :: csetr => d_ilu_solver_csetr - procedure, pass(sv) :: descr => d_ilu_solver_descr - procedure, pass(sv) :: default => d_ilu_solver_default - procedure, pass(sv) :: sizeof => d_ilu_solver_sizeof - procedure, pass(sv) :: get_nzeros => d_ilu_solver_get_nzeros - procedure, nopass :: get_wrksz => d_ilu_solver_get_wrksize - procedure, nopass :: get_fmt => d_ilu_solver_get_fmt - procedure, nopass :: get_id => d_ilu_solver_get_id - end type mld_d_ilu_solver_type - - - private :: d_ilu_solver_bld, d_ilu_solver_apply, & - & d_ilu_solver_free, & - & d_ilu_solver_descr, d_ilu_solver_sizeof, & - & d_ilu_solver_default, d_ilu_solver_dmp, & - & d_ilu_solver_apply_vect, d_ilu_solver_get_nzeros, & - & d_ilu_solver_get_fmt, d_ilu_solver_check, & - & d_ilu_solver_get_id, d_ilu_solver_get_wrksize - - - interface - subroutine mld_d_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, mld_d_ilu_solver_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_ilu_solver_type), intent(inout) :: sv - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - end subroutine mld_d_ilu_solver_apply_vect - end interface - - interface - subroutine mld_d_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, mld_d_ilu_solver_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_ilu_solver_type), intent(inout) :: sv - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_d_ilu_solver_apply - end interface - - interface - subroutine mld_d_ilu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, mld_d_ilu_solver_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_ilu_solver_bld - end interface - - interface - subroutine mld_d_ilu_solver_cnv(sv,info,amold,vmold,imold) - import :: mld_d_ilu_solver_type, psb_dpk_, & - & psb_d_base_sparse_mat, psb_d_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - class(mld_d_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_ilu_solver_cnv - end interface - - interface - subroutine mld_d_ilu_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, mld_d_ilu_solver_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, & - & psb_ipk_ - implicit none - class(mld_d_ilu_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_d_ilu_solver_dmp - end interface - - interface - subroutine mld_d_ilu_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, mld_d_ilu_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_ilu_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_ilu_solver_clone - end interface - - interface - subroutine mld_d_ilu_solver_clone_settings(sv,svout,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_base_solver_type, mld_d_ilu_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_ilu_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_ilu_solver_clone_settings - end interface - - interface - subroutine mld_d_ilu_solver_clear_data(sv,info) - import :: psb_desc_type, psb_dspmat_type, psb_d_base_sparse_mat, & - & psb_d_vect_type, psb_d_base_vect_type, psb_dpk_, & - & mld_d_ilu_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_d_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_ilu_solver_clear_data - end interface - -contains - - subroutine d_ilu_solver_default(sv) - - Implicit None - - ! Arguments - class(mld_d_ilu_solver_type), intent(inout) :: sv - - sv%fact_type = psb_ilu_n_ - sv%fill_in = 0 - sv%thresh = dzero - - return - end subroutine d_ilu_solver_default - - subroutine d_ilu_solver_check(sv,info) - - Implicit None - - ! Arguments - class(mld_d_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_ilu_solver_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - call mld_check_def(sv%fact_type,& - & 'Factorization',psb_ilu_n_,is_legal_ilu_fact) - - select case(sv%fact_type) - case(psb_ilu_n_,psb_milu_n_) - call mld_check_def(sv%fill_in,& - & 'Level',izero,is_int_non_negative) - case(psb_ilu_t_) - call mld_check_def(sv%thresh,& - & 'Eps',dzero,is_legal_d_fact_thrs) - end select - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine d_ilu_solver_check - - subroutine d_ilu_solver_cseti(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_d_ilu_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_ilu_solver_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(trim((what)))) - case('SUB_SOLVE') - sv%fact_type = val - case('SUB_FILLIN') - sv%fill_in = val - case default - call sv%mld_d_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_ilu_solver_cseti - - subroutine d_ilu_solver_csetc(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_d_ilu_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='d_ilu_solver_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - ival = mld_stringval(val) - select case(psb_toupper(trim((what)))) - case('SUB_SOLVE') - sv%fact_type = ival - case default - call sv%mld_d_base_solver_type%set(what,val,info,idx=idx) - end select - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info, name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_ilu_solver_csetc - - subroutine d_ilu_solver_csetr(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_d_ilu_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_ilu_solver_csetr' - - call psb_erractionsave(err_act) - info = psb_success_ - - select case(psb_toupper(what)) - case('SUB_ILUTHRS') - sv%thresh = val - case default - call sv%mld_d_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_ilu_solver_csetr - - subroutine d_ilu_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_d_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_ilu_solver_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sv%d)) then - deallocate(sv%d,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - end if - call sv%l%free() - call sv%u%free() - call sv%dv%free(info) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_ilu_solver_free - - subroutine d_ilu_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_d_ilu_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_d_ilu_solver_descr' - integer(psb_ipk_) :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' Incomplete factorization solver: ',& - & mld_fact_names(sv%fact_type) - select case(sv%fact_type) - case(psb_ilu_n_,psb_milu_n_) - write(iout_,*) ' Fill level:',sv%fill_in - case(psb_ilu_t_) - write(iout_,*) ' Fill level:',sv%fill_in - write(iout_,*) ' Fill threshold :',sv%thresh - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_ilu_solver_descr - - function d_ilu_solver_get_nzeros(sv) result(val) - - implicit none - ! Arguments - class(mld_d_ilu_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - val = val + sv%dv%get_nrows() - val = val + sv%l%get_nzeros() - val = val + sv%u%get_nzeros() - - return - end function d_ilu_solver_get_nzeros - - function d_ilu_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_d_ilu_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 2*psb_sizeof_ip + psb_sizeof_dp - val = val + sv%dv%sizeof() - val = val + sv%l%sizeof() - val = val + sv%u%sizeof() - - return - end function d_ilu_solver_sizeof - - function d_ilu_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "ILU solver" - end function d_ilu_solver_get_fmt - - function d_ilu_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = psb_ilu_n_ - end function d_ilu_solver_get_id - - function d_ilu_solver_get_wrksize() result(val) - implicit none - integer(psb_ipk_) :: val - - val = 2 - end function d_ilu_solver_get_wrksize - -end module mld_d_ilu_solver diff --git a/mlprec/mld_d_inner_mod.f90 b/mlprec/mld_d_inner_mod.f90 deleted file mode 100644 index 62b6834a..00000000 --- a/mlprec/mld_d_inner_mod.f90 +++ /dev/null @@ -1,131 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_inner_mod.f90 -! -! Module: mld_inner_mod -! -! This module defines the interfaces to inner MLD2P4 routines. -! The interfaces of the user level routines are defined in mld_prec_mod.f90. -! -module mld_d_inner_mod - - use psb_base_mod, only : psb_dspmat_type, psb_desc_type, psb_i_base_vect_type, & - & psb_dpk_, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_, & - & psb_d_vect_type, psb_lpk_, psb_ldspmat_type - use mld_d_prec_type, only : mld_dprec_type, mld_dml_parms, & - & mld_d_onelev_type, mld_dmlprec_wrk_type - - interface mld_mlprec_bld - subroutine mld_dmlprec_bld(a,desc_a,prec,info, amold, vmold,imold) - import :: psb_dspmat_type, psb_desc_type, psb_i_base_vect_type, & - & psb_dpk_, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ - import :: mld_dprec_type - implicit none - type(psb_dspmat_type), intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - type(mld_dprec_type), intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_dmlprec_bld - end interface mld_mlprec_bld - - interface mld_mlprec_aply - subroutine mld_dmlprec_aply(alpha,p,x,beta,y,desc_data,trans,work,info) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, psb_ipk_ - import :: mld_dprec_type - implicit none - type(psb_desc_type),intent(in) :: desc_data - type(mld_dprec_type), intent(inout) :: p - real(psb_dpk_),intent(in) :: alpha,beta - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - character,intent(in) :: trans - real(psb_dpk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - end subroutine mld_dmlprec_aply - subroutine mld_dmlprec_aply_vect(alpha,p,x,beta,y,desc_data,trans,work,info) - import :: psb_dspmat_type, psb_desc_type, & - & psb_dpk_, psb_d_vect_type, psb_ipk_ - import :: mld_dprec_type - implicit none - type(psb_desc_type),intent(in) :: desc_data - type(mld_dprec_type), intent(inout) :: p - real(psb_dpk_),intent(in) :: alpha,beta - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - character,intent(in) :: trans - real(psb_dpk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - end subroutine mld_dmlprec_aply_vect - end interface mld_mlprec_aply - - interface mld_map_to_tprol - subroutine mld_d_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, psb_ipk_, psb_lpk_, psb_ldspmat_type - import :: mld_d_onelev_type - implicit none - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), allocatable, intent(inout) :: ilaggr(:),nlaggr(:) - type(psb_ldspmat_type), intent(out) :: op_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_map_to_tprol - end interface mld_map_to_tprol - - abstract interface - subroutine mld_daggrmat_var_bld(a,desc_a,ilaggr,nlaggr,parms,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, psb_ipk_, psb_lpk_, psb_ldspmat_type - import :: mld_d_onelev_type, mld_dml_parms - implicit none - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(mld_dml_parms), intent(inout) :: parms - type(psb_dspmat_type), intent(inout) :: op_prol,ac,op_restr - type(psb_ldspmat_type), intent(inout) :: t_prol - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - end subroutine mld_daggrmat_var_bld - end interface - - procedure(mld_daggrmat_var_bld) :: mld_daggrmat_nosmth_bld, & - & mld_daggrmat_smth_bld, mld_daggrmat_minnrg_bld - -end module mld_d_inner_mod diff --git a/mlprec/mld_d_jac_smoother.f90 b/mlprec/mld_d_jac_smoother.f90 deleted file mode 100644 index 25bbed4b..00000000 --- a/mlprec/mld_d_jac_smoother.f90 +++ /dev/null @@ -1,454 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_d_jac_smoother_mod.f90 -! -! Module: mld_d_jac_smoother_mod -! -! This module defines: -! the mld_d_jac_smoother_type data structure containing the -! smoother for a Jacobi/block Jacobi smoother. -! The smoother stores in ND the block off-diagonal matrix. -! One special case is treated separately, when the solver is DIAG or L1-DIAG -! then the ND is the entire off-diagonal part of the matrix (including the -! main diagonal block), so that it becomes possible to implement -! a pure Jacobi or L1-Jacobi global solver. -! -module mld_d_jac_smoother - - use mld_d_base_smoother_mod - - type, extends(mld_d_base_smoother_type) :: mld_d_jac_smoother_type - ! The local solver component is inherited from the - ! parent type. - ! class(mld_d_base_solver_type), allocatable :: sv - ! - type(psb_dspmat_type), pointer :: pa => null() - type(psb_dspmat_type) :: nd - integer(psb_lpk_) :: nd_nnz_tot - logical :: checkres - logical :: printres - integer(psb_ipk_) :: checkiter - integer(psb_ipk_) :: printiter - real(psb_dpk_) :: tol - contains - procedure, pass(sm) :: apply_v => mld_d_jac_smoother_apply_vect - procedure, pass(sm) :: apply_a => mld_d_jac_smoother_apply - procedure, pass(sm) :: dump => mld_d_jac_smoother_dmp - procedure, pass(sm) :: build => mld_d_jac_smoother_bld - procedure, pass(sm) :: cnv => mld_d_jac_smoother_cnv - procedure, pass(sm) :: clone => mld_d_jac_smoother_clone - procedure, pass(sm) :: clone_settings => mld_d_jac_smoother_clone_settings - procedure, pass(sm) :: clear_data => mld_d_jac_smoother_clear_data - procedure, pass(sm) :: free => d_jac_smoother_free - procedure, pass(sm) :: cseti => mld_d_jac_smoother_cseti - procedure, pass(sm) :: csetc => mld_d_jac_smoother_csetc - procedure, pass(sm) :: csetr => mld_d_jac_smoother_csetr - procedure, pass(sm) :: descr => mld_d_jac_smoother_descr - procedure, pass(sm) :: sizeof => d_jac_smoother_sizeof - procedure, pass(sm) :: default => d_jac_smoother_default - procedure, pass(sm) :: get_nzeros => d_jac_smoother_get_nzeros - procedure, pass(sm) :: get_wrksz => d_jac_smoother_get_wrksize - procedure, nopass :: get_fmt => d_jac_smoother_get_fmt - procedure, nopass :: get_id => d_jac_smoother_get_id - end type mld_d_jac_smoother_type - - type, extends(mld_d_jac_smoother_type) :: mld_d_l1_jac_smoother_type - contains - procedure, pass(sm) :: build => mld_d_l1_jac_smoother_bld - procedure, pass(sm) :: clone => mld_d_l1_jac_smoother_clone - procedure, pass(sm) :: descr => mld_d_l1_jac_smoother_descr - procedure, nopass :: get_fmt => d_l1_jac_smoother_get_fmt - procedure, nopass :: get_id => d_l1_jac_smoother_get_id - end type mld_d_l1_jac_smoother_type - - private :: d_jac_smoother_free, & - & d_jac_smoother_sizeof, d_jac_smoother_get_nzeros, & - & d_jac_smoother_get_fmt, d_jac_smoother_get_id, & - & d_jac_smoother_get_wrksize - private :: d_l1_jac_smoother_get_fmt, d_l1_jac_smoother_get_id - - - interface - subroutine mld_d_jac_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,wv,info,init,initu) - import :: psb_desc_type, mld_d_jac_smoother_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type,& - & psb_ipk_ - - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_jac_smoother_type), intent(inout) :: sm - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - end subroutine mld_d_jac_smoother_apply_vect - end interface - - interface - subroutine mld_d_jac_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,info,init,initu) - import :: psb_desc_type, mld_d_jac_smoother_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, & - & psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_jac_smoother_type), intent(inout) :: sm - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_d_jac_smoother_apply - end interface - - interface - subroutine mld_d_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - import :: psb_desc_type, mld_d_jac_smoother_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_jac_smoother_bld - end interface - - interface - subroutine mld_d_jac_smoother_cnv(sm,info,amold,vmold,imold) - import :: mld_d_jac_smoother_type, psb_dpk_, & - & psb_d_base_sparse_mat, psb_d_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - class(mld_d_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_jac_smoother_cnv - end interface - - interface - subroutine mld_d_jac_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dpk_, mld_d_jac_smoother_type, psb_epk_, psb_desc_type, & - & psb_ipk_ - implicit none - class(mld_d_jac_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - end subroutine mld_d_jac_smoother_dmp - end interface - - interface - subroutine mld_d_jac_smoother_clone(sm,smout,info) - import :: mld_d_jac_smoother_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_ - class(mld_d_jac_smoother_type), intent(inout) :: sm - class(mld_d_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_jac_smoother_clone - end interface - - interface - subroutine mld_d_jac_smoother_clone_settings(sm,smout,info) - import :: mld_d_jac_smoother_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_ - class(mld_d_jac_smoother_type), intent(inout) :: sm - class(mld_d_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_jac_smoother_clone_settings - end interface - - interface - subroutine mld_d_jac_smoother_clear_data(sm,info) - import :: mld_d_jac_smoother_type, psb_dpk_, & - & mld_d_base_smoother_type, psb_ipk_ - class(mld_d_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_jac_smoother_clear_data - end interface - - interface - subroutine mld_d_jac_smoother_descr(sm,info,iout,coarse) - import :: mld_d_jac_smoother_type, psb_ipk_ - class(mld_d_jac_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - end subroutine mld_d_jac_smoother_descr - end interface - - interface - subroutine mld_d_jac_smoother_cseti(sm,what,val,info,idx) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dpk_, mld_d_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_d_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_d_jac_smoother_cseti - end interface - - interface - subroutine mld_d_jac_smoother_csetc(sm,what,val,info,idx) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dpk_, mld_d_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_d_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_d_jac_smoother_csetc - end interface - - interface - subroutine mld_d_jac_smoother_csetr(sm,what,val,info,idx) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dpk_, mld_d_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_d_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_d_jac_smoother_csetr - end interface - - - interface - subroutine mld_d_l1_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - import :: psb_desc_type, mld_d_l1_jac_smoother_type, psb_d_vect_type, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_l1_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_l1_jac_smoother_bld - end interface - - interface - subroutine mld_d_l1_jac_smoother_clone(sm,smout,info) - import :: mld_d_l1_jac_smoother_type, & - & mld_d_base_smoother_type, psb_ipk_ - class(mld_d_l1_jac_smoother_type), intent(inout) :: sm - class(mld_d_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_l1_jac_smoother_clone - end interface - - interface - subroutine mld_d_l1_jac_smoother_clone_settings(sm,smout,info) - import :: mld_d_l1_jac_smoother_type, & - & mld_d_base_smoother_type, psb_ipk_ - class(mld_d_l1_jac_smoother_type), intent(inout) :: sm - class(mld_d_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_l1_jac_smoother_clone_settings - end interface - - interface - subroutine mld_d_l1_jac_smoother_clear_data(sm,info) - import :: mld_d_l1_jac_smoother_type, & - & mld_d_base_smoother_type, psb_ipk_ - class(mld_d_l1_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_l1_jac_smoother_clear_data - end interface - - interface - subroutine mld_d_l1_jac_smoother_descr(sm,info,iout,coarse) - import :: mld_d_l1_jac_smoother_type, psb_ipk_ - class(mld_d_l1_jac_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - end subroutine mld_d_l1_jac_smoother_descr - end interface - -contains - - - subroutine d_jac_smoother_free(sm,info) - - - Implicit None - - ! Arguments - class(mld_d_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_jac_smoother_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - - - if (allocated(sm%sv)) then - call sm%sv%free(info) - if (info == psb_success_) deallocate(sm%sv,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - end if - call sm%nd%free() - sm%pa => null() - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_jac_smoother_free - - function d_jac_smoother_sizeof(sm) result(val) - - implicit none - ! Arguments - class(mld_d_jac_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = psb_sizeof_lp - if (allocated(sm%sv)) val = val + sm%sv%sizeof() - val = val + sm%nd%sizeof() - - return - end function d_jac_smoother_sizeof - - subroutine d_jac_smoother_default(sm) - - Implicit None - - ! Arguments - class(mld_d_jac_smoother_type), intent(inout) :: sm - - ! - ! Default: BJAC with no residual check - ! - sm%checkres = .false. - sm%printres = .false. - sm%checkiter = -1 - sm%printiter = -1 - sm%tol = 0 - - if (allocated(sm%sv)) then - call sm%sv%default() - end if - - return - end subroutine d_jac_smoother_default - - function d_jac_smoother_get_nzeros(sm) result(val) - - implicit none - ! Arguments - class(mld_d_jac_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - if (allocated(sm%sv)) val = val + sm%sv%get_nzeros() - val = val + sm%nd%get_nzeros() - - return - end function d_jac_smoother_get_nzeros - - function d_jac_smoother_get_wrksize(sm) result(val) - implicit none - class(mld_d_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_) :: val - - val = 2 - if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() - - end function d_jac_smoother_get_wrksize - - function d_jac_smoother_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Jacobi smoother" - end function d_jac_smoother_get_fmt - - function d_jac_smoother_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_jac_ - end function d_jac_smoother_get_id - - function d_l1_jac_smoother_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "L1-Jacobi smoother" - end function d_l1_jac_smoother_get_fmt - - function d_l1_jac_smoother_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_l1_jac_ - end function d_l1_jac_smoother_get_id - -end module mld_d_jac_smoother diff --git a/mlprec/mld_d_mumps_solver.F90 b/mlprec/mld_d_mumps_solver.F90 deleted file mode 100644 index d2a3a655..00000000 --- a/mlprec/mld_d_mumps_solver.F90 +++ /dev/null @@ -1,590 +0,0 @@ - -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -! File: mld_d_mumps_solver_mod.f90 -! -! Module: mld_d_mumps_solver_mod -! -! This module defines: -! - the mld_d_mumps_solver_type data structure containing the ingredients -! to interface with the MUMPS package. -! 1. The factorization can be either restricted to the diagonal block of the -! current image or distributed (and thus exact). -! -module mld_d_mumps_solver - use mld_d_base_solver_mod -#if defined(HAVE_MUMPS_) && defined(HAVE_MUMPS_MODULES_) - use dmumps_struc_def -#endif -#if defined(HAVE_MUMPS_) && defined(HAVE_MUMPS_INCLUDES_) - include 'dmumps_struc.h' -#endif - - - type :: mld_d_mumps_icntl_item - integer(psb_ipk_), allocatable :: item - end type mld_d_mumps_icntl_item - type :: mld_d_mumps_rcntl_item - real(psb_dpk_), allocatable :: item - end type mld_d_mumps_rcntl_item - - type, extends(mld_d_base_solver_type) :: mld_d_mumps_solver_type -#if defined(HAVE_MUMPS_) - type(dmumps_struc), allocatable :: id -#else - integer, allocatable :: id -#endif - type(mld_d_mumps_icntl_item), allocatable :: icntl(:) - type(mld_d_mumps_rcntl_item), allocatable :: rcntl(:) - ! - ! Controls to be set before MUMPS instantiation: - ! - ! IPAR(1) : MUMPS_LOC_GLOB 0==mld_local_solver_: LOCAL 1==mld_global_solver_: GLOBAL - ! IPAR(2) : MUMPS_PRINT_ERR print verbosity (see MUMPS) - ! IPAR(3) : MUMPS_SYM 0: non-symmetric 2: symmetric - integer(psb_ipk_), dimension(3) :: ipar - integer(psb_ipk_), allocatable :: local_ictxt - logical :: built = .false. - contains - procedure, pass(sv) :: build => d_mumps_solver_bld - procedure, pass(sv) :: apply_a => d_mumps_solver_apply - procedure, pass(sv) :: apply_v => d_mumps_solver_apply_vect - procedure, pass(sv) :: clone_settings => d_mumps_solver_clone_settings - procedure, pass(sv) :: clear_data => d_mumps_solver_clear_data - procedure, pass(sv) :: free => d_mumps_solver_free - procedure, pass(sv) :: descr => d_mumps_solver_descr - procedure, pass(sv) :: sizeof => d_mumps_solver_sizeof - procedure, pass(sv) :: csetc => d_mumps_solver_csetc - procedure, pass(sv) :: cseti => d_mumps_solver_cseti - procedure, pass(sv) :: csetr => d_mumps_solver_csetr - procedure, pass(sv) :: default => d_mumps_solver_default - procedure, nopass :: get_fmt => d_mumps_solver_get_fmt - procedure, nopass :: get_id => d_mumps_solver_get_id - procedure, pass(sv) :: is_global => d_mumps_solver_is_global - final :: d_mumps_solver_finalize - end type mld_d_mumps_solver_type - - - private :: d_mumps_solver_bld, d_mumps_solver_apply, & - & d_mumps_solver_free, d_mumps_solver_descr, & - & d_mumps_solver_sizeof, d_mumps_solver_apply_vect,& - & d_mumps_solver_cseti, d_mumps_solver_csetr, & - & d_mumps_solver_csetc, d_mumps_solver_clear_data, & - & d_mumps_solver_default, d_mumps_solver_get_fmt, & - & d_mumps_solver_clone_settings, & - & d_mumps_solver_get_id, d_mumps_solver_is_global - private :: d_mumps_solver_finalize - - interface - subroutine d_mumps_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, mld_d_mumps_solver_type, psb_d_vect_type, psb_dpk_, psb_spk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_mumps_solver_type), intent(inout) :: sv - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - end subroutine d_mumps_solver_apply_vect - end interface - - interface - subroutine d_mumps_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info,init,initu) - import :: psb_desc_type, mld_d_mumps_solver_type, psb_d_vect_type, psb_dpk_, psb_spk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_mumps_solver_type), intent(inout) :: sv - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine d_mumps_solver_apply - end interface - - interface - subroutine d_mumps_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - import :: psb_desc_type, mld_d_mumps_solver_type, psb_d_vect_type, psb_dpk_, & - & psb_dspmat_type, psb_d_base_sparse_mat, psb_d_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - - Implicit None - - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine d_mumps_solver_bld - end interface - -contains - - subroutine d_mumps_solver_clone_settings(sv,svout,info) - - use psb_base_mod - Implicit None - ! Arguments - class(mld_d_mumps_solver_type), intent(inout) :: sv - class(mld_d_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: k,err_act - character(len=20) :: name='d_mumps_solver_clone_settings' - - info = 0 - -#if defined(HAVE_MUMPS_) - - call psb_erractionsave(err_act) - - select type(svout) - class is(mld_d_mumps_solver_type) - svout%ipar(:) = sv%ipar(:) - svout%built = .false. - if (allocated(svout%icntl)) deallocate(svout%icntl,stat=info) - if (info == 0) allocate(svout%icntl(mld_mumps_icntl_size),stat=info) - if (info == 0) then - do k=1,mld_mumps_icntl_size - call psb_safe_ab_cpy(sv%icntl(k)%item,svout%icntl(k)%item,info) - end do - end if - - if (allocated(svout%rcntl)) deallocate(svout%rcntl,stat=info) - if (info == 0) allocate(svout%rcntl(mld_mumps_rcntl_size),stat=info) - if (info == 0) then - do k=1,mld_mumps_rcntl_size - call psb_safe_ab_cpy(sv%rcntl(k)%item,svout%rcntl(k)%item,info) - end do - end if - - class default - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -#endif - end subroutine d_mumps_solver_clone_settings - - subroutine d_mumps_solver_clear_data(sv,info) - use psb_base_mod, only : psb_exit - Implicit None - - ! Arguments - class(mld_d_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_mumps_solver_clear_data' - - info = 0 -#if defined(HAVE_MUMPS_) - call psb_erractionsave(err_act) - if (allocated(sv%id)) then - if (sv%built) then - sv%id%job = -2 - call dmumps(sv%id) - info = sv%id%infog(1) - if (info /= psb_success_) goto 9999 - end if - deallocate(sv%id, stat=info) - if (allocated(sv%local_ictxt)) then - call psb_exit(sv%local_ictxt,close=.false.) - deallocate(sv%local_ictxt,stat=info) - end if - sv%built=.false. - end if - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -#endif - end subroutine d_mumps_solver_clear_data - - subroutine d_mumps_solver_free(sv,info) - use psb_base_mod, only : psb_exit - Implicit None - - ! Arguments - class(mld_d_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_mumps_solver_free' - - info = 0 -#if defined(HAVE_MUMPS_) - call psb_erractionsave(err_act) - call sv%clear_data(info) - if ((info == 0).and.allocated(sv%icntl)) deallocate(sv%icntl,stat=info) - if ((info == 0).and.allocated(sv%rcntl)) deallocate(sv%rcntl,stat=info) - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -#endif - end subroutine d_mumps_solver_free - -subroutine d_mumps_solver_finalize(sv) - - Implicit None - - ! Arguments - type(mld_d_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_) :: info - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_mumps_solver_finalize' - - call sv%free(info) - - return - -end subroutine d_mumps_solver_finalize - -subroutine d_mumps_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_d_mumps_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt, me, np - character(len=20), parameter :: name='mld_z_mumps_solver_descr' - integer(psb_ipk_) :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' MUMPS Solver. ' - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -end subroutine d_mumps_solver_descr - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! WARNING: OTHER PARAMETERS OF MUMPS COULD BE ADDED. !! -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - -subroutine d_mumps_solver_csetc(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_d_mumps_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_mumps_solver_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - - - select case(psb_toupper(trim(what))) -#if defined(HAVE_MUMPS_) - case('MUMPS_LOC_GLOB') - sv%ipar(1) = sv%stringval(psb_toupper(trim(val))) -#endif - case default - call sv%mld_d_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -end subroutine d_mumps_solver_csetc - - -subroutine d_mumps_solver_cseti(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_d_mumps_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_mumps_solver_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) -#if defined(HAVE_MUMPS_) - case('MUMPS_LOC_GLOB') - sv%ipar(1) = val - case('MUMPS_PRINT_ERR') - sv%ipar(2) = val - case('MUMPS_SYM') - sv%ipar(3) = val - case('MUMPS_IPAR_ENTRY') - if(present(idx)) then - ! Note: this will allocate %item - sv%icntl(idx)%item = val - end if -#endif - case default - call sv%mld_d_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -end subroutine d_mumps_solver_cseti - -subroutine d_mumps_solver_csetr(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_d_mumps_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='d_mumps_solver_csetr' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) -#if defined(HAVE_MUMPS_) - case('MUMPS_RPAR_ENTRY') - if(present(idx)) then - ! Note: this will allocate %item - sv%rcntl(idx)%item = val - end if -#endif - case default - call sv%mld_d_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -end subroutine d_mumps_solver_csetr - -!!NOTE: BY DEFAULT BLR is activated with a dropping parameter to 1d-4 !! -subroutine d_mumps_solver_default(sv) - - Implicit none - - !Argument - class(mld_d_mumps_solver_type),intent(inout) :: sv - integer(psb_ipk_) :: info - integer(psb_ipk_) :: err_act,ictx,icomm - character(len=20) :: name='d_mumps_default' - - info = psb_success_ - call psb_erractionsave(err_act) - -#if defined(HAVE_MUMPS_) - if (.not.allocated(sv%id)) then - allocate(sv%id,stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_dealloc_ - call psb_errpush(info,name,a_err='mld_dmumps_default') - goto 9999 - end if - sv%built=.false. - end if - if (.not.allocated(sv%icntl)) then - allocate(sv%icntl(mld_mumps_icntl_size),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_dealloc_ - call psb_errpush(info,name,a_err='mld_dmumps_default') - goto 9999 - end if - end if - if (.not.allocated(sv%rcntl)) then - allocate(sv%rcntl(mld_mumps_rcntl_size),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_dealloc_ - call psb_errpush(info,name,a_err='mld_dmumps_default') - goto 9999 - end if - end if - ! INSTANTIATION OF sv%id needed to set parmater but mpi communicator needed - ! sv%id%job = -1 - ! sv%id%par=1 - ! call dmumps(sv%id) - sv%ipar = 0 - sv%ipar(1) = mld_global_solver_ - !sv%ipar(10)=6 - !sv%ipar(11)=0 - !sv%ipar(12)=6 - -#endif - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return - -end subroutine d_mumps_solver_default - -function d_mumps_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_d_mumps_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer :: i -#if defined(HAVE_MUMPS_) - val = (sv%id%INFOG(22)+sv%id%INFOG(32))*1d+6 -#else - val = 0 -#endif - ! val = 2*psb_sizeof_ip + psb_sizeof_dp - ! val = val + sv%symbsize - ! val = val + sv%numsize - return -end function d_mumps_solver_sizeof - -function d_mumps_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "MUMPS solver" -end function d_mumps_solver_get_fmt - -function d_mumps_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_mumps_ -end function d_mumps_solver_get_id - - -function d_mumps_solver_is_global(sv) result(val) - implicit none - class(mld_d_mumps_solver_type), intent(in) :: sv - logical :: val - - val = (sv%ipar(1) == mld_global_solver_ ) -end function d_mumps_solver_is_global - -end module mld_d_mumps_solver - diff --git a/mlprec/mld_d_onelev_mod.f90 b/mlprec/mld_d_onelev_mod.f90 deleted file mode 100644 index 67a6514d..00000000 --- a/mlprec/mld_d_onelev_mod.f90 +++ /dev/null @@ -1,824 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_d_onelev_mod.f90 -! -! Module: mld_d_onelev_mod -! -! This module defines: -! - the mld_d_onelev_type data structure containing one level -! of a multilevel preconditioner and related -! data structures; -! -! It contains routines for -! - Building and applying; -! - checking if the preconditioner is correctly defined; -! - printing a description of the preconditioner; -! - deallocating the preconditioner data structure. -! - -module mld_d_onelev_mod - - use mld_base_prec_type - use mld_d_base_smoother_mod - use mld_d_dec_aggregator_mod - use psb_base_mod, only : psb_dspmat_type, psb_d_vect_type, & - & psb_d_base_vect_type, psb_ldspmat_type, psb_dlinmap_type, psb_dpk_, & - & psb_ipk_, psb_epk_, psb_lpk_, psb_desc_type, psb_i_base_vect_type, & - & psb_erractionsave, psb_error_handler - ! - ! - ! Type: mld_donelev_type. - ! - ! It is the data type containing the necessary items for the current - ! level (essentially, the smoother, the current-level matrix - ! and the restriction and prolongation operators). - ! - ! type mld_donelev_type - ! class(mld_d_base_smoother_type), allocatable :: sm, sm2a - ! class(mld_d_base_smoother_type), pointer :: sm2 => null() - ! class(mld_dmlprec_wrk_type), allocatable :: wrk - ! class(mld_d_base_aggregator_type), allocatable :: aggr - ! type(mld_dml_parms) :: parms - ! type(psb_dspmat_type) :: ac - ! type(psb_desc_type) :: desc_ac - ! type(psb_dspmat_type), pointer :: base_a => null() - ! type(psb_desc_type), pointer :: base_desc => null() - ! type(psb_dlinmap_type) :: map - ! end type mld_donelev_type - ! - ! Note that d denotes the kind of the real data type to be chosen - ! according to single/double precision version of MLD2P4. - ! - ! sm,sm2a - class(mld_d_base_smoother_type), allocatable - ! The current level pre- and post-smooother. - ! sm2 - class(mld_d_base_smoother_type), pointer - ! The current level post-smooother; if sm2a is allocated - ! explicitly, then sm2 => sm2a, otherwise sm2 => sm. - ! wrk - class(mld_dmlprec_wrk_type), allocatable - ! Workspace for application of preconditioner; may be - ! pre-allocated to save time in the application within a - ! Krylov solver. - ! aggr - class(mld_d_base_aggregator_type), allocatable - ! The aggregator object: holds the algorithmic choices and - ! (possibly) additional data for building the aggregation. - ! parms - type(mld_dml_parms) - ! The parameters defining the multilevel strategy. - ! ac - The local part of the current-level matrix, built by - ! coarsening the previous-level matrix. - ! desc_ac - type(psb_desc_type). - ! The communication descriptor associated to the matrix - ! stored in ac. - ! base_a - type(psb_dspmat_type), pointer. - ! Pointer (really a pointer!) to the local part of the current - ! matrix (so we have a unified treatment of residuals). - ! We need this to avoid passing explicitly the current matrix - ! to the routine which applies the preconditioner. - ! base_desc - type(psb_desc_type), pointer. - ! Pointer to the communication descriptor associated to the - ! matrix pointed by base_a. - ! map - Stores the maps (restriction and prolongation) between the - ! vector spaces associated to the index spaces of the previous - ! and current levels. - ! - ! Methods: - ! Most methods follow the encapsulation hierarchy: they take whatever action - ! is appropriate for the current object, then call the corresponding method for - ! the contained object. - ! As an example: the descr() method prints out a description of the - ! level. It starts by invoking the descr() method of the parms object, - ! then calls the descr() method of the smoother object. - ! - ! descr - Prints a description of the object. - ! default - Set default values - ! dump - Dump to file object contents - ! set - Sets various parameters; when a request is unknown - ! it is passed to the smoother object for further processing. - ! check - Sanity checks. - ! sizeof - Total memory occupation in bytes - ! get_nzeros - Number of nonzeros - ! get_wrksz - How many workspace vector does apply_vect need - ! allocate_wrk - Allocate auxiliary workspace - ! free_wrk - Free auxiliary workspace - ! bld_tprol - Invoke the aggr method to build the tentative prolongator - ! mat_asb - Build the final (possibly smoothed) prolongator and coarse matrix. - ! - ! - type mld_dmlprec_wrk_type - real(psb_dpk_), allocatable :: tx(:), ty(:), x2l(:), y2l(:) - type(psb_d_vect_type) :: vtx, vty, vx2l, vy2l - type(psb_d_vect_type), allocatable :: wv(:) - contains - procedure, pass(wk) :: alloc => d_wrk_alloc - procedure, pass(wk) :: free => d_wrk_free - procedure, pass(wk) :: clone => d_wrk_clone - procedure, pass(wk) :: move_alloc => d_wrk_move_alloc - procedure, pass(wk) :: cnv => d_wrk_cnv - procedure, pass(wk) :: sizeof => d_wrk_sizeof - end type mld_dmlprec_wrk_type - private :: d_wrk_alloc, d_wrk_free, & - & d_wrk_clone, d_wrk_move_alloc, d_wrk_cnv, d_wrk_sizeof - - type mld_d_onelev_type - class(mld_d_base_smoother_type), allocatable :: sm, sm2a - class(mld_d_base_smoother_type), pointer :: sm2 => null() - class(mld_dmlprec_wrk_type), allocatable :: wrk - class(mld_d_base_aggregator_type), allocatable :: aggr - type(mld_dml_parms) :: parms - type(psb_dspmat_type) :: ac - integer(psb_ipk_) :: ac_nz_loc - integer(psb_lpk_) :: ac_nz_tot - type(psb_desc_type) :: desc_ac - type(psb_dspmat_type), pointer :: base_a => null() - type(psb_desc_type), pointer :: base_desc => null() - type(psb_ldspmat_type) :: tprol - type(psb_dlinmap_type) :: map - real(psb_dpk_) :: szratio - contains - procedure, pass(lv) :: bld_tprol => d_base_onelev_bld_tprol - procedure, pass(lv) :: mat_asb => mld_d_base_onelev_mat_asb - procedure, pass(lv) :: update_aggr => d_base_onelev_update_aggr - procedure, pass(lv) :: bld => mld_d_base_onelev_build - procedure, pass(lv) :: clone => d_base_onelev_clone - procedure, pass(lv) :: cnv => mld_d_base_onelev_cnv - procedure, pass(lv) :: descr => mld_d_base_onelev_descr - procedure, pass(lv) :: default => d_base_onelev_default - procedure, pass(lv) :: free => mld_d_base_onelev_free - procedure, pass(lv) :: nullify => d_base_onelev_nullify - procedure, pass(lv) :: check => mld_d_base_onelev_check - procedure, pass(lv) :: dump => mld_d_base_onelev_dump - procedure, pass(lv) :: cseti => mld_d_base_onelev_cseti - procedure, pass(lv) :: csetr => mld_d_base_onelev_csetr - procedure, pass(lv) :: csetc => mld_d_base_onelev_csetc - procedure, pass(lv) :: setsm => mld_d_base_onelev_setsm - procedure, pass(lv) :: setsv => mld_d_base_onelev_setsv - procedure, pass(lv) :: setag => mld_d_base_onelev_setag - generic, public :: set => cseti, csetr, csetc, setsm, setsv, setag - procedure, pass(lv) :: sizeof => d_base_onelev_sizeof - procedure, pass(lv) :: get_nzeros => d_base_onelev_get_nzeros - procedure, pass(lv) :: get_wrksz => d_base_onelev_get_wrksize - procedure, pass(lv) :: allocate_wrk => d_base_onelev_allocate_wrk - procedure, pass(lv) :: free_wrk => d_base_onelev_free_wrk - procedure, nopass :: stringval => mld_stringval - procedure, pass(lv) :: move_alloc => d_base_onelev_move_alloc - - end type mld_d_onelev_type - - type mld_d_onelev_node - type(mld_d_onelev_type) :: item - type(mld_d_onelev_node), pointer :: prev=>null(), next=>null() - end type mld_d_onelev_node - - private :: d_base_onelev_default, d_base_onelev_sizeof, & - & d_base_onelev_nullify, d_base_onelev_get_nzeros, & - & d_base_onelev_clone, d_base_onelev_move_alloc, & - & d_base_onelev_get_wrksize, d_base_onelev_allocate_wrk, & - & d_base_onelev_free_wrk - - interface - subroutine mld_d_base_onelev_mat_asb(lv,a,desc_a,ilaggr,nlaggr,t_prol,info) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, psb_ipk_, psb_ldspmat_type, psb_lpk_ - import :: mld_d_onelev_type - implicit none - class(mld_d_onelev_type), intent(inout), target :: lv - type(psb_dspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:),nlaggr(:) - type(psb_ldspmat_type), intent(inout) :: t_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_base_onelev_mat_asb - end interface - - interface - subroutine mld_d_base_onelev_build(lv,info,amold,vmold,imold,ilv) - import :: psb_d_base_sparse_mat, psb_d_base_vect_type, & - & psb_i_base_vect_type, psb_dpk_, mld_d_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - implicit none - class(mld_d_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - integer(psb_ipk_), intent(in), optional :: ilv - end subroutine mld_d_base_onelev_build - end interface - - interface - subroutine mld_d_base_onelev_descr(lv,il,nl,ilmin,info,iout) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dlinmap_type, psb_dpk_, mld_d_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - ! Arguments - class(mld_d_onelev_type), intent(in) :: lv - integer(psb_ipk_), intent(in) :: il,nl,ilmin - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - end subroutine mld_d_base_onelev_descr - end interface - - interface - subroutine mld_d_base_onelev_cnv(lv,info,amold,vmold,imold) - import :: mld_d_onelev_type, psb_d_base_vect_type, psb_dpk_, & - & psb_d_base_sparse_mat, psb_ipk_, psb_i_base_vect_type - ! Arguments - class(mld_d_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_d_base_onelev_cnv - end interface - -interface - subroutine mld_d_base_onelev_free(lv,info) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dlinmap_type, psb_dpk_, mld_d_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - implicit none - - class(mld_d_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_base_onelev_free - end interface - - interface - subroutine mld_d_base_onelev_check(lv,info) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dlinmap_type, psb_dpk_, mld_d_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - ! Arguments - class(mld_d_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_base_onelev_check - end interface - - interface - subroutine mld_d_base_onelev_setsm(lv,val,info,pos) - import :: psb_dpk_, mld_d_onelev_type, mld_d_base_smoother_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - ! Arguments - class(mld_d_onelev_type), target, intent(inout) :: lv - class(mld_d_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - end subroutine mld_d_base_onelev_setsm - end interface - - interface - subroutine mld_d_base_onelev_setsv(lv,val,info,pos) - import :: psb_dpk_, mld_d_onelev_type, mld_d_base_solver_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - ! Arguments - class(mld_d_onelev_type), target, intent(inout) :: lv - class(mld_d_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - end subroutine mld_d_base_onelev_setsv - end interface - - interface - subroutine mld_d_base_onelev_setag(lv,val,info,pos) - import :: psb_dpk_, mld_d_onelev_type, mld_d_base_aggregator_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - ! Arguments - class(mld_d_onelev_type), target, intent(inout) :: lv - class(mld_d_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - end subroutine mld_d_base_onelev_setag - end interface - - interface - subroutine mld_d_base_onelev_cseti(lv,what,val,info,pos,idx) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dlinmap_type, psb_dpk_, mld_d_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - ! Arguments - class(mld_d_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_d_base_onelev_cseti - end interface - - interface - subroutine mld_d_base_onelev_csetc(lv,what,val,info,pos,idx) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dlinmap_type, psb_dpk_, mld_d_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - ! Arguments - class(mld_d_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_d_base_onelev_csetc - end interface - - interface - subroutine mld_d_base_onelev_csetr(lv,what,val,info,pos,idx) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dlinmap_type, psb_dpk_, mld_d_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - class(mld_d_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_d_base_onelev_csetr - end interface - - interface - subroutine mld_d_base_onelev_dump(lv,level,info,prefix,head,ac,rp,smoother,& - & solver,tprol,global_num) - import :: psb_dspmat_type, psb_d_vect_type, psb_d_base_vect_type, & - & psb_dlinmap_type, psb_dpk_, mld_d_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - implicit none - class(mld_d_onelev_type), intent(in) :: lv - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: ac, rp, smoother, solver, tprol, global_num - end subroutine mld_d_base_onelev_dump - end interface - -contains - ! - ! Function returning the size of the mld_prec_type data structure - ! in bytes or in number of nonzeros of the operator(s) involved. - ! - - function d_base_onelev_get_nzeros(lv) result(val) - implicit none - class(mld_d_onelev_type), intent(in) :: lv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - if (allocated(lv%sm)) & - & val = lv%sm%get_nzeros() - if (allocated(lv%sm2a)) & - & val = val + lv%sm2a%get_nzeros() - end function d_base_onelev_get_nzeros - - function d_base_onelev_sizeof(lv) result(val) - implicit none - class(mld_d_onelev_type), intent(in) :: lv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = psb_sizeof_ip+psb_sizeof_lp - val = val + lv%desc_ac%sizeof() - val = val + lv%ac%sizeof() - val = val + lv%tprol%sizeof() - val = val + lv%map%sizeof() - if (allocated(lv%sm)) val = val + lv%sm%sizeof() - if (allocated(lv%sm2a)) val = val + lv%sm2a%sizeof() - if (allocated(lv%aggr)) val = val + lv%aggr%sizeof() - if (allocated(lv%wrk)) val = val + lv%wrk%sizeof() - end function d_base_onelev_sizeof - - - subroutine d_base_onelev_nullify(lv) - implicit none - - class(mld_d_onelev_type), intent(inout) :: lv - - nullify(lv%base_a) - nullify(lv%base_desc) - nullify(lv%sm2) - end subroutine d_base_onelev_nullify - - ! - ! Multilevel defaults: - ! multiplicative vs. additive ML framework; - ! Smoothed decoupled aggregation with zero threshold; - ! distributed coarse matrix; - ! damping omega computed with the max-norm estimate of the - ! dominant eigenvalue; - ! two-sided smoothing (i.e. V-cycle) with 1 smoothing sweep; - ! - - subroutine d_base_onelev_default(lv) - - Implicit None - - ! Arguments - class(mld_d_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_) :: info - - lv%parms%sweeps_pre = 1 - lv%parms%sweeps_post = 1 - lv%parms%ml_cycle = mld_vcycle_ml_ - lv%parms%aggr_type = mld_soc1_ - lv%parms%par_aggr_alg = mld_dec_aggr_ - lv%parms%aggr_ord = mld_aggr_ord_nat_ - lv%parms%aggr_prol = mld_smooth_prol_ - lv%parms%coarse_mat = mld_distr_mat_ - lv%parms%aggr_omega_alg = mld_eig_est_ - lv%parms%aggr_eig = mld_max_norm_ - lv%parms%aggr_filter = mld_no_filter_mat_ - lv%parms%aggr_omega_val = dzero - lv%parms%aggr_thresh = 0.01_psb_dpk_ - - if (allocated(lv%sm)) call lv%sm%default() - if (allocated(lv%sm2a)) then - call lv%sm2a%default() - lv%sm2 => lv%sm2a - else - lv%sm2 => lv%sm - end if - if (.not.allocated(lv%aggr)) allocate(mld_d_dec_aggregator_type :: lv%aggr,stat=info) - if (allocated(lv%aggr)) call lv%aggr%default() - - return - - end subroutine d_base_onelev_default - - subroutine d_base_onelev_bld_tprol(lv,a,desc_a,& - & ilaggr,nlaggr,t_prol,ag_data,info) - implicit none - class(mld_d_onelev_type), intent(inout), target :: lv - type(psb_dspmat_type), intent(inout) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_ldspmat_type), intent(out) :: t_prol - type(mld_daggr_data), intent(in) :: ag_data - integer(psb_ipk_), intent(out) :: info - - call lv%aggr%bld_tprol(lv%parms,ag_data,a,desc_a,ilaggr,nlaggr,t_prol,info) - - end subroutine d_base_onelev_bld_tprol - - - subroutine d_base_onelev_update_aggr(lv,lvnext,info) - implicit none - class(mld_d_onelev_type), intent(inout), target :: lv, lvnext - integer(psb_ipk_), intent(out) :: info - - call lv%aggr%update_next(lvnext%aggr,info) - - end subroutine d_base_onelev_update_aggr - - - subroutine d_base_onelev_clone(lv,lvout,info) - - Implicit None - - ! Arguments - class(mld_d_onelev_type), target, intent(inout) :: lv - class(mld_d_onelev_type), target, intent(inout) :: lvout - integer(psb_ipk_), intent(out) :: info - - info = psb_success_ - if (allocated(lv%sm)) then - call lv%sm%clone(lvout%sm,info) - else - if (allocated(lvout%sm)) then - call lvout%sm%free(info) - if (info==psb_success_) deallocate(lvout%sm,stat=info) - end if - end if - if (allocated(lv%sm2a)) then - call lv%sm%clone(lvout%sm2a,info) - lvout%sm2 => lvout%sm2a - else - if (allocated(lvout%sm2a)) then - call lvout%sm2a%free(info) - if (info==psb_success_) deallocate(lvout%sm2a,stat=info) - end if - lvout%sm2 => lvout%sm - end if - if (allocated(lv%aggr)) then - call lv%aggr%clone(lvout%aggr,info) - else - if (allocated(lvout%aggr)) then - call lvout%aggr%free(info) - if (info==psb_success_) deallocate(lvout%aggr,stat=info) - end if - end if - if (info == psb_success_) call lv%parms%clone(lvout%parms,info) - if (info == psb_success_) call lv%ac%clone(lvout%ac,info) - if (info == psb_success_) call lv%tprol%clone(lvout%tprol,info) - if (info == psb_success_) call lv%desc_ac%clone(lvout%desc_ac,info) - if (info == psb_success_) call lv%map%clone(lvout%map,info) - lvout%base_a => lv%base_a - lvout%base_desc => lv%base_desc - - return - - end subroutine d_base_onelev_clone - - subroutine d_base_onelev_move_alloc(lv, b,info) - use psb_base_mod - implicit none - class(mld_d_onelev_type), target, intent(inout) :: lv, b - integer(psb_ipk_), intent(out) :: info - - call b%free(info) - b%parms = lv%parms - b%szratio = lv%szratio - if (associated(lv%sm2,lv%sm2a)) then - call move_alloc(lv%sm,b%sm) - call move_alloc(lv%sm2a,b%sm2a) - b%sm2 =>b%sm2a - else - call move_alloc(lv%sm,b%sm) - call move_alloc(lv%sm2a,b%sm2a) - b%sm2 =>b%sm - end if - - call move_alloc(lv%aggr,b%aggr) - if (info == psb_success_) call psb_move_alloc(lv%ac,b%ac,info) - if (info == psb_success_) call psb_move_alloc(lv%tprol,b%tprol,info) - if (info == psb_success_) call psb_move_alloc(lv%desc_ac,b%desc_ac,info) - if (info == psb_success_) call psb_move_alloc(lv%map,b%map,info) - b%base_a => lv%base_a - b%base_desc => lv%base_desc - - end subroutine d_base_onelev_move_alloc - - - function d_base_onelev_get_wrksize(lv) result(val) - implicit none - class(mld_d_onelev_type), intent(inout) :: lv - integer(psb_ipk_) :: val - - val = 0 - ! SM and SM2A can share work vectors - if (allocated(lv%sm)) val = val + lv%sm%get_wrksz() - if (allocated(lv%sm2a)) val = max(val,lv%sm2a%get_wrksz()) - ! - ! Now for the ML application itself - ! - - ! VTX/VTY/VX2L/VY2L are stored explicitly - ! - - ! - ! additions for specific ML/cycles - ! - select case(lv%parms%ml_cycle) - case(mld_add_ml_,mld_mult_ml_,mld_vcycle_ml_, mld_wcycle_ml_) - ! We're good - - case(mld_kcycle_ml_, mld_kcyclesym_ml_) - ! - ! We need 7 in inneritkcycle. - ! Can we reuse vtx? - ! - val = val + 7 - - case default - ! Need a better error signaling ? - val = -1 - end select - - end function d_base_onelev_get_wrksize - - subroutine d_base_onelev_allocate_wrk(lv,info,vmold) - use psb_base_mod - implicit none - class(mld_d_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_vect_type), intent(in), optional :: vmold - ! - integer(psb_ipk_) :: nwv, i - info = psb_success_ - nwv = lv%get_wrksz() - if (.not.allocated(lv%wrk)) allocate(lv%wrk,stat=info) - if (info == 0) call lv%wrk%alloc(nwv,lv%base_desc,info,vmold=vmold) - - end subroutine d_base_onelev_allocate_wrk - - - subroutine d_base_onelev_free_wrk(lv,info) - use psb_base_mod - implicit none - class(mld_d_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: nwv,i - info = psb_success_ - - if (allocated(lv%wrk)) then - call lv%wrk%free(info) - if (info == 0) deallocate(lv%wrk,stat=info) - end if - end subroutine d_base_onelev_free_wrk - - subroutine d_wrk_alloc(wk,nwv,desc,info,vmold) - use psb_base_mod - - Implicit None - - ! Arguments - class(mld_dmlprec_wrk_type), target, intent(inout) :: wk - integer(psb_ipk_), intent(in) :: nwv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_vect_type), intent(in), optional :: vmold - ! - integer(psb_ipk_) :: i - - info = psb_success_ - call wk%free(info) - call psb_geasb(wk%vx2l,desc,info,& - & scratch=.true.,mold=vmold) - call psb_geasb(wk%vy2l,desc,info,& - & scratch=.true.,mold=vmold) - call psb_geasb(wk%vtx,desc,info,& - & scratch=.true.,mold=vmold) - call psb_geasb(wk%vty,desc,info,& - & scratch=.true.,mold=vmold) - allocate(wk%wv(nwv),stat=info) - do i=1,nwv - call psb_geasb(wk%wv(i),desc,info,& - & scratch=.true.,mold=vmold) - end do - - end subroutine d_wrk_alloc - - subroutine d_wrk_free(wk,info) - - Implicit None - - ! Arguments - class(mld_dmlprec_wrk_type), target, intent(inout) :: wk - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: i - info = psb_success_ - - if (allocated(wk%tx)) deallocate(wk%tx, stat=info) - if (allocated(wk%ty)) deallocate(wk%ty, stat=info) - if (allocated(wk%x2l)) deallocate(wk%x2l, stat=info) - if (allocated(wk%y2l)) deallocate(wk%y2l, stat=info) - call wk%vtx%free(info) - call wk%vty%free(info) - call wk%vx2l%free(info) - call wk%vy2l%free(info) - if (allocated(wk%wv)) then - do i=1,size(wk%wv) - call wk%wv(i)%free(info) - end do - deallocate(wk%wv, stat=info) - end if - - end subroutine d_wrk_free - - subroutine d_wrk_clone(wk,wkout,info) - use psb_base_mod - Implicit None - - ! Arguments - class(mld_dmlprec_wrk_type), target, intent(inout) :: wk - class(mld_dmlprec_wrk_type), target, intent(inout) :: wkout - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: i - info = psb_success_ - - call psb_safe_ab_cpy(wk%tx,wkout%tx,info) - call psb_safe_ab_cpy(wk%ty,wkout%ty,info) - call psb_safe_ab_cpy(wk%x2l,wkout%x2l,info) - call psb_safe_ab_cpy(wk%y2l,wkout%y2l,info) - call wk%vtx%clone(wkout%vtx,info) - call wk%vty%clone(wkout%vty,info) - call wk%vx2l%clone(wkout%vx2l,info) - call wk%vy2l%clone(wkout%vy2l,info) - if (allocated(wkout%wv)) then - do i=1,size(wkout%wv) - call wkout%wv(i)%free(info) - end do - deallocate( wkout%wv) - end if - allocate(wkout%wv(size(wk%wv)),stat=info) - do i=1,size(wk%wv) - call wk%wv(i)%clone(wkout%wv(i),info) - end do - return - - end subroutine d_wrk_clone - - subroutine d_wrk_move_alloc(wk, b,info) - implicit none - class(mld_dmlprec_wrk_type), target, intent(inout) :: wk, b - integer(psb_ipk_), intent(out) :: info - - call b%free(info) - call move_alloc(wk%tx,b%tx) - call move_alloc(wk%ty,b%ty) - call move_alloc(wk%x2l,b%x2l) - call move_alloc(wk%y2l,b%y2l) - ! - ! Should define V%move_alloc.... - call move_alloc(wk%vtx%v,b%vtx%v) - call move_alloc(wk%vty%v,b%vty%v) - call move_alloc(wk%vx2l%v,b%vx2l%v) - call move_alloc(wk%vy2l%v,b%vy2l%v) - call move_alloc(wk%wv,b%wv) - - end subroutine d_wrk_move_alloc - - subroutine d_wrk_cnv(wk,info,vmold) - use psb_base_mod - - Implicit None - - ! Arguments - class(mld_dmlprec_wrk_type), target, intent(inout) :: wk - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_vect_type), intent(in), optional :: vmold - ! - integer(psb_ipk_) :: i - - info = psb_success_ - if (present(vmold)) then - call wk%vtx%cnv(vmold) - call wk%vty%cnv(vmold) - call wk%vx2l%cnv(vmold) - call wk%vy2l%cnv(vmold) - if (allocated(wk%wv)) then - do i=1,size(wk%wv) - call wk%wv(i)%cnv(vmold) - end do - end if - end if - end subroutine d_wrk_cnv - - function d_wrk_sizeof(wk) result(val) - use psb_realloc_mod - implicit none - class(mld_dmlprec_wrk_type), intent(in) :: wk - integer(psb_epk_) :: val - integer :: i - val = 0 - val = val + (1_psb_epk_ * psb_sizeof_dp) * psb_size(wk%tx) - val = val + (1_psb_epk_ * psb_sizeof_dp) * psb_size(wk%ty) - val = val + (1_psb_epk_ * psb_sizeof_dp) * psb_size(wk%x2l) - val = val + (1_psb_epk_ * psb_sizeof_dp) * psb_size(wk%y2l) - val = val + wk%vtx%sizeof() - val = val + wk%vty%sizeof() - val = val + wk%vx2l%sizeof() - val = val + wk%vy2l%sizeof() - if (allocated(wk%wv)) then - do i=1, size(wk%wv) - val = val + wk%wv(i)%sizeof() - end do - end if - end function d_wrk_sizeof - -end module mld_d_onelev_mod diff --git a/mlprec/mld_d_prec_mod.f90 b/mlprec/mld_d_prec_mod.f90 deleted file mode 100644 index b5950be8..00000000 --- a/mlprec/mld_d_prec_mod.f90 +++ /dev/null @@ -1,139 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_d_prec_mod.f90 -! -! Module: mld_d_prec_mod -! -! This module defines the user interfaces to the real/complex, single/double -! precision versions of the user-level MLD2P4 routines. -! -module mld_d_prec_mod - - use mld_d_prec_type - use mld_d_jac_smoother - use mld_d_as_smoother - use mld_d_id_solver - use mld_d_diag_solver - use mld_d_l1_diag_solver - use mld_d_ilu_solver - use mld_d_gs_solver - - interface mld_precset - module procedure mld_d_iprecsetsm, mld_d_iprecsetsv, & - & mld_d_cprecseti, mld_d_cprecsetc, mld_d_cprecsetr, & - & mld_d_iprecsetag - end interface mld_precset - - interface mld_extprol_bld - subroutine mld_d_extprol_bld(a,desc_a,p,prolv,restrv,info,amold,vmold,imold) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & - & psb_d_base_sparse_mat, psb_d_base_vect_type, & - & psb_i_base_vect_type, mld_dprec_type, psb_ipk_ - - ! Arguments - type(psb_dspmat_type),intent(in), target :: a - type(psb_dspmat_type),intent(inout), target :: prolv(:) - type(psb_dspmat_type),intent(inout), target :: restrv(:) - type(psb_desc_type), intent(inout), target :: desc_a - type(mld_dprec_type),intent(inout),target :: p - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! !$ character, intent(in), optional :: upd - end subroutine mld_d_extprol_bld - end interface mld_extprol_bld - -contains - - subroutine mld_d_iprecsetsm(p,val,info,pos) - type(mld_dprec_type), intent(inout) :: p - class(mld_d_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - call p%set(val,info,pos=pos) - end subroutine mld_d_iprecsetsm - - subroutine mld_d_iprecsetsv(p,val,info,pos) - type(mld_dprec_type), intent(inout) :: p - class(mld_d_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - call p%set(val,info, pos=pos) - end subroutine mld_d_iprecsetsv - - subroutine mld_d_iprecsetag(p,val,info,pos) - type(mld_dprec_type), intent(inout) :: p - class(mld_d_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - call p%set(val,info, pos=pos) - end subroutine mld_d_iprecsetag - - subroutine mld_d_cprecseti(p,what,val,info,pos) - type(mld_dprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - call p%set(what,val,info,pos=pos) - end subroutine mld_d_cprecseti - - subroutine mld_d_cprecsetr(p,what,val,info,pos) - type(mld_dprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - call p%set(what,val,info,pos=pos) - end subroutine mld_d_cprecsetr - - subroutine mld_d_cprecsetc(p,what,val,info,pos) - type(mld_dprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - call p%set(what,val,info,pos=pos) - end subroutine mld_d_cprecsetc - -end module mld_d_prec_mod diff --git a/mlprec/mld_d_prec_type.f90 b/mlprec/mld_d_prec_type.f90 deleted file mode 100644 index b7e32109..00000000 --- a/mlprec/mld_d_prec_type.f90 +++ /dev/null @@ -1,964 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_d_prec_type.f90 -! -! Module: mld_d_prec_type -! -! This module defines: -! - the mld_d_prec_type data structure containing the preconditioner and related -! data structures; -! -! It contains routines for -! - Building and applying; -! - checking if the preconditioner is correctly defined; -! - printing a description of the preconditioner; -! - deallocating the preconditioner data structure. -! - -module mld_d_prec_type - - use mld_base_prec_type - use mld_d_base_solver_mod - use mld_d_base_smoother_mod - use mld_d_base_aggregator_mod - use mld_d_onelev_mod - use psb_base_mod, only : psb_erractionsave, psb_erractionrestore, psb_errstatus_fatal - use psb_prec_mod, only : psb_dprec_type - - ! - ! Type: mld_dprec_type. - ! - ! This is the data type containing all the information about the multilevel - ! preconditioner ('d', 's', 'c' and 'z', according to the real/complex, - ! single/double precision version of MLD2P4). - ! It consists of an array of 'one-level' intermediate data structures - ! of type mld_donelev_type, each containing the information needed to apply - ! the smoothing and the coarse-space correction at a generic level. RT is the - ! real data type, i.e. S for both S and C, and D for both D and Z. - ! - ! type mld_dprec_type - ! type(mld_donelev_type), allocatable :: precv(:) - ! end type mld_dprec_type - ! - ! Note that the levels are numbered in increasing order starting from - ! the level 1 as the finest one, and the number of levels is given by - ! size(precv(:)) which is the id of the coarsest level. - ! In the multigrid literature many authors number the levels in the opposite - ! order, with level 0 being the id of the coarsest level. - ! - ! - integer, parameter, private :: wv_size_=4 - - type, extends(psb_dprec_type) :: mld_dprec_type - ! integer(psb_ipk_) :: ictxt ! Now it's in the PSBLAS prec. - type(mld_daggr_data) :: ag_data - ! - ! Number of outer sweeps. Sometimes 2 V-cycles may be better than 1 W-cycle. - ! - integer(psb_ipk_) :: outer_sweeps = 1 - ! - ! Coarse solver requires some tricky checks, and for this we need to - ! record the choice in the format given by the user, - ! to keep track against what is put later in the multilevel array - ! - integer(psb_ipk_) :: coarse_solver = -1 - - ! - ! The multilevel hierarchy - ! - type(mld_d_onelev_type), allocatable :: precv(:) - contains - procedure, pass(prec) :: psb_d_apply2_vect => mld_d_apply2_vect - procedure, pass(prec) :: psb_d_apply1_vect => mld_d_apply1_vect - procedure, pass(prec) :: psb_d_apply2v => mld_d_apply2v - procedure, pass(prec) :: psb_d_apply1v => mld_d_apply1v - procedure, pass(prec) :: dump => mld_d_dump - procedure, pass(prec) :: cnv => mld_d_cnv - procedure, pass(prec) :: clone => mld_d_clone - procedure, pass(prec) :: free => mld_d_prec_free - procedure, pass(prec) :: allocate_wrk => mld_d_allocate_wrk - procedure, pass(prec) :: free_wrk => mld_d_free_wrk - procedure, pass(prec) :: is_allocated_wrk => mld_d_is_allocated_wrk - procedure, pass(prec) :: get_complexity => mld_d_get_compl - procedure, pass(prec) :: cmp_complexity => mld_d_cmp_compl - procedure, pass(prec) :: get_avg_cr => mld_d_get_avg_cr - procedure, pass(prec) :: cmp_avg_cr => mld_d_cmp_avg_cr - procedure, pass(prec) :: get_nlevs => mld_d_get_nlevs - procedure, pass(prec) :: get_nzeros => mld_d_get_nzeros - procedure, pass(prec) :: sizeof => mld_dprec_sizeof - procedure, pass(prec) :: setsm => mld_dprecsetsm - procedure, pass(prec) :: setsv => mld_dprecsetsv - procedure, pass(prec) :: setag => mld_dprecsetag - procedure, pass(prec) :: cseti => mld_dcprecseti - procedure, pass(prec) :: csetc => mld_dcprecsetc - procedure, pass(prec) :: csetr => mld_dcprecsetr - generic, public :: set => cseti, csetc, csetr, setsm, setsv, setag - procedure, pass(prec) :: get_smoother => mld_d_get_smootherp - procedure, pass(prec) :: get_solver => mld_d_get_solverp - procedure, pass(prec) :: move_alloc => d_prec_move_alloc - procedure, pass(prec) :: init => mld_dprecinit - procedure, pass(prec) :: build => mld_dprecbld - procedure, pass(prec) :: hierarchy_build => mld_d_hierarchy_bld - procedure, pass(prec) :: smoothers_build => mld_d_smoothers_bld - procedure, pass(prec) :: descr => mld_dfile_prec_descr - end type mld_dprec_type - - private :: mld_d_dump, mld_d_get_compl, mld_d_cmp_compl,& - & mld_d_get_avg_cr, mld_d_cmp_avg_cr,& - & mld_d_get_nzeros, mld_d_get_nlevs, d_prec_move_alloc - - - ! - ! Interfaces to routines for checking the definition of the preconditioner, - ! for printing its description and for deallocating its data structure - ! - - interface mld_precfree - module procedure mld_dprecfree - end interface - - - interface mld_precdescr - subroutine mld_dfile_prec_descr(prec,iout,root) - import :: mld_dprec_type, psb_ipk_ - implicit none - ! Arguments - class(mld_dprec_type), intent(in) :: prec - integer(psb_ipk_), intent(in), optional :: iout - integer(psb_ipk_), intent(in), optional :: root - end subroutine mld_dfile_prec_descr - end interface - - interface mld_sizeof - module procedure mld_dprec_sizeof - end interface - - interface mld_precapply - subroutine mld_dprecaply2_vect(prec,x,y,desc_data,info,trans,work) - import :: psb_dspmat_type, psb_desc_type, & - & psb_dpk_, psb_d_vect_type, mld_dprec_type, psb_ipk_ - type(psb_desc_type),intent(in) :: desc_data - type(mld_dprec_type), intent(inout) :: prec - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_dpk_),intent(inout), optional, target :: work(:) - end subroutine mld_dprecaply2_vect - subroutine mld_dprecaply1_vect(prec,x,desc_data,info,trans,work) - import :: psb_dspmat_type, psb_desc_type, & - & psb_dpk_, psb_d_vect_type, mld_dprec_type, psb_ipk_ - type(psb_desc_type),intent(in) :: desc_data - type(mld_dprec_type), intent(inout) :: prec - type(psb_d_vect_type),intent(inout) :: x - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_dpk_),intent(inout), optional, target :: work(:) - end subroutine mld_dprecaply1_vect - subroutine mld_dprecaply(prec,x,y,desc_data,info,trans,work) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, mld_dprec_type, psb_ipk_ - type(psb_desc_type),intent(in) :: desc_data - type(mld_dprec_type), intent(inout) :: prec - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_dpk_),intent(inout), optional, target :: work(:) - end subroutine mld_dprecaply - subroutine mld_dprecaply1(prec,x,desc_data,info,trans) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, mld_dprec_type, psb_ipk_ - type(psb_desc_type),intent(in) :: desc_data - type(mld_dprec_type), intent(inout) :: prec - real(psb_dpk_),intent(inout) :: x(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - end subroutine mld_dprecaply1 - end interface - - interface - subroutine mld_dprecsetsm(prec,val,info,ilev,ilmax,pos) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & - & mld_dprec_type, mld_d_base_smoother_type, psb_ipk_ - class(mld_dprec_type), target, intent(inout):: prec - class(mld_d_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - end subroutine mld_dprecsetsm - subroutine mld_dprecsetsv(prec,val,info,ilev,ilmax,pos) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & - & mld_dprec_type, mld_d_base_solver_type, psb_ipk_ - class(mld_dprec_type), intent(inout) :: prec - class(mld_d_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - end subroutine mld_dprecsetsv - subroutine mld_dprecsetag(prec,val,info,ilev,ilmax,pos) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & - & mld_dprec_type, mld_d_base_aggregator_type, psb_ipk_ - class(mld_dprec_type), intent(inout) :: prec - class(mld_d_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - end subroutine mld_dprecsetag - subroutine mld_dcprecseti(prec,what,val,info,ilev,ilmax,pos,idx) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & - & mld_dprec_type, psb_ipk_ - class(mld_dprec_type), intent(inout) :: prec - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx - character(len=*), optional, intent(in) :: pos - end subroutine mld_dcprecseti - subroutine mld_dcprecsetr(prec,what,val,info,ilev,ilmax,pos,idx) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & - & mld_dprec_type, psb_ipk_ - class(mld_dprec_type), intent(inout) :: prec - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx - character(len=*), optional, intent(in) :: pos - end subroutine mld_dcprecsetr - subroutine mld_dcprecsetc(prec,what,string,info,ilev,ilmax,pos,idx) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & - & mld_dprec_type, psb_ipk_ - class(mld_dprec_type), intent(inout) :: prec - character(len=*), intent(in) :: what - character(len=*), intent(in) :: string - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx - character(len=*), optional, intent(in) :: pos - end subroutine mld_dcprecsetc - end interface - - interface mld_precinit - subroutine mld_dprecinit(ictxt,prec,ptype,info) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & - & mld_dprec_type, psb_ipk_ - integer(psb_ipk_), intent(in) :: ictxt - class(mld_dprec_type), intent(inout) :: prec - character(len=*), intent(in) :: ptype - integer(psb_ipk_), intent(out) :: info - end subroutine mld_dprecinit - end interface mld_precinit - - interface mld_precbld - subroutine mld_dprecbld(a,desc_a,prec,info,amold,vmold,imold) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & - & psb_d_base_sparse_mat, psb_d_base_vect_type, & - & psb_i_base_vect_type, mld_dprec_type, psb_ipk_ - implicit none - type(psb_dspmat_type), intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_dprec_type), intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! character, intent(in),optional :: upd - end subroutine mld_dprecbld - end interface mld_precbld - - interface mld_hierarchy_bld - subroutine mld_d_hierarchy_bld(a,desc_a,prec,info) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & - & mld_dprec_type, psb_ipk_ - implicit none - type(psb_dspmat_type), intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_dprec_type), intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - ! character, intent(in),optional :: upd - end subroutine mld_d_hierarchy_bld - end interface mld_hierarchy_bld - - interface mld_smoothers_bld - subroutine mld_d_smoothers_bld(a,desc_a,prec,info,amold,vmold,imold) - import :: psb_dspmat_type, psb_desc_type, psb_dpk_, & - & psb_d_base_sparse_mat, psb_d_base_vect_type, & - & psb_i_base_vect_type, mld_dprec_type, psb_ipk_ - implicit none - type(psb_dspmat_type), intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_dprec_type), intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! character, intent(in),optional :: upd - end subroutine mld_d_smoothers_bld - end interface mld_smoothers_bld - -contains - ! - ! Function returning a pointer to the smoother - ! - function mld_d_get_smootherp(prec,ilev) result(val) - implicit none - class(mld_dprec_type), target, intent(in) :: prec - integer(psb_ipk_), optional :: ilev - class(mld_d_base_smoother_type), pointer :: val - integer(psb_ipk_) :: ilev_ - - val => null() - if (present(ilev)) then - ilev_ = ilev - else - ! What is a good default? - ilev_ = 1 - end if - if (allocated(prec%precv)) then - if ((1<=ilev_).and.(ilev_<=size(prec%precv))) then - if (allocated(prec%precv(ilev_)%sm)) then - val => prec%precv(ilev_)%sm - end if - end if - end if - end function mld_d_get_smootherp - ! - ! Function returning a pointer to the solver - ! - function mld_d_get_solverp(prec,ilev) result(val) - implicit none - class(mld_dprec_type), target, intent(in) :: prec - integer(psb_ipk_), optional :: ilev - class(mld_d_base_solver_type), pointer :: val - integer(psb_ipk_) :: ilev_ - - val => null() - if (present(ilev)) then - ilev_ = ilev - else - ! What is a good default? - ilev_ = 1 - end if - if (allocated(prec%precv)) then - if ((1<=ilev_).and.(ilev_<=size(prec%precv))) then - if (allocated(prec%precv(ilev_)%sm)) then - if (allocated(prec%precv(ilev_)%sm%sv)) then - val => prec%precv(ilev_)%sm%sv - end if - end if - end if - end if - end function mld_d_get_solverp - ! - ! Function returning the size of the precv(:) array - ! - function mld_d_get_nlevs(prec) result(val) - implicit none - class(mld_dprec_type), intent(in) :: prec - integer(psb_ipk_) :: val - val = 0 - if (allocated(prec%precv)) then - val = size(prec%precv) - end if - end function mld_d_get_nlevs - ! - ! Function returning the size of the mld_prec_type data structure - ! in bytes or in number of nonzeros of the operator(s) involved. - ! - function mld_d_get_nzeros(prec) result(val) - implicit none - class(mld_dprec_type), intent(in) :: prec - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - if (allocated(prec%precv)) then - do i=1, size(prec%precv) - val = val + prec%precv(i)%get_nzeros() - end do - end if - end function mld_d_get_nzeros - - function mld_dprec_sizeof(prec) result(val) - implicit none - class(mld_dprec_type), intent(in) :: prec - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - val = val + psb_sizeof_ip - if (allocated(prec%precv)) then - do i=1, size(prec%precv) - val = val + prec%precv(i)%sizeof() - end do - end if - end function mld_dprec_sizeof - - ! - ! Operator complexity: ratio of total number - ! of nonzeros in the aggregated matrices at the - ! various level to the nonzeroes at the fine level - ! (original matrix) - ! - - function mld_d_get_compl(prec) result(val) - implicit none - class(mld_dprec_type), intent(in) :: prec - real(psb_dpk_) :: val - - val = prec%ag_data%op_complexity - - end function mld_d_get_compl - - subroutine mld_d_cmp_compl(prec) - - implicit none - class(mld_dprec_type), intent(inout) :: prec - - real(psb_dpk_) :: num, den, nmin - integer(psb_ipk_) :: ictxt - integer(psb_ipk_) :: il - - num = -done - den = done - ictxt = prec%ictxt - if (allocated(prec%precv)) then - il = 1 - num = prec%precv(il)%base_a%get_nzeros() - if (num >= dzero) then - den = num - do il=2,size(prec%precv) - num = num + max(0,prec%precv(il)%base_a%get_nzeros()) - end do - end if - end if - nmin = num - call psb_min(ictxt,nmin) - if (nmin < dzero) then - num = dzero - den = done - else - call psb_sum(ictxt,num) - call psb_sum(ictxt,den) - end if - prec%ag_data%op_complexity = num/den - end subroutine mld_d_cmp_compl - - ! - ! Average coarsening ratio - ! - - function mld_d_get_avg_cr(prec) result(val) - implicit none - class(mld_dprec_type), intent(in) :: prec - real(psb_dpk_) :: val - - val = prec%ag_data%avg_cr - - end function mld_d_get_avg_cr - - subroutine mld_d_cmp_avg_cr(prec) - - implicit none - class(mld_dprec_type), intent(inout) :: prec - - real(psb_dpk_) :: avgcr - integer(psb_ipk_) :: ictxt - integer(psb_ipk_) :: il, nl, iam, np - - - avgcr = dzero - ictxt = prec%ictxt - call psb_info(ictxt,iam,np) - if (allocated(prec%precv)) then - nl = size(prec%precv) - do il=2,nl - avgcr = avgcr + max(dzero,prec%precv(il)%szratio) - end do - avgcr = avgcr / (nl-1) - end if - call psb_sum(ictxt,avgcr) - prec%ag_data%avg_cr = avgcr/np - end subroutine mld_d_cmp_avg_cr - - ! - ! Subroutines: mld_Tprec_free - ! Version: real - ! - ! These routines deallocate the mld_Tprec_type data structures. - ! - ! Arguments: - ! p - type(mld_Tprec_type), input. - ! The data structure to be deallocated. - ! info - integer, output. - ! error code. - ! - subroutine mld_dprecfree(p,info) - - implicit none - - ! Arguments - type(mld_dprec_type), intent(inout) :: p - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: me,err_act,i - character(len=20) :: name - - info=psb_success_ - name = 'mld_dprecfree' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; return - end if - - me=-1 - - call p%free(info) - - - return - - end subroutine mld_dprecfree - - subroutine mld_d_prec_free(prec,info) - - implicit none - - ! Arguments - class(mld_dprec_type), intent(inout) :: prec - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: me,err_act,i - character(len=20) :: name - - info=psb_success_ - name = 'mld_dprecfree' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - - me=-1 - if (allocated(prec%precv)) then - do i=1,size(prec%precv) - call prec%precv(i)%free(info) - end do - deallocate(prec%precv,stat=info) - end if - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_d_prec_free - - - - ! - ! Top level methods. - ! - subroutine mld_d_apply2_vect(prec,x,y,desc_data,info,trans,work) - implicit none - type(psb_desc_type),intent(in) :: desc_data - class(mld_dprec_type), intent(inout) :: prec - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_dpk_),intent(inout), optional, target :: work(:) - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_prec_apply' - - call psb_erractionsave(err_act) - - select type(prec) - type is (mld_dprec_type) - call mld_precapply(prec,x,y,desc_data,info,trans,work) - class default - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_d_apply2_vect - - subroutine mld_d_apply1_vect(prec,x,desc_data,info,trans,work) - implicit none - type(psb_desc_type),intent(in) :: desc_data - class(mld_dprec_type), intent(inout) :: prec - type(psb_d_vect_type),intent(inout) :: x - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_dpk_),intent(inout), optional, target :: work(:) - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_prec_apply' - - call psb_erractionsave(err_act) - - select type(prec) - type is (mld_dprec_type) - call mld_precapply(prec,x,desc_data,info,trans,work) - class default - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_d_apply1_vect - - - subroutine mld_d_apply2v(prec,x,y,desc_data,info,trans,work) - implicit none - type(psb_desc_type),intent(in) :: desc_data - class(mld_dprec_type), intent(inout) :: prec - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_dpk_),intent(inout), optional, target :: work(:) - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_prec_apply' - - call psb_erractionsave(err_act) - - select type(prec) - type is (mld_dprec_type) - call mld_precapply(prec,x,y,desc_data,info,trans,work) - class default - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_d_apply2v - - subroutine mld_d_apply1v(prec,x,desc_data,info,trans) - implicit none - type(psb_desc_type),intent(in) :: desc_data - class(mld_dprec_type), intent(inout) :: prec - real(psb_dpk_),intent(inout) :: x(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_prec_apply' - - call psb_erractionsave(err_act) - - select type(prec) - type is (mld_dprec_type) - call mld_precapply(prec,x,desc_data,info,trans) - class default - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_d_apply1v - - - subroutine mld_d_dump(prec,info,istart,iend,iproc,prefix,head,& - & ac,rp,smoother,solver,tprol,& - & global_num) - - implicit none - class(mld_dprec_type), intent(in) :: prec - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: istart, iend, iproc - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver,ac, rp, tprol, global_num - integer(psb_ipk_) :: i, j, il1, iln, lev - integer(psb_ipk_) :: icontxt, iam, np, iproc_ - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - ! len of prefix_ - - info = 0 - icontxt = prec%ictxt - call psb_info(icontxt,iam,np) - - iln = size(prec%precv) - if (present(istart)) then - il1 = max(1,istart) - else - il1 = min(2,iln) - end if - if (present(iend)) then - iln = min(iln, iend) - end if - iproc_ = -1 - if (present(iproc)) then - iproc_ = iproc - end if - - if ((iproc_ == -1).or.(iproc_==iam)) then - do lev=il1, iln - call prec%precv(lev)%dump(lev,info,prefix=prefix,head=head,& - & ac=ac,smoother=smoother,solver=solver,rp=rp,tprol=tprol, & - & global_num=global_num) - end do - end if - end subroutine mld_d_dump - - subroutine mld_d_cnv(prec,info,amold,vmold,imold) - - implicit none - class(mld_dprec_type), intent(inout) :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - integer(psb_ipk_) :: i - - info = psb_success_ - if (allocated(prec%precv)) then - do i=1,size(prec%precv) - if (info == psb_success_ ) & - & call prec%precv(i)%cnv(info,amold=amold,vmold=vmold,imold=imold) - end do - end if - - end subroutine mld_d_cnv - - subroutine mld_d_clone(prec,precout,info) - - implicit none - class(mld_dprec_type), intent(inout) :: prec - class(psb_dprec_type), intent(inout) :: precout - integer(psb_ipk_), intent(out) :: info - - call precout%free(info) - if (info == 0) call mld_d_inner_clone(prec,precout,info) - - end subroutine mld_d_clone - - subroutine mld_d_inner_clone(prec,precout,info) - - implicit none - class(mld_dprec_type), intent(inout) :: prec - class(psb_dprec_type), target, intent(inout) :: precout - integer(psb_ipk_), intent(out) :: info - ! Local vars - integer(psb_ipk_) :: i, j, ln, lev - integer(psb_ipk_) :: icontxt,iam, np - - info = psb_success_ - select type(pout => precout) - class is (mld_dprec_type) - pout%ictxt = prec%ictxt - pout%ag_data = prec%ag_data - pout%outer_sweeps = prec%outer_sweeps - if (allocated(prec%precv)) then - ln = size(prec%precv) - allocate(pout%precv(ln),stat=info) - if (info /= psb_success_) goto 9999 - if (ln >= 1) then - call prec%precv(1)%clone(pout%precv(1),info) - end if - do lev=2, ln - if (info /= psb_success_) exit - call prec%precv(lev)%clone(pout%precv(lev),info) - if (info == psb_success_) then - pout%precv(lev)%base_a => pout%precv(lev)%ac - pout%precv(lev)%base_desc => pout%precv(lev)%desc_ac - pout%precv(lev)%map%p_desc_U => pout%precv(lev-1)%base_desc - pout%precv(lev)%map%p_desc_V => pout%precv(lev)%base_desc - end if - end do - end if - if (allocated(prec%precv(1)%wrk)) & - & call pout%allocate_wrk(info,vmold=prec%precv(1)%wrk%vx2l%v) - - class default - write(0,*) 'Error: wrong out type' - info = psb_err_invalid_input_ - end select -9999 continue - end subroutine mld_d_inner_clone - - subroutine d_prec_move_alloc(prec, b,info) - use psb_base_mod - implicit none - class(mld_dprec_type), intent(inout) :: prec - class(mld_dprec_type), intent(inout), target :: b - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: i - - if (same_type_as(prec,b)) then - if (allocated(b%precv)) then - ! This might not be required if FINAL procedures are available. - call b%free(info) - if (info /= psb_success_) then - !????? -!!$ return - endif - end if - b%ictxt = prec%ictxt - b%ag_data = prec%ag_data - b%outer_sweeps = prec%outer_sweeps - - call move_alloc(prec%precv,b%precv) - ! Fix the pointers except on level 1. - do i=2, size(b%precv) - b%precv(i)%base_a => b%precv(i)%ac - b%precv(i)%base_desc => b%precv(i)%desc_ac - b%precv(i)%map%p_desc_U => b%precv(i-1)%base_desc - b%precv(i)%map%p_desc_V => b%precv(i)%base_desc - end do - - else - write(0,*) 'Warning: PREC%move_alloc onto different type?' - info = psb_err_internal_error_ - end if - end subroutine d_prec_move_alloc - - subroutine mld_d_allocate_wrk(prec,info,vmold,desc) - use psb_base_mod - implicit none - - ! Arguments - class(mld_dprec_type), intent(inout) :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_d_base_vect_type), intent(in), optional :: vmold - ! - ! In MLD the DESC optional argument is ignored, since - ! the necessary info is contained in the various entries of the - ! PRECV component. - type(psb_desc_type), intent(in), optional :: desc - - ! Local variables - integer(psb_ipk_) :: me,err_act,i,j,level,nlev, nc2l - character(len=20) :: name - - info=psb_success_ - name = 'mld_d_allocate_wrk' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - nlev = size(prec%precv) - level = 1 - do level = 1, nlev - call prec%precv(level)%allocate_wrk(info,vmold=vmold) - if (psb_errstatus_fatal()) then - nc2l = prec%precv(level)%base_desc%get_local_cols() - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nc2l/), a_err='real(psb_dpk_)') - goto 9999 - end if - end do - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_d_allocate_wrk - - subroutine mld_d_free_wrk(prec,info) - use psb_base_mod - implicit none - - ! Arguments - class(mld_dprec_type), intent(inout) :: prec - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: me,err_act,i,j,level, nlev, nc2l - character(len=20) :: name - - info=psb_success_ - name = 'mld_d_free_wrk' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - - if (allocated(prec%precv)) then - nlev = size(prec%precv) - do level = 1, nlev - call prec%precv(level)%free_wrk(info) - end do - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_d_free_wrk - - function mld_d_is_allocated_wrk(prec) result(res) - use psb_base_mod - implicit none - - ! Arguments - class(mld_dprec_type), intent(in) :: prec - logical :: res - - res = .false. - if (.not.allocated(prec%precv)) return - res = allocated(prec%precv(1)%wrk) - - end function mld_d_is_allocated_wrk - -end module mld_d_prec_type diff --git a/mlprec/mld_d_slu_solver.F90 b/mlprec/mld_d_slu_solver.F90 deleted file mode 100644 index 89dbc94b..00000000 --- a/mlprec/mld_d_slu_solver.F90 +++ /dev/null @@ -1,447 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_d_slu_solver_mod.f90 -! -! Module: mld_d_slu_solver_mod -! -! This module defines: -! - the mld_d_slu_solver_type data structure containing the ingredients -! to interface with the SuperLU package. -! 1. The factorization is restricted to the diagonal block of the -! current image. -! -module mld_d_slu_solver - - use iso_c_binding - use mld_d_base_solver_mod - -#if defined(IPK8) - - type, extends(mld_d_base_solver_type) :: mld_d_slu_solver_type - - end type mld_d_slu_solver_type - -#else - - type, extends(mld_d_base_solver_type) :: mld_d_slu_solver_type - type(c_ptr) :: lufactors=c_null_ptr - integer(c_long_long) :: symbsize=0, numsize=0 - contains - procedure, pass(sv) :: build => d_slu_solver_bld - procedure, pass(sv) :: apply_a => d_slu_solver_apply - procedure, pass(sv) :: apply_v => d_slu_solver_apply_vect - procedure, pass(sv) :: free => d_slu_solver_free - procedure, pass(sv) :: clear_data => d_slu_solver_clear_data - procedure, pass(sv) :: descr => d_slu_solver_descr - procedure, pass(sv) :: sizeof => d_slu_solver_sizeof - procedure, nopass :: get_fmt => d_slu_solver_get_fmt - procedure, nopass :: get_id => d_slu_solver_get_id - final :: d_slu_solver_finalize - end type mld_d_slu_solver_type - - - private :: d_slu_solver_bld, d_slu_solver_apply, & - & d_slu_solver_free, d_slu_solver_descr, & - & d_slu_solver_sizeof, d_slu_solver_apply_vect, & - & d_slu_solver_get_fmt, d_slu_solver_get_id, & - & d_slu_solver_clear_data - private :: d_slu_solver_finalize - - - - interface - function mld_dslu_fact(n,nnz,values,rowptr,colind,& - & lufactors)& - & bind(c,name='mld_dslu_fact') result(info) - use iso_c_binding - integer(c_int), value :: n,nnz - integer(c_int) :: info - integer(c_int) :: rowptr(*),colind(*) - real(c_double) :: values(*) - type(c_ptr) :: lufactors - end function mld_dslu_fact - end interface - - interface - function mld_dslu_solve(itrans,n,nrhs,b,ldb,lufactors)& - & bind(c,name='mld_dslu_solve') result(info) - use iso_c_binding - integer(c_int) :: info - integer(c_int), value :: itrans,n,nrhs,ldb - real(c_double) :: b(ldb,*) - type(c_ptr), value :: lufactors - end function mld_dslu_solve - end interface - - interface - function mld_dslu_free(lufactors)& - & bind(c,name='mld_dslu_free') result(info) - use iso_c_binding - integer(c_int) :: info - type(c_ptr), value :: lufactors - end function mld_dslu_free - end interface - -contains - - subroutine d_slu_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - use psb_base_mod - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_slu_solver_type), intent(inout) :: sv - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer, intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - - integer :: n_row,n_col - real(psb_dpk_), pointer :: ww(:) - integer :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='d_slu_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - else - allocate(ww(n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/n_col,0,0,0,0/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - endif - - ww(1:n_row) = x(1:n_row) - select case(trans_) - case('N') - info = mld_dslu_solve(0,n_row,1,ww,n_row,sv%lufactors) - case('T') - info = mld_dslu_solve(1,n_row,1,ww,n_row,sv%lufactors) - case('C') - info = mld_dslu_solve(2,n_row,1,ww,n_row,sv%lufactors) - case default - call psb_errpush(psb_err_internal_error_, & - & name,a_err='Invalid TRANS in ILU subsolve') - goto 9999 - end select - - if (info == psb_success_) & - & call psb_geaxpby(alpha,ww,beta,y,desc_data,info) - - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in subsolve') - goto 9999 - endif - - if (n_col > size(work)) then - deallocate(ww) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine d_slu_solver_apply - - subroutine d_slu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - use psb_base_mod - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_slu_solver_type), intent(inout) :: sv - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer, intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - - integer :: err_act - character(len=20) :: name='d_slu_solver_apply_vect' - - call psb_erractionsave(err_act) - - info = psb_success_ - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call x%v%sync() - call y%v%sync() - call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) - call y%v%set_host() - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine d_slu_solver_apply_vect - - subroutine d_slu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - - Implicit None - - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_slu_solver_type), intent(inout) :: sv - integer, intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - type(psb_dspmat_type) :: atmp - type(psb_d_csc_sparse_mat) :: acsc - type(psb_d_coo_sparse_mat) :: acoo - integer :: n_row,n_col, nrow_a, nztota - integer :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_slu_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - n_col = desc_a%get_local_cols() - - - call a%cscnv(atmp,info,type='coo') - call psb_rwextd(n_row,atmp,info,b=b) - call atmp%cscnv(info,type='coo',dupl=psb_dupl_add_) - nrow_a = atmp%get_nrows() - call atmp%a%csclip(acoo,info,jmax=nrow_a) - call acsc%mv_from_coo(acoo,info) - nztota = acsc%get_nzeros() - ! Fix the entries to call C-base SuperLU - acsc%ia(:) = acsc%ia(:) - 1 - acsc%icp(:) = acsc%icp(:) - 1 - info = mld_dslu_fact(nrow_a,nztota,acsc%val,& - & acsc%icp,acsc%ia,sv%lufactors) - - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='mld_dslu_fact' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - call acsc%free() - call atmp%free() - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_slu_solver_bld - - subroutine d_slu_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_d_slu_solver_type), intent(inout) :: sv - integer, intent(out) :: info - Integer :: err_act - character(len=20) :: name='d_slu_solver_free' - - call psb_erractionsave(err_act) - - info = psb_success_ - - call sv%clear_data(info) - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_slu_solver_free - - subroutine d_slu_solver_clear_data(sv,info) - - Implicit None - - ! Arguments - class(mld_d_slu_solver_type), intent(inout) :: sv - integer, intent(out) :: info - Integer :: err_act - character(len=20) :: name='d_slu_solver_clear_data' - - call psb_erractionsave(err_act) - - info = psb_success_ - if (c_associated(sv%lufactors)) info = mld_dslu_free(sv%lufactors) - sv%lufactors = c_null_ptr - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_slu_solver_clear_data - - subroutine d_slu_solver_finalize(sv) - - Implicit None - - ! Arguments - type(mld_d_slu_solver_type), intent(inout) :: sv - integer :: info - Integer :: err_act - character(len=20) :: name='d_slu_solver_finalize' - - call sv%free(info) - - return - - end subroutine d_slu_solver_finalize - - subroutine d_slu_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_d_slu_solver_type), intent(in) :: sv - integer, intent(out) :: info - integer, intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer :: err_act - integer :: ictxt, me, np - character(len=20), parameter :: name='mld_d_slu_solver_descr' - integer :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' SuperLU Sparse Factorization Solver. ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_slu_solver_descr - - function d_slu_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_d_slu_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer :: i - - val = 2*psb_sizeof_ip + psb_sizeof_dp - val = val + sv%symbsize - val = val + sv%numsize - return - end function d_slu_solver_sizeof - - function d_slu_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "SuperLU solver" - end function d_slu_solver_get_fmt - - function d_slu_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_slu_ - end function d_slu_solver_get_id -#endif -end module mld_d_slu_solver diff --git a/mlprec/mld_d_sludist_solver.F90 b/mlprec/mld_d_sludist_solver.F90 deleted file mode 100644 index 89f7ca97..00000000 --- a/mlprec/mld_d_sludist_solver.F90 +++ /dev/null @@ -1,465 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_d_sludist_solver_mod.f90 -! -! Module: mld_d_sludist_solver_mod -! -! This module defines: -! - the mld_d_sludist_solver_type data structure containing the ingredients -! to interface with the SuperLU_Dist package. -! 1. The factorization is distributed (and thus exact) -! -! -! -module mld_d_sludist_solver - - use iso_c_binding - use mld_d_base_solver_mod - -#if defined(LPK8) - - type, extends(mld_d_base_solver_type) :: mld_d_sludist_solver_type - - end type mld_d_sludist_solver_type -#else - type, extends(mld_d_base_solver_type) :: mld_d_sludist_solver_type - type(c_ptr) :: lufactors=c_null_ptr - integer(c_long_long) :: symbsize=0, numsize=0 - contains - procedure, pass(sv) :: build => d_sludist_solver_bld - procedure, pass(sv) :: apply_a => d_sludist_solver_apply - procedure, pass(sv) :: apply_v => d_sludist_solver_apply_vect - procedure, pass(sv) :: free => d_sludist_solver_free - procedure, pass(sv) :: clear_data => d_sludist_solver_clear_data - procedure, pass(sv) :: descr => d_sludist_solver_descr - procedure, pass(sv) :: sizeof => d_sludist_solver_sizeof - procedure, nopass :: get_fmt => d_sludist_solver_get_fmt - procedure, nopass :: get_id => d_sludist_solver_get_id - procedure, pass(sv) :: is_global => d_sludist_solver_is_global - final :: d_sludist_solver_finalize - end type mld_d_sludist_solver_type - - - private :: d_sludist_solver_bld, d_sludist_solver_apply, & - & d_sludist_solver_free, d_sludist_solver_descr, & - & d_sludist_solver_sizeof, d_sludist_solver_apply_vect, & - & d_sludist_solver_get_fmt, d_sludist_solver_get_id, & - & d_sludist_solver_is_global, d_sludist_solver_clear_data - private :: d_sludist_solver_finalize - - - interface - function mld_dsludist_fact(n,nl,nnz,ifrst, & - & values,rowptr,colind,lufactors,npr,npc) & - & bind(c,name='mld_dsludist_fact') result(info) - use iso_c_binding - integer(c_int), value :: n,nl,nnz,ifrst,npr,npc - integer(c_int) :: info - integer(c_int) :: rowptr(*),colind(*) - real(c_double) :: values(*) - type(c_ptr) :: lufactors - end function mld_dsludist_fact - end interface - - interface - function mld_dsludist_solve(itrans,n,nrhs, b, ldb, lufactors)& - & bind(c,name='mld_dsludist_solve') result(info) - use iso_c_binding - integer(c_int) :: info - integer(c_int), value :: itrans,n,nrhs,ldb - real(c_double) :: b(ldb,*) - type(c_ptr), value :: lufactors - end function mld_dsludist_solve - end interface - - interface - function mld_dsludist_free(lufactors)& - & bind(c,name='mld_dsludist_free') result(info) - use iso_c_binding - integer(c_int) :: info - type(c_ptr), value :: lufactors - end function mld_dsludist_free - end interface - -contains - - subroutine d_sludist_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - use psb_base_mod - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_sludist_solver_type), intent(inout) :: sv - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer, intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - - integer :: n_row,n_col - real(psb_dpk_), pointer :: ww(:) - integer :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='d_sludist_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - else - allocate(ww(n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/n_col/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - endif - - if (info == psb_success_)& - & call psb_geaxpby(done,x,dzero,ww,desc_data,info) - - select case(trans_) - case('N') - info = mld_dsludist_solve(0,n_row,1,ww,n_row,sv%lufactors) - case('T') - info = mld_dsludist_solve(1,n_row,1,ww,n_row,sv%lufactors) - case('C') - info = mld_dsludist_solve(2,n_row,1,ww,n_row,sv%lufactors) - case default - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Invalid TRANS in subsolve') - goto 9999 - end select - - if (info == psb_success_)& - & call psb_geaxpby(alpha,ww,beta,y,desc_data,info) - - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in subsolve') - goto 9999 - endif - - if (n_col > size(work)) then - deallocate(ww) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine d_sludist_solver_apply - - subroutine d_sludist_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - use psb_base_mod - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_sludist_solver_type), intent(inout) :: sv - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer, intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - - integer :: err_act - character(len=20) :: name='d_sludist_solver_apply_vect' - - call psb_erractionsave(err_act) - - info = psb_success_ - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - - call x%v%sync() - call y%v%sync() - call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) - call y%v%set_host() - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine d_sludist_solver_apply_vect - - subroutine d_sludist_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - - Implicit None - - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_sludist_solver_type), intent(inout) :: sv - integer, intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - type(psb_dspmat_type) :: atmp - type(psb_d_csr_sparse_mat) :: acsr - integer :: n_row,n_col, nrow_a, nztota, nglob, nzt, npr, npc - integer :: ifrst, ibcheck - integer :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_sludist_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - npr = np - npc = 1 - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - - n_row = desc_a%get_local_rows() - n_col = desc_a%get_local_cols() - nglob = desc_a%get_global_rows() - - call a%cscnv(atmp,info,type='coo') - call psb_rwextd(n_row,atmp,info,b=b) - call atmp%cscnv(info,type='csr',dupl=psb_dupl_add_) - call atmp%mv_to(acsr) - nrow_a = acsr%get_nrows() - nztota = acsr%get_nzeros() - ! Fix the entries to call C-base SuperLU - call psb_loc_to_glob(1,ifrst,desc_a,info) - call psb_loc_to_glob(nrow_a,ibcheck,desc_a,info) - call psb_loc_to_glob(acsr%ja(1:nztota),desc_a,info,iact='I') - acsr%ja(:) = acsr%ja(:) - 1 - acsr%irp(:) = acsr%irp(:) - 1 - ifrst = ifrst - 1 - info = mld_dsludist_fact(nglob,nrow_a,nztota,ifrst,& - & acsr%val,acsr%irp,acsr%ja,sv%lufactors,& - & npr,npc) - - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='mld_dsludist_fact' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - call acsr%free() - call atmp%free() - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_sludist_solver_bld - - subroutine d_sludist_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_d_sludist_solver_type), intent(inout) :: sv - integer, intent(out) :: info - Integer :: err_act - character(len=20) :: name='d_sludist_solver_free' - - call psb_erractionsave(err_act) - info = 0 - call sv%clear_data(info) - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_sludist_solver_free - - subroutine d_sludist_solver_clear_data(sv,info) - - Implicit None - - ! Arguments - class(mld_d_sludist_solver_type), intent(inout) :: sv - integer, intent(out) :: info - Integer :: err_act - character(len=20) :: name='d_sludist_solver_clear_data' - - call psb_erractionsave(err_act) - - info = psb_success_ - if (c_associated(sv%lufactors)) info = mld_dsludist_free(sv%lufactors) - sv%lufactors = c_null_ptr - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_sludist_solver_clear_data - - ! - function d_sludist_solver_is_global(sv) result(val) - implicit none - class(mld_d_sludist_solver_type), intent(in) :: sv - logical :: val - - val = .true. - end function d_sludist_solver_is_global - - subroutine d_sludist_solver_finalize(sv) - - Implicit None - - ! Arguments - type(mld_d_sludist_solver_type), intent(inout) :: sv - integer :: info - Integer :: err_act - character(len=20) :: name='d_sludist_solver_finalize' - - call sv%free(info) - - return - - end subroutine d_sludist_solver_finalize - - subroutine d_sludist_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_d_sludist_solver_type), intent(in) :: sv - integer, intent(out) :: info - integer, intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer :: err_act - integer :: ictxt, me, np - character(len=20), parameter :: name='mld_d_sludist_solver_descr' - integer :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' SuperLU_Dist Sparse Factorization Solver. ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_sludist_solver_descr - - function d_sludist_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_d_sludist_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer :: i - - val = 2*psb_sizeof_ip + psb_sizeof_dp - val = val + sv%symbsize - val = val + sv%numsize - return - end function d_sludist_solver_sizeof - - function d_sludist_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "SuperLU_Dist solver" - end function d_sludist_solver_get_fmt - - function d_sludist_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_sludist_ - end function d_sludist_solver_get_id -#endif -end module mld_d_sludist_solver diff --git a/mlprec/mld_d_symdec_aggregator_mod.f90 b/mlprec/mld_d_symdec_aggregator_mod.f90 deleted file mode 100644 index 0ba0ae7a..00000000 --- a/mlprec/mld_d_symdec_aggregator_mod.f90 +++ /dev/null @@ -1,105 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! Locally symmetrized (decoupled) aggregation algorithm. -! This version differs from the basic decoupled aggregation algorithm -! only because it works on (the pattern of) A+A^T instead of A. -! -! -module mld_d_symdec_aggregator_mod - - use mld_d_dec_aggregator_mod - !> \namespace mld_d_symdec_aggregator_mod \class mld_d_symdec_aggregator_type - !! \extends mld_d_dec_aggregator_mod::mld_d_dec_aggregator_type - !! - !! This version differs from the basic decoupled aggregation algorithm - !! only because it works on (the pattern of) A+A^T instead of A. - !! - ! - type, extends(mld_d_dec_aggregator_type) :: mld_d_symdec_aggregator_type - - contains - procedure, pass(ag) :: bld_tprol => mld_d_symdec_aggregator_build_tprol - procedure, pass(ag) :: descr => mld_d_symdec_aggregator_descr - procedure, nopass :: fmt => mld_d_symdec_aggregator_fmt - end type mld_d_symdec_aggregator_type - - - interface - subroutine mld_d_symdec_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,t_prol,info) - import :: mld_d_symdec_aggregator_type, psb_desc_type, psb_dspmat_type, psb_dpk_, & - & psb_ipk_, psb_lpk_, psb_ldspmat_type, mld_dml_parms, mld_daggr_data - implicit none - class(mld_d_symdec_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(mld_daggr_data), intent(in) :: ag_data - type(psb_dspmat_type), intent(inout) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_ldspmat_type), intent(out) :: t_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_d_symdec_aggregator_build_tprol - end interface - - -contains - - function mld_d_symdec_aggregator_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Symmetric Decoupled aggregation" - end function mld_d_symdec_aggregator_fmt - - subroutine mld_d_symdec_aggregator_descr(ag,parms,iout,info) - implicit none - class(mld_d_symdec_aggregator_type), intent(in) :: ag - type(mld_dml_parms), intent(in) :: parms - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - - write(iout,*) 'Decoupled Aggregator locally-symmetrized' - write(iout,*) 'Aggregator object type: ',ag%fmt() - call parms%mldescr(iout,info) - - return - end subroutine mld_d_symdec_aggregator_descr - -end module mld_d_symdec_aggregator_mod diff --git a/mlprec/mld_d_umf_solver.F90 b/mlprec/mld_d_umf_solver.F90 deleted file mode 100644 index cb018aa2..00000000 --- a/mlprec/mld_d_umf_solver.F90 +++ /dev/null @@ -1,453 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_d_umf_solver_mod.f90 -! -! Module: mld_d_umf_solver_mod -! -! This module defines: -! - the mld_d_umf_solver_type data structure containing the ingredients -! to interface with the UMFPACK package. -! 1. The factorization is restricted to the diagonal block of the -! current image. -! -module mld_d_umf_solver - - use iso_c_binding - use mld_d_base_solver_mod - -#if defined(IPK8) - type, extends(mld_d_base_solver_type) :: mld_d_umf_solver_type - - end type mld_d_umf_solver_type - -#else - - type, extends(mld_d_base_solver_type) :: mld_d_umf_solver_type - type(c_ptr) :: symbolic=c_null_ptr, numeric=c_null_ptr - integer(c_long_long) :: symbsize=0, numsize=0 - contains - procedure, pass(sv) :: build => d_umf_solver_bld - procedure, pass(sv) :: apply_a => d_umf_solver_apply - procedure, pass(sv) :: apply_v => d_umf_solver_apply_vect - procedure, pass(sv) :: free => d_umf_solver_free - procedure, pass(sv) :: clear_data => d_umf_solver_clear_data - procedure, pass(sv) :: descr => d_umf_solver_descr - procedure, pass(sv) :: sizeof => d_umf_solver_sizeof - procedure, nopass :: get_fmt => d_umf_solver_get_fmt - procedure, nopass :: get_id => d_umf_solver_get_id - final :: d_umf_solver_finalize - end type mld_d_umf_solver_type - - - private :: d_umf_solver_bld, d_umf_solver_apply, & - & d_umf_solver_free, d_umf_solver_descr, & - & d_umf_solver_sizeof, d_umf_solver_apply_vect, & - & d_umf_solver_get_fmt, d_umf_solver_get_id, & - & d_umf_solver_clear_data - private :: d_umf_solver_finalize - - - - interface - function mld_dumf_fact(n,nnz,values,rowind,colptr,& - & symptr,numptr,ssize,nsize)& - & bind(c,name='mld_dumf_fact') result(info) - use iso_c_binding - integer(c_int), value :: n,nnz - integer(c_int) :: info - integer(c_long_long) :: ssize, nsize - integer(c_int) :: rowind(*),colptr(*) - real(c_double) :: values(*) - type(c_ptr) :: symptr, numptr - end function mld_dumf_fact - end interface - - interface - function mld_dumf_solve(itrans,n,x, b, ldb, numptr)& - & bind(c,name='mld_dumf_solve') result(info) - use iso_c_binding - integer(c_int) :: info - integer(c_int), value :: itrans,n,ldb - real(c_double) :: x(*), b(ldb,*) - type(c_ptr), value :: numptr - end function mld_dumf_solve - end interface - - interface - function mld_dumf_free(symptr, numptr)& - & bind(c,name='mld_dumf_free') result(info) - use iso_c_binding - integer(c_int) :: info - type(c_ptr), value :: symptr, numptr - end function mld_dumf_free - end interface - -contains - - subroutine d_umf_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - use psb_base_mod - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_umf_solver_type), intent(inout) :: sv - real(psb_dpk_),intent(inout) :: x(:) - real(psb_dpk_),intent(inout) :: y(:) - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - integer, intent(out) :: info - character, intent(in), optional :: init - real(psb_dpk_),intent(inout), optional :: initu(:) - - integer :: n_row,n_col - real(psb_dpk_), pointer :: ww(:) - integer :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='d_umf_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - else - allocate(ww(n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/n_col,0,0,0,0/),& - & a_err='real(psb_dpk_)') - goto 9999 - end if - endif - - select case(trans_) - case('N') - info = mld_dumf_solve(0,n_row,ww,x,n_row,sv%numeric) - case('T') - ! - ! Note: with UMF, 1 meand Ctranspose, 2 means transpose - ! even for complex data. - ! - if (psb_d_is_complex_) then - info = mld_dumf_solve(2,n_row,ww,x,n_row,sv%numeric) - else - info = mld_dumf_solve(1,n_row,ww,x,n_row,sv%numeric) - end if - case('C') - info = mld_dumf_solve(1,n_row,ww,x,n_row,sv%numeric) - case default - call psb_errpush(psb_err_internal_error_,name,a_err='Invalid TRANS in ILU subsolve') - goto 9999 - end select - - if (info == psb_success_) call psb_geaxpby(alpha,ww,beta,y,desc_data,info) - - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Error in subsolve') - goto 9999 - endif - - if (n_col > size(work)) then - deallocate(ww) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine d_umf_solver_apply - - subroutine d_umf_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - use psb_base_mod - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_d_umf_solver_type), intent(inout) :: sv - type(psb_d_vect_type),intent(inout) :: x - type(psb_d_vect_type),intent(inout) :: y - real(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_dpk_),target, intent(inout) :: work(:) - type(psb_d_vect_type),intent(inout) :: wv(:) - integer, intent(out) :: info - character, intent(in), optional :: init - type(psb_d_vect_type),intent(inout), optional :: initu - - integer :: err_act - character(len=20) :: name='d_umf_solver_apply_vect' - - call psb_erractionsave(err_act) - - info = psb_success_ - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call x%v%sync() - call y%v%sync() - call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) - call y%v%set_host() - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine d_umf_solver_apply_vect - - subroutine d_umf_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - - Implicit None - - ! Arguments - type(psb_dspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_d_umf_solver_type), intent(inout) :: sv - integer, intent(out) :: info - type(psb_dspmat_type), intent(in), target, optional :: b - class(psb_d_base_sparse_mat), intent(in), optional :: amold - class(psb_d_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - type(psb_dspmat_type) :: atmp - type(psb_d_csc_sparse_mat) :: acsc - integer :: n_row,n_col, nrow_a, nztota - integer :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='d_umf_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - n_col = desc_a%get_local_cols() - - call a%cscnv(atmp,info,type='coo') - call psb_rwextd(n_row,atmp,info,b=b) - call atmp%cscnv(info,type='csc',dupl=psb_dupl_add_) - call atmp%mv_to(acsc) - nrow_a = acsc%get_nrows() - nztota = acsc%get_nzeros() - ! Fix the entres to call C-base UMFPACK. - acsc%ia(:) = acsc%ia(:) - 1 - acsc%icp(:) = acsc%icp(:) - 1 - info = mld_dumf_fact(nrow_a,nztota,acsc%val,& - & acsc%ia,acsc%icp,sv%symbolic,sv%numeric,& - & sv%symbsize,sv%numsize) - - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='mld_dumf_fact' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - call acsc%free() - call atmp%free() - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_umf_solver_bld - - subroutine d_umf_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_d_umf_solver_type), intent(inout) :: sv - integer, intent(out) :: info - Integer :: err_act - character(len=20) :: name='d_umf_solver_free' - - call psb_erractionsave(err_act) - - call sv%clear_data(info) - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_umf_solver_free - - - subroutine d_umf_solver_clear_data(sv,info) - - Implicit None - - ! Arguments - class(mld_d_umf_solver_type), intent(inout) :: sv - integer, intent(out) :: info - Integer :: err_act - character(len=20) :: name='d_umf_solver_clear_data' - - call psb_erractionsave(err_act) - info = 0 - if (c_associated(sv%symbolic).and.c_associated(sv%numeric)) then - info = mld_dumf_free(sv%symbolic,sv%numeric) - - if (info /= psb_success_) goto 9999 - sv%symbolic = c_null_ptr - sv%numeric = c_null_ptr - sv%symbsize = 0 - sv%numsize = 0 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_umf_solver_clear_data - - subroutine d_umf_solver_finalize(sv) - - Implicit None - - ! Arguments - type(mld_d_umf_solver_type), intent(inout) :: sv - integer :: info - Integer :: err_act - character(len=20) :: name='d_umf_solver_finalize' - - call sv%free(info) - - return - - end subroutine d_umf_solver_finalize - - subroutine d_umf_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_d_umf_solver_type), intent(in) :: sv - integer, intent(out) :: info - integer, intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer :: err_act - integer :: ictxt, me, np - character(len=20), parameter :: name='mld_d_umf_solver_descr' - integer :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' UMFPACK Sparse Factorization Solver. ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine d_umf_solver_descr - - function d_umf_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_d_umf_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer :: i - - val = 2*psb_sizeof_lp - val = val + sv%symbsize - val = val + sv%numsize - return - end function d_umf_solver_sizeof - - function d_umf_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "UMFPACK solver" - end function d_umf_solver_get_fmt - - function d_umf_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_umf_ - end function d_umf_solver_get_id -#endif -end module mld_d_umf_solver diff --git a/mlprec/mld_prec_mod.f90 b/mlprec/mld_prec_mod.f90 deleted file mode 100644 index 91995d85..00000000 --- a/mlprec/mld_prec_mod.f90 +++ /dev/null @@ -1,52 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_prec_mod.f90 -! -! Module: mld_prec_mod -! -! This module defines the interfaces to the real/complex, single/double -! precision versions of the user-level MLD2P4 routines. -! -module mld_prec_mod - - use mld_s_prec_mod - use mld_d_prec_mod - use mld_c_prec_mod - use mld_z_prec_mod - -end module mld_prec_mod diff --git a/mlprec/mld_prec_type.f90 b/mlprec/mld_prec_type.f90 deleted file mode 100644 index cf1b8ff2..00000000 --- a/mlprec/mld_prec_type.f90 +++ /dev/null @@ -1,67 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_prec_type.f90 -! -! Module: mld_prec_type -! -! This module defines: -! - the mld_prec_type data structure containing the preconditioner and related -! data structures; -! - integer constants defining the preconditioner; -! - character constants describing the preconditioner (used by the routines -! printing out a preconditioner description); -! - the interfaces to the routines for the management of the preconditioner -! data structure (see below). -! -! It contains routines for -! - converting character constants defining the preconditioner into integer -! constants; -! - checking if the preconditioner is correctly defined; -! - printing a description of the preconditioner; -! - deallocating the preconditioner data structure. -! - -module mld_prec_type - - use mld_base_prec_type - use mld_s_prec_type - use mld_d_prec_type - use mld_c_prec_type - use mld_z_prec_type - -end module mld_prec_type diff --git a/mlprec/mld_s_as_smoother.f90 b/mlprec/mld_s_as_smoother.f90 deleted file mode 100644 index 318cb72d..00000000 --- a/mlprec/mld_s_as_smoother.f90 +++ /dev/null @@ -1,471 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_s_as_smoother_mod.f90 -! -! Module: mld_s_as_smoother_mod -! -! This module defines: -! the mld_s_as_smoother_type data structure containing the -! smoother for an Additive Schwarz smoother. -! -! To begin with, the build procedure constructs the extended -! matrix A and its corresponding descriptor (this has multiple -! halo layers duplicated across different processes); it then -! stores in ND the block off-diagonal matrix, and builds the solver -! on the (extended) block diagonal matrix. -! -! The code allows for the variations of Additive Schwartz, Restricted -! Additive Schwartz and Additive Schwartz with Harmonic Extensions. -! From an implementation point of view, these are handled by -! combining application/non-application of the prolongator/restrictor -! operators. -! -module mld_s_as_smoother - - use mld_s_base_smoother_mod - - type, extends(mld_s_base_smoother_type) :: mld_s_as_smoother_type - ! The local solver component is inherited from the - ! parent type. - ! class(mld_s_base_solver_type), allocatable :: sv - ! - type(psb_sspmat_type) :: nd - type(psb_desc_type) :: desc_data - integer(psb_ipk_) :: novr, restr, prol - integer(psb_lpk_) :: nd_nnz_tot - contains - procedure, pass(sm) :: apply_v => mld_s_as_smoother_apply_vect - procedure, pass(sm) :: apply_a => mld_s_as_smoother_apply - procedure, pass(sm) :: check => mld_s_as_smoother_check - procedure, pass(sm) :: dump => mld_s_as_smoother_dmp - procedure, pass(sm) :: build => mld_s_as_smoother_bld - procedure, pass(sm) :: cnv => mld_s_as_smoother_cnv - procedure, pass(sm) :: clone => mld_s_as_smoother_clone - procedure, pass(sm) :: clone_settings => mld_s_as_smoother_clone_settings - procedure, pass(sm) :: clear_data => mld_s_as_smoother_clear_data - procedure, pass(sm) :: restr_a => mld_s_as_smoother_restr_a - procedure, pass(sm) :: prol_a => mld_s_as_smoother_prol_a - procedure, pass(sm) :: restr_v => mld_s_as_smoother_restr_v - procedure, pass(sm) :: prol_v => mld_s_as_smoother_prol_v - generic, public :: apply_restr => restr_v, restr_a - generic, public :: apply_prol => prol_v, prol_a - procedure, pass(sm) :: free => mld_s_as_smoother_free - procedure, pass(sm) :: cseti => mld_s_as_smoother_cseti - procedure, pass(sm) :: csetc => mld_s_as_smoother_csetc - procedure, pass(sm) :: descr => s_as_smoother_descr - procedure, pass(sm) :: sizeof => s_as_smoother_sizeof - procedure, pass(sm) :: default => s_as_smoother_default - procedure, pass(sm) :: get_nzeros => s_as_smoother_get_nzeros - procedure, pass(sm) :: get_wrksz => s_as_smoother_get_wrksize - procedure, nopass :: get_fmt => s_as_smoother_get_fmt - procedure, nopass :: get_id => s_as_smoother_get_id - end type mld_s_as_smoother_type - - - private :: s_as_smoother_descr, s_as_smoother_sizeof, & - & s_as_smoother_default, s_as_smoother_get_nzeros, & - & s_as_smoother_get_fmt, s_as_smoother_get_id, & - & s_as_smoother_get_wrksize - - character(len=6), parameter, private :: & - & restrict_names(0:4)=(/'none ','halo ',' ',' ',' '/) - character(len=12), parameter, private :: & - & prolong_names(0:3)=(/'none ','sum ','average ','square root'/) - - - interface - subroutine mld_s_as_smoother_check(sm,info) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_spk_, mld_s_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_s_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_as_smoother_check - end interface - - interface - subroutine mld_s_as_smoother_restr_v(sm,x,trans,work,info,data) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_spk_, mld_s_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - class(mld_s_as_smoother_type), intent(inout) :: sm - type(psb_s_vect_type),intent(inout) :: x - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - end subroutine mld_s_as_smoother_restr_v - end interface - - interface - subroutine mld_s_as_smoother_restr_a(sm,x,trans,work,info,data) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_spk_, mld_s_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - class(mld_s_as_smoother_type), intent(inout) :: sm - real(psb_spk_), intent(inout) :: x(:) - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - end subroutine mld_s_as_smoother_restr_a - end interface - - interface - subroutine mld_s_as_smoother_prol_v(sm,x,trans,work,info,data) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_spk_, mld_s_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - class(mld_s_as_smoother_type), intent(inout) :: sm - type(psb_s_vect_type),intent(inout) :: x - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - end subroutine mld_s_as_smoother_prol_v - end interface - - interface - subroutine mld_s_as_smoother_prol_a(sm,x,trans,work,info,data) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_spk_, mld_s_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - class(mld_s_as_smoother_type), intent(inout) :: sm - real(psb_spk_), intent(inout) :: x(:) - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - end subroutine mld_s_as_smoother_prol_a - end interface - - - interface - subroutine mld_s_as_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,wv,info,init,initu) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_spk_, mld_s_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_as_smoother_type), intent(inout) :: sm - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - end subroutine mld_s_as_smoother_apply_vect - end interface - - interface - subroutine mld_s_as_smoother_apply(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,info,init,initu) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_spk_, mld_s_as_smoother_type, psb_epk_,& - & psb_desc_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_as_smoother_type), intent(inout) :: sm - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_s_as_smoother_apply - end interface - - interface - subroutine mld_s_as_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_spk_, mld_s_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_s_base_sparse_mat, psb_ipk_,& - & psb_i_base_vect_type - implicit none - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_as_smoother_bld - end interface - - interface - subroutine mld_s_as_smoother_cnv(sm,info,amold,vmold,imold) - import :: psb_s_base_vect_type, & - & psb_spk_, mld_s_as_smoother_type, psb_epk_, & - & psb_s_base_sparse_mat, psb_ipk_, psb_i_base_vect_type - implicit none - class(mld_s_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_as_smoother_cnv - end interface - - interface - subroutine mld_s_as_smoother_cseti(sm,what,val,info,idx) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_spk_, mld_s_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_s_as_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_s_as_smoother_cseti - end interface - - interface - subroutine mld_s_as_smoother_csetc(sm,what,val,info,idx) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_spk_, mld_s_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_s_as_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_s_as_smoother_csetc - end interface - - interface - subroutine mld_s_as_smoother_free(sm,info) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_spk_, mld_s_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_s_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_as_smoother_free - end interface - - interface - subroutine mld_s_as_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_spk_, mld_s_as_smoother_type, psb_epk_, psb_desc_type, & - & psb_ipk_ - implicit none - class(mld_s_as_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - end subroutine mld_s_as_smoother_dmp - end interface - - interface - subroutine mld_s_as_smoother_clone(sm,smout,info) - import :: mld_s_as_smoother_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_ - class(mld_s_as_smoother_type), intent(inout) :: sm - class(mld_s_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_as_smoother_clone - end interface - - - interface - subroutine mld_s_as_smoother_clone_settings(sm,smout,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_smoother_type, mld_s_as_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_as_smoother_type), intent(inout) :: sm - class(mld_s_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_as_smoother_clone_settings - end interface - - interface - subroutine mld_s_as_smoother_clear_data(sm,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_as_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_as_smoother_clear_data - end interface - - -contains - - function s_as_smoother_sizeof(sm) result(val) - implicit none - ! Arguments - class(mld_s_as_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 3*psb_sizeof_ip + psb_sizeof_lp - if (allocated(sm%sv)) val = val + sm%sv%sizeof() - val = val + sm%nd%sizeof() - - return - end function s_as_smoother_sizeof - - function s_as_smoother_get_nzeros(sm) result(val) - implicit none - class(mld_s_as_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - if (allocated(sm%sv)) & - & val = sm%sv%get_nzeros() - val = val + sm%nd%get_nzeros() - - end function s_as_smoother_get_nzeros - - subroutine s_as_smoother_default(sm) - - use psb_base_mod, only : psb_halo_, psb_none_ - - Implicit None - - ! Arguments - class(mld_s_as_smoother_type), intent(inout) :: sm - - ! - ! Default: AS with 1 overlap layer - ! - sm%restr = psb_halo_ - sm%prol = psb_sum_ - sm%novr = 1 - - if (allocated(sm%sv)) then - call sm%sv%default() - end if - - return - end subroutine s_as_smoother_default - - - subroutine s_as_smoother_descr(sm,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_s_as_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_s_as_smoother_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (.not.coarse_) then - write(iout_,*) ' Additive Schwarz with ',& - & sm%novr, ' overlap layers.' - write(iout_,*) ' Restrictor: ',restrict_names(sm%restr) - write(iout_,*) ' Prolongator: ',prolong_names(sm%prol) - write(iout_,*) ' Local solver:' - endif - if (allocated(sm%sv)) then - call sm%sv%descr(info,iout_,coarse=coarse) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine s_as_smoother_descr - - function s_as_smoother_get_wrksize(sm) result(val) - implicit none - class(mld_s_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_) :: val - - val = 3 - if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() - - end function s_as_smoother_get_wrksize - - function s_as_smoother_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Additive Schwarz" - end function s_as_smoother_get_fmt - - function s_as_smoother_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_as_ - end function s_as_smoother_get_id - -end module mld_s_as_smoother diff --git a/mlprec/mld_s_base_aggregator_mod.f90 b/mlprec/mld_s_base_aggregator_mod.f90 deleted file mode 100644 index 462d867a..00000000 --- a/mlprec/mld_s_base_aggregator_mod.f90 +++ /dev/null @@ -1,519 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! The aggregator object hosts the aggregation method for building -! the multilevel hierarchy. -! -module mld_s_base_aggregator_mod - - use mld_base_prec_type, only : mld_sml_parms, mld_saggr_data - use psb_base_mod, only : psb_sspmat_type, psb_lsspmat_type, psb_s_vect_type, & - & psb_s_base_vect_type, psb_slinmap_type, psb_spk_, & - & psb_ls_csr_sparse_mat, psb_ls_coo_sparse_mat, & - & psb_s_csr_sparse_mat, psb_s_coo_sparse_mat, & - & psb_ipk_, psb_epk_, psb_lpk_, psb_desc_type, psb_i_base_vect_type, & - & psb_erractionsave, psb_error_handler, psb_success_, psb_toupper - ! - ! - ! - !> \class mld_s_base_aggregator_type - !! - !! It is the data type containing the basic interface definition for - !! building a multigrid hierarchy by aggregation. The base object has no attributes, - !! it is intended to be essentially an abstract type. - !! - !! - !! type mld_s_base_aggregator_type - !! end type - !! - !! - !! Methods: - !! - !! bld_tprol - Build a tentative prolongator - !! - !! mat_bld - Build prolongator/restrictor and coarse matrix ac - !! - !! mat_asb - Convert prolongator/restrictor/coarse matrix - !! and fix their descriptor(s) - !! - !! update_next - Transfer information to the next level; default is - !! to do nothing, i.e. aggregators at different - !! levels are independent. - !! - !! default - Apply defaults - !! set_aggr_type - For aggregator that have internal options. - !! fmt - Return a short string description - !! descr - Print a more detailed description - !! - !! cseti, csetr, csetc - Set internal parameters, if any - ! - type mld_s_base_aggregator_type - ! Do we want to purge explicit zeros when aggregating? - logical :: do_clean_zeros - contains - procedure, pass(ag) :: bld_tprol => mld_s_base_aggregator_build_tprol - procedure, pass(ag) :: mat_bld => mld_s_base_aggregator_mat_bld - procedure, pass(ag) :: mat_asb => mld_s_base_aggregator_mat_asb - procedure, pass(ag) :: bld_map => mld_s_base_aggregator_bld_map - procedure, pass(ag) :: update_next => mld_s_base_aggregator_update_next - procedure, pass(ag) :: clone => mld_s_base_aggregator_clone - procedure, pass(ag) :: free => mld_s_base_aggregator_free - procedure, pass(ag) :: default => mld_s_base_aggregator_default - procedure, pass(ag) :: descr => mld_s_base_aggregator_descr - procedure, pass(ag) :: sizeof => mld_s_base_aggregator_sizeof - procedure, pass(ag) :: set_aggr_type => mld_s_base_aggregator_set_aggr_type - procedure, nopass :: fmt => mld_s_base_aggregator_fmt - procedure, pass(ag) :: cseti => mld_s_base_aggregator_cseti - procedure, pass(ag) :: csetr => mld_s_base_aggregator_csetr - procedure, pass(ag) :: csetc => mld_s_base_aggregator_csetc - generic, public :: set => cseti, csetr, csetc - procedure, nopass :: xt_desc => mld_s_base_aggregator_xt_desc - end type mld_s_base_aggregator_type - - abstract interface - subroutine mld_s_soc_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, psb_ipk_, psb_lpk_ - implicit none - integer(psb_ipk_), intent(in) :: iorder - logical, intent(in) :: clean_zeros - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - real(psb_spk_), intent(in) :: theta - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_soc_map_bld - end interface - - interface mld_ptap - subroutine mld_s_ptap(a_csr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_cprol,coo_restr,info,desc_ax) - import :: psb_s_csr_sparse_mat, psb_sspmat_type, psb_desc_type, & - & psb_s_coo_sparse_mat, mld_sml_parms, psb_spk_, psb_ipk_, psb_lpk_ - implicit none - type(psb_s_csr_sparse_mat), intent(inout) :: a_csr - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - type(mld_sml_parms), intent(inout) :: parms - type(psb_s_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr - type(psb_desc_type), intent(inout) :: desc_cprol - type(psb_sspmat_type), intent(out) :: ac - integer(psb_ipk_), intent(out) :: info - type(psb_desc_type), intent(inout), optional :: desc_ax - end subroutine mld_s_ptap -!!$ subroutine mld_s_ls_ptap(a_csr,desc_a,nlaggr,parms,ac,& -!!$ & coo_prol,desc_cprol,coo_restr,info,desc_ax) -!!$ import :: psb_s_csr_sparse_mat, psb_lsspmat_type, psb_desc_type, & -!!$ & psb_ls_coo_sparse_mat, mld_sml_parms, psb_spk_, psb_ipk_, psb_lpk_ -!!$ implicit none -!!$ type(psb_s_csr_sparse_mat), intent(inout) :: a_csr -!!$ type(psb_desc_type), intent(in) :: desc_a -!!$ integer(psb_lpk_), intent(inout) :: nlaggr(:) -!!$ type(mld_sml_parms), intent(inout) :: parms -!!$ type(psb_ls_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr -!!$ type(psb_desc_type), intent(inout) :: desc_cprol -!!$ type(psb_lsspmat_type), intent(out) :: ac -!!$ integer(psb_ipk_), intent(out) :: info -!!$ type(psb_desc_type), intent(inout), optional :: desc_ax -!!$ end subroutine mld_s_ls_ptap -!!$ subroutine mld_ls_ptap(a_csr,desc_a,nlaggr,parms,ac,& -!!$ & coo_prol,desc_cprol,coo_restr,info,desc_ax) -!!$ import :: psb_ls_csr_sparse_mat, psb_lsspmat_type, psb_desc_type, & -!!$ & psb_ls_coo_sparse_mat, mld_sml_parms, psb_spk_, psb_ipk_, psb_lpk_ -!!$ implicit none -!!$ type(psb_ls_csr_sparse_mat), intent(inout) :: a_csr -!!$ type(psb_desc_type), intent(in) :: desc_a -!!$ integer(psb_lpk_), intent(inout) :: nlaggr(:) -!!$ type(mld_sml_parms), intent(inout) :: parms -!!$ type(psb_ls_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr -!!$ type(psb_desc_type), intent(inout) :: desc_cprol -!!$ type(psb_lsspmat_type), intent(out) :: ac -!!$ integer(psb_ipk_), intent(out) :: info -!!$ type(psb_desc_type), intent(inout), optional :: desc_ax -!!$ end subroutine mld_ls_ptap - end interface mld_ptap - -contains - - subroutine mld_s_base_aggregator_cseti(ag,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_s_base_aggregator_type), intent(inout) :: ag - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - ! Do nothing - info = 0 - end subroutine mld_s_base_aggregator_cseti - - subroutine mld_s_base_aggregator_csetr(ag,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_s_base_aggregator_type), intent(inout) :: ag - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - ! Do nothing - info = 0 - end subroutine mld_s_base_aggregator_csetr - - subroutine mld_s_base_aggregator_csetc(ag,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_s_base_aggregator_type), intent(inout) :: ag - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - ! Set clean zeros, or do nothing. - select case (psb_toupper(trim(what))) - case('AGGR_CLEAN_ZEROS') - select case (psb_toupper(trim(val))) - case('TRUE','T') - ag%do_clean_zeros = .true. - case('FALSE','F') - ag%do_clean_zeros = .false. - end select - end select - info = 0 - end subroutine mld_s_base_aggregator_csetc - - - subroutine mld_s_base_aggregator_update_next(ag,agnext,info) - implicit none - class(mld_s_base_aggregator_type), target, intent(inout) :: ag, agnext - integer(psb_ipk_), intent(out) :: info - - ! - ! Base version does nothing. - ! - info = 0 - end subroutine mld_s_base_aggregator_update_next - - subroutine mld_s_base_aggregator_clone(ag,agnext,info) - implicit none - class(mld_s_base_aggregator_type), intent(inout) :: ag - class(mld_s_base_aggregator_type), allocatable, intent(inout) :: agnext - integer(psb_ipk_), intent(out) :: info - - info = 0 - if (allocated(agnext)) then - call agnext%free(info) - if (info == 0) deallocate(agnext,stat=info) - end if - if (info /= 0) return - allocate(agnext,source=ag,stat=info) - - end subroutine mld_s_base_aggregator_clone - - subroutine mld_s_base_aggregator_free(ag,info) - implicit none - class(mld_s_base_aggregator_type), intent(inout) :: ag - integer(psb_ipk_), intent(out) :: info - - info = psb_success_ - return - end subroutine mld_s_base_aggregator_free - - subroutine mld_s_base_aggregator_default(ag) - implicit none - class(mld_s_base_aggregator_type), intent(inout) :: ag - ! Only one default setting - ag%do_clean_zeros = .true. - - return - end subroutine mld_s_base_aggregator_default - - function mld_s_base_aggregator_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Default aggregator " - end function mld_s_base_aggregator_fmt - - function mld_s_base_aggregator_sizeof(ag) result(val) - implicit none - class(mld_s_base_aggregator_type), intent(in) :: ag - integer(psb_epk_) :: val - - val = 1 - end function mld_s_base_aggregator_sizeof - - function mld_s_base_aggregator_xt_desc() result(val) - implicit none - logical :: val - - val = .false. - end function mld_s_base_aggregator_xt_desc - - subroutine mld_s_base_aggregator_descr(ag,parms,iout,info) - implicit none - class(mld_s_base_aggregator_type), intent(in) :: ag - type(mld_sml_parms), intent(in) :: parms - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - - write(iout,*) 'Aggregator object type: ',ag%fmt() - call parms%mldescr(iout,info) - - return - end subroutine mld_s_base_aggregator_descr - - subroutine mld_s_base_aggregator_set_aggr_type(ag,parms,info) - implicit none - class(mld_s_base_aggregator_type), intent(inout) :: ag - type(mld_sml_parms), intent(in) :: parms - integer(psb_ipk_), intent(out) :: info - - ! Do nothing - - return - end subroutine mld_s_base_aggregator_set_aggr_type - - ! - !> Function bld_tprol: - !! \memberof mld_s_base_aggregator_type - !! \brief Build a tentative prolongator. - !! The routine will map the local matrix entries to aggregates. - !! The mapping is store in ILAGGR; for each local row index I, - !! ILAGGR(I) contains the index of the aggregate to which index I - !! will contribute, in global numbering. - !! Many aggregations produce a binary tentative prolongator, but some - !! do not, hence we also need the OP_PROL output. - !! AG_DATA is passed here just in case some of the - !! aggregators need it internally, most of them will ignore. - !! - !! \param ag The input aggregator object - !! \param parms The auxiliary parameters object - !! \param ag_data Auxiliary global aggregation info - !! \param a The local matrix part - !! \param desc_a The descriptor - !! \param ilaggr Output aggregation map - !! \param nlaggr Sizes of ilaggr on all processes - !! \param op_prol The tentative prolongator operator - !! \param info Return code - !! - ! - subroutine mld_s_base_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,t_prol,info) - use psb_base_mod - implicit none - class(mld_s_base_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(mld_saggr_data), intent(in) :: ag_data - type(psb_sspmat_type), intent(inout) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lsspmat_type), intent(out) :: t_prol - integer(psb_ipk_), intent(out) :: info - - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_aggregator_build_tprol' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - - end subroutine mld_s_base_aggregator_build_tprol - - ! - !> Function mat_bld - !! \memberof mld_s_base_aggregator_type - !! \brief Build prolongator/restrictor/coarse matrix. - !! - !! - !! \param ag The input aggregator object - !! \param parms The auxiliary parameters object - !! \param a The local matrix part - !! \param desc_a The descriptor - !! \param ilaggr Aggregation map - !! \param nlaggr Sizes of ilaggr on all processes - !! \param ac On output the coarse matrix - !! \param op_prol On input, the tentative prolongator operator, on output - !! the final prolongator - !! \param op_restr On output, the restrictor operator; - !! in many cases it is the transpose of the prolongator. - !! \param info Return code - !! - subroutine mld_s_base_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - use psb_base_mod - implicit none - class(mld_s_base_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(psb_lsspmat_type), intent(inout) :: t_prol - type(psb_sspmat_type), intent(out) :: op_prol, ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_aggregator_mat_bld' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - end subroutine mld_s_base_aggregator_mat_bld - - ! - !> Function mat_asb - !! \memberof mld_s_base_aggregator_type - !! \brief Build prolongator/restrictor/coarse matrix. - !! - !! - !! \param ag The input aggregator object - !! \param parms The auxiliary parameters object - !! \param a The local matrix part - !! \param desc_a The descriptor - !! \param ilaggr Aggregation map - !! \param nlaggr Sizes of ilaggr on all processes - !! \param ac On output the coarse matrix - !! \param op_prol On input, the tentative prolongator operator, on output - !! the final prolongator - !! \param op_restr On output, the restrictor operator; - !! in many cases it is the transpose of the prolongator. - !! \param info Return code - !! - subroutine mld_s_base_aggregator_mat_asb(ag,parms,a,desc_a,& - & ac,desc_ac, op_prol,op_restr,info) - use psb_base_mod - implicit none - class(mld_s_base_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - type(psb_sspmat_type), intent(inout) :: op_prol,ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_aggregator_mat_asb' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - end subroutine mld_s_base_aggregator_mat_asb - - ! - !> Function bld_map - !! \memberof mld_s_base_aggregator_type - !! \brief Build linear map between hierarchy levels - !! - !! - !! \param ag The input aggregator object - !! \param desc_a The fine space descriptor - !! \param desc_ac The coarse space descriptor - !! \param ilaggr Aggregation map vector - !! \param nlaggr Sizes of ilaggr on all processes - !! \param op_prol The prolongator operator - !! \param op_restr The restrictor operator - !! \param map The output map - !! \param info Return code - !! - subroutine mld_s_base_aggregator_bld_map(ag,desc_a,desc_ac,ilaggr,nlaggr,& - & op_restr,op_prol,map,info) - use psb_base_mod - implicit none - class(mld_s_base_aggregator_type), target, intent(inout) :: ag - type(psb_desc_type), intent(in), target :: desc_a, desc_ac - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(psb_sspmat_type), intent(inout) :: op_restr, op_prol - type(psb_slinmap_type), intent(out) :: map - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_base_aggregator_bld_map' - - call psb_erractionsave(err_act) - ! - ! Copy the prolongation/restriction matrices into the descriptor map. - ! op_restr => PR^T i.e. restriction operator - ! op_prol => PR i.e. prolongation operator - ! - ! WARNING: need to check whether the copy into IOP_RESTR/IOP_PROL - ! is safe or not. - ! - ! This default implementation reuses desc_a/desc_ac through - ! pointers in the map structure. - ! - map = psb_linmap(psb_map_aggr_,desc_a,& - & desc_ac,op_restr,op_prol,ilaggr,nlaggr) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - end subroutine mld_s_base_aggregator_bld_map - - -end module mld_s_base_aggregator_mod diff --git a/mlprec/mld_s_base_smoother_mod.f90 b/mlprec/mld_s_base_smoother_mod.f90 deleted file mode 100644 index 9bef3fcf..00000000 --- a/mlprec/mld_s_base_smoother_mod.f90 +++ /dev/null @@ -1,412 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_s_base_smoother_mod.f90 -! -! Module: mld_s_base_smoother_mod -! -! This module defines: -! - the mld_s_base_smoother_type data structure containing the -! smoother and related data structures; -! -! It contains routines for -! - Building and applying; -! - checking if the smoother is correctly defined; -! - printing a description of the preconditioner; -! - deallocating the preconditioner data structure. -! -! What is the difference between a smoother and a solver? -! In the mathematics literature the two concepts are treated -! essentially as synonymous, but here we are using them in a more -! computer-science oriented fashion. In particular, a SMOOTHER object -! contains a SOLVER object: the SOLVER operates locally within the -! current process, whereas the SMOOTHER object accounts for (possible) -! interactions between processes. -! Some solvers (MUMPS and SuperLU_DIST) can also operate on the entire -! distributed matrix, in which case the smoother object essentially -! becomes transparent. -! -module mld_s_base_smoother_mod - - use mld_s_base_solver_mod - use psb_base_mod, only : psb_desc_type, psb_sspmat_type, psb_epk_,& - & psb_s_vect_type, psb_s_base_vect_type, psb_s_base_sparse_mat, & - & psb_spk_, psb_i_base_vect_type, psb_erractionsave, psb_error_handler - - ! - ! - ! - ! Type: mld_T_base_smoother_type. - ! - ! It holds the smoother a single level. Its only mandatory component is a solver - ! object which holds a local solver; this decoupling allows to have the same solver - ! e.g ILU to work with Jacobi with multiple sweeps as well as with any AS variant. - ! - ! type mld_T_base_smoother_type - ! class(mld_T_base_solver_type), allocatable :: sv - ! end type mld_T_base_smoother_type - ! - ! Methods: - ! - ! build - Compute the actual contents of the smoother; includes - ! invocation of the build method on the solver component. - ! free - Release memory - ! apply - Apply the smoother to a vector (or to an array); includes - ! invocation of the apply method on the solver component. - ! descr - Prints a description of the object. - ! default - Set default values - ! dump - Dump to file object contents - ! set - Sets various parameters; when a request is unknown - ! it is passed to the solver object for further processing. - ! check - Sanity checks. - ! sizeof - Total memory occupation in bytes - ! get_nzeros - Number of nonzeros - ! stringval - convert string to val for internal parms - ! get_fmt - short string descriptor - ! get_id - numeric id descriptro - ! get_wrksz - How many workspace vector does apply_vect need - ! - ! - ! - - type mld_s_base_smoother_type - class(mld_s_base_solver_type), allocatable :: sv - contains - procedure, pass(sm) :: apply_v => mld_s_base_smoother_apply_vect - procedure, pass(sm) :: apply_a => mld_s_base_smoother_apply - generic, public :: apply => apply_a, apply_v - procedure, pass(sm) :: check => mld_s_base_smoother_check - procedure, pass(sm) :: dump => mld_s_base_smoother_dmp - procedure, pass(sm) :: clone => mld_s_base_smoother_clone - procedure, pass(sm) :: build => mld_s_base_smoother_bld - procedure, pass(sm) :: cnv => mld_s_base_smoother_cnv - procedure, pass(sm) :: free => mld_s_base_smoother_free - procedure, pass(sm) :: clone_settings => mld_s_base_smoother_clone_settings - procedure, pass(sm) :: clear_data => mld_s_base_smoother_clear_data - procedure, pass(sm) :: cseti => mld_s_base_smoother_cseti - procedure, pass(sm) :: csetc => mld_s_base_smoother_csetc - procedure, pass(sm) :: csetr => mld_s_base_smoother_csetr - generic, public :: set => cseti, csetc, csetr - procedure, pass(sm) :: default => s_base_smoother_default - procedure, pass(sm) :: descr => mld_s_base_smoother_descr - procedure, pass(sm) :: sizeof => s_base_smoother_sizeof - procedure, pass(sm) :: get_nzeros => s_base_smoother_get_nzeros - procedure, pass(sm) :: get_wrksz => s_base_smoother_get_wrksize - procedure, nopass :: stringval => mld_stringval - procedure, nopass :: get_fmt => s_base_smoother_get_fmt - procedure, nopass :: get_id => s_base_smoother_get_id - end type mld_s_base_smoother_type - - - private :: s_base_smoother_sizeof, s_base_smoother_get_fmt, & - & s_base_smoother_default, s_base_smoother_get_nzeros, & - & s_base_smoother_get_id, s_base_smoother_get_wrksize - - - - interface - subroutine mld_s_base_smoother_apply(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,info,init,initu) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_base_smoother_type), intent(inout) :: sm - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_s_base_smoother_apply - end interface - - interface - subroutine mld_s_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,wv,info,init,initu) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_base_smoother_type), intent(inout) :: sm - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - end subroutine mld_s_base_smoother_apply_vect - end interface - - interface - subroutine mld_s_base_smoother_check(sm,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_base_smoother_check - end interface - - interface - subroutine mld_s_base_smoother_cseti(sm,what,val,info,idx) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_s_base_smoother_cseti - end interface - - interface - subroutine mld_s_base_smoother_csetc(sm,what,val,info,idx) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_ - class(mld_s_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_s_base_smoother_csetc - end interface - - interface - subroutine mld_s_base_smoother_csetr(sm,what,val,info,idx) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_s_base_smoother_csetr - end interface - - interface - subroutine mld_s_base_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_, psb_i_base_vect_type - ! Arguments - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_base_smoother_bld - end interface - - interface - subroutine mld_s_base_smoother_cnv(sm,info,amold,vmold,imold) - import :: psb_s_base_sparse_mat, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_, psb_i_base_vect_type - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_base_smoother_cnv - end interface - - interface - subroutine mld_s_base_smoother_free(sm,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_base_smoother_free - end interface - - interface - subroutine mld_s_base_smoother_descr(sm,info,iout,coarse) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_s_base_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - end subroutine mld_s_base_smoother_descr - end interface - - interface - subroutine mld_s_base_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_ - class(mld_s_base_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - end subroutine mld_s_base_smoother_dmp - end interface - - interface - subroutine mld_s_base_smoother_clone(sm,smout,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - class(mld_s_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_base_smoother_clone - end interface - - interface - subroutine mld_s_base_smoother_clone_settings(sm,smout,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - class(mld_s_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_base_smoother_clone_settings - end interface - - interface - subroutine mld_s_base_smoother_clear_data(sm,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_base_smoother_clear_data - end interface - -contains - ! - ! Function returning the size of the mld_prec_type data structure - ! in bytes or in number of nonzeros of the operator(s) involved. - ! - - function s_base_smoother_get_nzeros(sm) result(val) - implicit none - class(mld_s_base_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - if (allocated(sm%sv)) & - & val = sm%sv%get_nzeros() - end function s_base_smoother_get_nzeros - - function s_base_smoother_sizeof(sm) result(val) - implicit none - ! Arguments - class(mld_s_base_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - if (allocated(sm%sv)) then - val = sm%sv%sizeof() - end if - - return - end function s_base_smoother_sizeof - - ! - ! Set sensible defaults. - ! To be called immediately after allocation - ! - subroutine s_base_smoother_default(sm) - implicit none - ! Arguments - class(mld_s_base_smoother_type), intent(inout) :: sm - ! Do nothing for base version - - if (allocated(sm%sv)) call sm%sv%default() - - return - end subroutine s_base_smoother_default - - function s_base_smoother_get_wrksize(sm) result(val) - implicit none - class(mld_s_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_) :: val - - val = 0 - if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() - - end function s_base_smoother_get_wrksize - - function s_base_smoother_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Base smoother" - end function s_base_smoother_get_fmt - - function s_base_smoother_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_base_smooth_ - end function s_base_smoother_get_id - -end module mld_s_base_smoother_mod diff --git a/mlprec/mld_s_base_solver_mod.f90 b/mlprec/mld_s_base_solver_mod.f90 deleted file mode 100644 index d9a2101b..00000000 --- a/mlprec/mld_s_base_solver_mod.f90 +++ /dev/null @@ -1,421 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_s_base_solver_mod.f90 -! -! Module: mld_s_base_solver_mod -! -! This module defines: -! - the mld_s_base_solver_type data structure containing the -! basic solver type acting on a subdomain -! -! It contains routines for -! - Building and applying; -! - checking if the solver is correctly defined; -! - printing a description of the solver; -! - deallocating the data structure. -! - -module mld_s_base_solver_mod - - use mld_base_prec_type - use psb_base_mod, only : psb_sspmat_type, & - & psb_s_vect_type, psb_s_base_vect_type, psb_s_base_sparse_mat, & - & psb_spk_, psb_i_base_vect_type, psb_erractionsave, psb_error_handler - ! - ! - ! Type: mld_T_base_solver_type. - ! - ! It holds the local solver; it has no mandatory components. - ! - ! type mld_T_base_solver_type - ! end type mld_T_base_solver_type - ! - ! build - Compute the actual contents of the smoother; includes - ! invocation of the build method on the solver component. - ! free - Release memory - ! apply - Apply the smoother to a vector (or to an array); includes - ! invocation of the apply method on the solver component. - ! descr - Prints a description of the object. - ! default - Set default values - ! dump - Dump to file object contents - ! set - Sets various parameters; when a request is unknown - ! it is passed to the smoother object for further processing. - ! check - Sanity checks. - ! sizeof - Total memory occupation in bytes - ! get_nzeros - Number of nonzeros - ! stringval - convert string to val for internal parms - ! get_fmt - short string descriptor - ! get_id - numeric id descriptro - ! get_wrksz - How many workspace vector does apply_vect need - ! - ! - - type mld_s_base_solver_type - contains - procedure, pass(sv) :: apply_v => mld_s_base_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_s_base_solver_apply - generic, public :: apply => apply_a, apply_v - procedure, pass(sv) :: check => mld_s_base_solver_check - procedure, pass(sv) :: dump => mld_s_base_solver_dmp - procedure, pass(sv) :: clone => mld_s_base_solver_clone - procedure, pass(sv) :: clone_settings => mld_s_base_solver_clone_settings - procedure, pass(sv) :: clear_data => mld_s_base_solver_clear_data - procedure, pass(sv) :: build => mld_s_base_solver_bld - procedure, pass(sv) :: cnv => mld_s_base_solver_cnv - procedure, pass(sv) :: free => mld_s_base_solver_free - procedure, pass(sv) :: cseti => mld_s_base_solver_cseti - procedure, pass(sv) :: csetc => mld_s_base_solver_csetc - procedure, pass(sv) :: csetr => mld_s_base_solver_csetr - generic, public :: set => cseti, csetc, csetr - procedure, pass(sv) :: default => s_base_solver_default - procedure, pass(sv) :: descr => mld_s_base_solver_descr - procedure, pass(sv) :: sizeof => s_base_solver_sizeof - procedure, pass(sv) :: get_nzeros => s_base_solver_get_nzeros - procedure, nopass :: get_wrksz => s_base_solver_get_wrksize - procedure, nopass :: stringval => mld_stringval - procedure, nopass :: get_fmt => s_base_solver_get_fmt - procedure, nopass :: get_id => s_base_solver_get_id - procedure, nopass :: is_iterative => s_base_solver_is_iterative - procedure, pass(sv) :: is_global => s_base_solver_is_global - end type mld_s_base_solver_type - - private :: s_base_solver_sizeof, s_base_solver_default,& - & s_base_solver_get_nzeros, s_base_solver_get_fmt, & - & s_base_solver_is_iterative, s_base_solver_get_id, & - & s_base_solver_get_wrksize, s_base_solver_is_global - - - interface - subroutine mld_s_base_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_base_solver_type), intent(inout) :: sv - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_s_base_solver_apply - end interface - - - interface - subroutine mld_s_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_base_solver_type), intent(inout) :: sv - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - end subroutine mld_s_base_solver_apply_vect - end interface - - interface - subroutine mld_s_base_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, psb_ipk_, psb_i_base_vect_type - Implicit None - - ! Arguments - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type), intent(in), target, optional :: b - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_base_solver_bld - end interface - - interface - subroutine mld_s_base_solver_cnv(sv,info,amold,vmold,imold) - import :: psb_s_base_sparse_mat, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, psb_ipk_, psb_i_base_vect_type - Implicit None - - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_base_solver_cnv - end interface - - interface - subroutine mld_s_base_solver_check(sv,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_base_solver_check - end interface - - interface - subroutine mld_s_base_solver_cseti(sv,what,val,info,idx) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_s_base_solver_cseti - end interface - - interface - subroutine mld_s_base_solver_csetc(sv,what,val,info,idx) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_s_base_solver_csetc - end interface - - interface - subroutine mld_s_base_solver_csetr(sv,what,val,info,idx) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, psb_ipk_ - Implicit None - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_s_base_solver_csetr - end interface - - interface - subroutine mld_s_base_solver_free(sv,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_base_solver_free - end interface - - interface - subroutine mld_s_base_solver_descr(sv,info,iout,coarse) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_base_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - end subroutine mld_s_base_solver_descr - end interface - - interface - subroutine mld_s_base_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, psb_ipk_ - implicit none - class(mld_s_base_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_s_base_solver_dmp - end interface - - interface - subroutine mld_s_base_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_base_solver_clone - end interface - - interface - subroutine mld_s_base_solver_clone_settings(sv,svout,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_base_solver_clone_settings - end interface - - interface - subroutine mld_s_base_solver_clear_data(sv,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_base_solver_clear_data - end interface - -contains - ! - ! Function returning the size of the data structure - ! in bytes or in number of nonzeros of the operator(s) involved. - ! - - function s_base_solver_sizeof(sv) result(val) - implicit none - ! Arguments - class(mld_s_base_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - - return - end function s_base_solver_sizeof - - function s_base_solver_get_nzeros(sv) result(val) - implicit none - class(mld_s_base_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - end function s_base_solver_get_nzeros - - subroutine s_base_solver_default(sv) - implicit none - ! Arguments - class(mld_s_base_solver_type), intent(inout) :: sv - ! Do nothing for base version - - return - end subroutine s_base_solver_default - - function s_base_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Base solver" - end function s_base_solver_get_fmt - - ! - ! If this is true, then the solver needs a starting - ! guess. Currently only handled in JAC smoother. - ! - function s_base_solver_is_iterative() result(val) - implicit none - logical :: val - - val = .false. - end function s_base_solver_is_iterative - ! - ! Is the solver acting globally? In most cases - ! not, SuperLU_Dist does, MUMPS can do either. - ! - function s_base_solver_is_global(sv) result(val) - implicit none - class(mld_s_base_solver_type), intent(in) :: sv - logical :: val - - val = .false. - end function s_base_solver_is_global - - function s_base_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_f_none_ - end function s_base_solver_get_id - - function s_base_solver_get_wrksize() result(val) - implicit none - integer(psb_ipk_) :: val - - val = 0 - end function s_base_solver_get_wrksize - -end module mld_s_base_solver_mod diff --git a/mlprec/mld_s_dec_aggregator_mod.f90 b/mlprec/mld_s_dec_aggregator_mod.f90 deleted file mode 100644 index 082c792a..00000000 --- a/mlprec/mld_s_dec_aggregator_mod.f90 +++ /dev/null @@ -1,201 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! Basic (decoupled) aggregation algorithm. Based on the ideas in -! M. Brezina and P. Vanek, A black-box iterative solver based on a -! two-level Schwarz method, Computing, 63 (1999), 233-263. -! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed -! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 -! (1996), 179-196. -! -module mld_s_dec_aggregator_mod - - use mld_s_base_aggregator_mod - !> \namespace mld_s_dec_aggregator_mod \class mld_s_dec_aggregator_type - !! \extends mld_s_base_aggregator_mod::mld_s_base_aggregator_type - !! - !! type, extends(mld_s_base_aggregator_type) :: mld_s_dec_aggregator_type - !! procedure(mld_s_soc_map_bld), nopass, pointer :: soc_map_bld => null() - !! end type - !! - !! This is the simplest aggregation method: starting from the - !! strength-of-connection measure for defining the aggregation - !! presented in - !! - !! M. Brezina and P. Vanek, A black-box iterative solver based on a - !! two-level Schwarz method, Computing, 63 (1999), 233-263. - !! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed - !! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 - !! (1996), 179-196. - !! - !! it achieves parallelization by simply acting on the local matrix, - !! i.e. by "decoupling" the subdomains. - !! The data structure hosts a "map_bld" function pointer which allows to - !! choose other ways to measure "strength-of-connection", of which the - !! Vanek-Brezina-Mandel is the default. More details are available in - !! - !! P. D'Ambra, D. di Serafino and S. Filippone, On the development of - !! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math. - !! 57 (2007), 1181-1196. - !! - !! The soc_map_bld method is used inside the implementation of build_tprol - !! - ! - ! - type, extends(mld_s_base_aggregator_type) :: mld_s_dec_aggregator_type - procedure(mld_s_soc_map_bld), nopass, pointer :: soc_map_bld => null() - - contains - procedure, pass(ag) :: bld_tprol => mld_s_dec_aggregator_build_tprol - procedure, pass(ag) :: mat_bld => mld_s_dec_aggregator_mat_bld - procedure, pass(ag) :: mat_asb => mld_s_dec_aggregator_mat_asb - procedure, pass(ag) :: default => mld_s_dec_aggregator_default - procedure, pass(ag) :: set_aggr_type => mld_s_dec_aggregator_set_aggr_type - procedure, pass(ag) :: descr => mld_s_dec_aggregator_descr - procedure, nopass :: fmt => mld_s_dec_aggregator_fmt - end type mld_s_dec_aggregator_type - - - procedure(mld_s_soc_map_bld) :: mld_s_soc1_map_bld, mld_s_soc2_map_bld - - interface - subroutine mld_s_dec_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,t_prol,info) - import :: mld_s_dec_aggregator_type, psb_desc_type, psb_sspmat_type, psb_spk_, & - & psb_ipk_, psb_lpk_, psb_lsspmat_type, mld_sml_parms, mld_saggr_data - implicit none - class(mld_s_dec_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(mld_saggr_data), intent(in) :: ag_data - type(psb_sspmat_type), intent(inout) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lsspmat_type), intent(out) :: t_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_dec_aggregator_build_tprol - end interface - - interface - subroutine mld_s_dec_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - import :: mld_s_dec_aggregator_type, psb_desc_type, psb_sspmat_type, psb_spk_, & - & psb_ipk_, psb_lpk_, psb_lsspmat_type, mld_sml_parms - implicit none - class(mld_s_dec_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(psb_lsspmat_type), intent(inout) :: t_prol - type(psb_sspmat_type), intent(out) :: op_prol, ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_dec_aggregator_mat_bld - end interface - - interface - subroutine mld_s_dec_aggregator_mat_asb(ag,parms,a,desc_a,& - & ac,desc_ac,op_prol,op_restr,info) - import :: mld_s_dec_aggregator_type, psb_desc_type, psb_sspmat_type, psb_spk_, & - & psb_ipk_, psb_lpk_, psb_lsspmat_type, mld_sml_parms - implicit none - class(mld_s_dec_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - type(psb_sspmat_type), intent(inout) :: op_prol,ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_dec_aggregator_mat_asb - end interface - -contains - - subroutine mld_s_dec_aggregator_set_aggr_type(ag,parms,info) - use mld_base_prec_type - implicit none - class(mld_s_dec_aggregator_type), intent(inout) :: ag - type(mld_sml_parms), intent(in) :: parms - integer(psb_ipk_), intent(out) :: info - - select case(parms%aggr_type) - case (mld_noalg_) - ag%soc_map_bld => null() - case (mld_soc1_) - ag%soc_map_bld => mld_s_soc1_map_bld - case (mld_soc2_) - ag%soc_map_bld => mld_s_soc2_map_bld - case default - write(0,*) 'Unknown aggregation type, defaulting to SOC1' - ag%soc_map_bld => mld_s_soc1_map_bld - end select - - return - end subroutine mld_s_dec_aggregator_set_aggr_type - - - subroutine mld_s_dec_aggregator_default(ag) - implicit none - class(mld_s_dec_aggregator_type), intent(inout) :: ag - - call ag%mld_s_base_aggregator_type%default() - ag%soc_map_bld => mld_s_soc1_map_bld - - return - end subroutine mld_s_dec_aggregator_default - - function mld_s_dec_aggregator_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Decoupled aggregation" - end function mld_s_dec_aggregator_fmt - - subroutine mld_s_dec_aggregator_descr(ag,parms,iout,info) - implicit none - class(mld_s_dec_aggregator_type), intent(in) :: ag - type(mld_sml_parms), intent(in) :: parms - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - - write(iout,*) 'Decoupled Aggregator' - write(iout,*) 'Aggregator object type: ',ag%fmt() - call parms%mldescr(iout,info) - - return - end subroutine mld_s_dec_aggregator_descr - -end module mld_s_dec_aggregator_mod diff --git a/mlprec/mld_s_diag_solver.f90 b/mlprec/mld_s_diag_solver.f90 deleted file mode 100644 index a0f76a33..00000000 --- a/mlprec/mld_s_diag_solver.f90 +++ /dev/null @@ -1,398 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_s_diag_solver_mod.f90 -! -! Module: mld_s_diag_solver_mod -! -! This module defines: -! - the mld_s_diag_solver_type data structure containing the -! simple diagonal solver. This extracts the main diagonal of a matrix -! and precomputes its inverse. Combined with a Jacobi "smoother" generates -! what are commonly known as the classic Jacobi iterations -! -module mld_s_diag_solver - - use mld_s_base_solver_mod - - type, extends(mld_s_base_solver_type) :: mld_s_diag_solver_type - type(psb_s_vect_type), allocatable :: dv - real(psb_spk_), allocatable :: d(:) - contains - procedure, pass(sv) :: dump => mld_s_diag_solver_dmp - procedure, pass(sv) :: build => mld_s_diag_solver_bld - procedure, pass(sv) :: cnv => mld_s_diag_solver_cnv - procedure, pass(sv) :: clone => mld_s_diag_solver_clone - procedure, pass(sv) :: clear_data => mld_s_diag_solver_clear_data - procedure, pass(sv) :: apply_v => mld_s_diag_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_s_diag_solver_apply - procedure, pass(sv) :: free => s_diag_solver_free - procedure, pass(sv) :: descr => s_diag_solver_descr - procedure, pass(sv) :: sizeof => s_diag_solver_sizeof - procedure, pass(sv) :: get_nzeros => s_diag_solver_get_nzeros - procedure, nopass :: get_fmt => s_diag_solver_get_fmt - procedure, nopass :: get_id => s_diag_solver_get_id - end type mld_s_diag_solver_type - - - private :: s_diag_solver_free, s_diag_solver_descr, & - & s_diag_solver_sizeof, s_diag_solver_get_nzeros, & - & s_diag_solver_get_fmt, s_diag_solver_get_id - - - interface - subroutine mld_s_diag_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_diag_solver_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_diag_solver_type), intent(inout) :: sv - type(psb_s_vect_type), intent(inout) :: x - type(psb_s_vect_type), intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - end subroutine mld_s_diag_solver_apply_vect - end interface - - interface - subroutine mld_s_diag_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_diag_solver_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_diag_solver_type), intent(inout) :: sv - real(psb_spk_), intent(inout) :: x(:) - real(psb_spk_), intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_s_diag_solver_apply - end interface - - interface - subroutine mld_s_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_diag_solver_type, psb_ipk_, psb_i_base_vect_type - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type), intent(in), target, optional :: b - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_diag_solver_bld - end interface - - interface - subroutine mld_s_diag_solver_cnv(sv,info,amold,vmold,imold) - import :: psb_s_base_sparse_mat, psb_s_base_vect_type, psb_spk_, & - & mld_s_diag_solver_type, psb_ipk_, psb_i_base_vect_type - class(mld_s_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_diag_solver_cnv - end interface - - interface - subroutine mld_s_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, mld_s_diag_solver_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, & - & psb_ipk_ - implicit none - class(mld_s_diag_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_s_diag_solver_dmp - end interface - - interface - subroutine mld_s_diag_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, mld_s_diag_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_diag_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_diag_solver_clone - end interface - - interface - subroutine mld_s_diag_solver_clear_data(sv,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_diag_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_diag_solver_clear_data - end interface - - -contains - - subroutine s_diag_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_s_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_diag_solver_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sv%dv)) call sv%dv%free(info) - - if (allocated(sv%d)) then - deallocate(sv%d,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine s_diag_solver_free - - subroutine s_diag_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_s_diag_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_s_diag_solver_descr' - integer(psb_ipk_) :: iout_ - - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' Diagonal local solver ' - - return - - end subroutine s_diag_solver_descr - - function s_diag_solver_sizeof(sv) result(val) - implicit none - ! Arguments - class(mld_s_diag_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - if (allocated(sv%dv)) val = val + sv%dv%sizeof() - - return - end function s_diag_solver_sizeof - - function s_diag_solver_get_nzeros(sv) result(val) - implicit none - ! Arguments - class(mld_s_diag_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - if (allocated(sv%dv)) val = val + sv%dv%get_nrows() - - return - end function s_diag_solver_get_nzeros - - function s_diag_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Diag solver" - end function s_diag_solver_get_fmt - - function s_diag_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_diag_scale_ - end function s_diag_solver_get_id - -end module mld_s_diag_solver - -! -! Module: mld_s_l1_diag_solver_mod -! -! This module defines: -! - the mld_s_l1_diag_solver_type data structure containing the -! L1 diagonal solver. -! The solver is defined as a diagonal containing in each element the -! inverse of the sum of the absolute values of the matrix entries -! along the corresponding row. -! Combined with a Jacobi "smoother" generates -! what are commonly known as the L1-Jacobi iterations -! - -module mld_s_l1_diag_solver - - use mld_s_diag_solver - - type, extends(mld_s_diag_solver_type) :: mld_s_l1_diag_solver_type - contains - procedure, pass(sv) :: dump => mld_s_l1_diag_solver_dmp - procedure, pass(sv) :: build => mld_s_l1_diag_solver_bld - procedure, pass(sv) :: descr => s_l1_diag_solver_descr - procedure, nopass :: get_fmt => s_l1_diag_solver_get_fmt - procedure, nopass :: get_id => s_l1_diag_solver_get_id - end type mld_s_l1_diag_solver_type - - - private :: s_l1_diag_solver_descr, & - & s_l1_diag_solver_get_fmt, s_l1_diag_solver_get_id - - interface - subroutine mld_s_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_l1_diag_solver_type, psb_ipk_, psb_i_base_vect_type - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_l1_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type), intent(in), target, optional :: b - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_l1_diag_solver_bld - end interface - - interface - subroutine mld_s_l1_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, mld_s_l1_diag_solver_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, & - & psb_ipk_ - implicit none - class(mld_s_l1_diag_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_s_l1_diag_solver_dmp - end interface - -contains - - subroutine s_l1_diag_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_s_l1_diag_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_s_l1_diag_solver_descr' - integer(psb_ipk_) :: iout_ - - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' L1 Diagonal solver ' - - return - - end subroutine s_l1_diag_solver_descr - - function s_l1_diag_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "L1 Diag solver" - end function s_l1_diag_solver_get_fmt - - function s_l1_diag_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_l1_diag_scale_ - end function s_l1_diag_solver_get_id - -end module mld_s_l1_diag_solver - diff --git a/mlprec/mld_s_gs_solver.f90 b/mlprec/mld_s_gs_solver.f90 deleted file mode 100644 index e34766a4..00000000 --- a/mlprec/mld_s_gs_solver.f90 +++ /dev/null @@ -1,588 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! File: mld_s_gs_solver_mod.f90 -! -! Module: mld_s_gs_solver_mod -! -! This module defines: -! - the mld_s_gs_solver_type data structure containing the ingredients -! for a local Gauss-Seidel iteration. We provide Forward GS (FWGS) and -! backward GS (BWGS). The iterations are local to a process (they operate -! on the block diagonal). Combined with a Jacobi smoother will generate a -! hybrid-Gauss-Seidel solver, i.e. Gauss-Seidel within each process, Jacobi -! among the processes. -! With two objects as pre- and post-smoothers it is possible to build a -! Forward-Backward smoother, suitable for symmetric iterations. -! -module mld_s_gs_solver - - use mld_s_base_solver_mod - - type, extends(mld_s_base_solver_type) :: mld_s_gs_solver_type - type(psb_sspmat_type) :: l, u - integer(psb_ipk_) :: sweeps - real(psb_spk_) :: eps - contains - procedure, pass(sv) :: dump => mld_s_gs_solver_dmp - procedure, pass(sv) :: check => s_gs_solver_check - procedure, pass(sv) :: clone => mld_s_gs_solver_clone - procedure, pass(sv) :: clone_settings => mld_s_gs_solver_clone_settings - procedure, pass(sv) :: clear_data => mld_s_gs_solver_clear_data - procedure, pass(sv) :: build => mld_s_gs_solver_bld - procedure, pass(sv) :: cnv => mld_s_gs_solver_cnv - procedure, pass(sv) :: apply_v => mld_s_gs_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_s_gs_solver_apply - procedure, pass(sv) :: free => s_gs_solver_free - procedure, pass(sv) :: cseti => s_gs_solver_cseti - procedure, pass(sv) :: csetc => s_gs_solver_csetc - procedure, pass(sv) :: csetr => s_gs_solver_csetr - procedure, pass(sv) :: descr => s_gs_solver_descr - procedure, pass(sv) :: default => s_gs_solver_default - procedure, pass(sv) :: sizeof => s_gs_solver_sizeof - procedure, pass(sv) :: get_nzeros => s_gs_solver_get_nzeros - procedure, nopass :: get_wrksz => s_gs_solver_get_wrksize - procedure, nopass :: get_fmt => s_gs_solver_get_fmt - procedure, nopass :: get_id => s_gs_solver_get_id - procedure, nopass :: is_iterative => s_gs_solver_is_iterative - end type mld_s_gs_solver_type - - type, extends(mld_s_gs_solver_type) :: mld_s_bwgs_solver_type - contains - procedure, pass(sv) :: build => mld_s_bwgs_solver_bld - procedure, pass(sv) :: apply_v => mld_s_bwgs_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_s_bwgs_solver_apply - procedure, nopass :: get_fmt => s_bwgs_solver_get_fmt - procedure, nopass :: get_id => s_bwgs_solver_get_id - procedure, pass(sv) :: descr => s_bwgs_solver_descr - end type mld_s_bwgs_solver_type - - - private :: s_gs_solver_bld, s_gs_solver_apply, & - & s_gs_solver_free, & - & s_gs_solver_descr, s_gs_solver_sizeof, & - & s_gs_solver_default, s_gs_solver_dmp, & - & s_gs_solver_apply_vect, s_gs_solver_get_nzeros, & - & s_gs_solver_get_fmt, s_gs_solver_check,& - & s_gs_solver_is_iterative, & - & s_bwgs_solver_get_fmt, s_bwgs_solver_descr, & - & s_gs_solver_get_id, s_bwgs_solver_get_id, s_gs_solver_get_wrksize - - interface - subroutine mld_s_gs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, mld_s_gs_solver_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_gs_solver_type), intent(inout) :: sv - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - end subroutine mld_s_gs_solver_apply_vect - subroutine mld_s_bwgs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, mld_s_bwgs_solver_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_bwgs_solver_type), intent(inout) :: sv - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - end subroutine mld_s_bwgs_solver_apply_vect - end interface - - interface - subroutine mld_s_gs_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info,init,initu) - import :: psb_desc_type, mld_s_gs_solver_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_gs_solver_type), intent(inout) :: sv - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_s_gs_solver_apply - subroutine mld_s_bwgs_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, mld_s_bwgs_solver_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_bwgs_solver_type), intent(inout) :: sv - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_s_bwgs_solver_apply - end interface - - interface - subroutine mld_s_gs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, mld_s_gs_solver_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type), intent(in), target, optional :: b - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_gs_solver_bld - subroutine mld_s_bwgs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, mld_s_bwgs_solver_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_bwgs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type), intent(in), target, optional :: b - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_bwgs_solver_bld - end interface - - interface - subroutine mld_s_gs_solver_cnv(sv,info,amold,vmold,imold) - import :: mld_s_gs_solver_type, psb_spk_, & - & psb_s_base_sparse_mat, psb_s_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - class(mld_s_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_gs_solver_cnv - end interface - - interface - subroutine mld_s_gs_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, mld_s_gs_solver_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, & - & psb_ipk_ - implicit none - class(mld_s_gs_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_s_gs_solver_dmp - end interface - - interface - subroutine mld_s_gs_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, mld_s_gs_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_gs_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_gs_solver_clone - end interface - - interface - subroutine mld_s_gs_solver_clone_settings(sv,svout,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, mld_s_gs_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_gs_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_gs_solver_clone_settings - end interface - - interface - subroutine mld_s_gs_solver_clear_data(sv,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_gs_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_gs_solver_clear_data - end interface - -contains - - subroutine s_gs_solver_default(sv) - - Implicit None - - ! Arguments - class(mld_s_gs_solver_type), intent(inout) :: sv - - sv%sweeps = ione - sv%eps = dzero - - return - end subroutine s_gs_solver_default - - subroutine s_gs_solver_check(sv,info) - - Implicit None - - ! Arguments - class(mld_s_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_gs_solver_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - call mld_check_def(sv%sweeps,& - & 'GS Sweeps',ione,is_int_positive) - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine s_gs_solver_check - - subroutine s_gs_solver_cseti(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_s_gs_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_gs_solver_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) - case('SOLVER_SWEEPS') - sv%sweeps = val - case default - call sv%mld_s_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine s_gs_solver_cseti - - subroutine s_gs_solver_csetc(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_s_gs_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='s_gs_solver_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - - - call sv%mld_s_base_solver_type%set(what,val,info,idx=idx) - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info, name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine s_gs_solver_csetc - - subroutine s_gs_solver_csetr(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_s_gs_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_gs_solver_csetr' - - call psb_erractionsave(err_act) - info = psb_success_ - - select case(psb_toupper(what)) - case('SOLVER_EPS') - sv%eps = val - case default - call sv%mld_s_base_solver_type%set(what,val,info,idx=idx) - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine s_gs_solver_csetr - - subroutine s_gs_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_s_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_gs_solver_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - call sv%l%free() - call sv%u%free() - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine s_gs_solver_free - - subroutine s_gs_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_s_gs_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_s_gs_solver_descr' - integer(psb_ipk_) :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (sv%eps<=dzero) then - write(iout_,*) ' Forward Gauss-Seidel iterative solver with ',& - & sv%sweeps,' sweeps' - else - write(iout_,*) ' Forward Gauss-Seidel iterative solver with tolerance',& - & sv%eps,' and maxit', sv%sweeps - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine s_gs_solver_descr - - function s_gs_solver_get_nzeros(sv) result(val) - - implicit none - ! Arguments - class(mld_s_gs_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - val = val + sv%l%get_nzeros() - val = val + sv%u%get_nzeros() - - return - end function s_gs_solver_get_nzeros - - function s_gs_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_s_gs_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = psb_sizeof_ip - val = val + sv%l%sizeof() - val = val + sv%u%sizeof() - - return - end function s_gs_solver_sizeof - - function s_gs_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Forward Gauss-Seidel solver" - end function s_gs_solver_get_fmt - - function s_gs_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_gs_ - end function s_gs_solver_get_id - - ! - ! If this is true, then the solver needs a starting - ! guess. Currently only handled in JAC smoother. - ! - function s_gs_solver_is_iterative() result(val) - implicit none - logical :: val - - val = .true. - end function s_gs_solver_is_iterative - - subroutine s_bwgs_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_s_bwgs_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_s_bwgs_solver_descr' - integer(psb_ipk_) :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (sv%eps<=dzero) then - write(iout_,*) ' Backward Gauss-Seidel iterative solver with ',& - & sv%sweeps,' sweeps' - else - write(iout_,*) ' Backward Gauss-Seidel iterative solver with tolerance',& - & sv%eps,' and maxit', sv%sweeps - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine s_bwgs_solver_descr - - function s_bwgs_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Backward Gauss-Seidel solver" - end function s_bwgs_solver_get_fmt - - function s_bwgs_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_bwgs_ - end function s_bwgs_solver_get_id - - function s_gs_solver_get_wrksize() result(val) - implicit none - integer(psb_ipk_) :: val - - val = 2 - end function s_gs_solver_get_wrksize - -end module mld_s_gs_solver diff --git a/mlprec/mld_s_hybrid_aggregator_mod.F90 b/mlprec/mld_s_hybrid_aggregator_mod.F90 deleted file mode 100644 index b8a1ce23..00000000 --- a/mlprec/mld_s_hybrid_aggregator_mod.F90 +++ /dev/null @@ -1,125 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! The aggregator object hosts the aggregation method for building -! the multilevel hierarchy. This variant is based on the hybrid method -! presented in -! -! S. Gratton, P. Henon, P. Jiranek and X. Vasseur: -! Reducing complexity of algebraic multigrid by aggregation -! Numerical Lin. Algebra with Applications, 2016, 23:501-518 -! -module mld_s_hybrid_aggregator_mod - - use mld_s_dec_aggregator_mod - ! - ! sm - class(mld_T_base_smoother_type), allocatable - ! The current level preconditioner (aka smoother). - ! parms - type(mld_RTml_parms) - ! The parameters defining the multilevel strategy. - ! ac - The local part of the current-level matrix, built by - ! coarsening the previous-level matrix. - ! desc_ac - type(psb_desc_type). - ! The communication descriptor associated to the matrix - ! stored in ac. - ! base_a - type(psb_Tspmat_type), pointer. - ! Pointer (really a pointer!) to the local part of the current - ! matrix (so we have a unified treatment of residuals). - ! We need this to avoid passing explicitly the current matrix - ! to the routine which applies the preconditioner. - ! base_desc - type(psb_desc_type), pointer. - ! Pointer to the communication descriptor associated to the - ! matrix pointed by base_a. - ! map - Stores the maps (restriction and prolongation) between the - ! vector spaces associated to the index spaces of the previous - ! and current levels. - ! - ! Methods: - ! Most methods follow the encapsulation hierarchy: they take whatever action - ! is appropriate for the current object, then call the corresponding method for - ! the contained object. - ! As an example: the descr() method prints out a description of the - ! level. It starts by invoking the descr() method of the parms object, - ! then calls the descr() method of the smoother object. - ! - ! descr - Prints a description of the object. - ! default - Set default values - ! dump - Dump to file object contents - ! set - Sets various parameters; when a request is unknown - ! it is passed to the smoother object for further processing. - ! check - Sanity checks. - ! sizeof - Total memory occupation in bytes - ! get_nzeros - Number of nonzeros - ! - ! - type, extends(mld_s_dec_aggregator_type) :: mld_s_hybrid_aggregator_type - - contains - procedure, pass(ag) :: bld_tprol => mld_s_hybrid_aggregator_build_tprol - procedure, nopass :: fmt => mld_s_hybrid_aggregator_fmt - end type mld_s_hybrid_aggregator_type - - - interface - subroutine mld_s_hybrid_aggregator_build_tprol(ag,parms,a,desc_a,ilaggr,nlaggr,op_prol,info) - import :: mld_s_hybrid_aggregator_type, psb_desc_type, psb_sspmat_type, psb_spk_, & - & psb_ipk_, psb_long_int_k_, mld_sml_parms - implicit none - class(mld_s_hybrid_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - integer(psb_ipk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_sspmat_type), intent(out) :: op_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_hybrid_aggregator_build_tprol - end interface - -contains - - - function mld_s_hybrid_aggregator_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Hybrid Decoupled aggregation" - end function mld_s_hybrid_aggregator_fmt - - -end module mld_s_hybrid_aggregator_mod diff --git a/mlprec/mld_s_id_solver.f90 b/mlprec/mld_s_id_solver.f90 deleted file mode 100644 index b4a87e66..00000000 --- a/mlprec/mld_s_id_solver.f90 +++ /dev/null @@ -1,202 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! -! Identity solver. Reference for nullprec. -! -! -module mld_s_id_solver - - use mld_s_base_solver_mod - - type, extends(mld_s_base_solver_type) :: mld_s_id_solver_type - contains - procedure, pass(sv) :: build => s_id_solver_bld - procedure, pass(sv) :: clone => mld_s_id_solver_clone - procedure, pass(sv) :: apply_v => mld_s_id_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_s_id_solver_apply - procedure, pass(sv) :: free => s_id_solver_free - procedure, pass(sv) :: descr => s_id_solver_descr - procedure, nopass :: get_fmt => s_id_solver_get_fmt - procedure, nopass :: get_id => s_id_solver_get_id - end type mld_s_id_solver_type - - - private :: s_id_solver_bld, & - & s_id_solver_free, s_id_solver_get_fmt, & - & s_id_solver_descr, s_id_solver_get_id - - interface - subroutine mld_s_id_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_id_solver_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_id_solver_type), intent(inout) :: sv - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - end subroutine mld_s_id_solver_apply_vect - end interface - - interface - subroutine mld_s_id_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_id_solver_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_id_solver_type), intent(inout) :: sv - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_s_id_solver_apply - end interface - - interface - subroutine mld_s_id_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, mld_s_id_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_id_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_id_solver_clone - end interface - -contains - - - subroutine s_id_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - Implicit None - - ! Arguments - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_id_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type), intent(in), target, optional :: b - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - real(psb_spk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: i, err_act, debug_unit, debug_level - character(len=20) :: name='s_id_solver_bld', ch_err - - info=psb_success_ - - return - end subroutine s_id_solver_bld - - subroutine s_id_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_s_id_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_id_solver_free' - - info = psb_success_ - - return - end subroutine s_id_solver_free - - subroutine s_id_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_s_id_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_s_id_solver_descr' - integer(psb_ipk_) :: iout_ - - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' Identity local solver ' - - return - - end subroutine s_id_solver_descr - - function s_id_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Identity solver" - end function s_id_solver_get_fmt - - function s_id_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_f_none_ - end function s_id_solver_get_id - -end module mld_s_id_solver diff --git a/mlprec/mld_s_ilu_fact_mod.f90 b/mlprec/mld_s_ilu_fact_mod.f90 deleted file mode 100644 index 57651cf1..00000000 --- a/mlprec/mld_s_ilu_fact_mod.f90 +++ /dev/null @@ -1,91 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! File: mld_s_ilu_fact_mod.f90 -! -! Module: mld_s_ilu_fact_mod -! -! This module defines some interfaces used internally by the implementation of -! mld_s_ilu_solver, but not visible to the end user. -! -! -module mld_s_ilu_fact_mod - - use mld_s_base_solver_mod - - interface mld_ilu0_fact - subroutine mld_silu0_fact(ialg,a,l,u,d,info,blck,upd) - import psb_sspmat_type, psb_spk_, psb_ipk_ - integer(psb_ipk_), intent(in) :: ialg - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type),intent(in) :: a - type(psb_sspmat_type),intent(inout) :: l,u - type(psb_sspmat_type),intent(in), optional, target :: blck - character, intent(in), optional :: upd - real(psb_spk_), intent(inout) :: d(:) - end subroutine mld_silu0_fact - end interface - - interface mld_iluk_fact - subroutine mld_siluk_fact(fill_in,ialg,a,l,u,d,info,blck) - import psb_sspmat_type, psb_spk_, psb_ipk_ - integer(psb_ipk_), intent(in) :: fill_in,ialg - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type),intent(in) :: a - type(psb_sspmat_type),intent(inout) :: l,u - type(psb_sspmat_type),intent(in), optional, target :: blck - real(psb_spk_), intent(inout) :: d(:) - end subroutine mld_siluk_fact - end interface - - interface mld_ilut_fact - subroutine mld_silut_fact(fill_in,thres,a,l,u,d,info,blck,iscale) - import psb_sspmat_type, psb_spk_, psb_ipk_ - integer(psb_ipk_), intent(in) :: fill_in - real(psb_spk_), intent(in) :: thres - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type),intent(in) :: a - type(psb_sspmat_type),intent(inout) :: l,u - real(psb_spk_), intent(inout) :: d(:) - type(psb_sspmat_type),intent(in), optional, target :: blck - integer(psb_ipk_), intent(in), optional :: iscale - end subroutine mld_silut_fact - end interface - -end module mld_s_ilu_fact_mod diff --git a/mlprec/mld_s_ilu_solver.f90 b/mlprec/mld_s_ilu_solver.f90 deleted file mode 100644 index 051af244..00000000 --- a/mlprec/mld_s_ilu_solver.f90 +++ /dev/null @@ -1,502 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! File: mld_s_ilu_solver_mod.f90 -! -! Module: mld_s_ilu_solver_mod -! -! This module defines: -! - the mld_s_ilu_solver_type data structure containing the ingredients -! for a local Incomplete LU factorization. -! 1. The factorization is always restricted to the diagonal block of the -! current image (coherently with the definition of a SOLVER as a local -! object) -! 2. The code provides support for both pattern-based ILU(K) and -! threshold base ILU(T,L) -! 3. The diagonal is stored separately, so strictly speaking this is -! an incomplete LDU factorization; -! 4. The application phase is shared among all variants; -! -! -module mld_s_ilu_solver - - use mld_base_prec_type, only : mld_fact_names - use mld_s_base_solver_mod - use psb_s_ilu_fact_mod - - type, extends(mld_s_base_solver_type) :: mld_s_ilu_solver_type - type(psb_sspmat_type) :: l, u - real(psb_spk_), allocatable :: d(:) - type(psb_s_vect_type) :: dv - integer(psb_ipk_) :: fact_type, fill_in - real(psb_spk_) :: thresh - contains - procedure, pass(sv) :: dump => mld_s_ilu_solver_dmp - procedure, pass(sv) :: check => s_ilu_solver_check - procedure, pass(sv) :: clone => mld_s_ilu_solver_clone - procedure, pass(sv) :: clone_settings => mld_s_ilu_solver_clone_settings - procedure, pass(sv) :: clear_data => mld_s_ilu_solver_clear_data - procedure, pass(sv) :: build => mld_s_ilu_solver_bld - procedure, pass(sv) :: cnv => mld_s_ilu_solver_cnv - procedure, pass(sv) :: apply_v => mld_s_ilu_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_s_ilu_solver_apply - procedure, pass(sv) :: free => s_ilu_solver_free - procedure, pass(sv) :: cseti => s_ilu_solver_cseti - procedure, pass(sv) :: csetc => s_ilu_solver_csetc - procedure, pass(sv) :: csetr => s_ilu_solver_csetr - procedure, pass(sv) :: descr => s_ilu_solver_descr - procedure, pass(sv) :: default => s_ilu_solver_default - procedure, pass(sv) :: sizeof => s_ilu_solver_sizeof - procedure, pass(sv) :: get_nzeros => s_ilu_solver_get_nzeros - procedure, nopass :: get_wrksz => s_ilu_solver_get_wrksize - procedure, nopass :: get_fmt => s_ilu_solver_get_fmt - procedure, nopass :: get_id => s_ilu_solver_get_id - end type mld_s_ilu_solver_type - - - private :: s_ilu_solver_bld, s_ilu_solver_apply, & - & s_ilu_solver_free, & - & s_ilu_solver_descr, s_ilu_solver_sizeof, & - & s_ilu_solver_default, s_ilu_solver_dmp, & - & s_ilu_solver_apply_vect, s_ilu_solver_get_nzeros, & - & s_ilu_solver_get_fmt, s_ilu_solver_check, & - & s_ilu_solver_get_id, s_ilu_solver_get_wrksize - - - interface - subroutine mld_s_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, mld_s_ilu_solver_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_ilu_solver_type), intent(inout) :: sv - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - end subroutine mld_s_ilu_solver_apply_vect - end interface - - interface - subroutine mld_s_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, mld_s_ilu_solver_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_ilu_solver_type), intent(inout) :: sv - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_s_ilu_solver_apply - end interface - - interface - subroutine mld_s_ilu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, mld_s_ilu_solver_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type), intent(in), target, optional :: b - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_ilu_solver_bld - end interface - - interface - subroutine mld_s_ilu_solver_cnv(sv,info,amold,vmold,imold) - import :: mld_s_ilu_solver_type, psb_spk_, & - & psb_s_base_sparse_mat, psb_s_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - class(mld_s_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_ilu_solver_cnv - end interface - - interface - subroutine mld_s_ilu_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, mld_s_ilu_solver_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, & - & psb_ipk_ - implicit none - class(mld_s_ilu_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_s_ilu_solver_dmp - end interface - - interface - subroutine mld_s_ilu_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, mld_s_ilu_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_ilu_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_ilu_solver_clone - end interface - - interface - subroutine mld_s_ilu_solver_clone_settings(sv,svout,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_base_solver_type, mld_s_ilu_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_ilu_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_ilu_solver_clone_settings - end interface - - interface - subroutine mld_s_ilu_solver_clear_data(sv,info) - import :: psb_desc_type, psb_sspmat_type, psb_s_base_sparse_mat, & - & psb_s_vect_type, psb_s_base_vect_type, psb_spk_, & - & mld_s_ilu_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_s_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_ilu_solver_clear_data - end interface - -contains - - subroutine s_ilu_solver_default(sv) - - Implicit None - - ! Arguments - class(mld_s_ilu_solver_type), intent(inout) :: sv - - sv%fact_type = psb_ilu_n_ - sv%fill_in = 0 - sv%thresh = szero - - return - end subroutine s_ilu_solver_default - - subroutine s_ilu_solver_check(sv,info) - - Implicit None - - ! Arguments - class(mld_s_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_ilu_solver_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - call mld_check_def(sv%fact_type,& - & 'Factorization',psb_ilu_n_,is_legal_ilu_fact) - - select case(sv%fact_type) - case(psb_ilu_n_,psb_milu_n_) - call mld_check_def(sv%fill_in,& - & 'Level',izero,is_int_non_negative) - case(psb_ilu_t_) - call mld_check_def(sv%thresh,& - & 'Eps',szero,is_legal_s_fact_thrs) - end select - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine s_ilu_solver_check - - subroutine s_ilu_solver_cseti(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_s_ilu_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_ilu_solver_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(trim((what)))) - case('SUB_SOLVE') - sv%fact_type = val - case('SUB_FILLIN') - sv%fill_in = val - case default - call sv%mld_s_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine s_ilu_solver_cseti - - subroutine s_ilu_solver_csetc(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_s_ilu_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='s_ilu_solver_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - ival = mld_stringval(val) - select case(psb_toupper(trim((what)))) - case('SUB_SOLVE') - sv%fact_type = ival - case default - call sv%mld_s_base_solver_type%set(what,val,info,idx=idx) - end select - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info, name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine s_ilu_solver_csetc - - subroutine s_ilu_solver_csetr(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_s_ilu_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_ilu_solver_csetr' - - call psb_erractionsave(err_act) - info = psb_success_ - - select case(psb_toupper(what)) - case('SUB_ILUTHRS') - sv%thresh = val - case default - call sv%mld_s_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine s_ilu_solver_csetr - - subroutine s_ilu_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_s_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_ilu_solver_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sv%d)) then - deallocate(sv%d,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - end if - call sv%l%free() - call sv%u%free() - call sv%dv%free(info) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine s_ilu_solver_free - - subroutine s_ilu_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_s_ilu_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_s_ilu_solver_descr' - integer(psb_ipk_) :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' Incomplete factorization solver: ',& - & mld_fact_names(sv%fact_type) - select case(sv%fact_type) - case(psb_ilu_n_,psb_milu_n_) - write(iout_,*) ' Fill level:',sv%fill_in - case(psb_ilu_t_) - write(iout_,*) ' Fill level:',sv%fill_in - write(iout_,*) ' Fill threshold :',sv%thresh - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine s_ilu_solver_descr - - function s_ilu_solver_get_nzeros(sv) result(val) - - implicit none - ! Arguments - class(mld_s_ilu_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - val = val + sv%dv%get_nrows() - val = val + sv%l%get_nzeros() - val = val + sv%u%get_nzeros() - - return - end function s_ilu_solver_get_nzeros - - function s_ilu_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_s_ilu_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 2*psb_sizeof_ip + psb_sizeof_sp - val = val + sv%dv%sizeof() - val = val + sv%l%sizeof() - val = val + sv%u%sizeof() - - return - end function s_ilu_solver_sizeof - - function s_ilu_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "ILU solver" - end function s_ilu_solver_get_fmt - - function s_ilu_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = psb_ilu_n_ - end function s_ilu_solver_get_id - - function s_ilu_solver_get_wrksize() result(val) - implicit none - integer(psb_ipk_) :: val - - val = 2 - end function s_ilu_solver_get_wrksize - -end module mld_s_ilu_solver diff --git a/mlprec/mld_s_inner_mod.f90 b/mlprec/mld_s_inner_mod.f90 deleted file mode 100644 index 0be4b37b..00000000 --- a/mlprec/mld_s_inner_mod.f90 +++ /dev/null @@ -1,131 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_inner_mod.f90 -! -! Module: mld_inner_mod -! -! This module defines the interfaces to inner MLD2P4 routines. -! The interfaces of the user level routines are defined in mld_prec_mod.f90. -! -module mld_s_inner_mod - - use psb_base_mod, only : psb_sspmat_type, psb_desc_type, psb_i_base_vect_type, & - & psb_spk_, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_, & - & psb_s_vect_type, psb_lpk_, psb_lsspmat_type - use mld_s_prec_type, only : mld_sprec_type, mld_sml_parms, & - & mld_s_onelev_type, mld_smlprec_wrk_type - - interface mld_mlprec_bld - subroutine mld_smlprec_bld(a,desc_a,prec,info, amold, vmold,imold) - import :: psb_sspmat_type, psb_desc_type, psb_i_base_vect_type, & - & psb_spk_, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ - import :: mld_sprec_type - implicit none - type(psb_sspmat_type), intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - type(mld_sprec_type), intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_smlprec_bld - end interface mld_mlprec_bld - - interface mld_mlprec_aply - subroutine mld_smlprec_aply(alpha,p,x,beta,y,desc_data,trans,work,info) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, psb_ipk_ - import :: mld_sprec_type - implicit none - type(psb_desc_type),intent(in) :: desc_data - type(mld_sprec_type), intent(inout) :: p - real(psb_spk_),intent(in) :: alpha,beta - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - character,intent(in) :: trans - real(psb_spk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - end subroutine mld_smlprec_aply - subroutine mld_smlprec_aply_vect(alpha,p,x,beta,y,desc_data,trans,work,info) - import :: psb_sspmat_type, psb_desc_type, & - & psb_spk_, psb_s_vect_type, psb_ipk_ - import :: mld_sprec_type - implicit none - type(psb_desc_type),intent(in) :: desc_data - type(mld_sprec_type), intent(inout) :: p - real(psb_spk_),intent(in) :: alpha,beta - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - character,intent(in) :: trans - real(psb_spk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - end subroutine mld_smlprec_aply_vect - end interface mld_mlprec_aply - - interface mld_map_to_tprol - subroutine mld_s_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, psb_ipk_, psb_lpk_, psb_lsspmat_type - import :: mld_s_onelev_type - implicit none - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), allocatable, intent(inout) :: ilaggr(:),nlaggr(:) - type(psb_lsspmat_type), intent(out) :: op_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_map_to_tprol - end interface mld_map_to_tprol - - abstract interface - subroutine mld_saggrmat_var_bld(a,desc_a,ilaggr,nlaggr,parms,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, psb_ipk_, psb_lpk_, psb_lsspmat_type - import :: mld_s_onelev_type, mld_sml_parms - implicit none - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(mld_sml_parms), intent(inout) :: parms - type(psb_sspmat_type), intent(inout) :: op_prol,ac,op_restr - type(psb_lsspmat_type), intent(inout) :: t_prol - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - end subroutine mld_saggrmat_var_bld - end interface - - procedure(mld_saggrmat_var_bld) :: mld_saggrmat_nosmth_bld, & - & mld_saggrmat_smth_bld, mld_saggrmat_minnrg_bld - -end module mld_s_inner_mod diff --git a/mlprec/mld_s_jac_smoother.f90 b/mlprec/mld_s_jac_smoother.f90 deleted file mode 100644 index cbe6fead..00000000 --- a/mlprec/mld_s_jac_smoother.f90 +++ /dev/null @@ -1,454 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_s_jac_smoother_mod.f90 -! -! Module: mld_s_jac_smoother_mod -! -! This module defines: -! the mld_s_jac_smoother_type data structure containing the -! smoother for a Jacobi/block Jacobi smoother. -! The smoother stores in ND the block off-diagonal matrix. -! One special case is treated separately, when the solver is DIAG or L1-DIAG -! then the ND is the entire off-diagonal part of the matrix (including the -! main diagonal block), so that it becomes possible to implement -! a pure Jacobi or L1-Jacobi global solver. -! -module mld_s_jac_smoother - - use mld_s_base_smoother_mod - - type, extends(mld_s_base_smoother_type) :: mld_s_jac_smoother_type - ! The local solver component is inherited from the - ! parent type. - ! class(mld_s_base_solver_type), allocatable :: sv - ! - type(psb_sspmat_type), pointer :: pa => null() - type(psb_sspmat_type) :: nd - integer(psb_lpk_) :: nd_nnz_tot - logical :: checkres - logical :: printres - integer(psb_ipk_) :: checkiter - integer(psb_ipk_) :: printiter - real(psb_dpk_) :: tol - contains - procedure, pass(sm) :: apply_v => mld_s_jac_smoother_apply_vect - procedure, pass(sm) :: apply_a => mld_s_jac_smoother_apply - procedure, pass(sm) :: dump => mld_s_jac_smoother_dmp - procedure, pass(sm) :: build => mld_s_jac_smoother_bld - procedure, pass(sm) :: cnv => mld_s_jac_smoother_cnv - procedure, pass(sm) :: clone => mld_s_jac_smoother_clone - procedure, pass(sm) :: clone_settings => mld_s_jac_smoother_clone_settings - procedure, pass(sm) :: clear_data => mld_s_jac_smoother_clear_data - procedure, pass(sm) :: free => s_jac_smoother_free - procedure, pass(sm) :: cseti => mld_s_jac_smoother_cseti - procedure, pass(sm) :: csetc => mld_s_jac_smoother_csetc - procedure, pass(sm) :: csetr => mld_s_jac_smoother_csetr - procedure, pass(sm) :: descr => mld_s_jac_smoother_descr - procedure, pass(sm) :: sizeof => s_jac_smoother_sizeof - procedure, pass(sm) :: default => s_jac_smoother_default - procedure, pass(sm) :: get_nzeros => s_jac_smoother_get_nzeros - procedure, pass(sm) :: get_wrksz => s_jac_smoother_get_wrksize - procedure, nopass :: get_fmt => s_jac_smoother_get_fmt - procedure, nopass :: get_id => s_jac_smoother_get_id - end type mld_s_jac_smoother_type - - type, extends(mld_s_jac_smoother_type) :: mld_s_l1_jac_smoother_type - contains - procedure, pass(sm) :: build => mld_s_l1_jac_smoother_bld - procedure, pass(sm) :: clone => mld_s_l1_jac_smoother_clone - procedure, pass(sm) :: descr => mld_s_l1_jac_smoother_descr - procedure, nopass :: get_fmt => s_l1_jac_smoother_get_fmt - procedure, nopass :: get_id => s_l1_jac_smoother_get_id - end type mld_s_l1_jac_smoother_type - - private :: s_jac_smoother_free, & - & s_jac_smoother_sizeof, s_jac_smoother_get_nzeros, & - & s_jac_smoother_get_fmt, s_jac_smoother_get_id, & - & s_jac_smoother_get_wrksize - private :: s_l1_jac_smoother_get_fmt, s_l1_jac_smoother_get_id - - - interface - subroutine mld_s_jac_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,wv,info,init,initu) - import :: psb_desc_type, mld_s_jac_smoother_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type,& - & psb_ipk_ - - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_jac_smoother_type), intent(inout) :: sm - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - end subroutine mld_s_jac_smoother_apply_vect - end interface - - interface - subroutine mld_s_jac_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,info,init,initu) - import :: psb_desc_type, mld_s_jac_smoother_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, & - & psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_jac_smoother_type), intent(inout) :: sm - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - end subroutine mld_s_jac_smoother_apply - end interface - - interface - subroutine mld_s_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - import :: psb_desc_type, mld_s_jac_smoother_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_jac_smoother_bld - end interface - - interface - subroutine mld_s_jac_smoother_cnv(sm,info,amold,vmold,imold) - import :: mld_s_jac_smoother_type, psb_spk_, & - & psb_s_base_sparse_mat, psb_s_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - class(mld_s_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_jac_smoother_cnv - end interface - - interface - subroutine mld_s_jac_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_spk_, mld_s_jac_smoother_type, psb_epk_, psb_desc_type, & - & psb_ipk_ - implicit none - class(mld_s_jac_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - end subroutine mld_s_jac_smoother_dmp - end interface - - interface - subroutine mld_s_jac_smoother_clone(sm,smout,info) - import :: mld_s_jac_smoother_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_ - class(mld_s_jac_smoother_type), intent(inout) :: sm - class(mld_s_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_jac_smoother_clone - end interface - - interface - subroutine mld_s_jac_smoother_clone_settings(sm,smout,info) - import :: mld_s_jac_smoother_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_ - class(mld_s_jac_smoother_type), intent(inout) :: sm - class(mld_s_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_jac_smoother_clone_settings - end interface - - interface - subroutine mld_s_jac_smoother_clear_data(sm,info) - import :: mld_s_jac_smoother_type, psb_spk_, & - & mld_s_base_smoother_type, psb_ipk_ - class(mld_s_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_jac_smoother_clear_data - end interface - - interface - subroutine mld_s_jac_smoother_descr(sm,info,iout,coarse) - import :: mld_s_jac_smoother_type, psb_ipk_ - class(mld_s_jac_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - end subroutine mld_s_jac_smoother_descr - end interface - - interface - subroutine mld_s_jac_smoother_cseti(sm,what,val,info,idx) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_spk_, mld_s_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_s_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_s_jac_smoother_cseti - end interface - - interface - subroutine mld_s_jac_smoother_csetc(sm,what,val,info,idx) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_spk_, mld_s_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_s_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_s_jac_smoother_csetc - end interface - - interface - subroutine mld_s_jac_smoother_csetr(sm,what,val,info,idx) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_spk_, mld_s_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_s_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_s_jac_smoother_csetr - end interface - - - interface - subroutine mld_s_l1_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - import :: psb_desc_type, mld_s_l1_jac_smoother_type, psb_s_vect_type, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_l1_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_l1_jac_smoother_bld - end interface - - interface - subroutine mld_s_l1_jac_smoother_clone(sm,smout,info) - import :: mld_s_l1_jac_smoother_type, & - & mld_s_base_smoother_type, psb_ipk_ - class(mld_s_l1_jac_smoother_type), intent(inout) :: sm - class(mld_s_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_l1_jac_smoother_clone - end interface - - interface - subroutine mld_s_l1_jac_smoother_clone_settings(sm,smout,info) - import :: mld_s_l1_jac_smoother_type, & - & mld_s_base_smoother_type, psb_ipk_ - class(mld_s_l1_jac_smoother_type), intent(inout) :: sm - class(mld_s_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_l1_jac_smoother_clone_settings - end interface - - interface - subroutine mld_s_l1_jac_smoother_clear_data(sm,info) - import :: mld_s_l1_jac_smoother_type, & - & mld_s_base_smoother_type, psb_ipk_ - class(mld_s_l1_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_l1_jac_smoother_clear_data - end interface - - interface - subroutine mld_s_l1_jac_smoother_descr(sm,info,iout,coarse) - import :: mld_s_l1_jac_smoother_type, psb_ipk_ - class(mld_s_l1_jac_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - end subroutine mld_s_l1_jac_smoother_descr - end interface - -contains - - - subroutine s_jac_smoother_free(sm,info) - - - Implicit None - - ! Arguments - class(mld_s_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_jac_smoother_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - - - if (allocated(sm%sv)) then - call sm%sv%free(info) - if (info == psb_success_) deallocate(sm%sv,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - end if - call sm%nd%free() - sm%pa => null() - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine s_jac_smoother_free - - function s_jac_smoother_sizeof(sm) result(val) - - implicit none - ! Arguments - class(mld_s_jac_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = psb_sizeof_lp - if (allocated(sm%sv)) val = val + sm%sv%sizeof() - val = val + sm%nd%sizeof() - - return - end function s_jac_smoother_sizeof - - subroutine s_jac_smoother_default(sm) - - Implicit None - - ! Arguments - class(mld_s_jac_smoother_type), intent(inout) :: sm - - ! - ! Default: BJAC with no residual check - ! - sm%checkres = .false. - sm%printres = .false. - sm%checkiter = -1 - sm%printiter = -1 - sm%tol = 0 - - if (allocated(sm%sv)) then - call sm%sv%default() - end if - - return - end subroutine s_jac_smoother_default - - function s_jac_smoother_get_nzeros(sm) result(val) - - implicit none - ! Arguments - class(mld_s_jac_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - if (allocated(sm%sv)) val = val + sm%sv%get_nzeros() - val = val + sm%nd%get_nzeros() - - return - end function s_jac_smoother_get_nzeros - - function s_jac_smoother_get_wrksize(sm) result(val) - implicit none - class(mld_s_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_) :: val - - val = 2 - if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() - - end function s_jac_smoother_get_wrksize - - function s_jac_smoother_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Jacobi smoother" - end function s_jac_smoother_get_fmt - - function s_jac_smoother_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_jac_ - end function s_jac_smoother_get_id - - function s_l1_jac_smoother_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "L1-Jacobi smoother" - end function s_l1_jac_smoother_get_fmt - - function s_l1_jac_smoother_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_l1_jac_ - end function s_l1_jac_smoother_get_id - -end module mld_s_jac_smoother diff --git a/mlprec/mld_s_mumps_solver.F90 b/mlprec/mld_s_mumps_solver.F90 deleted file mode 100644 index d3951a9f..00000000 --- a/mlprec/mld_s_mumps_solver.F90 +++ /dev/null @@ -1,590 +0,0 @@ - -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -! File: mld_s_mumps_solver_mod.f90 -! -! Module: mld_s_mumps_solver_mod -! -! This module defines: -! - the mld_s_mumps_solver_type data structure containing the ingredients -! to interface with the MUMPS package. -! 1. The factorization can be either restricted to the diagonal block of the -! current image or distributed (and thus exact). -! -module mld_s_mumps_solver - use mld_s_base_solver_mod -#if defined(HAVE_MUMPS_) && defined(HAVE_MUMPS_MODULES_) - use smumps_struc_def -#endif -#if defined(HAVE_MUMPS_) && defined(HAVE_MUMPS_INCLUDES_) - include 'smumps_struc.h' -#endif - - - type :: mld_s_mumps_icntl_item - integer(psb_ipk_), allocatable :: item - end type mld_s_mumps_icntl_item - type :: mld_s_mumps_rcntl_item - real(psb_spk_), allocatable :: item - end type mld_s_mumps_rcntl_item - - type, extends(mld_s_base_solver_type) :: mld_s_mumps_solver_type -#if defined(HAVE_MUMPS_) - type(smumps_struc), allocatable :: id -#else - integer, allocatable :: id -#endif - type(mld_s_mumps_icntl_item), allocatable :: icntl(:) - type(mld_s_mumps_rcntl_item), allocatable :: rcntl(:) - ! - ! Controls to be set before MUMPS instantiation: - ! - ! IPAR(1) : MUMPS_LOC_GLOB 0==mld_local_solver_: LOCAL 1==mld_global_solver_: GLOBAL - ! IPAR(2) : MUMPS_PRINT_ERR print verbosity (see MUMPS) - ! IPAR(3) : MUMPS_SYM 0: non-symmetric 2: symmetric - integer(psb_ipk_), dimension(3) :: ipar - integer(psb_ipk_), allocatable :: local_ictxt - logical :: built = .false. - contains - procedure, pass(sv) :: build => s_mumps_solver_bld - procedure, pass(sv) :: apply_a => s_mumps_solver_apply - procedure, pass(sv) :: apply_v => s_mumps_solver_apply_vect - procedure, pass(sv) :: clone_settings => s_mumps_solver_clone_settings - procedure, pass(sv) :: clear_data => s_mumps_solver_clear_data - procedure, pass(sv) :: free => s_mumps_solver_free - procedure, pass(sv) :: descr => s_mumps_solver_descr - procedure, pass(sv) :: sizeof => s_mumps_solver_sizeof - procedure, pass(sv) :: csetc => s_mumps_solver_csetc - procedure, pass(sv) :: cseti => s_mumps_solver_cseti - procedure, pass(sv) :: csetr => s_mumps_solver_csetr - procedure, pass(sv) :: default => s_mumps_solver_default - procedure, nopass :: get_fmt => s_mumps_solver_get_fmt - procedure, nopass :: get_id => s_mumps_solver_get_id - procedure, pass(sv) :: is_global => s_mumps_solver_is_global - final :: s_mumps_solver_finalize - end type mld_s_mumps_solver_type - - - private :: s_mumps_solver_bld, s_mumps_solver_apply, & - & s_mumps_solver_free, s_mumps_solver_descr, & - & s_mumps_solver_sizeof, s_mumps_solver_apply_vect,& - & s_mumps_solver_cseti, s_mumps_solver_csetr, & - & s_mumps_solver_csetc, s_mumps_solver_clear_data, & - & s_mumps_solver_default, s_mumps_solver_get_fmt, & - & s_mumps_solver_clone_settings, & - & s_mumps_solver_get_id, s_mumps_solver_is_global - private :: s_mumps_solver_finalize - - interface - subroutine s_mumps_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, mld_s_mumps_solver_type, psb_s_vect_type, psb_dpk_, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_mumps_solver_type), intent(inout) :: sv - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - end subroutine s_mumps_solver_apply_vect - end interface - - interface - subroutine s_mumps_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info,init,initu) - import :: psb_desc_type, mld_s_mumps_solver_type, psb_s_vect_type, psb_dpk_, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_mumps_solver_type), intent(inout) :: sv - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - end subroutine s_mumps_solver_apply - end interface - - interface - subroutine s_mumps_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - import :: psb_desc_type, mld_s_mumps_solver_type, psb_s_vect_type, psb_spk_, & - & psb_sspmat_type, psb_s_base_sparse_mat, psb_s_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - - Implicit None - - ! Arguments - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_sspmat_type), intent(in), target, optional :: b - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine s_mumps_solver_bld - end interface - -contains - - subroutine s_mumps_solver_clone_settings(sv,svout,info) - - use psb_base_mod - Implicit None - ! Arguments - class(mld_s_mumps_solver_type), intent(inout) :: sv - class(mld_s_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: k,err_act - character(len=20) :: name='s_mumps_solver_clone_settings' - - info = 0 - -#if defined(HAVE_MUMPS_) - - call psb_erractionsave(err_act) - - select type(svout) - class is(mld_s_mumps_solver_type) - svout%ipar(:) = sv%ipar(:) - svout%built = .false. - if (allocated(svout%icntl)) deallocate(svout%icntl,stat=info) - if (info == 0) allocate(svout%icntl(mld_mumps_icntl_size),stat=info) - if (info == 0) then - do k=1,mld_mumps_icntl_size - call psb_safe_ab_cpy(sv%icntl(k)%item,svout%icntl(k)%item,info) - end do - end if - - if (allocated(svout%rcntl)) deallocate(svout%rcntl,stat=info) - if (info == 0) allocate(svout%rcntl(mld_mumps_rcntl_size),stat=info) - if (info == 0) then - do k=1,mld_mumps_rcntl_size - call psb_safe_ab_cpy(sv%rcntl(k)%item,svout%rcntl(k)%item,info) - end do - end if - - class default - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -#endif - end subroutine s_mumps_solver_clone_settings - - subroutine s_mumps_solver_clear_data(sv,info) - use psb_base_mod, only : psb_exit - Implicit None - - ! Arguments - class(mld_s_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - Integer(psb_ipk_) :: err_act - character(len=20) :: name='s_mumps_solver_clear_data' - - info = 0 -#if defined(HAVE_MUMPS_) - call psb_erractionsave(err_act) - if (allocated(sv%id)) then - if (sv%built) then - sv%id%job = -2 - call smumps(sv%id) - info = sv%id%infog(1) - if (info /= psb_success_) goto 9999 - end if - deallocate(sv%id, stat=info) - if (allocated(sv%local_ictxt)) then - call psb_exit(sv%local_ictxt,close=.false.) - deallocate(sv%local_ictxt,stat=info) - end if - sv%built=.false. - end if - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -#endif - end subroutine s_mumps_solver_clear_data - - subroutine s_mumps_solver_free(sv,info) - use psb_base_mod, only : psb_exit - Implicit None - - ! Arguments - class(mld_s_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - Integer(psb_ipk_) :: err_act - character(len=20) :: name='s_mumps_solver_free' - - info = 0 -#if defined(HAVE_MUMPS_) - call psb_erractionsave(err_act) - call sv%clear_data(info) - if ((info == 0).and.allocated(sv%icntl)) deallocate(sv%icntl,stat=info) - if ((info == 0).and.allocated(sv%rcntl)) deallocate(sv%rcntl,stat=info) - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -#endif - end subroutine s_mumps_solver_free - -subroutine s_mumps_solver_finalize(sv) - - Implicit None - - ! Arguments - type(mld_s_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_) :: info - Integer(psb_ipk_) :: err_act - character(len=20) :: name='s_mumps_solver_finalize' - - call sv%free(info) - - return - -end subroutine s_mumps_solver_finalize - -subroutine s_mumps_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_s_mumps_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt, me, np - character(len=20), parameter :: name='mld_z_mumps_solver_descr' - integer(psb_ipk_) :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' MUMPS Solver. ' - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -end subroutine s_mumps_solver_descr - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! WARNING: OTHER PARAMETERS OF MUMPS COULD BE ADDED. !! -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - -subroutine s_mumps_solver_csetc(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_s_mumps_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_mumps_solver_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - - - select case(psb_toupper(trim(what))) -#if defined(HAVE_MUMPS_) - case('MUMPS_LOC_GLOB') - sv%ipar(1) = sv%stringval(psb_toupper(trim(val))) -#endif - case default - call sv%mld_s_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -end subroutine s_mumps_solver_csetc - - -subroutine s_mumps_solver_cseti(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_s_mumps_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_mumps_solver_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) -#if defined(HAVE_MUMPS_) - case('MUMPS_LOC_GLOB') - sv%ipar(1) = val - case('MUMPS_PRINT_ERR') - sv%ipar(2) = val - case('MUMPS_SYM') - sv%ipar(3) = val - case('MUMPS_IPAR_ENTRY') - if(present(idx)) then - ! Note: this will allocate %item - sv%icntl(idx)%item = val - end if -#endif - case default - call sv%mld_s_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -end subroutine s_mumps_solver_cseti - -subroutine s_mumps_solver_csetr(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_s_mumps_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='s_mumps_solver_csetr' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) -#if defined(HAVE_MUMPS_) - case('MUMPS_RPAR_ENTRY') - if(present(idx)) then - ! Note: this will allocate %item - sv%rcntl(idx)%item = val - end if -#endif - case default - call sv%mld_s_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -end subroutine s_mumps_solver_csetr - -!!NOTE: BY DEFAULT BLR is activated with a dropping parameter to 1d-4 !! -subroutine s_mumps_solver_default(sv) - - Implicit none - - !Argument - class(mld_s_mumps_solver_type),intent(inout) :: sv - integer(psb_ipk_) :: info - integer(psb_ipk_) :: err_act,ictx,icomm - character(len=20) :: name='s_mumps_default' - - info = psb_success_ - call psb_erractionsave(err_act) - -#if defined(HAVE_MUMPS_) - if (.not.allocated(sv%id)) then - allocate(sv%id,stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_dealloc_ - call psb_errpush(info,name,a_err='mld_smumps_default') - goto 9999 - end if - sv%built=.false. - end if - if (.not.allocated(sv%icntl)) then - allocate(sv%icntl(mld_mumps_icntl_size),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_dealloc_ - call psb_errpush(info,name,a_err='mld_smumps_default') - goto 9999 - end if - end if - if (.not.allocated(sv%rcntl)) then - allocate(sv%rcntl(mld_mumps_rcntl_size),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_dealloc_ - call psb_errpush(info,name,a_err='mld_smumps_default') - goto 9999 - end if - end if - ! INSTANTIATION OF sv%id needed to set parmater but mpi communicator needed - ! sv%id%job = -1 - ! sv%id%par=1 - ! call dmumps(sv%id) - sv%ipar = 0 - sv%ipar(1) = mld_global_solver_ - !sv%ipar(10)=6 - !sv%ipar(11)=0 - !sv%ipar(12)=6 - -#endif - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return - -end subroutine s_mumps_solver_default - -function s_mumps_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_s_mumps_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer :: i -#if defined(HAVE_MUMPS_) - val = (sv%id%INFOG(22)+sv%id%INFOG(32))*1d+6 -#else - val = 0 -#endif - ! val = 2*psb_sizeof_ip + psb_sizeof_dp - ! val = val + sv%symbsize - ! val = val + sv%numsize - return -end function s_mumps_solver_sizeof - -function s_mumps_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "MUMPS solver" -end function s_mumps_solver_get_fmt - -function s_mumps_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_mumps_ -end function s_mumps_solver_get_id - - -function s_mumps_solver_is_global(sv) result(val) - implicit none - class(mld_s_mumps_solver_type), intent(in) :: sv - logical :: val - - val = (sv%ipar(1) == mld_global_solver_ ) -end function s_mumps_solver_is_global - -end module mld_s_mumps_solver - diff --git a/mlprec/mld_s_onelev_mod.f90 b/mlprec/mld_s_onelev_mod.f90 deleted file mode 100644 index 04a40f6a..00000000 --- a/mlprec/mld_s_onelev_mod.f90 +++ /dev/null @@ -1,824 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_s_onelev_mod.f90 -! -! Module: mld_s_onelev_mod -! -! This module defines: -! - the mld_s_onelev_type data structure containing one level -! of a multilevel preconditioner and related -! data structures; -! -! It contains routines for -! - Building and applying; -! - checking if the preconditioner is correctly defined; -! - printing a description of the preconditioner; -! - deallocating the preconditioner data structure. -! - -module mld_s_onelev_mod - - use mld_base_prec_type - use mld_s_base_smoother_mod - use mld_s_dec_aggregator_mod - use psb_base_mod, only : psb_sspmat_type, psb_s_vect_type, & - & psb_s_base_vect_type, psb_lsspmat_type, psb_slinmap_type, psb_spk_, & - & psb_ipk_, psb_epk_, psb_lpk_, psb_desc_type, psb_i_base_vect_type, & - & psb_erractionsave, psb_error_handler - ! - ! - ! Type: mld_sonelev_type. - ! - ! It is the data type containing the necessary items for the current - ! level (essentially, the smoother, the current-level matrix - ! and the restriction and prolongation operators). - ! - ! type mld_sonelev_type - ! class(mld_s_base_smoother_type), allocatable :: sm, sm2a - ! class(mld_s_base_smoother_type), pointer :: sm2 => null() - ! class(mld_smlprec_wrk_type), allocatable :: wrk - ! class(mld_s_base_aggregator_type), allocatable :: aggr - ! type(mld_sml_parms) :: parms - ! type(psb_sspmat_type) :: ac - ! type(psb_sesc_type) :: desc_ac - ! type(psb_sspmat_type), pointer :: base_a => null() - ! type(psb_desc_type), pointer :: base_desc => null() - ! type(psb_slinmap_type) :: map - ! end type mld_sonelev_type - ! - ! Note that s denotes the kind of the real data type to be chosen - ! according to single/double precision version of MLD2P4. - ! - ! sm,sm2a - class(mld_s_base_smoother_type), allocatable - ! The current level pre- and post-smooother. - ! sm2 - class(mld_s_base_smoother_type), pointer - ! The current level post-smooother; if sm2a is allocated - ! explicitly, then sm2 => sm2a, otherwise sm2 => sm. - ! wrk - class(mld_smlprec_wrk_type), allocatable - ! Workspace for application of preconditioner; may be - ! pre-allocated to save time in the application within a - ! Krylov solver. - ! aggr - class(mld_s_base_aggregator_type), allocatable - ! The aggregator object: holds the algorithmic choices and - ! (possibly) additional data for building the aggregation. - ! parms - type(mld_sml_parms) - ! The parameters defining the multilevel strategy. - ! ac - The local part of the current-level matrix, built by - ! coarsening the previous-level matrix. - ! desc_ac - type(psb_desc_type). - ! The communication descriptor associated to the matrix - ! stored in ac. - ! base_a - type(psb_sspmat_type), pointer. - ! Pointer (really a pointer!) to the local part of the current - ! matrix (so we have a unified treatment of residuals). - ! We need this to avoid passing explicitly the current matrix - ! to the routine which applies the preconditioner. - ! base_desc - type(psb_desc_type), pointer. - ! Pointer to the communication descriptor associated to the - ! matrix pointed by base_a. - ! map - Stores the maps (restriction and prolongation) between the - ! vector spaces associated to the index spaces of the previous - ! and current levels. - ! - ! Methods: - ! Most methods follow the encapsulation hierarchy: they take whatever action - ! is appropriate for the current object, then call the corresponding method for - ! the contained object. - ! As an example: the descr() method prints out a description of the - ! level. It starts by invoking the descr() method of the parms object, - ! then calls the descr() method of the smoother object. - ! - ! descr - Prints a description of the object. - ! default - Set default values - ! dump - Dump to file object contents - ! set - Sets various parameters; when a request is unknown - ! it is passed to the smoother object for further processing. - ! check - Sanity checks. - ! sizeof - Total memory occupation in bytes - ! get_nzeros - Number of nonzeros - ! get_wrksz - How many workspace vector does apply_vect need - ! allocate_wrk - Allocate auxiliary workspace - ! free_wrk - Free auxiliary workspace - ! bld_tprol - Invoke the aggr method to build the tentative prolongator - ! mat_asb - Build the final (possibly smoothed) prolongator and coarse matrix. - ! - ! - type mld_smlprec_wrk_type - real(psb_spk_), allocatable :: tx(:), ty(:), x2l(:), y2l(:) - type(psb_s_vect_type) :: vtx, vty, vx2l, vy2l - type(psb_s_vect_type), allocatable :: wv(:) - contains - procedure, pass(wk) :: alloc => s_wrk_alloc - procedure, pass(wk) :: free => s_wrk_free - procedure, pass(wk) :: clone => s_wrk_clone - procedure, pass(wk) :: move_alloc => s_wrk_move_alloc - procedure, pass(wk) :: cnv => s_wrk_cnv - procedure, pass(wk) :: sizeof => s_wrk_sizeof - end type mld_smlprec_wrk_type - private :: s_wrk_alloc, s_wrk_free, & - & s_wrk_clone, s_wrk_move_alloc, s_wrk_cnv, s_wrk_sizeof - - type mld_s_onelev_type - class(mld_s_base_smoother_type), allocatable :: sm, sm2a - class(mld_s_base_smoother_type), pointer :: sm2 => null() - class(mld_smlprec_wrk_type), allocatable :: wrk - class(mld_s_base_aggregator_type), allocatable :: aggr - type(mld_sml_parms) :: parms - type(psb_sspmat_type) :: ac - integer(psb_ipk_) :: ac_nz_loc - integer(psb_lpk_) :: ac_nz_tot - type(psb_desc_type) :: desc_ac - type(psb_sspmat_type), pointer :: base_a => null() - type(psb_desc_type), pointer :: base_desc => null() - type(psb_lsspmat_type) :: tprol - type(psb_slinmap_type) :: map - real(psb_spk_) :: szratio - contains - procedure, pass(lv) :: bld_tprol => s_base_onelev_bld_tprol - procedure, pass(lv) :: mat_asb => mld_s_base_onelev_mat_asb - procedure, pass(lv) :: update_aggr => s_base_onelev_update_aggr - procedure, pass(lv) :: bld => mld_s_base_onelev_build - procedure, pass(lv) :: clone => s_base_onelev_clone - procedure, pass(lv) :: cnv => mld_s_base_onelev_cnv - procedure, pass(lv) :: descr => mld_s_base_onelev_descr - procedure, pass(lv) :: default => s_base_onelev_default - procedure, pass(lv) :: free => mld_s_base_onelev_free - procedure, pass(lv) :: nullify => s_base_onelev_nullify - procedure, pass(lv) :: check => mld_s_base_onelev_check - procedure, pass(lv) :: dump => mld_s_base_onelev_dump - procedure, pass(lv) :: cseti => mld_s_base_onelev_cseti - procedure, pass(lv) :: csetr => mld_s_base_onelev_csetr - procedure, pass(lv) :: csetc => mld_s_base_onelev_csetc - procedure, pass(lv) :: setsm => mld_s_base_onelev_setsm - procedure, pass(lv) :: setsv => mld_s_base_onelev_setsv - procedure, pass(lv) :: setag => mld_s_base_onelev_setag - generic, public :: set => cseti, csetr, csetc, setsm, setsv, setag - procedure, pass(lv) :: sizeof => s_base_onelev_sizeof - procedure, pass(lv) :: get_nzeros => s_base_onelev_get_nzeros - procedure, pass(lv) :: get_wrksz => s_base_onelev_get_wrksize - procedure, pass(lv) :: allocate_wrk => s_base_onelev_allocate_wrk - procedure, pass(lv) :: free_wrk => s_base_onelev_free_wrk - procedure, nopass :: stringval => mld_stringval - procedure, pass(lv) :: move_alloc => s_base_onelev_move_alloc - - end type mld_s_onelev_type - - type mld_s_onelev_node - type(mld_s_onelev_type) :: item - type(mld_s_onelev_node), pointer :: prev=>null(), next=>null() - end type mld_s_onelev_node - - private :: s_base_onelev_default, s_base_onelev_sizeof, & - & s_base_onelev_nullify, s_base_onelev_get_nzeros, & - & s_base_onelev_clone, s_base_onelev_move_alloc, & - & s_base_onelev_get_wrksize, s_base_onelev_allocate_wrk, & - & s_base_onelev_free_wrk - - interface - subroutine mld_s_base_onelev_mat_asb(lv,a,desc_a,ilaggr,nlaggr,t_prol,info) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, psb_ipk_, psb_lsspmat_type, psb_lpk_ - import :: mld_s_onelev_type - implicit none - class(mld_s_onelev_type), intent(inout), target :: lv - type(psb_sspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:),nlaggr(:) - type(psb_lsspmat_type), intent(inout) :: t_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_base_onelev_mat_asb - end interface - - interface - subroutine mld_s_base_onelev_build(lv,info,amold,vmold,imold,ilv) - import :: psb_s_base_sparse_mat, psb_s_base_vect_type, & - & psb_i_base_vect_type, psb_spk_, mld_s_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - implicit none - class(mld_s_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - integer(psb_ipk_), intent(in), optional :: ilv - end subroutine mld_s_base_onelev_build - end interface - - interface - subroutine mld_s_base_onelev_descr(lv,il,nl,ilmin,info,iout) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_slinmap_type, psb_spk_, mld_s_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - ! Arguments - class(mld_s_onelev_type), intent(in) :: lv - integer(psb_ipk_), intent(in) :: il,nl,ilmin - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - end subroutine mld_s_base_onelev_descr - end interface - - interface - subroutine mld_s_base_onelev_cnv(lv,info,amold,vmold,imold) - import :: mld_s_onelev_type, psb_s_base_vect_type, psb_spk_, & - & psb_s_base_sparse_mat, psb_ipk_, psb_i_base_vect_type - ! Arguments - class(mld_s_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_s_base_onelev_cnv - end interface - -interface - subroutine mld_s_base_onelev_free(lv,info) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_slinmap_type, psb_spk_, mld_s_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - implicit none - - class(mld_s_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_base_onelev_free - end interface - - interface - subroutine mld_s_base_onelev_check(lv,info) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_slinmap_type, psb_spk_, mld_s_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - ! Arguments - class(mld_s_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_base_onelev_check - end interface - - interface - subroutine mld_s_base_onelev_setsm(lv,val,info,pos) - import :: psb_spk_, mld_s_onelev_type, mld_s_base_smoother_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - ! Arguments - class(mld_s_onelev_type), target, intent(inout) :: lv - class(mld_s_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - end subroutine mld_s_base_onelev_setsm - end interface - - interface - subroutine mld_s_base_onelev_setsv(lv,val,info,pos) - import :: psb_spk_, mld_s_onelev_type, mld_s_base_solver_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - ! Arguments - class(mld_s_onelev_type), target, intent(inout) :: lv - class(mld_s_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - end subroutine mld_s_base_onelev_setsv - end interface - - interface - subroutine mld_s_base_onelev_setag(lv,val,info,pos) - import :: psb_spk_, mld_s_onelev_type, mld_s_base_aggregator_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - ! Arguments - class(mld_s_onelev_type), target, intent(inout) :: lv - class(mld_s_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - end subroutine mld_s_base_onelev_setag - end interface - - interface - subroutine mld_s_base_onelev_cseti(lv,what,val,info,pos,idx) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_slinmap_type, psb_spk_, mld_s_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - ! Arguments - class(mld_s_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_s_base_onelev_cseti - end interface - - interface - subroutine mld_s_base_onelev_csetc(lv,what,val,info,pos,idx) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_slinmap_type, psb_spk_, mld_s_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - ! Arguments - class(mld_s_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_s_base_onelev_csetc - end interface - - interface - subroutine mld_s_base_onelev_csetr(lv,what,val,info,pos,idx) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_slinmap_type, psb_spk_, mld_s_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - class(mld_s_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_s_base_onelev_csetr - end interface - - interface - subroutine mld_s_base_onelev_dump(lv,level,info,prefix,head,ac,rp,smoother,& - & solver,tprol,global_num) - import :: psb_sspmat_type, psb_s_vect_type, psb_s_base_vect_type, & - & psb_slinmap_type, psb_spk_, mld_s_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - implicit none - class(mld_s_onelev_type), intent(in) :: lv - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: ac, rp, smoother, solver, tprol, global_num - end subroutine mld_s_base_onelev_dump - end interface - -contains - ! - ! Function returning the size of the mld_prec_type data structure - ! in bytes or in number of nonzeros of the operator(s) involved. - ! - - function s_base_onelev_get_nzeros(lv) result(val) - implicit none - class(mld_s_onelev_type), intent(in) :: lv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - if (allocated(lv%sm)) & - & val = lv%sm%get_nzeros() - if (allocated(lv%sm2a)) & - & val = val + lv%sm2a%get_nzeros() - end function s_base_onelev_get_nzeros - - function s_base_onelev_sizeof(lv) result(val) - implicit none - class(mld_s_onelev_type), intent(in) :: lv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = psb_sizeof_ip+psb_sizeof_lp - val = val + lv%desc_ac%sizeof() - val = val + lv%ac%sizeof() - val = val + lv%tprol%sizeof() - val = val + lv%map%sizeof() - if (allocated(lv%sm)) val = val + lv%sm%sizeof() - if (allocated(lv%sm2a)) val = val + lv%sm2a%sizeof() - if (allocated(lv%aggr)) val = val + lv%aggr%sizeof() - if (allocated(lv%wrk)) val = val + lv%wrk%sizeof() - end function s_base_onelev_sizeof - - - subroutine s_base_onelev_nullify(lv) - implicit none - - class(mld_s_onelev_type), intent(inout) :: lv - - nullify(lv%base_a) - nullify(lv%base_desc) - nullify(lv%sm2) - end subroutine s_base_onelev_nullify - - ! - ! Multilevel defaults: - ! multiplicative vs. additive ML framework; - ! Smoothed decoupled aggregation with zero threshold; - ! distributed coarse matrix; - ! damping omega computed with the max-norm estimate of the - ! dominant eigenvalue; - ! two-sided smoothing (i.e. V-cycle) with 1 smoothing sweep; - ! - - subroutine s_base_onelev_default(lv) - - Implicit None - - ! Arguments - class(mld_s_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_) :: info - - lv%parms%sweeps_pre = 1 - lv%parms%sweeps_post = 1 - lv%parms%ml_cycle = mld_vcycle_ml_ - lv%parms%aggr_type = mld_soc1_ - lv%parms%par_aggr_alg = mld_dec_aggr_ - lv%parms%aggr_ord = mld_aggr_ord_nat_ - lv%parms%aggr_prol = mld_smooth_prol_ - lv%parms%coarse_mat = mld_distr_mat_ - lv%parms%aggr_omega_alg = mld_eig_est_ - lv%parms%aggr_eig = mld_max_norm_ - lv%parms%aggr_filter = mld_no_filter_mat_ - lv%parms%aggr_omega_val = szero - lv%parms%aggr_thresh = 0.01_psb_spk_ - - if (allocated(lv%sm)) call lv%sm%default() - if (allocated(lv%sm2a)) then - call lv%sm2a%default() - lv%sm2 => lv%sm2a - else - lv%sm2 => lv%sm - end if - if (.not.allocated(lv%aggr)) allocate(mld_s_dec_aggregator_type :: lv%aggr,stat=info) - if (allocated(lv%aggr)) call lv%aggr%default() - - return - - end subroutine s_base_onelev_default - - subroutine s_base_onelev_bld_tprol(lv,a,desc_a,& - & ilaggr,nlaggr,t_prol,ag_data,info) - implicit none - class(mld_s_onelev_type), intent(inout), target :: lv - type(psb_sspmat_type), intent(inout) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lsspmat_type), intent(out) :: t_prol - type(mld_saggr_data), intent(in) :: ag_data - integer(psb_ipk_), intent(out) :: info - - call lv%aggr%bld_tprol(lv%parms,ag_data,a,desc_a,ilaggr,nlaggr,t_prol,info) - - end subroutine s_base_onelev_bld_tprol - - - subroutine s_base_onelev_update_aggr(lv,lvnext,info) - implicit none - class(mld_s_onelev_type), intent(inout), target :: lv, lvnext - integer(psb_ipk_), intent(out) :: info - - call lv%aggr%update_next(lvnext%aggr,info) - - end subroutine s_base_onelev_update_aggr - - - subroutine s_base_onelev_clone(lv,lvout,info) - - Implicit None - - ! Arguments - class(mld_s_onelev_type), target, intent(inout) :: lv - class(mld_s_onelev_type), target, intent(inout) :: lvout - integer(psb_ipk_), intent(out) :: info - - info = psb_success_ - if (allocated(lv%sm)) then - call lv%sm%clone(lvout%sm,info) - else - if (allocated(lvout%sm)) then - call lvout%sm%free(info) - if (info==psb_success_) deallocate(lvout%sm,stat=info) - end if - end if - if (allocated(lv%sm2a)) then - call lv%sm%clone(lvout%sm2a,info) - lvout%sm2 => lvout%sm2a - else - if (allocated(lvout%sm2a)) then - call lvout%sm2a%free(info) - if (info==psb_success_) deallocate(lvout%sm2a,stat=info) - end if - lvout%sm2 => lvout%sm - end if - if (allocated(lv%aggr)) then - call lv%aggr%clone(lvout%aggr,info) - else - if (allocated(lvout%aggr)) then - call lvout%aggr%free(info) - if (info==psb_success_) deallocate(lvout%aggr,stat=info) - end if - end if - if (info == psb_success_) call lv%parms%clone(lvout%parms,info) - if (info == psb_success_) call lv%ac%clone(lvout%ac,info) - if (info == psb_success_) call lv%tprol%clone(lvout%tprol,info) - if (info == psb_success_) call lv%desc_ac%clone(lvout%desc_ac,info) - if (info == psb_success_) call lv%map%clone(lvout%map,info) - lvout%base_a => lv%base_a - lvout%base_desc => lv%base_desc - - return - - end subroutine s_base_onelev_clone - - subroutine s_base_onelev_move_alloc(lv, b,info) - use psb_base_mod - implicit none - class(mld_s_onelev_type), target, intent(inout) :: lv, b - integer(psb_ipk_), intent(out) :: info - - call b%free(info) - b%parms = lv%parms - b%szratio = lv%szratio - if (associated(lv%sm2,lv%sm2a)) then - call move_alloc(lv%sm,b%sm) - call move_alloc(lv%sm2a,b%sm2a) - b%sm2 =>b%sm2a - else - call move_alloc(lv%sm,b%sm) - call move_alloc(lv%sm2a,b%sm2a) - b%sm2 =>b%sm - end if - - call move_alloc(lv%aggr,b%aggr) - if (info == psb_success_) call psb_move_alloc(lv%ac,b%ac,info) - if (info == psb_success_) call psb_move_alloc(lv%tprol,b%tprol,info) - if (info == psb_success_) call psb_move_alloc(lv%desc_ac,b%desc_ac,info) - if (info == psb_success_) call psb_move_alloc(lv%map,b%map,info) - b%base_a => lv%base_a - b%base_desc => lv%base_desc - - end subroutine s_base_onelev_move_alloc - - - function s_base_onelev_get_wrksize(lv) result(val) - implicit none - class(mld_s_onelev_type), intent(inout) :: lv - integer(psb_ipk_) :: val - - val = 0 - ! SM and SM2A can share work vectors - if (allocated(lv%sm)) val = val + lv%sm%get_wrksz() - if (allocated(lv%sm2a)) val = max(val,lv%sm2a%get_wrksz()) - ! - ! Now for the ML application itself - ! - - ! VTX/VTY/VX2L/VY2L are stored explicitly - ! - - ! - ! additions for specific ML/cycles - ! - select case(lv%parms%ml_cycle) - case(mld_add_ml_,mld_mult_ml_,mld_vcycle_ml_, mld_wcycle_ml_) - ! We're good - - case(mld_kcycle_ml_, mld_kcyclesym_ml_) - ! - ! We need 7 in inneritkcycle. - ! Can we reuse vtx? - ! - val = val + 7 - - case default - ! Need a better error signaling ? - val = -1 - end select - - end function s_base_onelev_get_wrksize - - subroutine s_base_onelev_allocate_wrk(lv,info,vmold) - use psb_base_mod - implicit none - class(mld_s_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_vect_type), intent(in), optional :: vmold - ! - integer(psb_ipk_) :: nwv, i - info = psb_success_ - nwv = lv%get_wrksz() - if (.not.allocated(lv%wrk)) allocate(lv%wrk,stat=info) - if (info == 0) call lv%wrk%alloc(nwv,lv%base_desc,info,vmold=vmold) - - end subroutine s_base_onelev_allocate_wrk - - - subroutine s_base_onelev_free_wrk(lv,info) - use psb_base_mod - implicit none - class(mld_s_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: nwv,i - info = psb_success_ - - if (allocated(lv%wrk)) then - call lv%wrk%free(info) - if (info == 0) deallocate(lv%wrk,stat=info) - end if - end subroutine s_base_onelev_free_wrk - - subroutine s_wrk_alloc(wk,nwv,desc,info,vmold) - use psb_base_mod - - Implicit None - - ! Arguments - class(mld_smlprec_wrk_type), target, intent(inout) :: wk - integer(psb_ipk_), intent(in) :: nwv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_vect_type), intent(in), optional :: vmold - ! - integer(psb_ipk_) :: i - - info = psb_success_ - call wk%free(info) - call psb_geasb(wk%vx2l,desc,info,& - & scratch=.true.,mold=vmold) - call psb_geasb(wk%vy2l,desc,info,& - & scratch=.true.,mold=vmold) - call psb_geasb(wk%vtx,desc,info,& - & scratch=.true.,mold=vmold) - call psb_geasb(wk%vty,desc,info,& - & scratch=.true.,mold=vmold) - allocate(wk%wv(nwv),stat=info) - do i=1,nwv - call psb_geasb(wk%wv(i),desc,info,& - & scratch=.true.,mold=vmold) - end do - - end subroutine s_wrk_alloc - - subroutine s_wrk_free(wk,info) - - Implicit None - - ! Arguments - class(mld_smlprec_wrk_type), target, intent(inout) :: wk - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: i - info = psb_success_ - - if (allocated(wk%tx)) deallocate(wk%tx, stat=info) - if (allocated(wk%ty)) deallocate(wk%ty, stat=info) - if (allocated(wk%x2l)) deallocate(wk%x2l, stat=info) - if (allocated(wk%y2l)) deallocate(wk%y2l, stat=info) - call wk%vtx%free(info) - call wk%vty%free(info) - call wk%vx2l%free(info) - call wk%vy2l%free(info) - if (allocated(wk%wv)) then - do i=1,size(wk%wv) - call wk%wv(i)%free(info) - end do - deallocate(wk%wv, stat=info) - end if - - end subroutine s_wrk_free - - subroutine s_wrk_clone(wk,wkout,info) - use psb_base_mod - Implicit None - - ! Arguments - class(mld_smlprec_wrk_type), target, intent(inout) :: wk - class(mld_smlprec_wrk_type), target, intent(inout) :: wkout - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: i - info = psb_success_ - - call psb_safe_ab_cpy(wk%tx,wkout%tx,info) - call psb_safe_ab_cpy(wk%ty,wkout%ty,info) - call psb_safe_ab_cpy(wk%x2l,wkout%x2l,info) - call psb_safe_ab_cpy(wk%y2l,wkout%y2l,info) - call wk%vtx%clone(wkout%vtx,info) - call wk%vty%clone(wkout%vty,info) - call wk%vx2l%clone(wkout%vx2l,info) - call wk%vy2l%clone(wkout%vy2l,info) - if (allocated(wkout%wv)) then - do i=1,size(wkout%wv) - call wkout%wv(i)%free(info) - end do - deallocate( wkout%wv) - end if - allocate(wkout%wv(size(wk%wv)),stat=info) - do i=1,size(wk%wv) - call wk%wv(i)%clone(wkout%wv(i),info) - end do - return - - end subroutine s_wrk_clone - - subroutine s_wrk_move_alloc(wk, b,info) - implicit none - class(mld_smlprec_wrk_type), target, intent(inout) :: wk, b - integer(psb_ipk_), intent(out) :: info - - call b%free(info) - call move_alloc(wk%tx,b%tx) - call move_alloc(wk%ty,b%ty) - call move_alloc(wk%x2l,b%x2l) - call move_alloc(wk%y2l,b%y2l) - ! - ! Should define V%move_alloc.... - call move_alloc(wk%vtx%v,b%vtx%v) - call move_alloc(wk%vty%v,b%vty%v) - call move_alloc(wk%vx2l%v,b%vx2l%v) - call move_alloc(wk%vy2l%v,b%vy2l%v) - call move_alloc(wk%wv,b%wv) - - end subroutine s_wrk_move_alloc - - subroutine s_wrk_cnv(wk,info,vmold) - use psb_base_mod - - Implicit None - - ! Arguments - class(mld_smlprec_wrk_type), target, intent(inout) :: wk - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_vect_type), intent(in), optional :: vmold - ! - integer(psb_ipk_) :: i - - info = psb_success_ - if (present(vmold)) then - call wk%vtx%cnv(vmold) - call wk%vty%cnv(vmold) - call wk%vx2l%cnv(vmold) - call wk%vy2l%cnv(vmold) - if (allocated(wk%wv)) then - do i=1,size(wk%wv) - call wk%wv(i)%cnv(vmold) - end do - end if - end if - end subroutine s_wrk_cnv - - function s_wrk_sizeof(wk) result(val) - use psb_realloc_mod - implicit none - class(mld_smlprec_wrk_type), intent(in) :: wk - integer(psb_epk_) :: val - integer :: i - val = 0 - val = val + (1_psb_epk_ * psb_sizeof_sp) * psb_size(wk%tx) - val = val + (1_psb_epk_ * psb_sizeof_sp) * psb_size(wk%ty) - val = val + (1_psb_epk_ * psb_sizeof_sp) * psb_size(wk%x2l) - val = val + (1_psb_epk_ * psb_sizeof_sp) * psb_size(wk%y2l) - val = val + wk%vtx%sizeof() - val = val + wk%vty%sizeof() - val = val + wk%vx2l%sizeof() - val = val + wk%vy2l%sizeof() - if (allocated(wk%wv)) then - do i=1, size(wk%wv) - val = val + wk%wv(i)%sizeof() - end do - end if - end function s_wrk_sizeof - -end module mld_s_onelev_mod diff --git a/mlprec/mld_s_prec_mod.f90 b/mlprec/mld_s_prec_mod.f90 deleted file mode 100644 index ea480571..00000000 --- a/mlprec/mld_s_prec_mod.f90 +++ /dev/null @@ -1,139 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_s_prec_mod.f90 -! -! Module: mld_s_prec_mod -! -! This module defines the user interfaces to the real/complex, single/double -! precision versions of the user-level MLD2P4 routines. -! -module mld_s_prec_mod - - use mld_s_prec_type - use mld_s_jac_smoother - use mld_s_as_smoother - use mld_s_id_solver - use mld_s_diag_solver - use mld_s_l1_diag_solver - use mld_s_ilu_solver - use mld_s_gs_solver - - interface mld_precset - module procedure mld_s_iprecsetsm, mld_s_iprecsetsv, & - & mld_s_cprecseti, mld_s_cprecsetc, mld_s_cprecsetr, & - & mld_s_iprecsetag - end interface mld_precset - - interface mld_extprol_bld - subroutine mld_s_extprol_bld(a,desc_a,p,prolv,restrv,info,amold,vmold,imold) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, & - & psb_s_base_sparse_mat, psb_s_base_vect_type, & - & psb_i_base_vect_type, mld_sprec_type, psb_ipk_ - - ! Arguments - type(psb_sspmat_type),intent(in), target :: a - type(psb_sspmat_type),intent(inout), target :: prolv(:) - type(psb_sspmat_type),intent(inout), target :: restrv(:) - type(psb_desc_type), intent(inout), target :: desc_a - type(mld_sprec_type),intent(inout),target :: p - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! !$ character, intent(in), optional :: upd - end subroutine mld_s_extprol_bld - end interface mld_extprol_bld - -contains - - subroutine mld_s_iprecsetsm(p,val,info,pos) - type(mld_sprec_type), intent(inout) :: p - class(mld_s_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - call p%set(val,info,pos=pos) - end subroutine mld_s_iprecsetsm - - subroutine mld_s_iprecsetsv(p,val,info,pos) - type(mld_sprec_type), intent(inout) :: p - class(mld_s_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - call p%set(val,info, pos=pos) - end subroutine mld_s_iprecsetsv - - subroutine mld_s_iprecsetag(p,val,info,pos) - type(mld_sprec_type), intent(inout) :: p - class(mld_s_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - call p%set(val,info, pos=pos) - end subroutine mld_s_iprecsetag - - subroutine mld_s_cprecseti(p,what,val,info,pos) - type(mld_sprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - call p%set(what,val,info,pos=pos) - end subroutine mld_s_cprecseti - - subroutine mld_s_cprecsetr(p,what,val,info,pos) - type(mld_sprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - call p%set(what,val,info,pos=pos) - end subroutine mld_s_cprecsetr - - subroutine mld_s_cprecsetc(p,what,val,info,pos) - type(mld_sprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - call p%set(what,val,info,pos=pos) - end subroutine mld_s_cprecsetc - -end module mld_s_prec_mod diff --git a/mlprec/mld_s_prec_type.f90 b/mlprec/mld_s_prec_type.f90 deleted file mode 100644 index 6b4fef93..00000000 --- a/mlprec/mld_s_prec_type.f90 +++ /dev/null @@ -1,964 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_s_prec_type.f90 -! -! Module: mld_s_prec_type -! -! This module defines: -! - the mld_s_prec_type data structure containing the preconditioner and related -! data structures; -! -! It contains routines for -! - Building and applying; -! - checking if the preconditioner is correctly defined; -! - printing a description of the preconditioner; -! - deallocating the preconditioner data structure. -! - -module mld_s_prec_type - - use mld_base_prec_type - use mld_s_base_solver_mod - use mld_s_base_smoother_mod - use mld_s_base_aggregator_mod - use mld_s_onelev_mod - use psb_base_mod, only : psb_erractionsave, psb_erractionrestore, psb_errstatus_fatal - use psb_prec_mod, only : psb_sprec_type - - ! - ! Type: mld_sprec_type. - ! - ! This is the data type containing all the information about the multilevel - ! preconditioner ('d', 's', 'c' and 'z', according to the real/complex, - ! single/double precision version of MLD2P4). - ! It consists of an array of 'one-level' intermediate data structures - ! of type mld_sonelev_type, each containing the information needed to apply - ! the smoothing and the coarse-space correction at a generic level. RT is the - ! real data type, i.e. S for both S and C, and D for both D and Z. - ! - ! type mld_sprec_type - ! type(mld_sonelev_type), allocatable :: precv(:) - ! end type mld_sprec_type - ! - ! Note that the levels are numbered in increasing order starting from - ! the level 1 as the finest one, and the number of levels is given by - ! size(precv(:)) which is the id of the coarsest level. - ! In the multigrid literature many authors number the levels in the opposite - ! order, with level 0 being the id of the coarsest level. - ! - ! - integer, parameter, private :: wv_size_=4 - - type, extends(psb_sprec_type) :: mld_sprec_type - ! integer(psb_ipk_) :: ictxt ! Now it's in the PSBLAS prec. - type(mld_saggr_data) :: ag_data - ! - ! Number of outer sweeps. Sometimes 2 V-cycles may be better than 1 W-cycle. - ! - integer(psb_ipk_) :: outer_sweeps = 1 - ! - ! Coarse solver requires some tricky checks, and for this we need to - ! record the choice in the format given by the user, - ! to keep track against what is put later in the multilevel array - ! - integer(psb_ipk_) :: coarse_solver = -1 - - ! - ! The multilevel hierarchy - ! - type(mld_s_onelev_type), allocatable :: precv(:) - contains - procedure, pass(prec) :: psb_s_apply2_vect => mld_s_apply2_vect - procedure, pass(prec) :: psb_s_apply1_vect => mld_s_apply1_vect - procedure, pass(prec) :: psb_s_apply2v => mld_s_apply2v - procedure, pass(prec) :: psb_s_apply1v => mld_s_apply1v - procedure, pass(prec) :: dump => mld_s_dump - procedure, pass(prec) :: cnv => mld_s_cnv - procedure, pass(prec) :: clone => mld_s_clone - procedure, pass(prec) :: free => mld_s_prec_free - procedure, pass(prec) :: allocate_wrk => mld_s_allocate_wrk - procedure, pass(prec) :: free_wrk => mld_s_free_wrk - procedure, pass(prec) :: is_allocated_wrk => mld_s_is_allocated_wrk - procedure, pass(prec) :: get_complexity => mld_s_get_compl - procedure, pass(prec) :: cmp_complexity => mld_s_cmp_compl - procedure, pass(prec) :: get_avg_cr => mld_s_get_avg_cr - procedure, pass(prec) :: cmp_avg_cr => mld_s_cmp_avg_cr - procedure, pass(prec) :: get_nlevs => mld_s_get_nlevs - procedure, pass(prec) :: get_nzeros => mld_s_get_nzeros - procedure, pass(prec) :: sizeof => mld_sprec_sizeof - procedure, pass(prec) :: setsm => mld_sprecsetsm - procedure, pass(prec) :: setsv => mld_sprecsetsv - procedure, pass(prec) :: setag => mld_sprecsetag - procedure, pass(prec) :: cseti => mld_scprecseti - procedure, pass(prec) :: csetc => mld_scprecsetc - procedure, pass(prec) :: csetr => mld_scprecsetr - generic, public :: set => cseti, csetc, csetr, setsm, setsv, setag - procedure, pass(prec) :: get_smoother => mld_s_get_smootherp - procedure, pass(prec) :: get_solver => mld_s_get_solverp - procedure, pass(prec) :: move_alloc => s_prec_move_alloc - procedure, pass(prec) :: init => mld_sprecinit - procedure, pass(prec) :: build => mld_sprecbld - procedure, pass(prec) :: hierarchy_build => mld_s_hierarchy_bld - procedure, pass(prec) :: smoothers_build => mld_s_smoothers_bld - procedure, pass(prec) :: descr => mld_sfile_prec_descr - end type mld_sprec_type - - private :: mld_s_dump, mld_s_get_compl, mld_s_cmp_compl,& - & mld_s_get_avg_cr, mld_s_cmp_avg_cr,& - & mld_s_get_nzeros, mld_s_get_nlevs, s_prec_move_alloc - - - ! - ! Interfaces to routines for checking the definition of the preconditioner, - ! for printing its description and for deallocating its data structure - ! - - interface mld_precfree - module procedure mld_sprecfree - end interface - - - interface mld_precdescr - subroutine mld_sfile_prec_descr(prec,iout,root) - import :: mld_sprec_type, psb_ipk_ - implicit none - ! Arguments - class(mld_sprec_type), intent(in) :: prec - integer(psb_ipk_), intent(in), optional :: iout - integer(psb_ipk_), intent(in), optional :: root - end subroutine mld_sfile_prec_descr - end interface - - interface mld_sizeof - module procedure mld_sprec_sizeof - end interface - - interface mld_precapply - subroutine mld_sprecaply2_vect(prec,x,y,desc_data,info,trans,work) - import :: psb_sspmat_type, psb_desc_type, & - & psb_spk_, psb_s_vect_type, mld_sprec_type, psb_ipk_ - type(psb_desc_type),intent(in) :: desc_data - type(mld_sprec_type), intent(inout) :: prec - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_spk_),intent(inout), optional, target :: work(:) - end subroutine mld_sprecaply2_vect - subroutine mld_sprecaply1_vect(prec,x,desc_data,info,trans,work) - import :: psb_sspmat_type, psb_desc_type, & - & psb_spk_, psb_s_vect_type, mld_sprec_type, psb_ipk_ - type(psb_desc_type),intent(in) :: desc_data - type(mld_sprec_type), intent(inout) :: prec - type(psb_s_vect_type),intent(inout) :: x - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_spk_),intent(inout), optional, target :: work(:) - end subroutine mld_sprecaply1_vect - subroutine mld_sprecaply(prec,x,y,desc_data,info,trans,work) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, mld_sprec_type, psb_ipk_ - type(psb_desc_type),intent(in) :: desc_data - type(mld_sprec_type), intent(inout) :: prec - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_spk_),intent(inout), optional, target :: work(:) - end subroutine mld_sprecaply - subroutine mld_sprecaply1(prec,x,desc_data,info,trans) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, mld_sprec_type, psb_ipk_ - type(psb_desc_type),intent(in) :: desc_data - type(mld_sprec_type), intent(inout) :: prec - real(psb_spk_),intent(inout) :: x(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - end subroutine mld_sprecaply1 - end interface - - interface - subroutine mld_sprecsetsm(prec,val,info,ilev,ilmax,pos) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, & - & mld_sprec_type, mld_s_base_smoother_type, psb_ipk_ - class(mld_sprec_type), target, intent(inout):: prec - class(mld_s_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - end subroutine mld_sprecsetsm - subroutine mld_sprecsetsv(prec,val,info,ilev,ilmax,pos) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, & - & mld_sprec_type, mld_s_base_solver_type, psb_ipk_ - class(mld_sprec_type), intent(inout) :: prec - class(mld_s_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - end subroutine mld_sprecsetsv - subroutine mld_sprecsetag(prec,val,info,ilev,ilmax,pos) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, & - & mld_sprec_type, mld_s_base_aggregator_type, psb_ipk_ - class(mld_sprec_type), intent(inout) :: prec - class(mld_s_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - end subroutine mld_sprecsetag - subroutine mld_scprecseti(prec,what,val,info,ilev,ilmax,pos,idx) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, & - & mld_sprec_type, psb_ipk_ - class(mld_sprec_type), intent(inout) :: prec - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx - character(len=*), optional, intent(in) :: pos - end subroutine mld_scprecseti - subroutine mld_scprecsetr(prec,what,val,info,ilev,ilmax,pos,idx) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, & - & mld_sprec_type, psb_ipk_ - class(mld_sprec_type), intent(inout) :: prec - character(len=*), intent(in) :: what - real(psb_spk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx - character(len=*), optional, intent(in) :: pos - end subroutine mld_scprecsetr - subroutine mld_scprecsetc(prec,what,string,info,ilev,ilmax,pos,idx) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, & - & mld_sprec_type, psb_ipk_ - class(mld_sprec_type), intent(inout) :: prec - character(len=*), intent(in) :: what - character(len=*), intent(in) :: string - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx - character(len=*), optional, intent(in) :: pos - end subroutine mld_scprecsetc - end interface - - interface mld_precinit - subroutine mld_sprecinit(ictxt,prec,ptype,info) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, & - & mld_sprec_type, psb_ipk_ - integer(psb_ipk_), intent(in) :: ictxt - class(mld_sprec_type), intent(inout) :: prec - character(len=*), intent(in) :: ptype - integer(psb_ipk_), intent(out) :: info - end subroutine mld_sprecinit - end interface mld_precinit - - interface mld_precbld - subroutine mld_sprecbld(a,desc_a,prec,info,amold,vmold,imold) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, & - & psb_s_base_sparse_mat, psb_s_base_vect_type, & - & psb_i_base_vect_type, mld_sprec_type, psb_ipk_ - implicit none - type(psb_sspmat_type), intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_sprec_type), intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! character, intent(in),optional :: upd - end subroutine mld_sprecbld - end interface mld_precbld - - interface mld_hierarchy_bld - subroutine mld_s_hierarchy_bld(a,desc_a,prec,info) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, & - & mld_sprec_type, psb_ipk_ - implicit none - type(psb_sspmat_type), intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_sprec_type), intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - ! character, intent(in),optional :: upd - end subroutine mld_s_hierarchy_bld - end interface mld_hierarchy_bld - - interface mld_smoothers_bld - subroutine mld_s_smoothers_bld(a,desc_a,prec,info,amold,vmold,imold) - import :: psb_sspmat_type, psb_desc_type, psb_spk_, & - & psb_s_base_sparse_mat, psb_s_base_vect_type, & - & psb_i_base_vect_type, mld_sprec_type, psb_ipk_ - implicit none - type(psb_sspmat_type), intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_sprec_type), intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! character, intent(in),optional :: upd - end subroutine mld_s_smoothers_bld - end interface mld_smoothers_bld - -contains - ! - ! Function returning a pointer to the smoother - ! - function mld_s_get_smootherp(prec,ilev) result(val) - implicit none - class(mld_sprec_type), target, intent(in) :: prec - integer(psb_ipk_), optional :: ilev - class(mld_s_base_smoother_type), pointer :: val - integer(psb_ipk_) :: ilev_ - - val => null() - if (present(ilev)) then - ilev_ = ilev - else - ! What is a good default? - ilev_ = 1 - end if - if (allocated(prec%precv)) then - if ((1<=ilev_).and.(ilev_<=size(prec%precv))) then - if (allocated(prec%precv(ilev_)%sm)) then - val => prec%precv(ilev_)%sm - end if - end if - end if - end function mld_s_get_smootherp - ! - ! Function returning a pointer to the solver - ! - function mld_s_get_solverp(prec,ilev) result(val) - implicit none - class(mld_sprec_type), target, intent(in) :: prec - integer(psb_ipk_), optional :: ilev - class(mld_s_base_solver_type), pointer :: val - integer(psb_ipk_) :: ilev_ - - val => null() - if (present(ilev)) then - ilev_ = ilev - else - ! What is a good default? - ilev_ = 1 - end if - if (allocated(prec%precv)) then - if ((1<=ilev_).and.(ilev_<=size(prec%precv))) then - if (allocated(prec%precv(ilev_)%sm)) then - if (allocated(prec%precv(ilev_)%sm%sv)) then - val => prec%precv(ilev_)%sm%sv - end if - end if - end if - end if - end function mld_s_get_solverp - ! - ! Function returning the size of the precv(:) array - ! - function mld_s_get_nlevs(prec) result(val) - implicit none - class(mld_sprec_type), intent(in) :: prec - integer(psb_ipk_) :: val - val = 0 - if (allocated(prec%precv)) then - val = size(prec%precv) - end if - end function mld_s_get_nlevs - ! - ! Function returning the size of the mld_prec_type data structure - ! in bytes or in number of nonzeros of the operator(s) involved. - ! - function mld_s_get_nzeros(prec) result(val) - implicit none - class(mld_sprec_type), intent(in) :: prec - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - if (allocated(prec%precv)) then - do i=1, size(prec%precv) - val = val + prec%precv(i)%get_nzeros() - end do - end if - end function mld_s_get_nzeros - - function mld_sprec_sizeof(prec) result(val) - implicit none - class(mld_sprec_type), intent(in) :: prec - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - val = val + psb_sizeof_ip - if (allocated(prec%precv)) then - do i=1, size(prec%precv) - val = val + prec%precv(i)%sizeof() - end do - end if - end function mld_sprec_sizeof - - ! - ! Operator complexity: ratio of total number - ! of nonzeros in the aggregated matrices at the - ! various level to the nonzeroes at the fine level - ! (original matrix) - ! - - function mld_s_get_compl(prec) result(val) - implicit none - class(mld_sprec_type), intent(in) :: prec - real(psb_spk_) :: val - - val = prec%ag_data%op_complexity - - end function mld_s_get_compl - - subroutine mld_s_cmp_compl(prec) - - implicit none - class(mld_sprec_type), intent(inout) :: prec - - real(psb_spk_) :: num, den, nmin - integer(psb_ipk_) :: ictxt - integer(psb_ipk_) :: il - - num = -sone - den = sone - ictxt = prec%ictxt - if (allocated(prec%precv)) then - il = 1 - num = prec%precv(il)%base_a%get_nzeros() - if (num >= szero) then - den = num - do il=2,size(prec%precv) - num = num + max(0,prec%precv(il)%base_a%get_nzeros()) - end do - end if - end if - nmin = num - call psb_min(ictxt,nmin) - if (nmin < szero) then - num = szero - den = sone - else - call psb_sum(ictxt,num) - call psb_sum(ictxt,den) - end if - prec%ag_data%op_complexity = num/den - end subroutine mld_s_cmp_compl - - ! - ! Average coarsening ratio - ! - - function mld_s_get_avg_cr(prec) result(val) - implicit none - class(mld_sprec_type), intent(in) :: prec - real(psb_spk_) :: val - - val = prec%ag_data%avg_cr - - end function mld_s_get_avg_cr - - subroutine mld_s_cmp_avg_cr(prec) - - implicit none - class(mld_sprec_type), intent(inout) :: prec - - real(psb_spk_) :: avgcr - integer(psb_ipk_) :: ictxt - integer(psb_ipk_) :: il, nl, iam, np - - - avgcr = szero - ictxt = prec%ictxt - call psb_info(ictxt,iam,np) - if (allocated(prec%precv)) then - nl = size(prec%precv) - do il=2,nl - avgcr = avgcr + max(szero,prec%precv(il)%szratio) - end do - avgcr = avgcr / (nl-1) - end if - call psb_sum(ictxt,avgcr) - prec%ag_data%avg_cr = avgcr/np - end subroutine mld_s_cmp_avg_cr - - ! - ! Subroutines: mld_Tprec_free - ! Version: real - ! - ! These routines deallocate the mld_Tprec_type data structures. - ! - ! Arguments: - ! p - type(mld_Tprec_type), input. - ! The data structure to be deallocated. - ! info - integer, output. - ! error code. - ! - subroutine mld_sprecfree(p,info) - - implicit none - - ! Arguments - type(mld_sprec_type), intent(inout) :: p - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: me,err_act,i - character(len=20) :: name - - info=psb_success_ - name = 'mld_sprecfree' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; return - end if - - me=-1 - - call p%free(info) - - - return - - end subroutine mld_sprecfree - - subroutine mld_s_prec_free(prec,info) - - implicit none - - ! Arguments - class(mld_sprec_type), intent(inout) :: prec - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: me,err_act,i - character(len=20) :: name - - info=psb_success_ - name = 'mld_sprecfree' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - - me=-1 - if (allocated(prec%precv)) then - do i=1,size(prec%precv) - call prec%precv(i)%free(info) - end do - deallocate(prec%precv,stat=info) - end if - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_s_prec_free - - - - ! - ! Top level methods. - ! - subroutine mld_s_apply2_vect(prec,x,y,desc_data,info,trans,work) - implicit none - type(psb_desc_type),intent(in) :: desc_data - class(mld_sprec_type), intent(inout) :: prec - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_spk_),intent(inout), optional, target :: work(:) - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_prec_apply' - - call psb_erractionsave(err_act) - - select type(prec) - type is (mld_sprec_type) - call mld_precapply(prec,x,y,desc_data,info,trans,work) - class default - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_s_apply2_vect - - subroutine mld_s_apply1_vect(prec,x,desc_data,info,trans,work) - implicit none - type(psb_desc_type),intent(in) :: desc_data - class(mld_sprec_type), intent(inout) :: prec - type(psb_s_vect_type),intent(inout) :: x - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_spk_),intent(inout), optional, target :: work(:) - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_prec_apply' - - call psb_erractionsave(err_act) - - select type(prec) - type is (mld_sprec_type) - call mld_precapply(prec,x,desc_data,info,trans,work) - class default - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_s_apply1_vect - - - subroutine mld_s_apply2v(prec,x,y,desc_data,info,trans,work) - implicit none - type(psb_desc_type),intent(in) :: desc_data - class(mld_sprec_type), intent(inout) :: prec - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - real(psb_spk_),intent(inout), optional, target :: work(:) - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_prec_apply' - - call psb_erractionsave(err_act) - - select type(prec) - type is (mld_sprec_type) - call mld_precapply(prec,x,y,desc_data,info,trans,work) - class default - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_s_apply2v - - subroutine mld_s_apply1v(prec,x,desc_data,info,trans) - implicit none - type(psb_desc_type),intent(in) :: desc_data - class(mld_sprec_type), intent(inout) :: prec - real(psb_spk_),intent(inout) :: x(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_prec_apply' - - call psb_erractionsave(err_act) - - select type(prec) - type is (mld_sprec_type) - call mld_precapply(prec,x,desc_data,info,trans) - class default - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_s_apply1v - - - subroutine mld_s_dump(prec,info,istart,iend,iproc,prefix,head,& - & ac,rp,smoother,solver,tprol,& - & global_num) - - implicit none - class(mld_sprec_type), intent(in) :: prec - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: istart, iend, iproc - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver,ac, rp, tprol, global_num - integer(psb_ipk_) :: i, j, il1, iln, lev - integer(psb_ipk_) :: icontxt, iam, np, iproc_ - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - ! len of prefix_ - - info = 0 - icontxt = prec%ictxt - call psb_info(icontxt,iam,np) - - iln = size(prec%precv) - if (present(istart)) then - il1 = max(1,istart) - else - il1 = min(2,iln) - end if - if (present(iend)) then - iln = min(iln, iend) - end if - iproc_ = -1 - if (present(iproc)) then - iproc_ = iproc - end if - - if ((iproc_ == -1).or.(iproc_==iam)) then - do lev=il1, iln - call prec%precv(lev)%dump(lev,info,prefix=prefix,head=head,& - & ac=ac,smoother=smoother,solver=solver,rp=rp,tprol=tprol, & - & global_num=global_num) - end do - end if - end subroutine mld_s_dump - - subroutine mld_s_cnv(prec,info,amold,vmold,imold) - - implicit none - class(mld_sprec_type), intent(inout) :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - integer(psb_ipk_) :: i - - info = psb_success_ - if (allocated(prec%precv)) then - do i=1,size(prec%precv) - if (info == psb_success_ ) & - & call prec%precv(i)%cnv(info,amold=amold,vmold=vmold,imold=imold) - end do - end if - - end subroutine mld_s_cnv - - subroutine mld_s_clone(prec,precout,info) - - implicit none - class(mld_sprec_type), intent(inout) :: prec - class(psb_sprec_type), intent(inout) :: precout - integer(psb_ipk_), intent(out) :: info - - call precout%free(info) - if (info == 0) call mld_s_inner_clone(prec,precout,info) - - end subroutine mld_s_clone - - subroutine mld_s_inner_clone(prec,precout,info) - - implicit none - class(mld_sprec_type), intent(inout) :: prec - class(psb_sprec_type), target, intent(inout) :: precout - integer(psb_ipk_), intent(out) :: info - ! Local vars - integer(psb_ipk_) :: i, j, ln, lev - integer(psb_ipk_) :: icontxt,iam, np - - info = psb_success_ - select type(pout => precout) - class is (mld_sprec_type) - pout%ictxt = prec%ictxt - pout%ag_data = prec%ag_data - pout%outer_sweeps = prec%outer_sweeps - if (allocated(prec%precv)) then - ln = size(prec%precv) - allocate(pout%precv(ln),stat=info) - if (info /= psb_success_) goto 9999 - if (ln >= 1) then - call prec%precv(1)%clone(pout%precv(1),info) - end if - do lev=2, ln - if (info /= psb_success_) exit - call prec%precv(lev)%clone(pout%precv(lev),info) - if (info == psb_success_) then - pout%precv(lev)%base_a => pout%precv(lev)%ac - pout%precv(lev)%base_desc => pout%precv(lev)%desc_ac - pout%precv(lev)%map%p_desc_U => pout%precv(lev-1)%base_desc - pout%precv(lev)%map%p_desc_V => pout%precv(lev)%base_desc - end if - end do - end if - if (allocated(prec%precv(1)%wrk)) & - & call pout%allocate_wrk(info,vmold=prec%precv(1)%wrk%vx2l%v) - - class default - write(0,*) 'Error: wrong out type' - info = psb_err_invalid_input_ - end select -9999 continue - end subroutine mld_s_inner_clone - - subroutine s_prec_move_alloc(prec, b,info) - use psb_base_mod - implicit none - class(mld_sprec_type), intent(inout) :: prec - class(mld_sprec_type), intent(inout), target :: b - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: i - - if (same_type_as(prec,b)) then - if (allocated(b%precv)) then - ! This might not be required if FINAL procedures are available. - call b%free(info) - if (info /= psb_success_) then - !????? -!!$ return - endif - end if - b%ictxt = prec%ictxt - b%ag_data = prec%ag_data - b%outer_sweeps = prec%outer_sweeps - - call move_alloc(prec%precv,b%precv) - ! Fix the pointers except on level 1. - do i=2, size(b%precv) - b%precv(i)%base_a => b%precv(i)%ac - b%precv(i)%base_desc => b%precv(i)%desc_ac - b%precv(i)%map%p_desc_U => b%precv(i-1)%base_desc - b%precv(i)%map%p_desc_V => b%precv(i)%base_desc - end do - - else - write(0,*) 'Warning: PREC%move_alloc onto different type?' - info = psb_err_internal_error_ - end if - end subroutine s_prec_move_alloc - - subroutine mld_s_allocate_wrk(prec,info,vmold,desc) - use psb_base_mod - implicit none - - ! Arguments - class(mld_sprec_type), intent(inout) :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_s_base_vect_type), intent(in), optional :: vmold - ! - ! In MLD the DESC optional argument is ignored, since - ! the necessary info is contained in the various entries of the - ! PRECV component. - type(psb_desc_type), intent(in), optional :: desc - - ! Local variables - integer(psb_ipk_) :: me,err_act,i,j,level,nlev, nc2l - character(len=20) :: name - - info=psb_success_ - name = 'mld_s_allocate_wrk' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - nlev = size(prec%precv) - level = 1 - do level = 1, nlev - call prec%precv(level)%allocate_wrk(info,vmold=vmold) - if (psb_errstatus_fatal()) then - nc2l = prec%precv(level)%base_desc%get_local_cols() - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nc2l/), a_err='real(psb_spk_)') - goto 9999 - end if - end do - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_s_allocate_wrk - - subroutine mld_s_free_wrk(prec,info) - use psb_base_mod - implicit none - - ! Arguments - class(mld_sprec_type), intent(inout) :: prec - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: me,err_act,i,j,level, nlev, nc2l - character(len=20) :: name - - info=psb_success_ - name = 'mld_s_free_wrk' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - - if (allocated(prec%precv)) then - nlev = size(prec%precv) - do level = 1, nlev - call prec%precv(level)%free_wrk(info) - end do - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_s_free_wrk - - function mld_s_is_allocated_wrk(prec) result(res) - use psb_base_mod - implicit none - - ! Arguments - class(mld_sprec_type), intent(in) :: prec - logical :: res - - res = .false. - if (.not.allocated(prec%precv)) return - res = allocated(prec%precv(1)%wrk) - - end function mld_s_is_allocated_wrk - -end module mld_s_prec_type diff --git a/mlprec/mld_s_slu_solver.F90 b/mlprec/mld_s_slu_solver.F90 deleted file mode 100644 index 0886eb48..00000000 --- a/mlprec/mld_s_slu_solver.F90 +++ /dev/null @@ -1,447 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_s_slu_solver_mod.f90 -! -! Module: mld_s_slu_solver_mod -! -! This module defines: -! - the mld_s_slu_solver_type data structure containing the ingredients -! to interface with the SuperLU package. -! 1. The factorization is restricted to the diagonal block of the -! current image. -! -module mld_s_slu_solver - - use iso_c_binding - use mld_s_base_solver_mod - -#if defined(IPK8) - - type, extends(mld_s_base_solver_type) :: mld_s_slu_solver_type - - end type mld_s_slu_solver_type - -#else - - type, extends(mld_s_base_solver_type) :: mld_s_slu_solver_type - type(c_ptr) :: lufactors=c_null_ptr - integer(c_long_long) :: symbsize=0, numsize=0 - contains - procedure, pass(sv) :: build => s_slu_solver_bld - procedure, pass(sv) :: apply_a => s_slu_solver_apply - procedure, pass(sv) :: apply_v => s_slu_solver_apply_vect - procedure, pass(sv) :: free => s_slu_solver_free - procedure, pass(sv) :: clear_data => s_slu_solver_clear_data - procedure, pass(sv) :: descr => s_slu_solver_descr - procedure, pass(sv) :: sizeof => s_slu_solver_sizeof - procedure, nopass :: get_fmt => s_slu_solver_get_fmt - procedure, nopass :: get_id => s_slu_solver_get_id - final :: s_slu_solver_finalize - end type mld_s_slu_solver_type - - - private :: s_slu_solver_bld, s_slu_solver_apply, & - & s_slu_solver_free, s_slu_solver_descr, & - & s_slu_solver_sizeof, s_slu_solver_apply_vect, & - & s_slu_solver_get_fmt, s_slu_solver_get_id, & - & s_slu_solver_clear_data - private :: s_slu_solver_finalize - - - - interface - function mld_sslu_fact(n,nnz,values,rowptr,colind,& - & lufactors)& - & bind(c,name='mld_sslu_fact') result(info) - use iso_c_binding - integer(c_int), value :: n,nnz - integer(c_int) :: info - integer(c_int) :: rowptr(*),colind(*) - real(c_float) :: values(*) - type(c_ptr) :: lufactors - end function mld_sslu_fact - end interface - - interface - function mld_sslu_solve(itrans,n,nrhs,b,ldb,lufactors)& - & bind(c,name='mld_sslu_solve') result(info) - use iso_c_binding - integer(c_int) :: info - integer(c_int), value :: itrans,n,nrhs,ldb - real(c_float) :: b(ldb,*) - type(c_ptr), value :: lufactors - end function mld_sslu_solve - end interface - - interface - function mld_sslu_free(lufactors)& - & bind(c,name='mld_sslu_free') result(info) - use iso_c_binding - integer(c_int) :: info - type(c_ptr), value :: lufactors - end function mld_sslu_free - end interface - -contains - - subroutine s_slu_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - use psb_base_mod - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_slu_solver_type), intent(inout) :: sv - real(psb_spk_),intent(inout) :: x(:) - real(psb_spk_),intent(inout) :: y(:) - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - integer, intent(out) :: info - character, intent(in), optional :: init - real(psb_spk_),intent(inout), optional :: initu(:) - - integer :: n_row,n_col - real(psb_spk_), pointer :: ww(:) - integer :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='s_slu_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - else - allocate(ww(n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/n_col,0,0,0,0/),& - & a_err='real(psb_spk_)') - goto 9999 - end if - endif - - ww(1:n_row) = x(1:n_row) - select case(trans_) - case('N') - info = mld_sslu_solve(0,n_row,1,ww,n_row,sv%lufactors) - case('T') - info = mld_sslu_solve(1,n_row,1,ww,n_row,sv%lufactors) - case('C') - info = mld_sslu_solve(2,n_row,1,ww,n_row,sv%lufactors) - case default - call psb_errpush(psb_err_internal_error_, & - & name,a_err='Invalid TRANS in ILU subsolve') - goto 9999 - end select - - if (info == psb_success_) & - & call psb_geaxpby(alpha,ww,beta,y,desc_data,info) - - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in subsolve') - goto 9999 - endif - - if (n_col > size(work)) then - deallocate(ww) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine s_slu_solver_apply - - subroutine s_slu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - use psb_base_mod - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_s_slu_solver_type), intent(inout) :: sv - type(psb_s_vect_type),intent(inout) :: x - type(psb_s_vect_type),intent(inout) :: y - real(psb_spk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - real(psb_spk_),target, intent(inout) :: work(:) - type(psb_s_vect_type),intent(inout) :: wv(:) - integer, intent(out) :: info - character, intent(in), optional :: init - type(psb_s_vect_type),intent(inout), optional :: initu - - integer :: err_act - character(len=20) :: name='s_slu_solver_apply_vect' - - call psb_erractionsave(err_act) - - info = psb_success_ - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call x%v%sync() - call y%v%sync() - call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) - call y%v%set_host() - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine s_slu_solver_apply_vect - - subroutine s_slu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - - Implicit None - - ! Arguments - type(psb_sspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_s_slu_solver_type), intent(inout) :: sv - integer, intent(out) :: info - type(psb_sspmat_type), intent(in), target, optional :: b - class(psb_s_base_sparse_mat), intent(in), optional :: amold - class(psb_s_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - type(psb_sspmat_type) :: atmp - type(psb_s_csc_sparse_mat) :: acsc - type(psb_s_coo_sparse_mat) :: acoo - integer :: n_row,n_col, nrow_a, nztota - integer :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='s_slu_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - n_col = desc_a%get_local_cols() - - - call a%cscnv(atmp,info,type='coo') - call psb_rwextd(n_row,atmp,info,b=b) - call atmp%cscnv(info,type='coo',dupl=psb_dupl_add_) - nrow_a = atmp%get_nrows() - call atmp%a%csclip(acoo,info,jmax=nrow_a) - call acsc%mv_from_coo(acoo,info) - nztota = acsc%get_nzeros() - ! Fix the entries to call C-base SuperLU - acsc%ia(:) = acsc%ia(:) - 1 - acsc%icp(:) = acsc%icp(:) - 1 - info = mld_sslu_fact(nrow_a,nztota,acsc%val,& - & acsc%icp,acsc%ia,sv%lufactors) - - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='mld_sslu_fact' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - call acsc%free() - call atmp%free() - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine s_slu_solver_bld - - subroutine s_slu_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_s_slu_solver_type), intent(inout) :: sv - integer, intent(out) :: info - Integer :: err_act - character(len=20) :: name='s_slu_solver_free' - - call psb_erractionsave(err_act) - - info = psb_success_ - - call sv%clear_data(info) - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine s_slu_solver_free - - subroutine s_slu_solver_clear_data(sv,info) - - Implicit None - - ! Arguments - class(mld_s_slu_solver_type), intent(inout) :: sv - integer, intent(out) :: info - Integer :: err_act - character(len=20) :: name='s_slu_solver_clear_data' - - call psb_erractionsave(err_act) - - info = psb_success_ - if (c_associated(sv%lufactors)) info = mld_sslu_free(sv%lufactors) - sv%lufactors = c_null_ptr - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine s_slu_solver_clear_data - - subroutine s_slu_solver_finalize(sv) - - Implicit None - - ! Arguments - type(mld_s_slu_solver_type), intent(inout) :: sv - integer :: info - Integer :: err_act - character(len=20) :: name='s_slu_solver_finalize' - - call sv%free(info) - - return - - end subroutine s_slu_solver_finalize - - subroutine s_slu_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_s_slu_solver_type), intent(in) :: sv - integer, intent(out) :: info - integer, intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer :: err_act - integer :: ictxt, me, np - character(len=20), parameter :: name='mld_s_slu_solver_descr' - integer :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' SuperLU Sparse Factorization Solver. ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine s_slu_solver_descr - - function s_slu_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_s_slu_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer :: i - - val = 2*psb_sizeof_ip + psb_sizeof_dp - val = val + sv%symbsize - val = val + sv%numsize - return - end function s_slu_solver_sizeof - - function s_slu_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "SuperLU solver" - end function s_slu_solver_get_fmt - - function s_slu_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_slu_ - end function s_slu_solver_get_id -#endif -end module mld_s_slu_solver diff --git a/mlprec/mld_s_symdec_aggregator_mod.f90 b/mlprec/mld_s_symdec_aggregator_mod.f90 deleted file mode 100644 index e7fa4c23..00000000 --- a/mlprec/mld_s_symdec_aggregator_mod.f90 +++ /dev/null @@ -1,105 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! Locally symmetrized (decoupled) aggregation algorithm. -! This version differs from the basic decoupled aggregation algorithm -! only because it works on (the pattern of) A+A^T instead of A. -! -! -module mld_s_symdec_aggregator_mod - - use mld_s_dec_aggregator_mod - !> \namespace mld_s_symdec_aggregator_mod \class mld_s_symdec_aggregator_type - !! \extends mld_s_dec_aggregator_mod::mld_s_dec_aggregator_type - !! - !! This version differs from the basic decoupled aggregation algorithm - !! only because it works on (the pattern of) A+A^T instead of A. - !! - ! - type, extends(mld_s_dec_aggregator_type) :: mld_s_symdec_aggregator_type - - contains - procedure, pass(ag) :: bld_tprol => mld_s_symdec_aggregator_build_tprol - procedure, pass(ag) :: descr => mld_s_symdec_aggregator_descr - procedure, nopass :: fmt => mld_s_symdec_aggregator_fmt - end type mld_s_symdec_aggregator_type - - - interface - subroutine mld_s_symdec_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,t_prol,info) - import :: mld_s_symdec_aggregator_type, psb_desc_type, psb_sspmat_type, psb_spk_, & - & psb_ipk_, psb_lpk_, psb_lsspmat_type, mld_sml_parms, mld_saggr_data - implicit none - class(mld_s_symdec_aggregator_type), target, intent(inout) :: ag - type(mld_sml_parms), intent(inout) :: parms - type(mld_saggr_data), intent(in) :: ag_data - type(psb_sspmat_type), intent(inout) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lsspmat_type), intent(out) :: t_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_s_symdec_aggregator_build_tprol - end interface - - -contains - - function mld_s_symdec_aggregator_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Symmetric Decoupled aggregation" - end function mld_s_symdec_aggregator_fmt - - subroutine mld_s_symdec_aggregator_descr(ag,parms,iout,info) - implicit none - class(mld_s_symdec_aggregator_type), intent(in) :: ag - type(mld_sml_parms), intent(in) :: parms - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - - write(iout,*) 'Decoupled Aggregator locally-symmetrized' - write(iout,*) 'Aggregator object type: ',ag%fmt() - call parms%mldescr(iout,info) - - return - end subroutine mld_s_symdec_aggregator_descr - -end module mld_s_symdec_aggregator_mod diff --git a/mlprec/mld_z_as_smoother.f90 b/mlprec/mld_z_as_smoother.f90 deleted file mode 100644 index 146dcb9e..00000000 --- a/mlprec/mld_z_as_smoother.f90 +++ /dev/null @@ -1,471 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_z_as_smoother_mod.f90 -! -! Module: mld_z_as_smoother_mod -! -! This module defines: -! the mld_z_as_smoother_type data structure containing the -! smoother for an Additive Schwarz smoother. -! -! To begin with, the build procedure constructs the extended -! matrix A and its corresponding descriptor (this has multiple -! halo layers duplicated across different processes); it then -! stores in ND the block off-diagonal matrix, and builds the solver -! on the (extended) block diagonal matrix. -! -! The code allows for the variations of Additive Schwartz, Restricted -! Additive Schwartz and Additive Schwartz with Harmonic Extensions. -! From an implementation point of view, these are handled by -! combining application/non-application of the prolongator/restrictor -! operators. -! -module mld_z_as_smoother - - use mld_z_base_smoother_mod - - type, extends(mld_z_base_smoother_type) :: mld_z_as_smoother_type - ! The local solver component is inherited from the - ! parent type. - ! class(mld_z_base_solver_type), allocatable :: sv - ! - type(psb_zspmat_type) :: nd - type(psb_desc_type) :: desc_data - integer(psb_ipk_) :: novr, restr, prol - integer(psb_lpk_) :: nd_nnz_tot - contains - procedure, pass(sm) :: apply_v => mld_z_as_smoother_apply_vect - procedure, pass(sm) :: apply_a => mld_z_as_smoother_apply - procedure, pass(sm) :: check => mld_z_as_smoother_check - procedure, pass(sm) :: dump => mld_z_as_smoother_dmp - procedure, pass(sm) :: build => mld_z_as_smoother_bld - procedure, pass(sm) :: cnv => mld_z_as_smoother_cnv - procedure, pass(sm) :: clone => mld_z_as_smoother_clone - procedure, pass(sm) :: clone_settings => mld_z_as_smoother_clone_settings - procedure, pass(sm) :: clear_data => mld_z_as_smoother_clear_data - procedure, pass(sm) :: restr_a => mld_z_as_smoother_restr_a - procedure, pass(sm) :: prol_a => mld_z_as_smoother_prol_a - procedure, pass(sm) :: restr_v => mld_z_as_smoother_restr_v - procedure, pass(sm) :: prol_v => mld_z_as_smoother_prol_v - generic, public :: apply_restr => restr_v, restr_a - generic, public :: apply_prol => prol_v, prol_a - procedure, pass(sm) :: free => mld_z_as_smoother_free - procedure, pass(sm) :: cseti => mld_z_as_smoother_cseti - procedure, pass(sm) :: csetc => mld_z_as_smoother_csetc - procedure, pass(sm) :: descr => z_as_smoother_descr - procedure, pass(sm) :: sizeof => z_as_smoother_sizeof - procedure, pass(sm) :: default => z_as_smoother_default - procedure, pass(sm) :: get_nzeros => z_as_smoother_get_nzeros - procedure, pass(sm) :: get_wrksz => z_as_smoother_get_wrksize - procedure, nopass :: get_fmt => z_as_smoother_get_fmt - procedure, nopass :: get_id => z_as_smoother_get_id - end type mld_z_as_smoother_type - - - private :: z_as_smoother_descr, z_as_smoother_sizeof, & - & z_as_smoother_default, z_as_smoother_get_nzeros, & - & z_as_smoother_get_fmt, z_as_smoother_get_id, & - & z_as_smoother_get_wrksize - - character(len=6), parameter, private :: & - & restrict_names(0:4)=(/'none ','halo ',' ',' ',' '/) - character(len=12), parameter, private :: & - & prolong_names(0:3)=(/'none ','sum ','average ','square root'/) - - - interface - subroutine mld_z_as_smoother_check(sm,info) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_dpk_, mld_z_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_z_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_as_smoother_check - end interface - - interface - subroutine mld_z_as_smoother_restr_v(sm,x,trans,work,info,data) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_dpk_, mld_z_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - class(mld_z_as_smoother_type), intent(inout) :: sm - type(psb_z_vect_type),intent(inout) :: x - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - end subroutine mld_z_as_smoother_restr_v - end interface - - interface - subroutine mld_z_as_smoother_restr_a(sm,x,trans,work,info,data) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_dpk_, mld_z_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - class(mld_z_as_smoother_type), intent(inout) :: sm - complex(psb_dpk_), intent(inout) :: x(:) - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - end subroutine mld_z_as_smoother_restr_a - end interface - - interface - subroutine mld_z_as_smoother_prol_v(sm,x,trans,work,info,data) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_dpk_, mld_z_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - class(mld_z_as_smoother_type), intent(inout) :: sm - type(psb_z_vect_type),intent(inout) :: x - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - end subroutine mld_z_as_smoother_prol_v - end interface - - interface - subroutine mld_z_as_smoother_prol_a(sm,x,trans,work,info,data) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_dpk_, mld_z_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - class(mld_z_as_smoother_type), intent(inout) :: sm - complex(psb_dpk_), intent(inout) :: x(:) - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: data - end subroutine mld_z_as_smoother_prol_a - end interface - - - interface - subroutine mld_z_as_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,wv,info,init,initu) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_dpk_, mld_z_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_as_smoother_type), intent(inout) :: sm - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - end subroutine mld_z_as_smoother_apply_vect - end interface - - interface - subroutine mld_z_as_smoother_apply(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,info,init,initu) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_dpk_, mld_z_as_smoother_type, psb_epk_,& - & psb_desc_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_as_smoother_type), intent(inout) :: sm - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_z_as_smoother_apply - end interface - - interface - subroutine mld_z_as_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_dpk_, mld_z_as_smoother_type, psb_epk_, & - & psb_desc_type, psb_z_base_sparse_mat, psb_ipk_,& - & psb_i_base_vect_type - implicit none - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_as_smoother_bld - end interface - - interface - subroutine mld_z_as_smoother_cnv(sm,info,amold,vmold,imold) - import :: psb_z_base_vect_type, & - & psb_dpk_, mld_z_as_smoother_type, psb_epk_, & - & psb_z_base_sparse_mat, psb_ipk_, psb_i_base_vect_type - implicit none - class(mld_z_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_as_smoother_cnv - end interface - - interface - subroutine mld_z_as_smoother_cseti(sm,what,val,info,idx) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_dpk_, mld_z_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_z_as_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_z_as_smoother_cseti - end interface - - interface - subroutine mld_z_as_smoother_csetc(sm,what,val,info,idx) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_dpk_, mld_z_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_z_as_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_z_as_smoother_csetc - end interface - - interface - subroutine mld_z_as_smoother_free(sm,info) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_dpk_, mld_z_as_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_z_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_as_smoother_free - end interface - - interface - subroutine mld_z_as_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_dpk_, mld_z_as_smoother_type, psb_epk_, psb_desc_type, & - & psb_ipk_ - implicit none - class(mld_z_as_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - end subroutine mld_z_as_smoother_dmp - end interface - - interface - subroutine mld_z_as_smoother_clone(sm,smout,info) - import :: mld_z_as_smoother_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_ - class(mld_z_as_smoother_type), intent(inout) :: sm - class(mld_z_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_as_smoother_clone - end interface - - - interface - subroutine mld_z_as_smoother_clone_settings(sm,smout,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_smoother_type, mld_z_as_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_as_smoother_type), intent(inout) :: sm - class(mld_z_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_as_smoother_clone_settings - end interface - - interface - subroutine mld_z_as_smoother_clear_data(sm,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_as_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_as_smoother_clear_data - end interface - - -contains - - function z_as_smoother_sizeof(sm) result(val) - implicit none - ! Arguments - class(mld_z_as_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 3*psb_sizeof_ip + psb_sizeof_lp - if (allocated(sm%sv)) val = val + sm%sv%sizeof() - val = val + sm%nd%sizeof() - - return - end function z_as_smoother_sizeof - - function z_as_smoother_get_nzeros(sm) result(val) - implicit none - class(mld_z_as_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - if (allocated(sm%sv)) & - & val = sm%sv%get_nzeros() - val = val + sm%nd%get_nzeros() - - end function z_as_smoother_get_nzeros - - subroutine z_as_smoother_default(sm) - - use psb_base_mod, only : psb_halo_, psb_none_ - - Implicit None - - ! Arguments - class(mld_z_as_smoother_type), intent(inout) :: sm - - ! - ! Default: AS with 1 overlap layer - ! - sm%restr = psb_halo_ - sm%prol = psb_sum_ - sm%novr = 1 - - if (allocated(sm%sv)) then - call sm%sv%default() - end if - - return - end subroutine z_as_smoother_default - - - subroutine z_as_smoother_descr(sm,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_z_as_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_z_as_smoother_descr' - integer(psb_ipk_) :: iout_ - logical :: coarse_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(coarse)) then - coarse_ = coarse - else - coarse_ = .false. - end if - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (.not.coarse_) then - write(iout_,*) ' Additive Schwarz with ',& - & sm%novr, ' overlap layers.' - write(iout_,*) ' Restrictor: ',restrict_names(sm%restr) - write(iout_,*) ' Prolongator: ',prolong_names(sm%prol) - write(iout_,*) ' Local solver:' - endif - if (allocated(sm%sv)) then - call sm%sv%descr(info,iout_,coarse=coarse) - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine z_as_smoother_descr - - function z_as_smoother_get_wrksize(sm) result(val) - implicit none - class(mld_z_as_smoother_type), intent(inout) :: sm - integer(psb_ipk_) :: val - - val = 3 - if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() - - end function z_as_smoother_get_wrksize - - function z_as_smoother_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Additive Schwarz" - end function z_as_smoother_get_fmt - - function z_as_smoother_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_as_ - end function z_as_smoother_get_id - -end module mld_z_as_smoother diff --git a/mlprec/mld_z_base_aggregator_mod.f90 b/mlprec/mld_z_base_aggregator_mod.f90 deleted file mode 100644 index 607f7c44..00000000 --- a/mlprec/mld_z_base_aggregator_mod.f90 +++ /dev/null @@ -1,519 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! The aggregator object hosts the aggregation method for building -! the multilevel hierarchy. -! -module mld_z_base_aggregator_mod - - use mld_base_prec_type, only : mld_dml_parms, mld_daggr_data - use psb_base_mod, only : psb_zspmat_type, psb_lzspmat_type, psb_z_vect_type, & - & psb_z_base_vect_type, psb_zlinmap_type, psb_dpk_, & - & psb_lz_csr_sparse_mat, psb_lz_coo_sparse_mat, & - & psb_z_csr_sparse_mat, psb_z_coo_sparse_mat, & - & psb_ipk_, psb_epk_, psb_lpk_, psb_desc_type, psb_i_base_vect_type, & - & psb_erractionsave, psb_error_handler, psb_success_, psb_toupper - ! - ! - ! - !> \class mld_z_base_aggregator_type - !! - !! It is the data type containing the basic interface definition for - !! building a multigrid hierarchy by aggregation. The base object has no attributes, - !! it is intended to be essentially an abstract type. - !! - !! - !! type mld_z_base_aggregator_type - !! end type - !! - !! - !! Methods: - !! - !! bld_tprol - Build a tentative prolongator - !! - !! mat_bld - Build prolongator/restrictor and coarse matrix ac - !! - !! mat_asb - Convert prolongator/restrictor/coarse matrix - !! and fix their descriptor(s) - !! - !! update_next - Transfer information to the next level; default is - !! to do nothing, i.e. aggregators at different - !! levels are independent. - !! - !! default - Apply defaults - !! set_aggr_type - For aggregator that have internal options. - !! fmt - Return a short string description - !! descr - Print a more detailed description - !! - !! cseti, csetr, csetc - Set internal parameters, if any - ! - type mld_z_base_aggregator_type - ! Do we want to purge explicit zeros when aggregating? - logical :: do_clean_zeros - contains - procedure, pass(ag) :: bld_tprol => mld_z_base_aggregator_build_tprol - procedure, pass(ag) :: mat_bld => mld_z_base_aggregator_mat_bld - procedure, pass(ag) :: mat_asb => mld_z_base_aggregator_mat_asb - procedure, pass(ag) :: bld_map => mld_z_base_aggregator_bld_map - procedure, pass(ag) :: update_next => mld_z_base_aggregator_update_next - procedure, pass(ag) :: clone => mld_z_base_aggregator_clone - procedure, pass(ag) :: free => mld_z_base_aggregator_free - procedure, pass(ag) :: default => mld_z_base_aggregator_default - procedure, pass(ag) :: descr => mld_z_base_aggregator_descr - procedure, pass(ag) :: sizeof => mld_z_base_aggregator_sizeof - procedure, pass(ag) :: set_aggr_type => mld_z_base_aggregator_set_aggr_type - procedure, nopass :: fmt => mld_z_base_aggregator_fmt - procedure, pass(ag) :: cseti => mld_z_base_aggregator_cseti - procedure, pass(ag) :: csetr => mld_z_base_aggregator_csetr - procedure, pass(ag) :: csetc => mld_z_base_aggregator_csetc - generic, public :: set => cseti, csetr, csetc - procedure, nopass :: xt_desc => mld_z_base_aggregator_xt_desc - end type mld_z_base_aggregator_type - - abstract interface - subroutine mld_z_soc_map_bld(iorder,theta,clean_zeros,a,desc_a,nlaggr,ilaggr,info) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, psb_ipk_, psb_lpk_ - implicit none - integer(psb_ipk_), intent(in) :: iorder - logical, intent(in) :: clean_zeros - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - real(psb_dpk_), intent(in) :: theta - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_soc_map_bld - end interface - - interface mld_ptap - subroutine mld_z_ptap(a_csr,desc_a,nlaggr,parms,ac,& - & coo_prol,desc_cprol,coo_restr,info,desc_ax) - import :: psb_z_csr_sparse_mat, psb_zspmat_type, psb_desc_type, & - & psb_z_coo_sparse_mat, mld_dml_parms, psb_dpk_, psb_ipk_, psb_lpk_ - implicit none - type(psb_z_csr_sparse_mat), intent(inout) :: a_csr - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), intent(inout) :: nlaggr(:) - type(mld_dml_parms), intent(inout) :: parms - type(psb_z_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr - type(psb_desc_type), intent(inout) :: desc_cprol - type(psb_zspmat_type), intent(out) :: ac - integer(psb_ipk_), intent(out) :: info - type(psb_desc_type), intent(inout), optional :: desc_ax - end subroutine mld_z_ptap -!!$ subroutine mld_z_lz_ptap(a_csr,desc_a,nlaggr,parms,ac,& -!!$ & coo_prol,desc_cprol,coo_restr,info,desc_ax) -!!$ import :: psb_z_csr_sparse_mat, psb_lzspmat_type, psb_desc_type, & -!!$ & psb_lz_coo_sparse_mat, mld_dml_parms, psb_dpk_, psb_ipk_, psb_lpk_ -!!$ implicit none -!!$ type(psb_z_csr_sparse_mat), intent(inout) :: a_csr -!!$ type(psb_desc_type), intent(in) :: desc_a -!!$ integer(psb_lpk_), intent(inout) :: nlaggr(:) -!!$ type(mld_dml_parms), intent(inout) :: parms -!!$ type(psb_lz_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr -!!$ type(psb_desc_type), intent(inout) :: desc_cprol -!!$ type(psb_lzspmat_type), intent(out) :: ac -!!$ integer(psb_ipk_), intent(out) :: info -!!$ type(psb_desc_type), intent(inout), optional :: desc_ax -!!$ end subroutine mld_z_lz_ptap -!!$ subroutine mld_lz_ptap(a_csr,desc_a,nlaggr,parms,ac,& -!!$ & coo_prol,desc_cprol,coo_restr,info,desc_ax) -!!$ import :: psb_lz_csr_sparse_mat, psb_lzspmat_type, psb_desc_type, & -!!$ & psb_lz_coo_sparse_mat, mld_dml_parms, psb_dpk_, psb_ipk_, psb_lpk_ -!!$ implicit none -!!$ type(psb_lz_csr_sparse_mat), intent(inout) :: a_csr -!!$ type(psb_desc_type), intent(in) :: desc_a -!!$ integer(psb_lpk_), intent(inout) :: nlaggr(:) -!!$ type(mld_dml_parms), intent(inout) :: parms -!!$ type(psb_lz_coo_sparse_mat), intent(inout) :: coo_prol, coo_restr -!!$ type(psb_desc_type), intent(inout) :: desc_cprol -!!$ type(psb_lzspmat_type), intent(out) :: ac -!!$ integer(psb_ipk_), intent(out) :: info -!!$ type(psb_desc_type), intent(inout), optional :: desc_ax -!!$ end subroutine mld_lz_ptap - end interface mld_ptap - -contains - - subroutine mld_z_base_aggregator_cseti(ag,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_z_base_aggregator_type), intent(inout) :: ag - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - ! Do nothing - info = 0 - end subroutine mld_z_base_aggregator_cseti - - subroutine mld_z_base_aggregator_csetr(ag,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_z_base_aggregator_type), intent(inout) :: ag - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - ! Do nothing - info = 0 - end subroutine mld_z_base_aggregator_csetr - - subroutine mld_z_base_aggregator_csetc(ag,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_z_base_aggregator_type), intent(inout) :: ag - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - ! Set clean zeros, or do nothing. - select case (psb_toupper(trim(what))) - case('AGGR_CLEAN_ZEROS') - select case (psb_toupper(trim(val))) - case('TRUE','T') - ag%do_clean_zeros = .true. - case('FALSE','F') - ag%do_clean_zeros = .false. - end select - end select - info = 0 - end subroutine mld_z_base_aggregator_csetc - - - subroutine mld_z_base_aggregator_update_next(ag,agnext,info) - implicit none - class(mld_z_base_aggregator_type), target, intent(inout) :: ag, agnext - integer(psb_ipk_), intent(out) :: info - - ! - ! Base version does nothing. - ! - info = 0 - end subroutine mld_z_base_aggregator_update_next - - subroutine mld_z_base_aggregator_clone(ag,agnext,info) - implicit none - class(mld_z_base_aggregator_type), intent(inout) :: ag - class(mld_z_base_aggregator_type), allocatable, intent(inout) :: agnext - integer(psb_ipk_), intent(out) :: info - - info = 0 - if (allocated(agnext)) then - call agnext%free(info) - if (info == 0) deallocate(agnext,stat=info) - end if - if (info /= 0) return - allocate(agnext,source=ag,stat=info) - - end subroutine mld_z_base_aggregator_clone - - subroutine mld_z_base_aggregator_free(ag,info) - implicit none - class(mld_z_base_aggregator_type), intent(inout) :: ag - integer(psb_ipk_), intent(out) :: info - - info = psb_success_ - return - end subroutine mld_z_base_aggregator_free - - subroutine mld_z_base_aggregator_default(ag) - implicit none - class(mld_z_base_aggregator_type), intent(inout) :: ag - ! Only one default setting - ag%do_clean_zeros = .true. - - return - end subroutine mld_z_base_aggregator_default - - function mld_z_base_aggregator_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Default aggregator " - end function mld_z_base_aggregator_fmt - - function mld_z_base_aggregator_sizeof(ag) result(val) - implicit none - class(mld_z_base_aggregator_type), intent(in) :: ag - integer(psb_epk_) :: val - - val = 1 - end function mld_z_base_aggregator_sizeof - - function mld_z_base_aggregator_xt_desc() result(val) - implicit none - logical :: val - - val = .false. - end function mld_z_base_aggregator_xt_desc - - subroutine mld_z_base_aggregator_descr(ag,parms,iout,info) - implicit none - class(mld_z_base_aggregator_type), intent(in) :: ag - type(mld_dml_parms), intent(in) :: parms - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - - write(iout,*) 'Aggregator object type: ',ag%fmt() - call parms%mldescr(iout,info) - - return - end subroutine mld_z_base_aggregator_descr - - subroutine mld_z_base_aggregator_set_aggr_type(ag,parms,info) - implicit none - class(mld_z_base_aggregator_type), intent(inout) :: ag - type(mld_dml_parms), intent(in) :: parms - integer(psb_ipk_), intent(out) :: info - - ! Do nothing - - return - end subroutine mld_z_base_aggregator_set_aggr_type - - ! - !> Function bld_tprol: - !! \memberof mld_z_base_aggregator_type - !! \brief Build a tentative prolongator. - !! The routine will map the local matrix entries to aggregates. - !! The mapping is store in ILAGGR; for each local row index I, - !! ILAGGR(I) contains the index of the aggregate to which index I - !! will contribute, in global numbering. - !! Many aggregations produce a binary tentative prolongator, but some - !! do not, hence we also need the OP_PROL output. - !! AG_DATA is passed here just in case some of the - !! aggregators need it internally, most of them will ignore. - !! - !! \param ag The input aggregator object - !! \param parms The auxiliary parameters object - !! \param ag_data Auxiliary global aggregation info - !! \param a The local matrix part - !! \param desc_a The descriptor - !! \param ilaggr Output aggregation map - !! \param nlaggr Sizes of ilaggr on all processes - !! \param op_prol The tentative prolongator operator - !! \param info Return code - !! - ! - subroutine mld_z_base_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,t_prol,info) - use psb_base_mod - implicit none - class(mld_z_base_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(mld_daggr_data), intent(in) :: ag_data - type(psb_zspmat_type), intent(inout) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lzspmat_type), intent(out) :: t_prol - integer(psb_ipk_), intent(out) :: info - - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_aggregator_build_tprol' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - - end subroutine mld_z_base_aggregator_build_tprol - - ! - !> Function mat_bld - !! \memberof mld_z_base_aggregator_type - !! \brief Build prolongator/restrictor/coarse matrix. - !! - !! - !! \param ag The input aggregator object - !! \param parms The auxiliary parameters object - !! \param a The local matrix part - !! \param desc_a The descriptor - !! \param ilaggr Aggregation map - !! \param nlaggr Sizes of ilaggr on all processes - !! \param ac On output the coarse matrix - !! \param op_prol On input, the tentative prolongator operator, on output - !! the final prolongator - !! \param op_restr On output, the restrictor operator; - !! in many cases it is the transpose of the prolongator. - !! \param info Return code - !! - subroutine mld_z_base_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - use psb_base_mod - implicit none - class(mld_z_base_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(psb_lzspmat_type), intent(inout) :: t_prol - type(psb_zspmat_type), intent(out) :: op_prol, ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_aggregator_mat_bld' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - end subroutine mld_z_base_aggregator_mat_bld - - ! - !> Function mat_asb - !! \memberof mld_z_base_aggregator_type - !! \brief Build prolongator/restrictor/coarse matrix. - !! - !! - !! \param ag The input aggregator object - !! \param parms The auxiliary parameters object - !! \param a The local matrix part - !! \param desc_a The descriptor - !! \param ilaggr Aggregation map - !! \param nlaggr Sizes of ilaggr on all processes - !! \param ac On output the coarse matrix - !! \param op_prol On input, the tentative prolongator operator, on output - !! the final prolongator - !! \param op_restr On output, the restrictor operator; - !! in many cases it is the transpose of the prolongator. - !! \param info Return code - !! - subroutine mld_z_base_aggregator_mat_asb(ag,parms,a,desc_a,& - & ac,desc_ac, op_prol,op_restr,info) - use psb_base_mod - implicit none - class(mld_z_base_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - type(psb_zspmat_type), intent(inout) :: op_prol,ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_aggregator_mat_asb' - - call psb_erractionsave(err_act) - - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - end subroutine mld_z_base_aggregator_mat_asb - - ! - !> Function bld_map - !! \memberof mld_z_base_aggregator_type - !! \brief Build linear map between hierarchy levels - !! - !! - !! \param ag The input aggregator object - !! \param desc_a The fine space descriptor - !! \param desc_ac The coarse space descriptor - !! \param ilaggr Aggregation map vector - !! \param nlaggr Sizes of ilaggr on all processes - !! \param op_prol The prolongator operator - !! \param op_restr The restrictor operator - !! \param map The output map - !! \param info Return code - !! - subroutine mld_z_base_aggregator_bld_map(ag,desc_a,desc_ac,ilaggr,nlaggr,& - & op_restr,op_prol,map,info) - use psb_base_mod - implicit none - class(mld_z_base_aggregator_type), target, intent(inout) :: ag - type(psb_desc_type), intent(in), target :: desc_a, desc_ac - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(psb_zspmat_type), intent(inout) :: op_restr, op_prol - type(psb_zlinmap_type), intent(out) :: map - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_base_aggregator_bld_map' - - call psb_erractionsave(err_act) - ! - ! Copy the prolongation/restriction matrices into the descriptor map. - ! op_restr => PR^T i.e. restriction operator - ! op_prol => PR i.e. prolongation operator - ! - ! WARNING: need to check whether the copy into IOP_RESTR/IOP_PROL - ! is safe or not. - ! - ! This default implementation reuses desc_a/desc_ac through - ! pointers in the map structure. - ! - map = psb_linmap(psb_map_aggr_,desc_a,& - & desc_ac,op_restr,op_prol,ilaggr,nlaggr) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return - end subroutine mld_z_base_aggregator_bld_map - - -end module mld_z_base_aggregator_mod diff --git a/mlprec/mld_z_base_smoother_mod.f90 b/mlprec/mld_z_base_smoother_mod.f90 deleted file mode 100644 index 867664ba..00000000 --- a/mlprec/mld_z_base_smoother_mod.f90 +++ /dev/null @@ -1,412 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_z_base_smoother_mod.f90 -! -! Module: mld_z_base_smoother_mod -! -! This module defines: -! - the mld_z_base_smoother_type data structure containing the -! smoother and related data structures; -! -! It contains routines for -! - Building and applying; -! - checking if the smoother is correctly defined; -! - printing a description of the preconditioner; -! - deallocating the preconditioner data structure. -! -! What is the difference between a smoother and a solver? -! In the mathematics literature the two concepts are treated -! essentially as synonymous, but here we are using them in a more -! computer-science oriented fashion. In particular, a SMOOTHER object -! contains a SOLVER object: the SOLVER operates locally within the -! current process, whereas the SMOOTHER object accounts for (possible) -! interactions between processes. -! Some solvers (MUMPS and SuperLU_DIST) can also operate on the entire -! distributed matrix, in which case the smoother object essentially -! becomes transparent. -! -module mld_z_base_smoother_mod - - use mld_z_base_solver_mod - use psb_base_mod, only : psb_desc_type, psb_zspmat_type, psb_epk_,& - & psb_z_vect_type, psb_z_base_vect_type, psb_z_base_sparse_mat, & - & psb_dpk_, psb_i_base_vect_type, psb_erractionsave, psb_error_handler - - ! - ! - ! - ! Type: mld_T_base_smoother_type. - ! - ! It holds the smoother a single level. Its only mandatory component is a solver - ! object which holds a local solver; this decoupling allows to have the same solver - ! e.g ILU to work with Jacobi with multiple sweeps as well as with any AS variant. - ! - ! type mld_T_base_smoother_type - ! class(mld_T_base_solver_type), allocatable :: sv - ! end type mld_T_base_smoother_type - ! - ! Methods: - ! - ! build - Compute the actual contents of the smoother; includes - ! invocation of the build method on the solver component. - ! free - Release memory - ! apply - Apply the smoother to a vector (or to an array); includes - ! invocation of the apply method on the solver component. - ! descr - Prints a description of the object. - ! default - Set default values - ! dump - Dump to file object contents - ! set - Sets various parameters; when a request is unknown - ! it is passed to the solver object for further processing. - ! check - Sanity checks. - ! sizeof - Total memory occupation in bytes - ! get_nzeros - Number of nonzeros - ! stringval - convert string to val for internal parms - ! get_fmt - short string descriptor - ! get_id - numeric id descriptro - ! get_wrksz - How many workspace vector does apply_vect need - ! - ! - ! - - type mld_z_base_smoother_type - class(mld_z_base_solver_type), allocatable :: sv - contains - procedure, pass(sm) :: apply_v => mld_z_base_smoother_apply_vect - procedure, pass(sm) :: apply_a => mld_z_base_smoother_apply - generic, public :: apply => apply_a, apply_v - procedure, pass(sm) :: check => mld_z_base_smoother_check - procedure, pass(sm) :: dump => mld_z_base_smoother_dmp - procedure, pass(sm) :: clone => mld_z_base_smoother_clone - procedure, pass(sm) :: build => mld_z_base_smoother_bld - procedure, pass(sm) :: cnv => mld_z_base_smoother_cnv - procedure, pass(sm) :: free => mld_z_base_smoother_free - procedure, pass(sm) :: clone_settings => mld_z_base_smoother_clone_settings - procedure, pass(sm) :: clear_data => mld_z_base_smoother_clear_data - procedure, pass(sm) :: cseti => mld_z_base_smoother_cseti - procedure, pass(sm) :: csetc => mld_z_base_smoother_csetc - procedure, pass(sm) :: csetr => mld_z_base_smoother_csetr - generic, public :: set => cseti, csetc, csetr - procedure, pass(sm) :: default => z_base_smoother_default - procedure, pass(sm) :: descr => mld_z_base_smoother_descr - procedure, pass(sm) :: sizeof => z_base_smoother_sizeof - procedure, pass(sm) :: get_nzeros => z_base_smoother_get_nzeros - procedure, pass(sm) :: get_wrksz => z_base_smoother_get_wrksize - procedure, nopass :: stringval => mld_stringval - procedure, nopass :: get_fmt => z_base_smoother_get_fmt - procedure, nopass :: get_id => z_base_smoother_get_id - end type mld_z_base_smoother_type - - - private :: z_base_smoother_sizeof, z_base_smoother_get_fmt, & - & z_base_smoother_default, z_base_smoother_get_nzeros, & - & z_base_smoother_get_id, z_base_smoother_get_wrksize - - - - interface - subroutine mld_z_base_smoother_apply(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,info,init,initu) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_base_smoother_type), intent(inout) :: sm - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_z_base_smoother_apply - end interface - - interface - subroutine mld_z_base_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,& - & trans,sweeps,work,wv,info,init,initu) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_base_smoother_type), intent(inout) :: sm - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - end subroutine mld_z_base_smoother_apply_vect - end interface - - interface - subroutine mld_z_base_smoother_check(sm,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_base_smoother_check - end interface - - interface - subroutine mld_z_base_smoother_cseti(sm,what,val,info,idx) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_z_base_smoother_cseti - end interface - - interface - subroutine mld_z_base_smoother_csetc(sm,what,val,info,idx) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_ - class(mld_z_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_z_base_smoother_csetc - end interface - - interface - subroutine mld_z_base_smoother_csetr(sm,what,val,info,idx) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_z_base_smoother_csetr - end interface - - interface - subroutine mld_z_base_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_, psb_i_base_vect_type - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_base_smoother_bld - end interface - - interface - subroutine mld_z_base_smoother_cnv(sm,info,amold,vmold,imold) - import :: psb_z_base_sparse_mat, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_, psb_i_base_vect_type - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_base_smoother_cnv - end interface - - interface - subroutine mld_z_base_smoother_free(sm,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_base_smoother_free - end interface - - interface - subroutine mld_z_base_smoother_descr(sm,info,iout,coarse) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_ - ! Arguments - class(mld_z_base_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - end subroutine mld_z_base_smoother_descr - end interface - - interface - subroutine mld_z_base_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_ - class(mld_z_base_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - end subroutine mld_z_base_smoother_dmp - end interface - - interface - subroutine mld_z_base_smoother_clone(sm,smout,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - class(mld_z_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_base_smoother_clone - end interface - - interface - subroutine mld_z_base_smoother_clone_settings(sm,smout,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - class(mld_z_base_smoother_type), intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_base_smoother_clone_settings - end interface - - interface - subroutine mld_z_base_smoother_clear_data(sm,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_base_smoother_clear_data - end interface - -contains - ! - ! Function returning the size of the mld_prec_type data structure - ! in bytes or in number of nonzeros of the operator(s) involved. - ! - - function z_base_smoother_get_nzeros(sm) result(val) - implicit none - class(mld_z_base_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - if (allocated(sm%sv)) & - & val = sm%sv%get_nzeros() - end function z_base_smoother_get_nzeros - - function z_base_smoother_sizeof(sm) result(val) - implicit none - ! Arguments - class(mld_z_base_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - if (allocated(sm%sv)) then - val = sm%sv%sizeof() - end if - - return - end function z_base_smoother_sizeof - - ! - ! Set sensible defaults. - ! To be called immediately after allocation - ! - subroutine z_base_smoother_default(sm) - implicit none - ! Arguments - class(mld_z_base_smoother_type), intent(inout) :: sm - ! Do nothing for base version - - if (allocated(sm%sv)) call sm%sv%default() - - return - end subroutine z_base_smoother_default - - function z_base_smoother_get_wrksize(sm) result(val) - implicit none - class(mld_z_base_smoother_type), intent(inout) :: sm - integer(psb_ipk_) :: val - - val = 0 - if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() - - end function z_base_smoother_get_wrksize - - function z_base_smoother_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Base smoother" - end function z_base_smoother_get_fmt - - function z_base_smoother_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_base_smooth_ - end function z_base_smoother_get_id - -end module mld_z_base_smoother_mod diff --git a/mlprec/mld_z_base_solver_mod.f90 b/mlprec/mld_z_base_solver_mod.f90 deleted file mode 100644 index 3b3d47de..00000000 --- a/mlprec/mld_z_base_solver_mod.f90 +++ /dev/null @@ -1,421 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_z_base_solver_mod.f90 -! -! Module: mld_z_base_solver_mod -! -! This module defines: -! - the mld_z_base_solver_type data structure containing the -! basic solver type acting on a subdomain -! -! It contains routines for -! - Building and applying; -! - checking if the solver is correctly defined; -! - printing a description of the solver; -! - deallocating the data structure. -! - -module mld_z_base_solver_mod - - use mld_base_prec_type - use psb_base_mod, only : psb_zspmat_type, & - & psb_z_vect_type, psb_z_base_vect_type, psb_z_base_sparse_mat, & - & psb_dpk_, psb_i_base_vect_type, psb_erractionsave, psb_error_handler - ! - ! - ! Type: mld_T_base_solver_type. - ! - ! It holds the local solver; it has no mandatory components. - ! - ! type mld_T_base_solver_type - ! end type mld_T_base_solver_type - ! - ! build - Compute the actual contents of the smoother; includes - ! invocation of the build method on the solver component. - ! free - Release memory - ! apply - Apply the smoother to a vector (or to an array); includes - ! invocation of the apply method on the solver component. - ! descr - Prints a description of the object. - ! default - Set default values - ! dump - Dump to file object contents - ! set - Sets various parameters; when a request is unknown - ! it is passed to the smoother object for further processing. - ! check - Sanity checks. - ! sizeof - Total memory occupation in bytes - ! get_nzeros - Number of nonzeros - ! stringval - convert string to val for internal parms - ! get_fmt - short string descriptor - ! get_id - numeric id descriptro - ! get_wrksz - How many workspace vector does apply_vect need - ! - ! - - type mld_z_base_solver_type - contains - procedure, pass(sv) :: apply_v => mld_z_base_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_z_base_solver_apply - generic, public :: apply => apply_a, apply_v - procedure, pass(sv) :: check => mld_z_base_solver_check - procedure, pass(sv) :: dump => mld_z_base_solver_dmp - procedure, pass(sv) :: clone => mld_z_base_solver_clone - procedure, pass(sv) :: clone_settings => mld_z_base_solver_clone_settings - procedure, pass(sv) :: clear_data => mld_z_base_solver_clear_data - procedure, pass(sv) :: build => mld_z_base_solver_bld - procedure, pass(sv) :: cnv => mld_z_base_solver_cnv - procedure, pass(sv) :: free => mld_z_base_solver_free - procedure, pass(sv) :: cseti => mld_z_base_solver_cseti - procedure, pass(sv) :: csetc => mld_z_base_solver_csetc - procedure, pass(sv) :: csetr => mld_z_base_solver_csetr - generic, public :: set => cseti, csetc, csetr - procedure, pass(sv) :: default => z_base_solver_default - procedure, pass(sv) :: descr => mld_z_base_solver_descr - procedure, pass(sv) :: sizeof => z_base_solver_sizeof - procedure, pass(sv) :: get_nzeros => z_base_solver_get_nzeros - procedure, nopass :: get_wrksz => z_base_solver_get_wrksize - procedure, nopass :: stringval => mld_stringval - procedure, nopass :: get_fmt => z_base_solver_get_fmt - procedure, nopass :: get_id => z_base_solver_get_id - procedure, nopass :: is_iterative => z_base_solver_is_iterative - procedure, pass(sv) :: is_global => z_base_solver_is_global - end type mld_z_base_solver_type - - private :: z_base_solver_sizeof, z_base_solver_default,& - & z_base_solver_get_nzeros, z_base_solver_get_fmt, & - & z_base_solver_is_iterative, z_base_solver_get_id, & - & z_base_solver_get_wrksize, z_base_solver_is_global - - - interface - subroutine mld_z_base_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_base_solver_type), intent(inout) :: sv - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_z_base_solver_apply - end interface - - - interface - subroutine mld_z_base_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_base_solver_type), intent(inout) :: sv - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - end subroutine mld_z_base_solver_apply_vect - end interface - - interface - subroutine mld_z_base_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, psb_ipk_, psb_i_base_vect_type - Implicit None - - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_base_solver_bld - end interface - - interface - subroutine mld_z_base_solver_cnv(sv,info,amold,vmold,imold) - import :: psb_z_base_sparse_mat, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, psb_ipk_, psb_i_base_vect_type - Implicit None - - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_base_solver_cnv - end interface - - interface - subroutine mld_z_base_solver_check(sv,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_base_solver_check - end interface - - interface - subroutine mld_z_base_solver_cseti(sv,what,val,info,idx) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_z_base_solver_cseti - end interface - - interface - subroutine mld_z_base_solver_csetc(sv,what,val,info,idx) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_z_base_solver_csetc - end interface - - interface - subroutine mld_z_base_solver_csetr(sv,what,val,info,idx) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, psb_ipk_ - Implicit None - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_z_base_solver_csetr - end interface - - interface - subroutine mld_z_base_solver_free(sv,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_base_solver_free - end interface - - interface - subroutine mld_z_base_solver_descr(sv,info,iout,coarse) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_base_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - end subroutine mld_z_base_solver_descr - end interface - - interface - subroutine mld_z_base_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, psb_ipk_ - implicit none - class(mld_z_base_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_z_base_solver_dmp - end interface - - interface - subroutine mld_z_base_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_base_solver_clone - end interface - - interface - subroutine mld_z_base_solver_clone_settings(sv,svout,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_base_solver_clone_settings - end interface - - interface - subroutine mld_z_base_solver_clear_data(sv,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_base_solver_clear_data - end interface - -contains - ! - ! Function returning the size of the data structure - ! in bytes or in number of nonzeros of the operator(s) involved. - ! - - function z_base_solver_sizeof(sv) result(val) - implicit none - ! Arguments - class(mld_z_base_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - - return - end function z_base_solver_sizeof - - function z_base_solver_get_nzeros(sv) result(val) - implicit none - class(mld_z_base_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - end function z_base_solver_get_nzeros - - subroutine z_base_solver_default(sv) - implicit none - ! Arguments - class(mld_z_base_solver_type), intent(inout) :: sv - ! Do nothing for base version - - return - end subroutine z_base_solver_default - - function z_base_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Base solver" - end function z_base_solver_get_fmt - - ! - ! If this is true, then the solver needs a starting - ! guess. Currently only handled in JAC smoother. - ! - function z_base_solver_is_iterative() result(val) - implicit none - logical :: val - - val = .false. - end function z_base_solver_is_iterative - ! - ! Is the solver acting globally? In most cases - ! not, SuperLU_Dist does, MUMPS can do either. - ! - function z_base_solver_is_global(sv) result(val) - implicit none - class(mld_z_base_solver_type), intent(in) :: sv - logical :: val - - val = .false. - end function z_base_solver_is_global - - function z_base_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_f_none_ - end function z_base_solver_get_id - - function z_base_solver_get_wrksize() result(val) - implicit none - integer(psb_ipk_) :: val - - val = 0 - end function z_base_solver_get_wrksize - -end module mld_z_base_solver_mod diff --git a/mlprec/mld_z_dec_aggregator_mod.f90 b/mlprec/mld_z_dec_aggregator_mod.f90 deleted file mode 100644 index de0025c3..00000000 --- a/mlprec/mld_z_dec_aggregator_mod.f90 +++ /dev/null @@ -1,201 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! Basic (decoupled) aggregation algorithm. Based on the ideas in -! M. Brezina and P. Vanek, A black-box iterative solver based on a -! two-level Schwarz method, Computing, 63 (1999), 233-263. -! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed -! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 -! (1996), 179-196. -! -module mld_z_dec_aggregator_mod - - use mld_z_base_aggregator_mod - !> \namespace mld_z_dec_aggregator_mod \class mld_z_dec_aggregator_type - !! \extends mld_z_base_aggregator_mod::mld_z_base_aggregator_type - !! - !! type, extends(mld_z_base_aggregator_type) :: mld_z_dec_aggregator_type - !! procedure(mld_z_soc_map_bld), nopass, pointer :: soc_map_bld => null() - !! end type - !! - !! This is the simplest aggregation method: starting from the - !! strength-of-connection measure for defining the aggregation - !! presented in - !! - !! M. Brezina and P. Vanek, A black-box iterative solver based on a - !! two-level Schwarz method, Computing, 63 (1999), 233-263. - !! P. Vanek, J. Mandel and M. Brezina, Algebraic Multigrid by Smoothed - !! Aggregation for Second and Fourth Order Elliptic Problems, Computing, 56 - !! (1996), 179-196. - !! - !! it achieves parallelization by simply acting on the local matrix, - !! i.e. by "decoupling" the subdomains. - !! The data structure hosts a "map_bld" function pointer which allows to - !! choose other ways to measure "strength-of-connection", of which the - !! Vanek-Brezina-Mandel is the default. More details are available in - !! - !! P. D'Ambra, D. di Serafino and S. Filippone, On the development of - !! PSBLAS-based parallel two-level Schwarz preconditioners, Appl. Num. Math. - !! 57 (2007), 1181-1196. - !! - !! The soc_map_bld method is used inside the implementation of build_tprol - !! - ! - ! - type, extends(mld_z_base_aggregator_type) :: mld_z_dec_aggregator_type - procedure(mld_z_soc_map_bld), nopass, pointer :: soc_map_bld => null() - - contains - procedure, pass(ag) :: bld_tprol => mld_z_dec_aggregator_build_tprol - procedure, pass(ag) :: mat_bld => mld_z_dec_aggregator_mat_bld - procedure, pass(ag) :: mat_asb => mld_z_dec_aggregator_mat_asb - procedure, pass(ag) :: default => mld_z_dec_aggregator_default - procedure, pass(ag) :: set_aggr_type => mld_z_dec_aggregator_set_aggr_type - procedure, pass(ag) :: descr => mld_z_dec_aggregator_descr - procedure, nopass :: fmt => mld_z_dec_aggregator_fmt - end type mld_z_dec_aggregator_type - - - procedure(mld_z_soc_map_bld) :: mld_z_soc1_map_bld, mld_z_soc2_map_bld - - interface - subroutine mld_z_dec_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,t_prol,info) - import :: mld_z_dec_aggregator_type, psb_desc_type, psb_zspmat_type, psb_dpk_, & - & psb_ipk_, psb_lpk_, psb_lzspmat_type, mld_dml_parms, mld_daggr_data - implicit none - class(mld_z_dec_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(mld_daggr_data), intent(in) :: ag_data - type(psb_zspmat_type), intent(inout) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lzspmat_type), intent(out) :: t_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_dec_aggregator_build_tprol - end interface - - interface - subroutine mld_z_dec_aggregator_mat_bld(ag,parms,a,desc_a,ilaggr,nlaggr,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - import :: mld_z_dec_aggregator_type, psb_desc_type, psb_zspmat_type, psb_dpk_, & - & psb_ipk_, psb_lpk_, psb_lzspmat_type, mld_dml_parms - implicit none - class(mld_z_dec_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(psb_lzspmat_type), intent(inout) :: t_prol - type(psb_zspmat_type), intent(out) :: op_prol, ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_dec_aggregator_mat_bld - end interface - - interface - subroutine mld_z_dec_aggregator_mat_asb(ag,parms,a,desc_a,& - & ac,desc_ac,op_prol,op_restr,info) - import :: mld_z_dec_aggregator_type, psb_desc_type, psb_zspmat_type, psb_dpk_, & - & psb_ipk_, psb_lpk_, psb_lzspmat_type, mld_dml_parms - implicit none - class(mld_z_dec_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - type(psb_zspmat_type), intent(inout) :: op_prol,ac,op_restr - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_dec_aggregator_mat_asb - end interface - -contains - - subroutine mld_z_dec_aggregator_set_aggr_type(ag,parms,info) - use mld_base_prec_type - implicit none - class(mld_z_dec_aggregator_type), intent(inout) :: ag - type(mld_dml_parms), intent(in) :: parms - integer(psb_ipk_), intent(out) :: info - - select case(parms%aggr_type) - case (mld_noalg_) - ag%soc_map_bld => null() - case (mld_soc1_) - ag%soc_map_bld => mld_z_soc1_map_bld - case (mld_soc2_) - ag%soc_map_bld => mld_z_soc2_map_bld - case default - write(0,*) 'Unknown aggregation type, defaulting to SOC1' - ag%soc_map_bld => mld_z_soc1_map_bld - end select - - return - end subroutine mld_z_dec_aggregator_set_aggr_type - - - subroutine mld_z_dec_aggregator_default(ag) - implicit none - class(mld_z_dec_aggregator_type), intent(inout) :: ag - - call ag%mld_z_base_aggregator_type%default() - ag%soc_map_bld => mld_z_soc1_map_bld - - return - end subroutine mld_z_dec_aggregator_default - - function mld_z_dec_aggregator_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Decoupled aggregation" - end function mld_z_dec_aggregator_fmt - - subroutine mld_z_dec_aggregator_descr(ag,parms,iout,info) - implicit none - class(mld_z_dec_aggregator_type), intent(in) :: ag - type(mld_dml_parms), intent(in) :: parms - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - - write(iout,*) 'Decoupled Aggregator' - write(iout,*) 'Aggregator object type: ',ag%fmt() - call parms%mldescr(iout,info) - - return - end subroutine mld_z_dec_aggregator_descr - -end module mld_z_dec_aggregator_mod diff --git a/mlprec/mld_z_diag_solver.f90 b/mlprec/mld_z_diag_solver.f90 deleted file mode 100644 index 2a62ce11..00000000 --- a/mlprec/mld_z_diag_solver.f90 +++ /dev/null @@ -1,398 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_z_diag_solver_mod.f90 -! -! Module: mld_z_diag_solver_mod -! -! This module defines: -! - the mld_z_diag_solver_type data structure containing the -! simple diagonal solver. This extracts the main diagonal of a matrix -! and precomputes its inverse. Combined with a Jacobi "smoother" generates -! what are commonly known as the classic Jacobi iterations -! -module mld_z_diag_solver - - use mld_z_base_solver_mod - - type, extends(mld_z_base_solver_type) :: mld_z_diag_solver_type - type(psb_z_vect_type), allocatable :: dv - complex(psb_dpk_), allocatable :: d(:) - contains - procedure, pass(sv) :: dump => mld_z_diag_solver_dmp - procedure, pass(sv) :: build => mld_z_diag_solver_bld - procedure, pass(sv) :: cnv => mld_z_diag_solver_cnv - procedure, pass(sv) :: clone => mld_z_diag_solver_clone - procedure, pass(sv) :: clear_data => mld_z_diag_solver_clear_data - procedure, pass(sv) :: apply_v => mld_z_diag_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_z_diag_solver_apply - procedure, pass(sv) :: free => z_diag_solver_free - procedure, pass(sv) :: descr => z_diag_solver_descr - procedure, pass(sv) :: sizeof => z_diag_solver_sizeof - procedure, pass(sv) :: get_nzeros => z_diag_solver_get_nzeros - procedure, nopass :: get_fmt => z_diag_solver_get_fmt - procedure, nopass :: get_id => z_diag_solver_get_id - end type mld_z_diag_solver_type - - - private :: z_diag_solver_free, z_diag_solver_descr, & - & z_diag_solver_sizeof, z_diag_solver_get_nzeros, & - & z_diag_solver_get_fmt, z_diag_solver_get_id - - - interface - subroutine mld_z_diag_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_diag_solver_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_diag_solver_type), intent(inout) :: sv - type(psb_z_vect_type), intent(inout) :: x - type(psb_z_vect_type), intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - end subroutine mld_z_diag_solver_apply_vect - end interface - - interface - subroutine mld_z_diag_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_diag_solver_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_diag_solver_type), intent(inout) :: sv - complex(psb_dpk_), intent(inout) :: x(:) - complex(psb_dpk_), intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_z_diag_solver_apply - end interface - - interface - subroutine mld_z_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_diag_solver_type, psb_ipk_, psb_i_base_vect_type - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_diag_solver_bld - end interface - - interface - subroutine mld_z_diag_solver_cnv(sv,info,amold,vmold,imold) - import :: psb_z_base_sparse_mat, psb_z_base_vect_type, psb_dpk_, & - & mld_z_diag_solver_type, psb_ipk_, psb_i_base_vect_type - class(mld_z_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_diag_solver_cnv - end interface - - interface - subroutine mld_z_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, mld_z_diag_solver_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, & - & psb_ipk_ - implicit none - class(mld_z_diag_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_z_diag_solver_dmp - end interface - - interface - subroutine mld_z_diag_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, mld_z_diag_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_diag_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_diag_solver_clone - end interface - - interface - subroutine mld_z_diag_solver_clear_data(sv,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_diag_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_diag_solver_clear_data - end interface - - -contains - - subroutine z_diag_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_z_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_diag_solver_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sv%dv)) call sv%dv%free(info) - - if (allocated(sv%d)) then - deallocate(sv%d,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine z_diag_solver_free - - subroutine z_diag_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_z_diag_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_z_diag_solver_descr' - integer(psb_ipk_) :: iout_ - - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' Diagonal local solver ' - - return - - end subroutine z_diag_solver_descr - - function z_diag_solver_sizeof(sv) result(val) - implicit none - ! Arguments - class(mld_z_diag_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - if (allocated(sv%dv)) val = val + sv%dv%sizeof() - - return - end function z_diag_solver_sizeof - - function z_diag_solver_get_nzeros(sv) result(val) - implicit none - ! Arguments - class(mld_z_diag_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - if (allocated(sv%dv)) val = val + sv%dv%get_nrows() - - return - end function z_diag_solver_get_nzeros - - function z_diag_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Diag solver" - end function z_diag_solver_get_fmt - - function z_diag_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_diag_scale_ - end function z_diag_solver_get_id - -end module mld_z_diag_solver - -! -! Module: mld_z_l1_diag_solver_mod -! -! This module defines: -! - the mld_z_l1_diag_solver_type data structure containing the -! L1 diagonal solver. -! The solver is defined as a diagonal containing in each element the -! inverse of the sum of the absolute values of the matrix entries -! along the corresponding row. -! Combined with a Jacobi "smoother" generates -! what are commonly known as the L1-Jacobi iterations -! - -module mld_z_l1_diag_solver - - use mld_z_diag_solver - - type, extends(mld_z_diag_solver_type) :: mld_z_l1_diag_solver_type - contains - procedure, pass(sv) :: dump => mld_z_l1_diag_solver_dmp - procedure, pass(sv) :: build => mld_z_l1_diag_solver_bld - procedure, pass(sv) :: descr => z_l1_diag_solver_descr - procedure, nopass :: get_fmt => z_l1_diag_solver_get_fmt - procedure, nopass :: get_id => z_l1_diag_solver_get_id - end type mld_z_l1_diag_solver_type - - - private :: z_l1_diag_solver_descr, & - & z_l1_diag_solver_get_fmt, z_l1_diag_solver_get_id - - interface - subroutine mld_z_l1_diag_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_l1_diag_solver_type, psb_ipk_, psb_i_base_vect_type - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_l1_diag_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_l1_diag_solver_bld - end interface - - interface - subroutine mld_z_l1_diag_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, mld_z_l1_diag_solver_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, & - & psb_ipk_ - implicit none - class(mld_z_l1_diag_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_z_l1_diag_solver_dmp - end interface - -contains - - subroutine z_l1_diag_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_z_l1_diag_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_z_l1_diag_solver_descr' - integer(psb_ipk_) :: iout_ - - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' L1 Diagonal solver ' - - return - - end subroutine z_l1_diag_solver_descr - - function z_l1_diag_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "L1 Diag solver" - end function z_l1_diag_solver_get_fmt - - function z_l1_diag_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_l1_diag_scale_ - end function z_l1_diag_solver_get_id - -end module mld_z_l1_diag_solver - diff --git a/mlprec/mld_z_gs_solver.f90 b/mlprec/mld_z_gs_solver.f90 deleted file mode 100644 index 710867e7..00000000 --- a/mlprec/mld_z_gs_solver.f90 +++ /dev/null @@ -1,588 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! File: mld_z_gs_solver_mod.f90 -! -! Module: mld_z_gs_solver_mod -! -! This module defines: -! - the mld_z_gs_solver_type data structure containing the ingredients -! for a local Gauss-Seidel iteration. We provide Forward GS (FWGS) and -! backward GS (BWGS). The iterations are local to a process (they operate -! on the block diagonal). Combined with a Jacobi smoother will generate a -! hybrid-Gauss-Seidel solver, i.e. Gauss-Seidel within each process, Jacobi -! among the processes. -! With two objects as pre- and post-smoothers it is possible to build a -! Forward-Backward smoother, suitable for symmetric iterations. -! -module mld_z_gs_solver - - use mld_z_base_solver_mod - - type, extends(mld_z_base_solver_type) :: mld_z_gs_solver_type - type(psb_zspmat_type) :: l, u - integer(psb_ipk_) :: sweeps - real(psb_dpk_) :: eps - contains - procedure, pass(sv) :: dump => mld_z_gs_solver_dmp - procedure, pass(sv) :: check => z_gs_solver_check - procedure, pass(sv) :: clone => mld_z_gs_solver_clone - procedure, pass(sv) :: clone_settings => mld_z_gs_solver_clone_settings - procedure, pass(sv) :: clear_data => mld_z_gs_solver_clear_data - procedure, pass(sv) :: build => mld_z_gs_solver_bld - procedure, pass(sv) :: cnv => mld_z_gs_solver_cnv - procedure, pass(sv) :: apply_v => mld_z_gs_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_z_gs_solver_apply - procedure, pass(sv) :: free => z_gs_solver_free - procedure, pass(sv) :: cseti => z_gs_solver_cseti - procedure, pass(sv) :: csetc => z_gs_solver_csetc - procedure, pass(sv) :: csetr => z_gs_solver_csetr - procedure, pass(sv) :: descr => z_gs_solver_descr - procedure, pass(sv) :: default => z_gs_solver_default - procedure, pass(sv) :: sizeof => z_gs_solver_sizeof - procedure, pass(sv) :: get_nzeros => z_gs_solver_get_nzeros - procedure, nopass :: get_wrksz => z_gs_solver_get_wrksize - procedure, nopass :: get_fmt => z_gs_solver_get_fmt - procedure, nopass :: get_id => z_gs_solver_get_id - procedure, nopass :: is_iterative => z_gs_solver_is_iterative - end type mld_z_gs_solver_type - - type, extends(mld_z_gs_solver_type) :: mld_z_bwgs_solver_type - contains - procedure, pass(sv) :: build => mld_z_bwgs_solver_bld - procedure, pass(sv) :: apply_v => mld_z_bwgs_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_z_bwgs_solver_apply - procedure, nopass :: get_fmt => z_bwgs_solver_get_fmt - procedure, nopass :: get_id => z_bwgs_solver_get_id - procedure, pass(sv) :: descr => z_bwgs_solver_descr - end type mld_z_bwgs_solver_type - - - private :: z_gs_solver_bld, z_gs_solver_apply, & - & z_gs_solver_free, & - & z_gs_solver_descr, z_gs_solver_sizeof, & - & z_gs_solver_default, z_gs_solver_dmp, & - & z_gs_solver_apply_vect, z_gs_solver_get_nzeros, & - & z_gs_solver_get_fmt, z_gs_solver_check,& - & z_gs_solver_is_iterative, & - & z_bwgs_solver_get_fmt, z_bwgs_solver_descr, & - & z_gs_solver_get_id, z_bwgs_solver_get_id, z_gs_solver_get_wrksize - - interface - subroutine mld_z_gs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, mld_z_gs_solver_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_gs_solver_type), intent(inout) :: sv - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - end subroutine mld_z_gs_solver_apply_vect - subroutine mld_z_bwgs_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, mld_z_bwgs_solver_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_bwgs_solver_type), intent(inout) :: sv - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - end subroutine mld_z_bwgs_solver_apply_vect - end interface - - interface - subroutine mld_z_gs_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info,init,initu) - import :: psb_desc_type, mld_z_gs_solver_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_gs_solver_type), intent(inout) :: sv - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_z_gs_solver_apply - subroutine mld_z_bwgs_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, mld_z_bwgs_solver_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_bwgs_solver_type), intent(inout) :: sv - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_z_bwgs_solver_apply - end interface - - interface - subroutine mld_z_gs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, mld_z_gs_solver_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_gs_solver_bld - subroutine mld_z_bwgs_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, mld_z_bwgs_solver_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_bwgs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_bwgs_solver_bld - end interface - - interface - subroutine mld_z_gs_solver_cnv(sv,info,amold,vmold,imold) - import :: mld_z_gs_solver_type, psb_dpk_, & - & psb_z_base_sparse_mat, psb_z_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - class(mld_z_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_gs_solver_cnv - end interface - - interface - subroutine mld_z_gs_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, mld_z_gs_solver_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, & - & psb_ipk_ - implicit none - class(mld_z_gs_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_z_gs_solver_dmp - end interface - - interface - subroutine mld_z_gs_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, mld_z_gs_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_gs_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_gs_solver_clone - end interface - - interface - subroutine mld_z_gs_solver_clone_settings(sv,svout,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, mld_z_gs_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_gs_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_gs_solver_clone_settings - end interface - - interface - subroutine mld_z_gs_solver_clear_data(sv,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_gs_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_gs_solver_clear_data - end interface - -contains - - subroutine z_gs_solver_default(sv) - - Implicit None - - ! Arguments - class(mld_z_gs_solver_type), intent(inout) :: sv - - sv%sweeps = ione - sv%eps = dzero - - return - end subroutine z_gs_solver_default - - subroutine z_gs_solver_check(sv,info) - - Implicit None - - ! Arguments - class(mld_z_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_gs_solver_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - call mld_check_def(sv%sweeps,& - & 'GS Sweeps',ione,is_int_positive) - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine z_gs_solver_check - - subroutine z_gs_solver_cseti(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_z_gs_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_gs_solver_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) - case('SOLVER_SWEEPS') - sv%sweeps = val - case default - call sv%mld_z_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_gs_solver_cseti - - subroutine z_gs_solver_csetc(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_z_gs_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='z_gs_solver_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - - - call sv%mld_z_base_solver_type%set(what,val,info,idx=idx) - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info, name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_gs_solver_csetc - - subroutine z_gs_solver_csetr(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_z_gs_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_gs_solver_csetr' - - call psb_erractionsave(err_act) - info = psb_success_ - - select case(psb_toupper(what)) - case('SOLVER_EPS') - sv%eps = val - case default - call sv%mld_z_base_solver_type%set(what,val,info,idx=idx) - end select - - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_gs_solver_csetr - - subroutine z_gs_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_z_gs_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_gs_solver_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - call sv%l%free() - call sv%u%free() - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_gs_solver_free - - subroutine z_gs_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_z_gs_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_z_gs_solver_descr' - integer(psb_ipk_) :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (sv%eps<=dzero) then - write(iout_,*) ' Forward Gauss-Seidel iterative solver with ',& - & sv%sweeps,' sweeps' - else - write(iout_,*) ' Forward Gauss-Seidel iterative solver with tolerance',& - & sv%eps,' and maxit', sv%sweeps - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_gs_solver_descr - - function z_gs_solver_get_nzeros(sv) result(val) - - implicit none - ! Arguments - class(mld_z_gs_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - val = val + sv%l%get_nzeros() - val = val + sv%u%get_nzeros() - - return - end function z_gs_solver_get_nzeros - - function z_gs_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_z_gs_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = psb_sizeof_ip - val = val + sv%l%sizeof() - val = val + sv%u%sizeof() - - return - end function z_gs_solver_sizeof - - function z_gs_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Forward Gauss-Seidel solver" - end function z_gs_solver_get_fmt - - function z_gs_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_gs_ - end function z_gs_solver_get_id - - ! - ! If this is true, then the solver needs a starting - ! guess. Currently only handled in JAC smoother. - ! - function z_gs_solver_is_iterative() result(val) - implicit none - logical :: val - - val = .true. - end function z_gs_solver_is_iterative - - subroutine z_bwgs_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_z_bwgs_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_z_bwgs_solver_descr' - integer(psb_ipk_) :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - if (sv%eps<=dzero) then - write(iout_,*) ' Backward Gauss-Seidel iterative solver with ',& - & sv%sweeps,' sweeps' - else - write(iout_,*) ' Backward Gauss-Seidel iterative solver with tolerance',& - & sv%eps,' and maxit', sv%sweeps - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_bwgs_solver_descr - - function z_bwgs_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Backward Gauss-Seidel solver" - end function z_bwgs_solver_get_fmt - - function z_bwgs_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_bwgs_ - end function z_bwgs_solver_get_id - - function z_gs_solver_get_wrksize() result(val) - implicit none - integer(psb_ipk_) :: val - - val = 2 - end function z_gs_solver_get_wrksize - -end module mld_z_gs_solver diff --git a/mlprec/mld_z_hybrid_aggregator_mod.F90 b/mlprec/mld_z_hybrid_aggregator_mod.F90 deleted file mode 100644 index 75ff9719..00000000 --- a/mlprec/mld_z_hybrid_aggregator_mod.F90 +++ /dev/null @@ -1,125 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! The aggregator object hosts the aggregation method for building -! the multilevel hierarchy. This variant is based on the hybrid method -! presented in -! -! S. Gratton, P. Henon, P. Jiranek and X. Vasseur: -! Reducing complexity of algebraic multigrid by aggregation -! Numerical Lin. Algebra with Applications, 2016, 23:501-518 -! -module mld_z_hybrid_aggregator_mod - - use mld_z_dec_aggregator_mod - ! - ! sm - class(mld_T_base_smoother_type), allocatable - ! The current level preconditioner (aka smoother). - ! parms - type(mld_RTml_parms) - ! The parameters defining the multilevel strategy. - ! ac - The local part of the current-level matrix, built by - ! coarsening the previous-level matrix. - ! desc_ac - type(psb_desc_type). - ! The communication descriptor associated to the matrix - ! stored in ac. - ! base_a - type(psb_Tspmat_type), pointer. - ! Pointer (really a pointer!) to the local part of the current - ! matrix (so we have a unified treatment of residuals). - ! We need this to avoid passing explicitly the current matrix - ! to the routine which applies the preconditioner. - ! base_desc - type(psb_desc_type), pointer. - ! Pointer to the communication descriptor associated to the - ! matrix pointed by base_a. - ! map - Stores the maps (restriction and prolongation) between the - ! vector spaces associated to the index spaces of the previous - ! and current levels. - ! - ! Methods: - ! Most methods follow the encapsulation hierarchy: they take whatever action - ! is appropriate for the current object, then call the corresponding method for - ! the contained object. - ! As an example: the descr() method prints out a description of the - ! level. It starts by invoking the descr() method of the parms object, - ! then calls the descr() method of the smoother object. - ! - ! descr - Prints a description of the object. - ! default - Set default values - ! dump - Dump to file object contents - ! set - Sets various parameters; when a request is unknown - ! it is passed to the smoother object for further processing. - ! check - Sanity checks. - ! sizeof - Total memory occupation in bytes - ! get_nzeros - Number of nonzeros - ! - ! - type, extends(mld_z_dec_aggregator_type) :: mld_z_hybrid_aggregator_type - - contains - procedure, pass(ag) :: bld_tprol => mld_z_hybrid_aggregator_build_tprol - procedure, nopass :: fmt => mld_z_hybrid_aggregator_fmt - end type mld_z_hybrid_aggregator_type - - - interface - subroutine mld_z_hybrid_aggregator_build_tprol(ag,parms,a,desc_a,ilaggr,nlaggr,op_prol,info) - import :: mld_z_hybrid_aggregator_type, psb_desc_type, psb_zspmat_type, psb_dpk_, & - & psb_ipk_, psb_long_int_k_, mld_dml_parms - implicit none - class(mld_z_hybrid_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(in) :: desc_a - integer(psb_ipk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_zspmat_type), intent(out) :: op_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_hybrid_aggregator_build_tprol - end interface - -contains - - - function mld_z_hybrid_aggregator_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Hybrid Decoupled aggregation" - end function mld_z_hybrid_aggregator_fmt - - -end module mld_z_hybrid_aggregator_mod diff --git a/mlprec/mld_z_id_solver.f90 b/mlprec/mld_z_id_solver.f90 deleted file mode 100644 index 3b85a4df..00000000 --- a/mlprec/mld_z_id_solver.f90 +++ /dev/null @@ -1,202 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! -! Identity solver. Reference for nullprec. -! -! -module mld_z_id_solver - - use mld_z_base_solver_mod - - type, extends(mld_z_base_solver_type) :: mld_z_id_solver_type - contains - procedure, pass(sv) :: build => z_id_solver_bld - procedure, pass(sv) :: clone => mld_z_id_solver_clone - procedure, pass(sv) :: apply_v => mld_z_id_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_z_id_solver_apply - procedure, pass(sv) :: free => z_id_solver_free - procedure, pass(sv) :: descr => z_id_solver_descr - procedure, nopass :: get_fmt => z_id_solver_get_fmt - procedure, nopass :: get_id => z_id_solver_get_id - end type mld_z_id_solver_type - - - private :: z_id_solver_bld, & - & z_id_solver_free, z_id_solver_get_fmt, & - & z_id_solver_descr, z_id_solver_get_id - - interface - subroutine mld_z_id_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_id_solver_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_id_solver_type), intent(inout) :: sv - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - end subroutine mld_z_id_solver_apply_vect - end interface - - interface - subroutine mld_z_id_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_id_solver_type, psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_id_solver_type), intent(inout) :: sv - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_z_id_solver_apply - end interface - - interface - subroutine mld_z_id_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, mld_z_id_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_id_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_id_solver_clone - end interface - -contains - - - subroutine z_id_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - Implicit None - - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_id_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - integer(psb_ipk_) :: n_row,n_col, nrow_a, nztota - complex(psb_dpk_), pointer :: ww(:), aux(:), tx(:),ty(:) - integer(psb_ipk_) :: i, err_act, debug_unit, debug_level - character(len=20) :: name='z_id_solver_bld', ch_err - - info=psb_success_ - - return - end subroutine z_id_solver_bld - - subroutine z_id_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_z_id_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_id_solver_free' - - info = psb_success_ - - return - end subroutine z_id_solver_free - - subroutine z_id_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_z_id_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_z_id_solver_descr' - integer(psb_ipk_) :: iout_ - - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' Identity local solver ' - - return - - end subroutine z_id_solver_descr - - function z_id_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Identity solver" - end function z_id_solver_get_fmt - - function z_id_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_f_none_ - end function z_id_solver_get_id - -end module mld_z_id_solver diff --git a/mlprec/mld_z_ilu_fact_mod.f90 b/mlprec/mld_z_ilu_fact_mod.f90 deleted file mode 100644 index 45e63e17..00000000 --- a/mlprec/mld_z_ilu_fact_mod.f90 +++ /dev/null @@ -1,91 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! File: mld_z_ilu_fact_mod.f90 -! -! Module: mld_z_ilu_fact_mod -! -! This module defines some interfaces used internally by the implementation of -! mld_z_ilu_solver, but not visible to the end user. -! -! -module mld_z_ilu_fact_mod - - use mld_z_base_solver_mod - - interface mld_ilu0_fact - subroutine mld_zilu0_fact(ialg,a,l,u,d,info,blck,upd) - import psb_zspmat_type, psb_dpk_, psb_ipk_ - integer(psb_ipk_), intent(in) :: ialg - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type),intent(in) :: a - type(psb_zspmat_type),intent(inout) :: l,u - type(psb_zspmat_type),intent(in), optional, target :: blck - character, intent(in), optional :: upd - complex(psb_dpk_), intent(inout) :: d(:) - end subroutine mld_zilu0_fact - end interface - - interface mld_iluk_fact - subroutine mld_ziluk_fact(fill_in,ialg,a,l,u,d,info,blck) - import psb_zspmat_type, psb_dpk_, psb_ipk_ - integer(psb_ipk_), intent(in) :: fill_in,ialg - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type),intent(in) :: a - type(psb_zspmat_type),intent(inout) :: l,u - type(psb_zspmat_type),intent(in), optional, target :: blck - complex(psb_dpk_), intent(inout) :: d(:) - end subroutine mld_ziluk_fact - end interface - - interface mld_ilut_fact - subroutine mld_zilut_fact(fill_in,thres,a,l,u,d,info,blck,iscale) - import psb_zspmat_type, psb_dpk_, psb_ipk_ - integer(psb_ipk_), intent(in) :: fill_in - real(psb_dpk_), intent(in) :: thres - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type),intent(in) :: a - type(psb_zspmat_type),intent(inout) :: l,u - complex(psb_dpk_), intent(inout) :: d(:) - type(psb_zspmat_type),intent(in), optional, target :: blck - integer(psb_ipk_), intent(in), optional :: iscale - end subroutine mld_zilut_fact - end interface - -end module mld_z_ilu_fact_mod diff --git a/mlprec/mld_z_ilu_solver.f90 b/mlprec/mld_z_ilu_solver.f90 deleted file mode 100644 index 18d13b06..00000000 --- a/mlprec/mld_z_ilu_solver.f90 +++ /dev/null @@ -1,502 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! File: mld_z_ilu_solver_mod.f90 -! -! Module: mld_z_ilu_solver_mod -! -! This module defines: -! - the mld_z_ilu_solver_type data structure containing the ingredients -! for a local Incomplete LU factorization. -! 1. The factorization is always restricted to the diagonal block of the -! current image (coherently with the definition of a SOLVER as a local -! object) -! 2. The code provides support for both pattern-based ILU(K) and -! threshold base ILU(T,L) -! 3. The diagonal is stored separately, so strictly speaking this is -! an incomplete LDU factorization; -! 4. The application phase is shared among all variants; -! -! -module mld_z_ilu_solver - - use mld_base_prec_type, only : mld_fact_names - use mld_z_base_solver_mod - use psb_z_ilu_fact_mod - - type, extends(mld_z_base_solver_type) :: mld_z_ilu_solver_type - type(psb_zspmat_type) :: l, u - complex(psb_dpk_), allocatable :: d(:) - type(psb_z_vect_type) :: dv - integer(psb_ipk_) :: fact_type, fill_in - real(psb_dpk_) :: thresh - contains - procedure, pass(sv) :: dump => mld_z_ilu_solver_dmp - procedure, pass(sv) :: check => z_ilu_solver_check - procedure, pass(sv) :: clone => mld_z_ilu_solver_clone - procedure, pass(sv) :: clone_settings => mld_z_ilu_solver_clone_settings - procedure, pass(sv) :: clear_data => mld_z_ilu_solver_clear_data - procedure, pass(sv) :: build => mld_z_ilu_solver_bld - procedure, pass(sv) :: cnv => mld_z_ilu_solver_cnv - procedure, pass(sv) :: apply_v => mld_z_ilu_solver_apply_vect - procedure, pass(sv) :: apply_a => mld_z_ilu_solver_apply - procedure, pass(sv) :: free => z_ilu_solver_free - procedure, pass(sv) :: cseti => z_ilu_solver_cseti - procedure, pass(sv) :: csetc => z_ilu_solver_csetc - procedure, pass(sv) :: csetr => z_ilu_solver_csetr - procedure, pass(sv) :: descr => z_ilu_solver_descr - procedure, pass(sv) :: default => z_ilu_solver_default - procedure, pass(sv) :: sizeof => z_ilu_solver_sizeof - procedure, pass(sv) :: get_nzeros => z_ilu_solver_get_nzeros - procedure, nopass :: get_wrksz => z_ilu_solver_get_wrksize - procedure, nopass :: get_fmt => z_ilu_solver_get_fmt - procedure, nopass :: get_id => z_ilu_solver_get_id - end type mld_z_ilu_solver_type - - - private :: z_ilu_solver_bld, z_ilu_solver_apply, & - & z_ilu_solver_free, & - & z_ilu_solver_descr, z_ilu_solver_sizeof, & - & z_ilu_solver_default, z_ilu_solver_dmp, & - & z_ilu_solver_apply_vect, z_ilu_solver_get_nzeros, & - & z_ilu_solver_get_fmt, z_ilu_solver_check, & - & z_ilu_solver_get_id, z_ilu_solver_get_wrksize - - - interface - subroutine mld_z_ilu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, mld_z_ilu_solver_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_ilu_solver_type), intent(inout) :: sv - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - end subroutine mld_z_ilu_solver_apply_vect - end interface - - interface - subroutine mld_z_ilu_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - import :: psb_desc_type, mld_z_ilu_solver_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_ilu_solver_type), intent(inout) :: sv - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_z_ilu_solver_apply - end interface - - interface - subroutine mld_z_ilu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - import :: psb_desc_type, mld_z_ilu_solver_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_ilu_solver_bld - end interface - - interface - subroutine mld_z_ilu_solver_cnv(sv,info,amold,vmold,imold) - import :: mld_z_ilu_solver_type, psb_dpk_, & - & psb_z_base_sparse_mat, psb_z_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - implicit none - class(mld_z_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_ilu_solver_cnv - end interface - - interface - subroutine mld_z_ilu_solver_dmp(sv,desc,level,info,prefix,head,solver,global_num) - import :: psb_desc_type, mld_z_ilu_solver_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, & - & psb_ipk_ - implicit none - class(mld_z_ilu_solver_type), intent(in) :: sv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: solver, global_num - end subroutine mld_z_ilu_solver_dmp - end interface - - interface - subroutine mld_z_ilu_solver_clone(sv,svout,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, mld_z_ilu_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_ilu_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), allocatable, intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_ilu_solver_clone - end interface - - interface - subroutine mld_z_ilu_solver_clone_settings(sv,svout,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_base_solver_type, mld_z_ilu_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_ilu_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_ilu_solver_clone_settings - end interface - - interface - subroutine mld_z_ilu_solver_clear_data(sv,info) - import :: psb_desc_type, psb_zspmat_type, psb_z_base_sparse_mat, & - & psb_z_vect_type, psb_z_base_vect_type, psb_dpk_, & - & mld_z_ilu_solver_type, psb_ipk_ - Implicit None - - ! Arguments - class(mld_z_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_ilu_solver_clear_data - end interface - -contains - - subroutine z_ilu_solver_default(sv) - - Implicit None - - ! Arguments - class(mld_z_ilu_solver_type), intent(inout) :: sv - - sv%fact_type = psb_ilu_n_ - sv%fill_in = 0 - sv%thresh = dzero - - return - end subroutine z_ilu_solver_default - - subroutine z_ilu_solver_check(sv,info) - - Implicit None - - ! Arguments - class(mld_z_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_ilu_solver_check' - - call psb_erractionsave(err_act) - info = psb_success_ - - call mld_check_def(sv%fact_type,& - & 'Factorization',psb_ilu_n_,is_legal_ilu_fact) - - select case(sv%fact_type) - case(psb_ilu_n_,psb_milu_n_) - call mld_check_def(sv%fill_in,& - & 'Level',izero,is_int_non_negative) - case(psb_ilu_t_) - call mld_check_def(sv%thresh,& - & 'Eps',dzero,is_legal_d_fact_thrs) - end select - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine z_ilu_solver_check - - subroutine z_ilu_solver_cseti(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_z_ilu_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_ilu_solver_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(trim((what)))) - case('SUB_SOLVE') - sv%fact_type = val - case('SUB_FILLIN') - sv%fill_in = val - case default - call sv%mld_z_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_ilu_solver_cseti - - subroutine z_ilu_solver_csetc(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_z_ilu_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act, ival - character(len=20) :: name='z_ilu_solver_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - ival = mld_stringval(val) - select case(psb_toupper(trim((what)))) - case('SUB_SOLVE') - sv%fact_type = ival - case default - call sv%mld_z_base_solver_type%set(what,val,info,idx=idx) - end select - - if (info /= psb_success_) then - info = psb_err_from_subroutine_ - call psb_errpush(info, name) - goto 9999 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_ilu_solver_csetc - - subroutine z_ilu_solver_csetr(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_z_ilu_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_ilu_solver_csetr' - - call psb_erractionsave(err_act) - info = psb_success_ - - select case(psb_toupper(what)) - case('SUB_ILUTHRS') - sv%thresh = val - case default - call sv%mld_z_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_ilu_solver_csetr - - subroutine z_ilu_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_z_ilu_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_ilu_solver_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - if (allocated(sv%d)) then - deallocate(sv%d,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - end if - call sv%l%free() - call sv%u%free() - call sv%dv%free(info) - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_ilu_solver_free - - subroutine z_ilu_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_z_ilu_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - character(len=20), parameter :: name='mld_z_ilu_solver_descr' - integer(psb_ipk_) :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' Incomplete factorization solver: ',& - & mld_fact_names(sv%fact_type) - select case(sv%fact_type) - case(psb_ilu_n_,psb_milu_n_) - write(iout_,*) ' Fill level:',sv%fill_in - case(psb_ilu_t_) - write(iout_,*) ' Fill level:',sv%fill_in - write(iout_,*) ' Fill threshold :',sv%thresh - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_ilu_solver_descr - - function z_ilu_solver_get_nzeros(sv) result(val) - - implicit none - ! Arguments - class(mld_z_ilu_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - val = val + sv%dv%get_nrows() - val = val + sv%l%get_nzeros() - val = val + sv%u%get_nzeros() - - return - end function z_ilu_solver_get_nzeros - - function z_ilu_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_z_ilu_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 2*psb_sizeof_ip + (2*psb_sizeof_dp) - val = val + sv%dv%sizeof() - val = val + sv%l%sizeof() - val = val + sv%u%sizeof() - - return - end function z_ilu_solver_sizeof - - function z_ilu_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "ILU solver" - end function z_ilu_solver_get_fmt - - function z_ilu_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = psb_ilu_n_ - end function z_ilu_solver_get_id - - function z_ilu_solver_get_wrksize() result(val) - implicit none - integer(psb_ipk_) :: val - - val = 2 - end function z_ilu_solver_get_wrksize - -end module mld_z_ilu_solver diff --git a/mlprec/mld_z_inner_mod.f90 b/mlprec/mld_z_inner_mod.f90 deleted file mode 100644 index d59854b8..00000000 --- a/mlprec/mld_z_inner_mod.f90 +++ /dev/null @@ -1,131 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_inner_mod.f90 -! -! Module: mld_inner_mod -! -! This module defines the interfaces to inner MLD2P4 routines. -! The interfaces of the user level routines are defined in mld_prec_mod.f90. -! -module mld_z_inner_mod - - use psb_base_mod, only : psb_zspmat_type, psb_desc_type, psb_i_base_vect_type, & - & psb_dpk_, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_, & - & psb_z_vect_type, psb_lpk_, psb_lzspmat_type - use mld_z_prec_type, only : mld_zprec_type, mld_dml_parms, & - & mld_z_onelev_type, mld_zmlprec_wrk_type - - interface mld_mlprec_bld - subroutine mld_zmlprec_bld(a,desc_a,prec,info, amold, vmold,imold) - import :: psb_zspmat_type, psb_desc_type, psb_i_base_vect_type, & - & psb_dpk_, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ - import :: mld_zprec_type - implicit none - type(psb_zspmat_type), intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - type(mld_zprec_type), intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_zmlprec_bld - end interface mld_mlprec_bld - - interface mld_mlprec_aply - subroutine mld_zmlprec_aply(alpha,p,x,beta,y,desc_data,trans,work,info) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, psb_ipk_ - import :: mld_zprec_type - implicit none - type(psb_desc_type),intent(in) :: desc_data - type(mld_zprec_type), intent(inout) :: p - complex(psb_dpk_),intent(in) :: alpha,beta - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - character,intent(in) :: trans - complex(psb_dpk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - end subroutine mld_zmlprec_aply - subroutine mld_zmlprec_aply_vect(alpha,p,x,beta,y,desc_data,trans,work,info) - import :: psb_zspmat_type, psb_desc_type, & - & psb_dpk_, psb_z_vect_type, psb_ipk_ - import :: mld_zprec_type - implicit none - type(psb_desc_type),intent(in) :: desc_data - type(mld_zprec_type), intent(inout) :: p - complex(psb_dpk_),intent(in) :: alpha,beta - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - character,intent(in) :: trans - complex(psb_dpk_),target :: work(:) - integer(psb_ipk_), intent(out) :: info - end subroutine mld_zmlprec_aply_vect - end interface mld_mlprec_aply - - interface mld_map_to_tprol - subroutine mld_z_map_to_tprol(desc_a,ilaggr,nlaggr,op_prol,info) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, psb_ipk_, psb_lpk_, psb_lzspmat_type - import :: mld_z_onelev_type - implicit none - type(psb_desc_type), intent(in) :: desc_a - integer(psb_lpk_), allocatable, intent(inout) :: ilaggr(:),nlaggr(:) - type(psb_lzspmat_type), intent(out) :: op_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_map_to_tprol - end interface mld_map_to_tprol - - abstract interface - subroutine mld_zaggrmat_var_bld(a,desc_a,ilaggr,nlaggr,parms,& - & ac,desc_ac,op_prol,op_restr,t_prol,info) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, psb_ipk_, psb_lpk_, psb_lzspmat_type - import :: mld_z_onelev_type, mld_dml_parms - implicit none - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:), nlaggr(:) - type(mld_dml_parms), intent(inout) :: parms - type(psb_zspmat_type), intent(inout) :: op_prol,ac,op_restr - type(psb_lzspmat_type), intent(inout) :: t_prol - type(psb_desc_type), intent(inout) :: desc_ac - integer(psb_ipk_), intent(out) :: info - end subroutine mld_zaggrmat_var_bld - end interface - - procedure(mld_zaggrmat_var_bld) :: mld_zaggrmat_nosmth_bld, & - & mld_zaggrmat_smth_bld, mld_zaggrmat_minnrg_bld - -end module mld_z_inner_mod diff --git a/mlprec/mld_z_jac_smoother.f90 b/mlprec/mld_z_jac_smoother.f90 deleted file mode 100644 index 628636b7..00000000 --- a/mlprec/mld_z_jac_smoother.f90 +++ /dev/null @@ -1,454 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_z_jac_smoother_mod.f90 -! -! Module: mld_z_jac_smoother_mod -! -! This module defines: -! the mld_z_jac_smoother_type data structure containing the -! smoother for a Jacobi/block Jacobi smoother. -! The smoother stores in ND the block off-diagonal matrix. -! One special case is treated separately, when the solver is DIAG or L1-DIAG -! then the ND is the entire off-diagonal part of the matrix (including the -! main diagonal block), so that it becomes possible to implement -! a pure Jacobi or L1-Jacobi global solver. -! -module mld_z_jac_smoother - - use mld_z_base_smoother_mod - - type, extends(mld_z_base_smoother_type) :: mld_z_jac_smoother_type - ! The local solver component is inherited from the - ! parent type. - ! class(mld_z_base_solver_type), allocatable :: sv - ! - type(psb_zspmat_type), pointer :: pa => null() - type(psb_zspmat_type) :: nd - integer(psb_lpk_) :: nd_nnz_tot - logical :: checkres - logical :: printres - integer(psb_ipk_) :: checkiter - integer(psb_ipk_) :: printiter - real(psb_dpk_) :: tol - contains - procedure, pass(sm) :: apply_v => mld_z_jac_smoother_apply_vect - procedure, pass(sm) :: apply_a => mld_z_jac_smoother_apply - procedure, pass(sm) :: dump => mld_z_jac_smoother_dmp - procedure, pass(sm) :: build => mld_z_jac_smoother_bld - procedure, pass(sm) :: cnv => mld_z_jac_smoother_cnv - procedure, pass(sm) :: clone => mld_z_jac_smoother_clone - procedure, pass(sm) :: clone_settings => mld_z_jac_smoother_clone_settings - procedure, pass(sm) :: clear_data => mld_z_jac_smoother_clear_data - procedure, pass(sm) :: free => z_jac_smoother_free - procedure, pass(sm) :: cseti => mld_z_jac_smoother_cseti - procedure, pass(sm) :: csetc => mld_z_jac_smoother_csetc - procedure, pass(sm) :: csetr => mld_z_jac_smoother_csetr - procedure, pass(sm) :: descr => mld_z_jac_smoother_descr - procedure, pass(sm) :: sizeof => z_jac_smoother_sizeof - procedure, pass(sm) :: default => z_jac_smoother_default - procedure, pass(sm) :: get_nzeros => z_jac_smoother_get_nzeros - procedure, pass(sm) :: get_wrksz => z_jac_smoother_get_wrksize - procedure, nopass :: get_fmt => z_jac_smoother_get_fmt - procedure, nopass :: get_id => z_jac_smoother_get_id - end type mld_z_jac_smoother_type - - type, extends(mld_z_jac_smoother_type) :: mld_z_l1_jac_smoother_type - contains - procedure, pass(sm) :: build => mld_z_l1_jac_smoother_bld - procedure, pass(sm) :: clone => mld_z_l1_jac_smoother_clone - procedure, pass(sm) :: descr => mld_z_l1_jac_smoother_descr - procedure, nopass :: get_fmt => z_l1_jac_smoother_get_fmt - procedure, nopass :: get_id => z_l1_jac_smoother_get_id - end type mld_z_l1_jac_smoother_type - - private :: z_jac_smoother_free, & - & z_jac_smoother_sizeof, z_jac_smoother_get_nzeros, & - & z_jac_smoother_get_fmt, z_jac_smoother_get_id, & - & z_jac_smoother_get_wrksize - private :: z_l1_jac_smoother_get_fmt, z_l1_jac_smoother_get_id - - - interface - subroutine mld_z_jac_smoother_apply_vect(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,wv,info,init,initu) - import :: psb_desc_type, mld_z_jac_smoother_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type,& - & psb_ipk_ - - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_jac_smoother_type), intent(inout) :: sm - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - end subroutine mld_z_jac_smoother_apply_vect - end interface - - interface - subroutine mld_z_jac_smoother_apply(alpha,sm,x,beta,y,desc_data,trans,& - & sweeps,work,info,init,initu) - import :: psb_desc_type, mld_z_jac_smoother_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, & - & psb_ipk_ - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_jac_smoother_type), intent(inout) :: sm - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - integer(psb_ipk_), intent(in) :: sweeps - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine mld_z_jac_smoother_apply - end interface - - interface - subroutine mld_z_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - import :: psb_desc_type, mld_z_jac_smoother_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_jac_smoother_bld - end interface - - interface - subroutine mld_z_jac_smoother_cnv(sm,info,amold,vmold,imold) - import :: mld_z_jac_smoother_type, psb_dpk_, & - & psb_z_base_sparse_mat, psb_z_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - class(mld_z_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_jac_smoother_cnv - end interface - - interface - subroutine mld_z_jac_smoother_dmp(sm,desc,level,info,prefix,head,smoother,solver,global_num) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_dpk_, mld_z_jac_smoother_type, psb_epk_, psb_desc_type, & - & psb_ipk_ - implicit none - class(mld_z_jac_smoother_type), intent(in) :: sm - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver, global_num - end subroutine mld_z_jac_smoother_dmp - end interface - - interface - subroutine mld_z_jac_smoother_clone(sm,smout,info) - import :: mld_z_jac_smoother_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_ - class(mld_z_jac_smoother_type), intent(inout) :: sm - class(mld_z_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_jac_smoother_clone - end interface - - interface - subroutine mld_z_jac_smoother_clone_settings(sm,smout,info) - import :: mld_z_jac_smoother_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_ - class(mld_z_jac_smoother_type), intent(inout) :: sm - class(mld_z_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_jac_smoother_clone_settings - end interface - - interface - subroutine mld_z_jac_smoother_clear_data(sm,info) - import :: mld_z_jac_smoother_type, psb_dpk_, & - & mld_z_base_smoother_type, psb_ipk_ - class(mld_z_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_jac_smoother_clear_data - end interface - - interface - subroutine mld_z_jac_smoother_descr(sm,info,iout,coarse) - import :: mld_z_jac_smoother_type, psb_ipk_ - class(mld_z_jac_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - end subroutine mld_z_jac_smoother_descr - end interface - - interface - subroutine mld_z_jac_smoother_cseti(sm,what,val,info,idx) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_dpk_, mld_z_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_z_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_z_jac_smoother_cseti - end interface - - interface - subroutine mld_z_jac_smoother_csetc(sm,what,val,info,idx) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_dpk_, mld_z_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_z_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_z_jac_smoother_csetc - end interface - - interface - subroutine mld_z_jac_smoother_csetr(sm,what,val,info,idx) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_dpk_, mld_z_jac_smoother_type, psb_epk_, psb_desc_type, psb_ipk_ - implicit none - class(mld_z_jac_smoother_type), intent(inout) :: sm - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_z_jac_smoother_csetr - end interface - - - interface - subroutine mld_z_l1_jac_smoother_bld(a,desc_a,sm,info,amold,vmold,imold) - import :: psb_desc_type, mld_z_l1_jac_smoother_type, psb_z_vect_type, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_l1_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_l1_jac_smoother_bld - end interface - - interface - subroutine mld_z_l1_jac_smoother_clone(sm,smout,info) - import :: mld_z_l1_jac_smoother_type, & - & mld_z_base_smoother_type, psb_ipk_ - class(mld_z_l1_jac_smoother_type), intent(inout) :: sm - class(mld_z_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_l1_jac_smoother_clone - end interface - - interface - subroutine mld_z_l1_jac_smoother_clone_settings(sm,smout,info) - import :: mld_z_l1_jac_smoother_type, & - & mld_z_base_smoother_type, psb_ipk_ - class(mld_z_l1_jac_smoother_type), intent(inout) :: sm - class(mld_z_base_smoother_type), allocatable, intent(inout) :: smout - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_l1_jac_smoother_clone_settings - end interface - - interface - subroutine mld_z_l1_jac_smoother_clear_data(sm,info) - import :: mld_z_l1_jac_smoother_type, & - & mld_z_base_smoother_type, psb_ipk_ - class(mld_z_l1_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_l1_jac_smoother_clear_data - end interface - - interface - subroutine mld_z_l1_jac_smoother_descr(sm,info,iout,coarse) - import :: mld_z_l1_jac_smoother_type, psb_ipk_ - class(mld_z_l1_jac_smoother_type), intent(in) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - end subroutine mld_z_l1_jac_smoother_descr - end interface - -contains - - - subroutine z_jac_smoother_free(sm,info) - - - Implicit None - - ! Arguments - class(mld_z_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_jac_smoother_free' - - call psb_erractionsave(err_act) - info = psb_success_ - - - - if (allocated(sm%sv)) then - call sm%sv%free(info) - if (info == psb_success_) deallocate(sm%sv,stat=info) - if (info /= psb_success_) then - info = psb_err_alloc_dealloc_ - call psb_errpush(info,name) - goto 9999 - end if - end if - call sm%nd%free() - sm%pa => null() - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_jac_smoother_free - - function z_jac_smoother_sizeof(sm) result(val) - - implicit none - ! Arguments - class(mld_z_jac_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = psb_sizeof_lp - if (allocated(sm%sv)) val = val + sm%sv%sizeof() - val = val + sm%nd%sizeof() - - return - end function z_jac_smoother_sizeof - - subroutine z_jac_smoother_default(sm) - - Implicit None - - ! Arguments - class(mld_z_jac_smoother_type), intent(inout) :: sm - - ! - ! Default: BJAC with no residual check - ! - sm%checkres = .false. - sm%printres = .false. - sm%checkiter = -1 - sm%printiter = -1 - sm%tol = 0 - - if (allocated(sm%sv)) then - call sm%sv%default() - end if - - return - end subroutine z_jac_smoother_default - - function z_jac_smoother_get_nzeros(sm) result(val) - - implicit none - ! Arguments - class(mld_z_jac_smoother_type), intent(in) :: sm - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = 0 - if (allocated(sm%sv)) val = val + sm%sv%get_nzeros() - val = val + sm%nd%get_nzeros() - - return - end function z_jac_smoother_get_nzeros - - function z_jac_smoother_get_wrksize(sm) result(val) - implicit none - class(mld_z_jac_smoother_type), intent(inout) :: sm - integer(psb_ipk_) :: val - - val = 2 - if (allocated(sm%sv)) val = val + sm%sv%get_wrksz() - - end function z_jac_smoother_get_wrksize - - function z_jac_smoother_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Jacobi smoother" - end function z_jac_smoother_get_fmt - - function z_jac_smoother_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_jac_ - end function z_jac_smoother_get_id - - function z_l1_jac_smoother_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "L1-Jacobi smoother" - end function z_l1_jac_smoother_get_fmt - - function z_l1_jac_smoother_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_l1_jac_ - end function z_l1_jac_smoother_get_id - -end module mld_z_jac_smoother diff --git a/mlprec/mld_z_mumps_solver.F90 b/mlprec/mld_z_mumps_solver.F90 deleted file mode 100644 index 8f461a73..00000000 --- a/mlprec/mld_z_mumps_solver.F90 +++ /dev/null @@ -1,590 +0,0 @@ - -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! Current version of this file contributed by: -! Ambra Abdullahi Hassan -! -! -! File: mld_z_mumps_solver_mod.f90 -! -! Module: mld_z_mumps_solver_mod -! -! This module defines: -! - the mld_z_mumps_solver_type data structure containing the ingredients -! to interface with the MUMPS package. -! 1. The factorization can be either restricted to the diagonal block of the -! current image or distributed (and thus exact). -! -module mld_z_mumps_solver - use mld_z_base_solver_mod -#if defined(HAVE_MUMPS_) && defined(HAVE_MUMPS_MODULES_) - use zmumps_struc_def -#endif -#if defined(HAVE_MUMPS_) && defined(HAVE_MUMPS_INCLUDES_) - include 'zmumps_struc.h' -#endif - - - type :: mld_z_mumps_icntl_item - integer(psb_ipk_), allocatable :: item - end type mld_z_mumps_icntl_item - type :: mld_z_mumps_rcntl_item - real(psb_dpk_), allocatable :: item - end type mld_z_mumps_rcntl_item - - type, extends(mld_z_base_solver_type) :: mld_z_mumps_solver_type -#if defined(HAVE_MUMPS_) - type(zmumps_struc), allocatable :: id -#else - integer, allocatable :: id -#endif - type(mld_z_mumps_icntl_item), allocatable :: icntl(:) - type(mld_z_mumps_rcntl_item), allocatable :: rcntl(:) - ! - ! Controls to be set before MUMPS instantiation: - ! - ! IPAR(1) : MUMPS_LOC_GLOB 0==mld_local_solver_: LOCAL 1==mld_global_solver_: GLOBAL - ! IPAR(2) : MUMPS_PRINT_ERR print verbosity (see MUMPS) - ! IPAR(3) : MUMPS_SYM 0: non-symmetric 2: symmetric - integer(psb_ipk_), dimension(3) :: ipar - integer(psb_ipk_), allocatable :: local_ictxt - logical :: built = .false. - contains - procedure, pass(sv) :: build => z_mumps_solver_bld - procedure, pass(sv) :: apply_a => z_mumps_solver_apply - procedure, pass(sv) :: apply_v => z_mumps_solver_apply_vect - procedure, pass(sv) :: clone_settings => z_mumps_solver_clone_settings - procedure, pass(sv) :: clear_data => z_mumps_solver_clear_data - procedure, pass(sv) :: free => z_mumps_solver_free - procedure, pass(sv) :: descr => z_mumps_solver_descr - procedure, pass(sv) :: sizeof => z_mumps_solver_sizeof - procedure, pass(sv) :: csetc => z_mumps_solver_csetc - procedure, pass(sv) :: cseti => z_mumps_solver_cseti - procedure, pass(sv) :: csetr => z_mumps_solver_csetr - procedure, pass(sv) :: default => z_mumps_solver_default - procedure, nopass :: get_fmt => z_mumps_solver_get_fmt - procedure, nopass :: get_id => z_mumps_solver_get_id - procedure, pass(sv) :: is_global => z_mumps_solver_is_global - final :: z_mumps_solver_finalize - end type mld_z_mumps_solver_type - - - private :: z_mumps_solver_bld, z_mumps_solver_apply, & - & z_mumps_solver_free, z_mumps_solver_descr, & - & z_mumps_solver_sizeof, z_mumps_solver_apply_vect,& - & z_mumps_solver_cseti, z_mumps_solver_csetr, & - & z_mumps_solver_csetc, z_mumps_solver_clear_data, & - & z_mumps_solver_default, z_mumps_solver_get_fmt, & - & z_mumps_solver_clone_settings, & - & z_mumps_solver_get_id, z_mumps_solver_is_global - private :: z_mumps_solver_finalize - - interface - subroutine z_mumps_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - import :: psb_desc_type, mld_z_mumps_solver_type, psb_z_vect_type, psb_dpk_, psb_spk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_mumps_solver_type), intent(inout) :: sv - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - end subroutine z_mumps_solver_apply_vect - end interface - - interface - subroutine z_mumps_solver_apply(alpha,sv,x,beta,y,desc_data,trans,work,info,init,initu) - import :: psb_desc_type, mld_z_mumps_solver_type, psb_z_vect_type, psb_dpk_, psb_spk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type, psb_ipk_ - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_mumps_solver_type), intent(inout) :: sv - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer(psb_ipk_), intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - end subroutine z_mumps_solver_apply - end interface - - interface - subroutine z_mumps_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - import :: psb_desc_type, mld_z_mumps_solver_type, psb_z_vect_type, psb_dpk_, & - & psb_zspmat_type, psb_z_base_sparse_mat, psb_z_base_vect_type,& - & psb_ipk_, psb_i_base_vect_type - - Implicit None - - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine z_mumps_solver_bld - end interface - -contains - - subroutine z_mumps_solver_clone_settings(sv,svout,info) - - use psb_base_mod - Implicit None - ! Arguments - class(mld_z_mumps_solver_type), intent(inout) :: sv - class(mld_z_base_solver_type), intent(inout) :: svout - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: k,err_act - character(len=20) :: name='z_mumps_solver_clone_settings' - - info = 0 - -#if defined(HAVE_MUMPS_) - - call psb_erractionsave(err_act) - - select type(svout) - class is(mld_z_mumps_solver_type) - svout%ipar(:) = sv%ipar(:) - svout%built = .false. - if (allocated(svout%icntl)) deallocate(svout%icntl,stat=info) - if (info == 0) allocate(svout%icntl(mld_mumps_icntl_size),stat=info) - if (info == 0) then - do k=1,mld_mumps_icntl_size - call psb_safe_ab_cpy(sv%icntl(k)%item,svout%icntl(k)%item,info) - end do - end if - - if (allocated(svout%rcntl)) deallocate(svout%rcntl,stat=info) - if (info == 0) allocate(svout%rcntl(mld_mumps_rcntl_size),stat=info) - if (info == 0) then - do k=1,mld_mumps_rcntl_size - call psb_safe_ab_cpy(sv%rcntl(k)%item,svout%rcntl(k)%item,info) - end do - end if - - class default - info = psb_err_internal_error_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - - return -#endif - end subroutine z_mumps_solver_clone_settings - - subroutine z_mumps_solver_clear_data(sv,info) - use psb_base_mod, only : psb_exit - Implicit None - - ! Arguments - class(mld_z_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - Integer(psb_ipk_) :: err_act - character(len=20) :: name='z_mumps_solver_clear_data' - - info = 0 -#if defined(HAVE_MUMPS_) - call psb_erractionsave(err_act) - if (allocated(sv%id)) then - if (sv%built) then - sv%id%job = -2 - call zmumps(sv%id) - info = sv%id%infog(1) - if (info /= psb_success_) goto 9999 - end if - deallocate(sv%id, stat=info) - if (allocated(sv%local_ictxt)) then - call psb_exit(sv%local_ictxt,close=.false.) - deallocate(sv%local_ictxt,stat=info) - end if - sv%built=.false. - end if - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -#endif - end subroutine z_mumps_solver_clear_data - - subroutine z_mumps_solver_free(sv,info) - use psb_base_mod, only : psb_exit - Implicit None - - ! Arguments - class(mld_z_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_), intent(out) :: info - Integer(psb_ipk_) :: err_act - character(len=20) :: name='z_mumps_solver_free' - - info = 0 -#if defined(HAVE_MUMPS_) - call psb_erractionsave(err_act) - call sv%clear_data(info) - if ((info == 0).and.allocated(sv%icntl)) deallocate(sv%icntl,stat=info) - if ((info == 0).and.allocated(sv%rcntl)) deallocate(sv%rcntl,stat=info) - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -#endif - end subroutine z_mumps_solver_free - -subroutine z_mumps_solver_finalize(sv) - - Implicit None - - ! Arguments - type(mld_z_mumps_solver_type), intent(inout) :: sv - integer(psb_ipk_) :: info - Integer(psb_ipk_) :: err_act - character(len=20) :: name='z_mumps_solver_finalize' - - call sv%free(info) - - return - -end subroutine z_mumps_solver_finalize - -subroutine z_mumps_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_z_mumps_solver_type), intent(in) :: sv - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer(psb_ipk_) :: err_act - integer(psb_ipk_) :: ictxt, me, np - character(len=20), parameter :: name='mld_z_mumps_solver_descr' - integer(psb_ipk_) :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' MUMPS Solver. ' - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -end subroutine z_mumps_solver_descr - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! WARNING: OTHER PARAMETERS OF MUMPS COULD BE ADDED. !! -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - -subroutine z_mumps_solver_csetc(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_z_mumps_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_mumps_solver_csetc' - - info = psb_success_ - call psb_erractionsave(err_act) - - - select case(psb_toupper(trim(what))) -#if defined(HAVE_MUMPS_) - case('MUMPS_LOC_GLOB') - sv%ipar(1) = sv%stringval(psb_toupper(trim(val))) -#endif - case default - call sv%mld_z_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -end subroutine z_mumps_solver_csetc - - -subroutine z_mumps_solver_cseti(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_z_mumps_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_mumps_solver_cseti' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) -#if defined(HAVE_MUMPS_) - case('MUMPS_LOC_GLOB') - sv%ipar(1) = val - case('MUMPS_PRINT_ERR') - sv%ipar(2) = val - case('MUMPS_SYM') - sv%ipar(3) = val - case('MUMPS_IPAR_ENTRY') - if(present(idx)) then - ! Note: this will allocate %item - sv%icntl(idx)%item = val - end if -#endif - case default - call sv%mld_z_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -end subroutine z_mumps_solver_cseti - -subroutine z_mumps_solver_csetr(sv,what,val,info,idx) - - Implicit None - - ! Arguments - class(mld_z_mumps_solver_type), intent(inout) :: sv - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: idx - integer(psb_ipk_) :: err_act - character(len=20) :: name='z_mumps_solver_csetr' - - info = psb_success_ - call psb_erractionsave(err_act) - - select case(psb_toupper(what)) -#if defined(HAVE_MUMPS_) - case('MUMPS_RPAR_ENTRY') - if(present(idx)) then - ! Note: this will allocate %item - sv%rcntl(idx)%item = val - end if -#endif - case default - call sv%mld_z_base_solver_type%set(what,val,info,idx=idx) - end select - - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return -end subroutine z_mumps_solver_csetr - -!!NOTE: BY DEFAULT BLR is activated with a dropping parameter to 1d-4 !! -subroutine z_mumps_solver_default(sv) - - Implicit none - - !Argument - class(mld_z_mumps_solver_type),intent(inout) :: sv - integer(psb_ipk_) :: info - integer(psb_ipk_) :: err_act,ictx,icomm - character(len=20) :: name='z_mumps_default' - - info = psb_success_ - call psb_erractionsave(err_act) - -#if defined(HAVE_MUMPS_) - if (.not.allocated(sv%id)) then - allocate(sv%id,stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_dealloc_ - call psb_errpush(info,name,a_err='mld_zmumps_default') - goto 9999 - end if - sv%built=.false. - end if - if (.not.allocated(sv%icntl)) then - allocate(sv%icntl(mld_mumps_icntl_size),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_dealloc_ - call psb_errpush(info,name,a_err='mld_zmumps_default') - goto 9999 - end if - end if - if (.not.allocated(sv%rcntl)) then - allocate(sv%rcntl(mld_mumps_rcntl_size),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_dealloc_ - call psb_errpush(info,name,a_err='mld_zmumps_default') - goto 9999 - end if - end if - ! INSTANTIATION OF sv%id needed to set parmater but mpi communicator needed - ! sv%id%job = -1 - ! sv%id%par=1 - ! call dmumps(sv%id) - sv%ipar = 0 - sv%ipar(1) = mld_global_solver_ - !sv%ipar(10)=6 - !sv%ipar(11)=0 - !sv%ipar(12)=6 - -#endif - call psb_erractionrestore(err_act) - return - -9999 continue - call psb_erractionrestore(err_act) - if (err_act == psb_act_abort_) then - call psb_error() - return - end if - return - -end subroutine z_mumps_solver_default - -function z_mumps_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_z_mumps_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer :: i -#if defined(HAVE_MUMPS_) - val = (sv%id%INFOG(22)+sv%id%INFOG(32))*1d+6 -#else - val = 0 -#endif - ! val = 2*psb_sizeof_ip + psb_sizeof_dp - ! val = val + sv%symbsize - ! val = val + sv%numsize - return -end function z_mumps_solver_sizeof - -function z_mumps_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "MUMPS solver" -end function z_mumps_solver_get_fmt - -function z_mumps_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_mumps_ -end function z_mumps_solver_get_id - - -function z_mumps_solver_is_global(sv) result(val) - implicit none - class(mld_z_mumps_solver_type), intent(in) :: sv - logical :: val - - val = (sv%ipar(1) == mld_global_solver_ ) -end function z_mumps_solver_is_global - -end module mld_z_mumps_solver - diff --git a/mlprec/mld_z_onelev_mod.f90 b/mlprec/mld_z_onelev_mod.f90 deleted file mode 100644 index 96a560cd..00000000 --- a/mlprec/mld_z_onelev_mod.f90 +++ /dev/null @@ -1,824 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_z_onelev_mod.f90 -! -! Module: mld_z_onelev_mod -! -! This module defines: -! - the mld_z_onelev_type data structure containing one level -! of a multilevel preconditioner and related -! data structures; -! -! It contains routines for -! - Building and applying; -! - checking if the preconditioner is correctly defined; -! - printing a description of the preconditioner; -! - deallocating the preconditioner data structure. -! - -module mld_z_onelev_mod - - use mld_base_prec_type - use mld_z_base_smoother_mod - use mld_z_dec_aggregator_mod - use psb_base_mod, only : psb_zspmat_type, psb_z_vect_type, & - & psb_z_base_vect_type, psb_lzspmat_type, psb_zlinmap_type, psb_dpk_, & - & psb_ipk_, psb_epk_, psb_lpk_, psb_desc_type, psb_i_base_vect_type, & - & psb_erractionsave, psb_error_handler - ! - ! - ! Type: mld_zonelev_type. - ! - ! It is the data type containing the necessary items for the current - ! level (essentially, the smoother, the current-level matrix - ! and the restriction and prolongation operators). - ! - ! type mld_zonelev_type - ! class(mld_z_base_smoother_type), allocatable :: sm, sm2a - ! class(mld_z_base_smoother_type), pointer :: sm2 => null() - ! class(mld_zmlprec_wrk_type), allocatable :: wrk - ! class(mld_z_base_aggregator_type), allocatable :: aggr - ! type(mld_dml_parms) :: parms - ! type(psb_zspmat_type) :: ac - ! type(psb_zesc_type) :: desc_ac - ! type(psb_zspmat_type), pointer :: base_a => null() - ! type(psb_desc_type), pointer :: base_desc => null() - ! type(psb_zlinmap_type) :: map - ! end type mld_zonelev_type - ! - ! Note that d denotes the kind of the real data type to be chosen - ! according to single/double precision version of MLD2P4. - ! - ! sm,sm2a - class(mld_z_base_smoother_type), allocatable - ! The current level pre- and post-smooother. - ! sm2 - class(mld_z_base_smoother_type), pointer - ! The current level post-smooother; if sm2a is allocated - ! explicitly, then sm2 => sm2a, otherwise sm2 => sm. - ! wrk - class(mld_zmlprec_wrk_type), allocatable - ! Workspace for application of preconditioner; may be - ! pre-allocated to save time in the application within a - ! Krylov solver. - ! aggr - class(mld_z_base_aggregator_type), allocatable - ! The aggregator object: holds the algorithmic choices and - ! (possibly) additional data for building the aggregation. - ! parms - type(mld_dml_parms) - ! The parameters defining the multilevel strategy. - ! ac - The local part of the current-level matrix, built by - ! coarsening the previous-level matrix. - ! desc_ac - type(psb_desc_type). - ! The communication descriptor associated to the matrix - ! stored in ac. - ! base_a - type(psb_zspmat_type), pointer. - ! Pointer (really a pointer!) to the local part of the current - ! matrix (so we have a unified treatment of residuals). - ! We need this to avoid passing explicitly the current matrix - ! to the routine which applies the preconditioner. - ! base_desc - type(psb_desc_type), pointer. - ! Pointer to the communication descriptor associated to the - ! matrix pointed by base_a. - ! map - Stores the maps (restriction and prolongation) between the - ! vector spaces associated to the index spaces of the previous - ! and current levels. - ! - ! Methods: - ! Most methods follow the encapsulation hierarchy: they take whatever action - ! is appropriate for the current object, then call the corresponding method for - ! the contained object. - ! As an example: the descr() method prints out a description of the - ! level. It starts by invoking the descr() method of the parms object, - ! then calls the descr() method of the smoother object. - ! - ! descr - Prints a description of the object. - ! default - Set default values - ! dump - Dump to file object contents - ! set - Sets various parameters; when a request is unknown - ! it is passed to the smoother object for further processing. - ! check - Sanity checks. - ! sizeof - Total memory occupation in bytes - ! get_nzeros - Number of nonzeros - ! get_wrksz - How many workspace vector does apply_vect need - ! allocate_wrk - Allocate auxiliary workspace - ! free_wrk - Free auxiliary workspace - ! bld_tprol - Invoke the aggr method to build the tentative prolongator - ! mat_asb - Build the final (possibly smoothed) prolongator and coarse matrix. - ! - ! - type mld_zmlprec_wrk_type - complex(psb_dpk_), allocatable :: tx(:), ty(:), x2l(:), y2l(:) - type(psb_z_vect_type) :: vtx, vty, vx2l, vy2l - type(psb_z_vect_type), allocatable :: wv(:) - contains - procedure, pass(wk) :: alloc => z_wrk_alloc - procedure, pass(wk) :: free => z_wrk_free - procedure, pass(wk) :: clone => z_wrk_clone - procedure, pass(wk) :: move_alloc => z_wrk_move_alloc - procedure, pass(wk) :: cnv => z_wrk_cnv - procedure, pass(wk) :: sizeof => z_wrk_sizeof - end type mld_zmlprec_wrk_type - private :: z_wrk_alloc, z_wrk_free, & - & z_wrk_clone, z_wrk_move_alloc, z_wrk_cnv, z_wrk_sizeof - - type mld_z_onelev_type - class(mld_z_base_smoother_type), allocatable :: sm, sm2a - class(mld_z_base_smoother_type), pointer :: sm2 => null() - class(mld_zmlprec_wrk_type), allocatable :: wrk - class(mld_z_base_aggregator_type), allocatable :: aggr - type(mld_dml_parms) :: parms - type(psb_zspmat_type) :: ac - integer(psb_ipk_) :: ac_nz_loc - integer(psb_lpk_) :: ac_nz_tot - type(psb_desc_type) :: desc_ac - type(psb_zspmat_type), pointer :: base_a => null() - type(psb_desc_type), pointer :: base_desc => null() - type(psb_lzspmat_type) :: tprol - type(psb_zlinmap_type) :: map - real(psb_dpk_) :: szratio - contains - procedure, pass(lv) :: bld_tprol => z_base_onelev_bld_tprol - procedure, pass(lv) :: mat_asb => mld_z_base_onelev_mat_asb - procedure, pass(lv) :: update_aggr => z_base_onelev_update_aggr - procedure, pass(lv) :: bld => mld_z_base_onelev_build - procedure, pass(lv) :: clone => z_base_onelev_clone - procedure, pass(lv) :: cnv => mld_z_base_onelev_cnv - procedure, pass(lv) :: descr => mld_z_base_onelev_descr - procedure, pass(lv) :: default => z_base_onelev_default - procedure, pass(lv) :: free => mld_z_base_onelev_free - procedure, pass(lv) :: nullify => z_base_onelev_nullify - procedure, pass(lv) :: check => mld_z_base_onelev_check - procedure, pass(lv) :: dump => mld_z_base_onelev_dump - procedure, pass(lv) :: cseti => mld_z_base_onelev_cseti - procedure, pass(lv) :: csetr => mld_z_base_onelev_csetr - procedure, pass(lv) :: csetc => mld_z_base_onelev_csetc - procedure, pass(lv) :: setsm => mld_z_base_onelev_setsm - procedure, pass(lv) :: setsv => mld_z_base_onelev_setsv - procedure, pass(lv) :: setag => mld_z_base_onelev_setag - generic, public :: set => cseti, csetr, csetc, setsm, setsv, setag - procedure, pass(lv) :: sizeof => z_base_onelev_sizeof - procedure, pass(lv) :: get_nzeros => z_base_onelev_get_nzeros - procedure, pass(lv) :: get_wrksz => z_base_onelev_get_wrksize - procedure, pass(lv) :: allocate_wrk => z_base_onelev_allocate_wrk - procedure, pass(lv) :: free_wrk => z_base_onelev_free_wrk - procedure, nopass :: stringval => mld_stringval - procedure, pass(lv) :: move_alloc => z_base_onelev_move_alloc - - end type mld_z_onelev_type - - type mld_z_onelev_node - type(mld_z_onelev_type) :: item - type(mld_z_onelev_node), pointer :: prev=>null(), next=>null() - end type mld_z_onelev_node - - private :: z_base_onelev_default, z_base_onelev_sizeof, & - & z_base_onelev_nullify, z_base_onelev_get_nzeros, & - & z_base_onelev_clone, z_base_onelev_move_alloc, & - & z_base_onelev_get_wrksize, z_base_onelev_allocate_wrk, & - & z_base_onelev_free_wrk - - interface - subroutine mld_z_base_onelev_mat_asb(lv,a,desc_a,ilaggr,nlaggr,t_prol,info) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, psb_ipk_, psb_lzspmat_type, psb_lpk_ - import :: mld_z_onelev_type - implicit none - class(mld_z_onelev_type), intent(inout), target :: lv - type(psb_zspmat_type), intent(in) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), intent(inout) :: ilaggr(:),nlaggr(:) - type(psb_lzspmat_type), intent(inout) :: t_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_base_onelev_mat_asb - end interface - - interface - subroutine mld_z_base_onelev_build(lv,info,amold,vmold,imold,ilv) - import :: psb_z_base_sparse_mat, psb_z_base_vect_type, & - & psb_i_base_vect_type, psb_dpk_, mld_z_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - implicit none - class(mld_z_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - integer(psb_ipk_), intent(in), optional :: ilv - end subroutine mld_z_base_onelev_build - end interface - - interface - subroutine mld_z_base_onelev_descr(lv,il,nl,ilmin,info,iout) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_zlinmap_type, psb_dpk_, mld_z_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - ! Arguments - class(mld_z_onelev_type), intent(in) :: lv - integer(psb_ipk_), intent(in) :: il,nl,ilmin - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: iout - end subroutine mld_z_base_onelev_descr - end interface - - interface - subroutine mld_z_base_onelev_cnv(lv,info,amold,vmold,imold) - import :: mld_z_onelev_type, psb_z_base_vect_type, psb_dpk_, & - & psb_z_base_sparse_mat, psb_ipk_, psb_i_base_vect_type - ! Arguments - class(mld_z_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - end subroutine mld_z_base_onelev_cnv - end interface - -interface - subroutine mld_z_base_onelev_free(lv,info) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_zlinmap_type, psb_dpk_, mld_z_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - implicit none - - class(mld_z_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_base_onelev_free - end interface - - interface - subroutine mld_z_base_onelev_check(lv,info) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_zlinmap_type, psb_dpk_, mld_z_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - ! Arguments - class(mld_z_onelev_type), intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_base_onelev_check - end interface - - interface - subroutine mld_z_base_onelev_setsm(lv,val,info,pos) - import :: psb_dpk_, mld_z_onelev_type, mld_z_base_smoother_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - ! Arguments - class(mld_z_onelev_type), target, intent(inout) :: lv - class(mld_z_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - end subroutine mld_z_base_onelev_setsm - end interface - - interface - subroutine mld_z_base_onelev_setsv(lv,val,info,pos) - import :: psb_dpk_, mld_z_onelev_type, mld_z_base_solver_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - ! Arguments - class(mld_z_onelev_type), target, intent(inout) :: lv - class(mld_z_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - end subroutine mld_z_base_onelev_setsv - end interface - - interface - subroutine mld_z_base_onelev_setag(lv,val,info,pos) - import :: psb_dpk_, mld_z_onelev_type, mld_z_base_aggregator_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - ! Arguments - class(mld_z_onelev_type), target, intent(inout) :: lv - class(mld_z_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - end subroutine mld_z_base_onelev_setag - end interface - - interface - subroutine mld_z_base_onelev_cseti(lv,what,val,info,pos,idx) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_zlinmap_type, psb_dpk_, mld_z_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - ! Arguments - class(mld_z_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_z_base_onelev_cseti - end interface - - interface - subroutine mld_z_base_onelev_csetc(lv,what,val,info,pos,idx) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_zlinmap_type, psb_dpk_, mld_z_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - ! Arguments - class(mld_z_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_z_base_onelev_csetc - end interface - - interface - subroutine mld_z_base_onelev_csetr(lv,what,val,info,pos,idx) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_zlinmap_type, psb_dpk_, mld_z_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - Implicit None - - class(mld_z_onelev_type), intent(inout) :: lv - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - integer(psb_ipk_), intent(in), optional :: idx - end subroutine mld_z_base_onelev_csetr - end interface - - interface - subroutine mld_z_base_onelev_dump(lv,level,info,prefix,head,ac,rp,smoother,& - & solver,tprol,global_num) - import :: psb_zspmat_type, psb_z_vect_type, psb_z_base_vect_type, & - & psb_zlinmap_type, psb_dpk_, mld_z_onelev_type, & - & psb_ipk_, psb_epk_, psb_desc_type - implicit none - class(mld_z_onelev_type), intent(in) :: lv - integer(psb_ipk_), intent(in) :: level - integer(psb_ipk_), intent(out) :: info - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: ac, rp, smoother, solver, tprol, global_num - end subroutine mld_z_base_onelev_dump - end interface - -contains - ! - ! Function returning the size of the mld_prec_type data structure - ! in bytes or in number of nonzeros of the operator(s) involved. - ! - - function z_base_onelev_get_nzeros(lv) result(val) - implicit none - class(mld_z_onelev_type), intent(in) :: lv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - if (allocated(lv%sm)) & - & val = lv%sm%get_nzeros() - if (allocated(lv%sm2a)) & - & val = val + lv%sm2a%get_nzeros() - end function z_base_onelev_get_nzeros - - function z_base_onelev_sizeof(lv) result(val) - implicit none - class(mld_z_onelev_type), intent(in) :: lv - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - - val = psb_sizeof_ip+psb_sizeof_lp - val = val + lv%desc_ac%sizeof() - val = val + lv%ac%sizeof() - val = val + lv%tprol%sizeof() - val = val + lv%map%sizeof() - if (allocated(lv%sm)) val = val + lv%sm%sizeof() - if (allocated(lv%sm2a)) val = val + lv%sm2a%sizeof() - if (allocated(lv%aggr)) val = val + lv%aggr%sizeof() - if (allocated(lv%wrk)) val = val + lv%wrk%sizeof() - end function z_base_onelev_sizeof - - - subroutine z_base_onelev_nullify(lv) - implicit none - - class(mld_z_onelev_type), intent(inout) :: lv - - nullify(lv%base_a) - nullify(lv%base_desc) - nullify(lv%sm2) - end subroutine z_base_onelev_nullify - - ! - ! Multilevel defaults: - ! multiplicative vs. additive ML framework; - ! Smoothed decoupled aggregation with zero threshold; - ! distributed coarse matrix; - ! damping omega computed with the max-norm estimate of the - ! dominant eigenvalue; - ! two-sided smoothing (i.e. V-cycle) with 1 smoothing sweep; - ! - - subroutine z_base_onelev_default(lv) - - Implicit None - - ! Arguments - class(mld_z_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_) :: info - - lv%parms%sweeps_pre = 1 - lv%parms%sweeps_post = 1 - lv%parms%ml_cycle = mld_vcycle_ml_ - lv%parms%aggr_type = mld_soc1_ - lv%parms%par_aggr_alg = mld_dec_aggr_ - lv%parms%aggr_ord = mld_aggr_ord_nat_ - lv%parms%aggr_prol = mld_smooth_prol_ - lv%parms%coarse_mat = mld_distr_mat_ - lv%parms%aggr_omega_alg = mld_eig_est_ - lv%parms%aggr_eig = mld_max_norm_ - lv%parms%aggr_filter = mld_no_filter_mat_ - lv%parms%aggr_omega_val = dzero - lv%parms%aggr_thresh = 0.01_psb_dpk_ - - if (allocated(lv%sm)) call lv%sm%default() - if (allocated(lv%sm2a)) then - call lv%sm2a%default() - lv%sm2 => lv%sm2a - else - lv%sm2 => lv%sm - end if - if (.not.allocated(lv%aggr)) allocate(mld_z_dec_aggregator_type :: lv%aggr,stat=info) - if (allocated(lv%aggr)) call lv%aggr%default() - - return - - end subroutine z_base_onelev_default - - subroutine z_base_onelev_bld_tprol(lv,a,desc_a,& - & ilaggr,nlaggr,t_prol,ag_data,info) - implicit none - class(mld_z_onelev_type), intent(inout), target :: lv - type(psb_zspmat_type), intent(inout) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lzspmat_type), intent(out) :: t_prol - type(mld_daggr_data), intent(in) :: ag_data - integer(psb_ipk_), intent(out) :: info - - call lv%aggr%bld_tprol(lv%parms,ag_data,a,desc_a,ilaggr,nlaggr,t_prol,info) - - end subroutine z_base_onelev_bld_tprol - - - subroutine z_base_onelev_update_aggr(lv,lvnext,info) - implicit none - class(mld_z_onelev_type), intent(inout), target :: lv, lvnext - integer(psb_ipk_), intent(out) :: info - - call lv%aggr%update_next(lvnext%aggr,info) - - end subroutine z_base_onelev_update_aggr - - - subroutine z_base_onelev_clone(lv,lvout,info) - - Implicit None - - ! Arguments - class(mld_z_onelev_type), target, intent(inout) :: lv - class(mld_z_onelev_type), target, intent(inout) :: lvout - integer(psb_ipk_), intent(out) :: info - - info = psb_success_ - if (allocated(lv%sm)) then - call lv%sm%clone(lvout%sm,info) - else - if (allocated(lvout%sm)) then - call lvout%sm%free(info) - if (info==psb_success_) deallocate(lvout%sm,stat=info) - end if - end if - if (allocated(lv%sm2a)) then - call lv%sm%clone(lvout%sm2a,info) - lvout%sm2 => lvout%sm2a - else - if (allocated(lvout%sm2a)) then - call lvout%sm2a%free(info) - if (info==psb_success_) deallocate(lvout%sm2a,stat=info) - end if - lvout%sm2 => lvout%sm - end if - if (allocated(lv%aggr)) then - call lv%aggr%clone(lvout%aggr,info) - else - if (allocated(lvout%aggr)) then - call lvout%aggr%free(info) - if (info==psb_success_) deallocate(lvout%aggr,stat=info) - end if - end if - if (info == psb_success_) call lv%parms%clone(lvout%parms,info) - if (info == psb_success_) call lv%ac%clone(lvout%ac,info) - if (info == psb_success_) call lv%tprol%clone(lvout%tprol,info) - if (info == psb_success_) call lv%desc_ac%clone(lvout%desc_ac,info) - if (info == psb_success_) call lv%map%clone(lvout%map,info) - lvout%base_a => lv%base_a - lvout%base_desc => lv%base_desc - - return - - end subroutine z_base_onelev_clone - - subroutine z_base_onelev_move_alloc(lv, b,info) - use psb_base_mod - implicit none - class(mld_z_onelev_type), target, intent(inout) :: lv, b - integer(psb_ipk_), intent(out) :: info - - call b%free(info) - b%parms = lv%parms - b%szratio = lv%szratio - if (associated(lv%sm2,lv%sm2a)) then - call move_alloc(lv%sm,b%sm) - call move_alloc(lv%sm2a,b%sm2a) - b%sm2 =>b%sm2a - else - call move_alloc(lv%sm,b%sm) - call move_alloc(lv%sm2a,b%sm2a) - b%sm2 =>b%sm - end if - - call move_alloc(lv%aggr,b%aggr) - if (info == psb_success_) call psb_move_alloc(lv%ac,b%ac,info) - if (info == psb_success_) call psb_move_alloc(lv%tprol,b%tprol,info) - if (info == psb_success_) call psb_move_alloc(lv%desc_ac,b%desc_ac,info) - if (info == psb_success_) call psb_move_alloc(lv%map,b%map,info) - b%base_a => lv%base_a - b%base_desc => lv%base_desc - - end subroutine z_base_onelev_move_alloc - - - function z_base_onelev_get_wrksize(lv) result(val) - implicit none - class(mld_z_onelev_type), intent(inout) :: lv - integer(psb_ipk_) :: val - - val = 0 - ! SM and SM2A can share work vectors - if (allocated(lv%sm)) val = val + lv%sm%get_wrksz() - if (allocated(lv%sm2a)) val = max(val,lv%sm2a%get_wrksz()) - ! - ! Now for the ML application itself - ! - - ! VTX/VTY/VX2L/VY2L are stored explicitly - ! - - ! - ! additions for specific ML/cycles - ! - select case(lv%parms%ml_cycle) - case(mld_add_ml_,mld_mult_ml_,mld_vcycle_ml_, mld_wcycle_ml_) - ! We're good - - case(mld_kcycle_ml_, mld_kcyclesym_ml_) - ! - ! We need 7 in inneritkcycle. - ! Can we reuse vtx? - ! - val = val + 7 - - case default - ! Need a better error signaling ? - val = -1 - end select - - end function z_base_onelev_get_wrksize - - subroutine z_base_onelev_allocate_wrk(lv,info,vmold) - use psb_base_mod - implicit none - class(mld_z_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_vect_type), intent(in), optional :: vmold - ! - integer(psb_ipk_) :: nwv, i - info = psb_success_ - nwv = lv%get_wrksz() - if (.not.allocated(lv%wrk)) allocate(lv%wrk,stat=info) - if (info == 0) call lv%wrk%alloc(nwv,lv%base_desc,info,vmold=vmold) - - end subroutine z_base_onelev_allocate_wrk - - - subroutine z_base_onelev_free_wrk(lv,info) - use psb_base_mod - implicit none - class(mld_z_onelev_type), target, intent(inout) :: lv - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: nwv,i - info = psb_success_ - - if (allocated(lv%wrk)) then - call lv%wrk%free(info) - if (info == 0) deallocate(lv%wrk,stat=info) - end if - end subroutine z_base_onelev_free_wrk - - subroutine z_wrk_alloc(wk,nwv,desc,info,vmold) - use psb_base_mod - - Implicit None - - ! Arguments - class(mld_zmlprec_wrk_type), target, intent(inout) :: wk - integer(psb_ipk_), intent(in) :: nwv - type(psb_desc_type), intent(in) :: desc - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_vect_type), intent(in), optional :: vmold - ! - integer(psb_ipk_) :: i - - info = psb_success_ - call wk%free(info) - call psb_geasb(wk%vx2l,desc,info,& - & scratch=.true.,mold=vmold) - call psb_geasb(wk%vy2l,desc,info,& - & scratch=.true.,mold=vmold) - call psb_geasb(wk%vtx,desc,info,& - & scratch=.true.,mold=vmold) - call psb_geasb(wk%vty,desc,info,& - & scratch=.true.,mold=vmold) - allocate(wk%wv(nwv),stat=info) - do i=1,nwv - call psb_geasb(wk%wv(i),desc,info,& - & scratch=.true.,mold=vmold) - end do - - end subroutine z_wrk_alloc - - subroutine z_wrk_free(wk,info) - - Implicit None - - ! Arguments - class(mld_zmlprec_wrk_type), target, intent(inout) :: wk - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: i - info = psb_success_ - - if (allocated(wk%tx)) deallocate(wk%tx, stat=info) - if (allocated(wk%ty)) deallocate(wk%ty, stat=info) - if (allocated(wk%x2l)) deallocate(wk%x2l, stat=info) - if (allocated(wk%y2l)) deallocate(wk%y2l, stat=info) - call wk%vtx%free(info) - call wk%vty%free(info) - call wk%vx2l%free(info) - call wk%vy2l%free(info) - if (allocated(wk%wv)) then - do i=1,size(wk%wv) - call wk%wv(i)%free(info) - end do - deallocate(wk%wv, stat=info) - end if - - end subroutine z_wrk_free - - subroutine z_wrk_clone(wk,wkout,info) - use psb_base_mod - Implicit None - - ! Arguments - class(mld_zmlprec_wrk_type), target, intent(inout) :: wk - class(mld_zmlprec_wrk_type), target, intent(inout) :: wkout - integer(psb_ipk_), intent(out) :: info - ! - integer(psb_ipk_) :: i - info = psb_success_ - - call psb_safe_ab_cpy(wk%tx,wkout%tx,info) - call psb_safe_ab_cpy(wk%ty,wkout%ty,info) - call psb_safe_ab_cpy(wk%x2l,wkout%x2l,info) - call psb_safe_ab_cpy(wk%y2l,wkout%y2l,info) - call wk%vtx%clone(wkout%vtx,info) - call wk%vty%clone(wkout%vty,info) - call wk%vx2l%clone(wkout%vx2l,info) - call wk%vy2l%clone(wkout%vy2l,info) - if (allocated(wkout%wv)) then - do i=1,size(wkout%wv) - call wkout%wv(i)%free(info) - end do - deallocate( wkout%wv) - end if - allocate(wkout%wv(size(wk%wv)),stat=info) - do i=1,size(wk%wv) - call wk%wv(i)%clone(wkout%wv(i),info) - end do - return - - end subroutine z_wrk_clone - - subroutine z_wrk_move_alloc(wk, b,info) - implicit none - class(mld_zmlprec_wrk_type), target, intent(inout) :: wk, b - integer(psb_ipk_), intent(out) :: info - - call b%free(info) - call move_alloc(wk%tx,b%tx) - call move_alloc(wk%ty,b%ty) - call move_alloc(wk%x2l,b%x2l) - call move_alloc(wk%y2l,b%y2l) - ! - ! Should define V%move_alloc.... - call move_alloc(wk%vtx%v,b%vtx%v) - call move_alloc(wk%vty%v,b%vty%v) - call move_alloc(wk%vx2l%v,b%vx2l%v) - call move_alloc(wk%vy2l%v,b%vy2l%v) - call move_alloc(wk%wv,b%wv) - - end subroutine z_wrk_move_alloc - - subroutine z_wrk_cnv(wk,info,vmold) - use psb_base_mod - - Implicit None - - ! Arguments - class(mld_zmlprec_wrk_type), target, intent(inout) :: wk - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_vect_type), intent(in), optional :: vmold - ! - integer(psb_ipk_) :: i - - info = psb_success_ - if (present(vmold)) then - call wk%vtx%cnv(vmold) - call wk%vty%cnv(vmold) - call wk%vx2l%cnv(vmold) - call wk%vy2l%cnv(vmold) - if (allocated(wk%wv)) then - do i=1,size(wk%wv) - call wk%wv(i)%cnv(vmold) - end do - end if - end if - end subroutine z_wrk_cnv - - function z_wrk_sizeof(wk) result(val) - use psb_realloc_mod - implicit none - class(mld_zmlprec_wrk_type), intent(in) :: wk - integer(psb_epk_) :: val - integer :: i - val = 0 - val = val + (1_psb_epk_ * (2*psb_sizeof_dp)) * psb_size(wk%tx) - val = val + (1_psb_epk_ * (2*psb_sizeof_dp)) * psb_size(wk%ty) - val = val + (1_psb_epk_ * (2*psb_sizeof_dp)) * psb_size(wk%x2l) - val = val + (1_psb_epk_ * (2*psb_sizeof_dp)) * psb_size(wk%y2l) - val = val + wk%vtx%sizeof() - val = val + wk%vty%sizeof() - val = val + wk%vx2l%sizeof() - val = val + wk%vy2l%sizeof() - if (allocated(wk%wv)) then - do i=1, size(wk%wv) - val = val + wk%wv(i)%sizeof() - end do - end if - end function z_wrk_sizeof - -end module mld_z_onelev_mod diff --git a/mlprec/mld_z_prec_mod.f90 b/mlprec/mld_z_prec_mod.f90 deleted file mode 100644 index 104bff58..00000000 --- a/mlprec/mld_z_prec_mod.f90 +++ /dev/null @@ -1,139 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_z_prec_mod.f90 -! -! Module: mld_z_prec_mod -! -! This module defines the user interfaces to the real/complex, single/double -! precision versions of the user-level MLD2P4 routines. -! -module mld_z_prec_mod - - use mld_z_prec_type - use mld_z_jac_smoother - use mld_z_as_smoother - use mld_z_id_solver - use mld_z_diag_solver - use mld_z_l1_diag_solver - use mld_z_ilu_solver - use mld_z_gs_solver - - interface mld_precset - module procedure mld_z_iprecsetsm, mld_z_iprecsetsv, & - & mld_z_cprecseti, mld_z_cprecsetc, mld_z_cprecsetr, & - & mld_z_iprecsetag - end interface mld_precset - - interface mld_extprol_bld - subroutine mld_z_extprol_bld(a,desc_a,p,prolv,restrv,info,amold,vmold,imold) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & - & psb_z_base_sparse_mat, psb_z_base_vect_type, & - & psb_i_base_vect_type, mld_zprec_type, psb_ipk_ - - ! Arguments - type(psb_zspmat_type),intent(in), target :: a - type(psb_zspmat_type),intent(inout), target :: prolv(:) - type(psb_zspmat_type),intent(inout), target :: restrv(:) - type(psb_desc_type), intent(inout), target :: desc_a - type(mld_zprec_type),intent(inout),target :: p - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! !$ character, intent(in), optional :: upd - end subroutine mld_z_extprol_bld - end interface mld_extprol_bld - -contains - - subroutine mld_z_iprecsetsm(p,val,info,pos) - type(mld_zprec_type), intent(inout) :: p - class(mld_z_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - call p%set(val,info,pos=pos) - end subroutine mld_z_iprecsetsm - - subroutine mld_z_iprecsetsv(p,val,info,pos) - type(mld_zprec_type), intent(inout) :: p - class(mld_z_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - call p%set(val,info, pos=pos) - end subroutine mld_z_iprecsetsv - - subroutine mld_z_iprecsetag(p,val,info,pos) - type(mld_zprec_type), intent(inout) :: p - class(mld_z_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - call p%set(val,info, pos=pos) - end subroutine mld_z_iprecsetag - - subroutine mld_z_cprecseti(p,what,val,info,pos) - type(mld_zprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - call p%set(what,val,info,pos=pos) - end subroutine mld_z_cprecseti - - subroutine mld_z_cprecsetr(p,what,val,info,pos) - type(mld_zprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - call p%set(what,val,info,pos=pos) - end subroutine mld_z_cprecsetr - - subroutine mld_z_cprecsetc(p,what,val,info,pos) - type(mld_zprec_type), intent(inout) :: p - character(len=*), intent(in) :: what - character(len=*), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - character(len=*), optional, intent(in) :: pos - - call p%set(what,val,info,pos=pos) - end subroutine mld_z_cprecsetc - -end module mld_z_prec_mod diff --git a/mlprec/mld_z_prec_type.f90 b/mlprec/mld_z_prec_type.f90 deleted file mode 100644 index 14c1068f..00000000 --- a/mlprec/mld_z_prec_type.f90 +++ /dev/null @@ -1,964 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! File: mld_z_prec_type.f90 -! -! Module: mld_z_prec_type -! -! This module defines: -! - the mld_z_prec_type data structure containing the preconditioner and related -! data structures; -! -! It contains routines for -! - Building and applying; -! - checking if the preconditioner is correctly defined; -! - printing a description of the preconditioner; -! - deallocating the preconditioner data structure. -! - -module mld_z_prec_type - - use mld_base_prec_type - use mld_z_base_solver_mod - use mld_z_base_smoother_mod - use mld_z_base_aggregator_mod - use mld_z_onelev_mod - use psb_base_mod, only : psb_erractionsave, psb_erractionrestore, psb_errstatus_fatal - use psb_prec_mod, only : psb_zprec_type - - ! - ! Type: mld_zprec_type. - ! - ! This is the data type containing all the information about the multilevel - ! preconditioner ('d', 's', 'c' and 'z', according to the real/complex, - ! single/double precision version of MLD2P4). - ! It consists of an array of 'one-level' intermediate data structures - ! of type mld_zonelev_type, each containing the information needed to apply - ! the smoothing and the coarse-space correction at a generic level. RT is the - ! real data type, i.e. S for both S and C, and D for both D and Z. - ! - ! type mld_zprec_type - ! type(mld_zonelev_type), allocatable :: precv(:) - ! end type mld_zprec_type - ! - ! Note that the levels are numbered in increasing order starting from - ! the level 1 as the finest one, and the number of levels is given by - ! size(precv(:)) which is the id of the coarsest level. - ! In the multigrid literature many authors number the levels in the opposite - ! order, with level 0 being the id of the coarsest level. - ! - ! - integer, parameter, private :: wv_size_=4 - - type, extends(psb_zprec_type) :: mld_zprec_type - ! integer(psb_ipk_) :: ictxt ! Now it's in the PSBLAS prec. - type(mld_daggr_data) :: ag_data - ! - ! Number of outer sweeps. Sometimes 2 V-cycles may be better than 1 W-cycle. - ! - integer(psb_ipk_) :: outer_sweeps = 1 - ! - ! Coarse solver requires some tricky checks, and for this we need to - ! record the choice in the format given by the user, - ! to keep track against what is put later in the multilevel array - ! - integer(psb_ipk_) :: coarse_solver = -1 - - ! - ! The multilevel hierarchy - ! - type(mld_z_onelev_type), allocatable :: precv(:) - contains - procedure, pass(prec) :: psb_z_apply2_vect => mld_z_apply2_vect - procedure, pass(prec) :: psb_z_apply1_vect => mld_z_apply1_vect - procedure, pass(prec) :: psb_z_apply2v => mld_z_apply2v - procedure, pass(prec) :: psb_z_apply1v => mld_z_apply1v - procedure, pass(prec) :: dump => mld_z_dump - procedure, pass(prec) :: cnv => mld_z_cnv - procedure, pass(prec) :: clone => mld_z_clone - procedure, pass(prec) :: free => mld_z_prec_free - procedure, pass(prec) :: allocate_wrk => mld_z_allocate_wrk - procedure, pass(prec) :: free_wrk => mld_z_free_wrk - procedure, pass(prec) :: is_allocated_wrk => mld_z_is_allocated_wrk - procedure, pass(prec) :: get_complexity => mld_z_get_compl - procedure, pass(prec) :: cmp_complexity => mld_z_cmp_compl - procedure, pass(prec) :: get_avg_cr => mld_z_get_avg_cr - procedure, pass(prec) :: cmp_avg_cr => mld_z_cmp_avg_cr - procedure, pass(prec) :: get_nlevs => mld_z_get_nlevs - procedure, pass(prec) :: get_nzeros => mld_z_get_nzeros - procedure, pass(prec) :: sizeof => mld_zprec_sizeof - procedure, pass(prec) :: setsm => mld_zprecsetsm - procedure, pass(prec) :: setsv => mld_zprecsetsv - procedure, pass(prec) :: setag => mld_zprecsetag - procedure, pass(prec) :: cseti => mld_zcprecseti - procedure, pass(prec) :: csetc => mld_zcprecsetc - procedure, pass(prec) :: csetr => mld_zcprecsetr - generic, public :: set => cseti, csetc, csetr, setsm, setsv, setag - procedure, pass(prec) :: get_smoother => mld_z_get_smootherp - procedure, pass(prec) :: get_solver => mld_z_get_solverp - procedure, pass(prec) :: move_alloc => z_prec_move_alloc - procedure, pass(prec) :: init => mld_zprecinit - procedure, pass(prec) :: build => mld_zprecbld - procedure, pass(prec) :: hierarchy_build => mld_z_hierarchy_bld - procedure, pass(prec) :: smoothers_build => mld_z_smoothers_bld - procedure, pass(prec) :: descr => mld_zfile_prec_descr - end type mld_zprec_type - - private :: mld_z_dump, mld_z_get_compl, mld_z_cmp_compl,& - & mld_z_get_avg_cr, mld_z_cmp_avg_cr,& - & mld_z_get_nzeros, mld_z_get_nlevs, z_prec_move_alloc - - - ! - ! Interfaces to routines for checking the definition of the preconditioner, - ! for printing its description and for deallocating its data structure - ! - - interface mld_precfree - module procedure mld_zprecfree - end interface - - - interface mld_precdescr - subroutine mld_zfile_prec_descr(prec,iout,root) - import :: mld_zprec_type, psb_ipk_ - implicit none - ! Arguments - class(mld_zprec_type), intent(in) :: prec - integer(psb_ipk_), intent(in), optional :: iout - integer(psb_ipk_), intent(in), optional :: root - end subroutine mld_zfile_prec_descr - end interface - - interface mld_sizeof - module procedure mld_zprec_sizeof - end interface - - interface mld_precapply - subroutine mld_zprecaply2_vect(prec,x,y,desc_data,info,trans,work) - import :: psb_zspmat_type, psb_desc_type, & - & psb_dpk_, psb_z_vect_type, mld_zprec_type, psb_ipk_ - type(psb_desc_type),intent(in) :: desc_data - type(mld_zprec_type), intent(inout) :: prec - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_dpk_),intent(inout), optional, target :: work(:) - end subroutine mld_zprecaply2_vect - subroutine mld_zprecaply1_vect(prec,x,desc_data,info,trans,work) - import :: psb_zspmat_type, psb_desc_type, & - & psb_dpk_, psb_z_vect_type, mld_zprec_type, psb_ipk_ - type(psb_desc_type),intent(in) :: desc_data - type(mld_zprec_type), intent(inout) :: prec - type(psb_z_vect_type),intent(inout) :: x - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_dpk_),intent(inout), optional, target :: work(:) - end subroutine mld_zprecaply1_vect - subroutine mld_zprecaply(prec,x,y,desc_data,info,trans,work) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, mld_zprec_type, psb_ipk_ - type(psb_desc_type),intent(in) :: desc_data - type(mld_zprec_type), intent(inout) :: prec - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_dpk_),intent(inout), optional, target :: work(:) - end subroutine mld_zprecaply - subroutine mld_zprecaply1(prec,x,desc_data,info,trans) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, mld_zprec_type, psb_ipk_ - type(psb_desc_type),intent(in) :: desc_data - type(mld_zprec_type), intent(inout) :: prec - complex(psb_dpk_),intent(inout) :: x(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - end subroutine mld_zprecaply1 - end interface - - interface - subroutine mld_zprecsetsm(prec,val,info,ilev,ilmax,pos) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & - & mld_zprec_type, mld_z_base_smoother_type, psb_ipk_ - class(mld_zprec_type), target, intent(inout):: prec - class(mld_z_base_smoother_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - end subroutine mld_zprecsetsm - subroutine mld_zprecsetsv(prec,val,info,ilev,ilmax,pos) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & - & mld_zprec_type, mld_z_base_solver_type, psb_ipk_ - class(mld_zprec_type), intent(inout) :: prec - class(mld_z_base_solver_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - end subroutine mld_zprecsetsv - subroutine mld_zprecsetag(prec,val,info,ilev,ilmax,pos) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & - & mld_zprec_type, mld_z_base_aggregator_type, psb_ipk_ - class(mld_zprec_type), intent(inout) :: prec - class(mld_z_base_aggregator_type), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax - character(len=*), optional, intent(in) :: pos - end subroutine mld_zprecsetag - subroutine mld_zcprecseti(prec,what,val,info,ilev,ilmax,pos,idx) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & - & mld_zprec_type, psb_ipk_ - class(mld_zprec_type), intent(inout) :: prec - character(len=*), intent(in) :: what - integer(psb_ipk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx - character(len=*), optional, intent(in) :: pos - end subroutine mld_zcprecseti - subroutine mld_zcprecsetr(prec,what,val,info,ilev,ilmax,pos,idx) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & - & mld_zprec_type, psb_ipk_ - class(mld_zprec_type), intent(inout) :: prec - character(len=*), intent(in) :: what - real(psb_dpk_), intent(in) :: val - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx - character(len=*), optional, intent(in) :: pos - end subroutine mld_zcprecsetr - subroutine mld_zcprecsetc(prec,what,string,info,ilev,ilmax,pos,idx) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & - & mld_zprec_type, psb_ipk_ - class(mld_zprec_type), intent(inout) :: prec - character(len=*), intent(in) :: what - character(len=*), intent(in) :: string - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), optional, intent(in) :: ilev,ilmax,idx - character(len=*), optional, intent(in) :: pos - end subroutine mld_zcprecsetc - end interface - - interface mld_precinit - subroutine mld_zprecinit(ictxt,prec,ptype,info) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & - & mld_zprec_type, psb_ipk_ - integer(psb_ipk_), intent(in) :: ictxt - class(mld_zprec_type), intent(inout) :: prec - character(len=*), intent(in) :: ptype - integer(psb_ipk_), intent(out) :: info - end subroutine mld_zprecinit - end interface mld_precinit - - interface mld_precbld - subroutine mld_zprecbld(a,desc_a,prec,info,amold,vmold,imold) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & - & psb_z_base_sparse_mat, psb_z_base_vect_type, & - & psb_i_base_vect_type, mld_zprec_type, psb_ipk_ - implicit none - type(psb_zspmat_type), intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_zprec_type), intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! character, intent(in),optional :: upd - end subroutine mld_zprecbld - end interface mld_precbld - - interface mld_hierarchy_bld - subroutine mld_z_hierarchy_bld(a,desc_a,prec,info) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & - & mld_zprec_type, psb_ipk_ - implicit none - type(psb_zspmat_type), intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_zprec_type), intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - ! character, intent(in),optional :: upd - end subroutine mld_z_hierarchy_bld - end interface mld_hierarchy_bld - - interface mld_smoothers_bld - subroutine mld_z_smoothers_bld(a,desc_a,prec,info,amold,vmold,imold) - import :: psb_zspmat_type, psb_desc_type, psb_dpk_, & - & psb_z_base_sparse_mat, psb_z_base_vect_type, & - & psb_i_base_vect_type, mld_zprec_type, psb_ipk_ - implicit none - type(psb_zspmat_type), intent(in), target :: a - type(psb_desc_type), intent(inout), target :: desc_a - class(mld_zprec_type), intent(inout), target :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! character, intent(in),optional :: upd - end subroutine mld_z_smoothers_bld - end interface mld_smoothers_bld - -contains - ! - ! Function returning a pointer to the smoother - ! - function mld_z_get_smootherp(prec,ilev) result(val) - implicit none - class(mld_zprec_type), target, intent(in) :: prec - integer(psb_ipk_), optional :: ilev - class(mld_z_base_smoother_type), pointer :: val - integer(psb_ipk_) :: ilev_ - - val => null() - if (present(ilev)) then - ilev_ = ilev - else - ! What is a good default? - ilev_ = 1 - end if - if (allocated(prec%precv)) then - if ((1<=ilev_).and.(ilev_<=size(prec%precv))) then - if (allocated(prec%precv(ilev_)%sm)) then - val => prec%precv(ilev_)%sm - end if - end if - end if - end function mld_z_get_smootherp - ! - ! Function returning a pointer to the solver - ! - function mld_z_get_solverp(prec,ilev) result(val) - implicit none - class(mld_zprec_type), target, intent(in) :: prec - integer(psb_ipk_), optional :: ilev - class(mld_z_base_solver_type), pointer :: val - integer(psb_ipk_) :: ilev_ - - val => null() - if (present(ilev)) then - ilev_ = ilev - else - ! What is a good default? - ilev_ = 1 - end if - if (allocated(prec%precv)) then - if ((1<=ilev_).and.(ilev_<=size(prec%precv))) then - if (allocated(prec%precv(ilev_)%sm)) then - if (allocated(prec%precv(ilev_)%sm%sv)) then - val => prec%precv(ilev_)%sm%sv - end if - end if - end if - end if - end function mld_z_get_solverp - ! - ! Function returning the size of the precv(:) array - ! - function mld_z_get_nlevs(prec) result(val) - implicit none - class(mld_zprec_type), intent(in) :: prec - integer(psb_ipk_) :: val - val = 0 - if (allocated(prec%precv)) then - val = size(prec%precv) - end if - end function mld_z_get_nlevs - ! - ! Function returning the size of the mld_prec_type data structure - ! in bytes or in number of nonzeros of the operator(s) involved. - ! - function mld_z_get_nzeros(prec) result(val) - implicit none - class(mld_zprec_type), intent(in) :: prec - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - if (allocated(prec%precv)) then - do i=1, size(prec%precv) - val = val + prec%precv(i)%get_nzeros() - end do - end if - end function mld_z_get_nzeros - - function mld_zprec_sizeof(prec) result(val) - implicit none - class(mld_zprec_type), intent(in) :: prec - integer(psb_epk_) :: val - integer(psb_ipk_) :: i - val = 0 - val = val + psb_sizeof_ip - if (allocated(prec%precv)) then - do i=1, size(prec%precv) - val = val + prec%precv(i)%sizeof() - end do - end if - end function mld_zprec_sizeof - - ! - ! Operator complexity: ratio of total number - ! of nonzeros in the aggregated matrices at the - ! various level to the nonzeroes at the fine level - ! (original matrix) - ! - - function mld_z_get_compl(prec) result(val) - implicit none - class(mld_zprec_type), intent(in) :: prec - complex(psb_dpk_) :: val - - val = prec%ag_data%op_complexity - - end function mld_z_get_compl - - subroutine mld_z_cmp_compl(prec) - - implicit none - class(mld_zprec_type), intent(inout) :: prec - - real(psb_dpk_) :: num, den, nmin - integer(psb_ipk_) :: ictxt - integer(psb_ipk_) :: il - - num = -done - den = done - ictxt = prec%ictxt - if (allocated(prec%precv)) then - il = 1 - num = prec%precv(il)%base_a%get_nzeros() - if (num >= dzero) then - den = num - do il=2,size(prec%precv) - num = num + max(0,prec%precv(il)%base_a%get_nzeros()) - end do - end if - end if - nmin = num - call psb_min(ictxt,nmin) - if (nmin < dzero) then - num = dzero - den = done - else - call psb_sum(ictxt,num) - call psb_sum(ictxt,den) - end if - prec%ag_data%op_complexity = num/den - end subroutine mld_z_cmp_compl - - ! - ! Average coarsening ratio - ! - - function mld_z_get_avg_cr(prec) result(val) - implicit none - class(mld_zprec_type), intent(in) :: prec - complex(psb_dpk_) :: val - - val = prec%ag_data%avg_cr - - end function mld_z_get_avg_cr - - subroutine mld_z_cmp_avg_cr(prec) - - implicit none - class(mld_zprec_type), intent(inout) :: prec - - real(psb_dpk_) :: avgcr - integer(psb_ipk_) :: ictxt - integer(psb_ipk_) :: il, nl, iam, np - - - avgcr = dzero - ictxt = prec%ictxt - call psb_info(ictxt,iam,np) - if (allocated(prec%precv)) then - nl = size(prec%precv) - do il=2,nl - avgcr = avgcr + max(dzero,prec%precv(il)%szratio) - end do - avgcr = avgcr / (nl-1) - end if - call psb_sum(ictxt,avgcr) - prec%ag_data%avg_cr = avgcr/np - end subroutine mld_z_cmp_avg_cr - - ! - ! Subroutines: mld_Tprec_free - ! Version: complex - ! - ! These routines deallocate the mld_Tprec_type data structures. - ! - ! Arguments: - ! p - type(mld_Tprec_type), input. - ! The data structure to be deallocated. - ! info - integer, output. - ! error code. - ! - subroutine mld_zprecfree(p,info) - - implicit none - - ! Arguments - type(mld_zprec_type), intent(inout) :: p - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: me,err_act,i - character(len=20) :: name - - info=psb_success_ - name = 'mld_zprecfree' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; return - end if - - me=-1 - - call p%free(info) - - - return - - end subroutine mld_zprecfree - - subroutine mld_z_prec_free(prec,info) - - implicit none - - ! Arguments - class(mld_zprec_type), intent(inout) :: prec - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: me,err_act,i - character(len=20) :: name - - info=psb_success_ - name = 'mld_zprecfree' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - - me=-1 - if (allocated(prec%precv)) then - do i=1,size(prec%precv) - call prec%precv(i)%free(info) - end do - deallocate(prec%precv,stat=info) - end if - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_z_prec_free - - - - ! - ! Top level methods. - ! - subroutine mld_z_apply2_vect(prec,x,y,desc_data,info,trans,work) - implicit none - type(psb_desc_type),intent(in) :: desc_data - class(mld_zprec_type), intent(inout) :: prec - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_dpk_),intent(inout), optional, target :: work(:) - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_prec_apply' - - call psb_erractionsave(err_act) - - select type(prec) - type is (mld_zprec_type) - call mld_precapply(prec,x,y,desc_data,info,trans,work) - class default - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_z_apply2_vect - - subroutine mld_z_apply1_vect(prec,x,desc_data,info,trans,work) - implicit none - type(psb_desc_type),intent(in) :: desc_data - class(mld_zprec_type), intent(inout) :: prec - type(psb_z_vect_type),intent(inout) :: x - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_dpk_),intent(inout), optional, target :: work(:) - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_prec_apply' - - call psb_erractionsave(err_act) - - select type(prec) - type is (mld_zprec_type) - call mld_precapply(prec,x,desc_data,info,trans,work) - class default - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_z_apply1_vect - - - subroutine mld_z_apply2v(prec,x,y,desc_data,info,trans,work) - implicit none - type(psb_desc_type),intent(in) :: desc_data - class(mld_zprec_type), intent(inout) :: prec - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - complex(psb_dpk_),intent(inout), optional, target :: work(:) - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_prec_apply' - - call psb_erractionsave(err_act) - - select type(prec) - type is (mld_zprec_type) - call mld_precapply(prec,x,y,desc_data,info,trans,work) - class default - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_z_apply2v - - subroutine mld_z_apply1v(prec,x,desc_data,info,trans) - implicit none - type(psb_desc_type),intent(in) :: desc_data - class(mld_zprec_type), intent(inout) :: prec - complex(psb_dpk_),intent(inout) :: x(:) - integer(psb_ipk_), intent(out) :: info - character(len=1), optional :: trans - Integer(psb_ipk_) :: err_act - character(len=20) :: name='d_prec_apply' - - call psb_erractionsave(err_act) - - select type(prec) - type is (mld_zprec_type) - call mld_precapply(prec,x,desc_data,info,trans) - class default - info = psb_err_missing_override_method_ - call psb_errpush(info,name) - goto 9999 - end select - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_z_apply1v - - - subroutine mld_z_dump(prec,info,istart,iend,iproc,prefix,head,& - & ac,rp,smoother,solver,tprol,& - & global_num) - - implicit none - class(mld_zprec_type), intent(in) :: prec - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_), intent(in), optional :: istart, iend, iproc - character(len=*), intent(in), optional :: prefix, head - logical, optional, intent(in) :: smoother, solver,ac, rp, tprol, global_num - integer(psb_ipk_) :: i, j, il1, iln, lev - integer(psb_ipk_) :: icontxt, iam, np, iproc_ - character(len=80) :: prefix_ - character(len=120) :: fname ! len should be at least 20 more than - ! len of prefix_ - - info = 0 - icontxt = prec%ictxt - call psb_info(icontxt,iam,np) - - iln = size(prec%precv) - if (present(istart)) then - il1 = max(1,istart) - else - il1 = min(2,iln) - end if - if (present(iend)) then - iln = min(iln, iend) - end if - iproc_ = -1 - if (present(iproc)) then - iproc_ = iproc - end if - - if ((iproc_ == -1).or.(iproc_==iam)) then - do lev=il1, iln - call prec%precv(lev)%dump(lev,info,prefix=prefix,head=head,& - & ac=ac,smoother=smoother,solver=solver,rp=rp,tprol=tprol, & - & global_num=global_num) - end do - end if - end subroutine mld_z_dump - - subroutine mld_z_cnv(prec,info,amold,vmold,imold) - - implicit none - class(mld_zprec_type), intent(inout) :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - - integer(psb_ipk_) :: i - - info = psb_success_ - if (allocated(prec%precv)) then - do i=1,size(prec%precv) - if (info == psb_success_ ) & - & call prec%precv(i)%cnv(info,amold=amold,vmold=vmold,imold=imold) - end do - end if - - end subroutine mld_z_cnv - - subroutine mld_z_clone(prec,precout,info) - - implicit none - class(mld_zprec_type), intent(inout) :: prec - class(psb_zprec_type), intent(inout) :: precout - integer(psb_ipk_), intent(out) :: info - - call precout%free(info) - if (info == 0) call mld_z_inner_clone(prec,precout,info) - - end subroutine mld_z_clone - - subroutine mld_z_inner_clone(prec,precout,info) - - implicit none - class(mld_zprec_type), intent(inout) :: prec - class(psb_zprec_type), target, intent(inout) :: precout - integer(psb_ipk_), intent(out) :: info - ! Local vars - integer(psb_ipk_) :: i, j, ln, lev - integer(psb_ipk_) :: icontxt,iam, np - - info = psb_success_ - select type(pout => precout) - class is (mld_zprec_type) - pout%ictxt = prec%ictxt - pout%ag_data = prec%ag_data - pout%outer_sweeps = prec%outer_sweeps - if (allocated(prec%precv)) then - ln = size(prec%precv) - allocate(pout%precv(ln),stat=info) - if (info /= psb_success_) goto 9999 - if (ln >= 1) then - call prec%precv(1)%clone(pout%precv(1),info) - end if - do lev=2, ln - if (info /= psb_success_) exit - call prec%precv(lev)%clone(pout%precv(lev),info) - if (info == psb_success_) then - pout%precv(lev)%base_a => pout%precv(lev)%ac - pout%precv(lev)%base_desc => pout%precv(lev)%desc_ac - pout%precv(lev)%map%p_desc_U => pout%precv(lev-1)%base_desc - pout%precv(lev)%map%p_desc_V => pout%precv(lev)%base_desc - end if - end do - end if - if (allocated(prec%precv(1)%wrk)) & - & call pout%allocate_wrk(info,vmold=prec%precv(1)%wrk%vx2l%v) - - class default - write(0,*) 'Error: wrong out type' - info = psb_err_invalid_input_ - end select -9999 continue - end subroutine mld_z_inner_clone - - subroutine z_prec_move_alloc(prec, b,info) - use psb_base_mod - implicit none - class(mld_zprec_type), intent(inout) :: prec - class(mld_zprec_type), intent(inout), target :: b - integer(psb_ipk_), intent(out) :: info - integer(psb_ipk_) :: i - - if (same_type_as(prec,b)) then - if (allocated(b%precv)) then - ! This might not be required if FINAL procedures are available. - call b%free(info) - if (info /= psb_success_) then - !????? -!!$ return - endif - end if - b%ictxt = prec%ictxt - b%ag_data = prec%ag_data - b%outer_sweeps = prec%outer_sweeps - - call move_alloc(prec%precv,b%precv) - ! Fix the pointers except on level 1. - do i=2, size(b%precv) - b%precv(i)%base_a => b%precv(i)%ac - b%precv(i)%base_desc => b%precv(i)%desc_ac - b%precv(i)%map%p_desc_U => b%precv(i-1)%base_desc - b%precv(i)%map%p_desc_V => b%precv(i)%base_desc - end do - - else - write(0,*) 'Warning: PREC%move_alloc onto different type?' - info = psb_err_internal_error_ - end if - end subroutine z_prec_move_alloc - - subroutine mld_z_allocate_wrk(prec,info,vmold,desc) - use psb_base_mod - implicit none - - ! Arguments - class(mld_zprec_type), intent(inout) :: prec - integer(psb_ipk_), intent(out) :: info - class(psb_z_base_vect_type), intent(in), optional :: vmold - ! - ! In MLD the DESC optional argument is ignored, since - ! the necessary info is contained in the various entries of the - ! PRECV component. - type(psb_desc_type), intent(in), optional :: desc - - ! Local variables - integer(psb_ipk_) :: me,err_act,i,j,level,nlev, nc2l - character(len=20) :: name - - info=psb_success_ - name = 'mld_z_allocate_wrk' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - nlev = size(prec%precv) - level = 1 - do level = 1, nlev - call prec%precv(level)%allocate_wrk(info,vmold=vmold) - if (psb_errstatus_fatal()) then - nc2l = prec%precv(level)%base_desc%get_local_cols() - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/2*nc2l/), a_err='complex(psb_dpk_)') - goto 9999 - end if - end do - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_z_allocate_wrk - - subroutine mld_z_free_wrk(prec,info) - use psb_base_mod - implicit none - - ! Arguments - class(mld_zprec_type), intent(inout) :: prec - integer(psb_ipk_), intent(out) :: info - - ! Local variables - integer(psb_ipk_) :: me,err_act,i,j,level, nlev, nc2l - character(len=20) :: name - - info=psb_success_ - name = 'mld_z_free_wrk' - call psb_erractionsave(err_act) - if (psb_errstatus_fatal()) then - info = psb_err_internal_error_; goto 9999 - end if - - if (allocated(prec%precv)) then - nlev = size(prec%precv) - do level = 1, nlev - call prec%precv(level)%free_wrk(info) - end do - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine mld_z_free_wrk - - function mld_z_is_allocated_wrk(prec) result(res) - use psb_base_mod - implicit none - - ! Arguments - class(mld_zprec_type), intent(in) :: prec - logical :: res - - res = .false. - if (.not.allocated(prec%precv)) return - res = allocated(prec%precv(1)%wrk) - - end function mld_z_is_allocated_wrk - -end module mld_z_prec_type diff --git a/mlprec/mld_z_slu_solver.F90 b/mlprec/mld_z_slu_solver.F90 deleted file mode 100644 index ca43e6e9..00000000 --- a/mlprec/mld_z_slu_solver.F90 +++ /dev/null @@ -1,447 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_z_slu_solver_mod.f90 -! -! Module: mld_z_slu_solver_mod -! -! This module defines: -! - the mld_z_slu_solver_type data structure containing the ingredients -! to interface with the SuperLU package. -! 1. The factorization is restricted to the diagonal block of the -! current image. -! -module mld_z_slu_solver - - use iso_c_binding - use mld_z_base_solver_mod - -#if defined(IPK8) - - type, extends(mld_z_base_solver_type) :: mld_z_slu_solver_type - - end type mld_z_slu_solver_type - -#else - - type, extends(mld_z_base_solver_type) :: mld_z_slu_solver_type - type(c_ptr) :: lufactors=c_null_ptr - integer(c_long_long) :: symbsize=0, numsize=0 - contains - procedure, pass(sv) :: build => z_slu_solver_bld - procedure, pass(sv) :: apply_a => z_slu_solver_apply - procedure, pass(sv) :: apply_v => z_slu_solver_apply_vect - procedure, pass(sv) :: free => z_slu_solver_free - procedure, pass(sv) :: clear_data => z_slu_solver_clear_data - procedure, pass(sv) :: descr => z_slu_solver_descr - procedure, pass(sv) :: sizeof => z_slu_solver_sizeof - procedure, nopass :: get_fmt => z_slu_solver_get_fmt - procedure, nopass :: get_id => z_slu_solver_get_id - final :: z_slu_solver_finalize - end type mld_z_slu_solver_type - - - private :: z_slu_solver_bld, z_slu_solver_apply, & - & z_slu_solver_free, z_slu_solver_descr, & - & z_slu_solver_sizeof, z_slu_solver_apply_vect, & - & z_slu_solver_get_fmt, z_slu_solver_get_id, & - & z_slu_solver_clear_data - private :: z_slu_solver_finalize - - - - interface - function mld_zslu_fact(n,nnz,values,rowptr,colind,& - & lufactors)& - & bind(c,name='mld_zslu_fact') result(info) - use iso_c_binding - integer(c_int), value :: n,nnz - integer(c_int) :: info - integer(c_int) :: rowptr(*),colind(*) - complex(c_double_complex) :: values(*) - type(c_ptr) :: lufactors - end function mld_zslu_fact - end interface - - interface - function mld_zslu_solve(itrans,n,nrhs,b,ldb,lufactors)& - & bind(c,name='mld_zslu_solve') result(info) - use iso_c_binding - integer(c_int) :: info - integer(c_int), value :: itrans,n,nrhs,ldb - complex(c_double_complex) :: b(ldb,*) - type(c_ptr), value :: lufactors - end function mld_zslu_solve - end interface - - interface - function mld_zslu_free(lufactors)& - & bind(c,name='mld_zslu_free') result(info) - use iso_c_binding - integer(c_int) :: info - type(c_ptr), value :: lufactors - end function mld_zslu_free - end interface - -contains - - subroutine z_slu_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - use psb_base_mod - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_slu_solver_type), intent(inout) :: sv - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer, intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - - integer :: n_row,n_col - complex(psb_dpk_), pointer :: ww(:) - integer :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='z_slu_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - else - allocate(ww(n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/n_col,0,0,0,0/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - endif - - ww(1:n_row) = x(1:n_row) - select case(trans_) - case('N') - info = mld_zslu_solve(0,n_row,1,ww,n_row,sv%lufactors) - case('T') - info = mld_zslu_solve(1,n_row,1,ww,n_row,sv%lufactors) - case('C') - info = mld_zslu_solve(2,n_row,1,ww,n_row,sv%lufactors) - case default - call psb_errpush(psb_err_internal_error_, & - & name,a_err='Invalid TRANS in ILU subsolve') - goto 9999 - end select - - if (info == psb_success_) & - & call psb_geaxpby(alpha,ww,beta,y,desc_data,info) - - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in subsolve') - goto 9999 - endif - - if (n_col > size(work)) then - deallocate(ww) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine z_slu_solver_apply - - subroutine z_slu_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - use psb_base_mod - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_slu_solver_type), intent(inout) :: sv - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer, intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - - integer :: err_act - character(len=20) :: name='z_slu_solver_apply_vect' - - call psb_erractionsave(err_act) - - info = psb_success_ - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call x%v%sync() - call y%v%sync() - call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) - call y%v%set_host() - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine z_slu_solver_apply_vect - - subroutine z_slu_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - - Implicit None - - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_slu_solver_type), intent(inout) :: sv - integer, intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - type(psb_zspmat_type) :: atmp - type(psb_z_csc_sparse_mat) :: acsc - type(psb_z_coo_sparse_mat) :: acoo - integer :: n_row,n_col, nrow_a, nztota - integer :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='z_slu_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - n_col = desc_a%get_local_cols() - - - call a%cscnv(atmp,info,type='coo') - call psb_rwextd(n_row,atmp,info,b=b) - call atmp%cscnv(info,type='coo',dupl=psb_dupl_add_) - nrow_a = atmp%get_nrows() - call atmp%a%csclip(acoo,info,jmax=nrow_a) - call acsc%mv_from_coo(acoo,info) - nztota = acsc%get_nzeros() - ! Fix the entries to call C-base SuperLU - acsc%ia(:) = acsc%ia(:) - 1 - acsc%icp(:) = acsc%icp(:) - 1 - info = mld_zslu_fact(nrow_a,nztota,acsc%val,& - & acsc%icp,acsc%ia,sv%lufactors) - - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='mld_zslu_fact' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - call acsc%free() - call atmp%free() - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_slu_solver_bld - - subroutine z_slu_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_z_slu_solver_type), intent(inout) :: sv - integer, intent(out) :: info - Integer :: err_act - character(len=20) :: name='z_slu_solver_free' - - call psb_erractionsave(err_act) - - info = psb_success_ - - call sv%clear_data(info) - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_slu_solver_free - - subroutine z_slu_solver_clear_data(sv,info) - - Implicit None - - ! Arguments - class(mld_z_slu_solver_type), intent(inout) :: sv - integer, intent(out) :: info - Integer :: err_act - character(len=20) :: name='z_slu_solver_clear_data' - - call psb_erractionsave(err_act) - - info = psb_success_ - if (c_associated(sv%lufactors)) info = mld_zslu_free(sv%lufactors) - sv%lufactors = c_null_ptr - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_slu_solver_clear_data - - subroutine z_slu_solver_finalize(sv) - - Implicit None - - ! Arguments - type(mld_z_slu_solver_type), intent(inout) :: sv - integer :: info - Integer :: err_act - character(len=20) :: name='z_slu_solver_finalize' - - call sv%free(info) - - return - - end subroutine z_slu_solver_finalize - - subroutine z_slu_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_z_slu_solver_type), intent(in) :: sv - integer, intent(out) :: info - integer, intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer :: err_act - integer :: ictxt, me, np - character(len=20), parameter :: name='mld_z_slu_solver_descr' - integer :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' SuperLU Sparse Factorization Solver. ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_slu_solver_descr - - function z_slu_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_z_slu_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer :: i - - val = 2*psb_sizeof_ip + psb_sizeof_dp - val = val + sv%symbsize - val = val + sv%numsize - return - end function z_slu_solver_sizeof - - function z_slu_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "SuperLU solver" - end function z_slu_solver_get_fmt - - function z_slu_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_slu_ - end function z_slu_solver_get_id -#endif -end module mld_z_slu_solver diff --git a/mlprec/mld_z_sludist_solver.F90 b/mlprec/mld_z_sludist_solver.F90 deleted file mode 100644 index ba276ead..00000000 --- a/mlprec/mld_z_sludist_solver.F90 +++ /dev/null @@ -1,465 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_z_sludist_solver_mod.f90 -! -! Module: mld_z_sludist_solver_mod -! -! This module defines: -! - the mld_z_sludist_solver_type data structure containing the ingredients -! to interface with the SuperLU_Dist package. -! 1. The factorization is distributed (and thus exact) -! -! -! -module mld_z_sludist_solver - - use iso_c_binding - use mld_z_base_solver_mod - -#if defined(LPK8) - - type, extends(mld_z_base_solver_type) :: mld_z_sludist_solver_type - - end type mld_z_sludist_solver_type -#else - type, extends(mld_z_base_solver_type) :: mld_z_sludist_solver_type - type(c_ptr) :: lufactors=c_null_ptr - integer(c_long_long) :: symbsize=0, numsize=0 - contains - procedure, pass(sv) :: build => z_sludist_solver_bld - procedure, pass(sv) :: apply_a => z_sludist_solver_apply - procedure, pass(sv) :: apply_v => z_sludist_solver_apply_vect - procedure, pass(sv) :: free => z_sludist_solver_free - procedure, pass(sv) :: clear_data => z_sludist_solver_clear_data - procedure, pass(sv) :: descr => z_sludist_solver_descr - procedure, pass(sv) :: sizeof => z_sludist_solver_sizeof - procedure, nopass :: get_fmt => z_sludist_solver_get_fmt - procedure, nopass :: get_id => z_sludist_solver_get_id - procedure, pass(sv) :: is_global => z_sludist_solver_is_global - final :: z_sludist_solver_finalize - end type mld_z_sludist_solver_type - - - private :: z_sludist_solver_bld, z_sludist_solver_apply, & - & z_sludist_solver_free, z_sludist_solver_descr, & - & z_sludist_solver_sizeof, z_sludist_solver_apply_vect, & - & z_sludist_solver_get_fmt, z_sludist_solver_get_id, & - & z_sludist_solver_is_global, z_sludist_solver_clear_data - private :: z_sludist_solver_finalize - - - interface - function mld_zsludist_fact(n,nl,nnz,ifrst, & - & values,rowptr,colind,lufactors,npr,npc) & - & bind(c,name='mld_zsludist_fact') result(info) - use iso_c_binding - integer(c_int), value :: n,nl,nnz,ifrst,npr,npc - integer(c_int) :: info - integer(c_int) :: rowptr(*),colind(*) - complex(c_double_complex) :: values(*) - type(c_ptr) :: lufactors - end function mld_zsludist_fact - end interface - - interface - function mld_zsludist_solve(itrans,n,nrhs, b, ldb, lufactors)& - & bind(c,name='mld_zsludist_solve') result(info) - use iso_c_binding - integer(c_int) :: info - integer(c_int), value :: itrans,n,nrhs,ldb - complex(c_double_complex) :: b(ldb,*) - type(c_ptr), value :: lufactors - end function mld_zsludist_solve - end interface - - interface - function mld_zsludist_free(lufactors)& - & bind(c,name='mld_zsludist_free') result(info) - use iso_c_binding - integer(c_int) :: info - type(c_ptr), value :: lufactors - end function mld_zsludist_free - end interface - -contains - - subroutine z_sludist_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - use psb_base_mod - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_sludist_solver_type), intent(inout) :: sv - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer, intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - - integer :: n_row,n_col - complex(psb_dpk_), pointer :: ww(:) - integer :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='z_sludist_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - else - allocate(ww(n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/n_col/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - endif - - if (info == psb_success_)& - & call psb_geaxpby(zone,x,zzero,ww,desc_data,info) - - select case(trans_) - case('N') - info = mld_zsludist_solve(0,n_row,1,ww,n_row,sv%lufactors) - case('T') - info = mld_zsludist_solve(1,n_row,1,ww,n_row,sv%lufactors) - case('C') - info = mld_zsludist_solve(2,n_row,1,ww,n_row,sv%lufactors) - case default - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Invalid TRANS in subsolve') - goto 9999 - end select - - if (info == psb_success_)& - & call psb_geaxpby(alpha,ww,beta,y,desc_data,info) - - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,& - & name,a_err='Error in subsolve') - goto 9999 - endif - - if (n_col > size(work)) then - deallocate(ww) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine z_sludist_solver_apply - - subroutine z_sludist_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - use psb_base_mod - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_sludist_solver_type), intent(inout) :: sv - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer, intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - - integer :: err_act - character(len=20) :: name='z_sludist_solver_apply_vect' - - call psb_erractionsave(err_act) - - info = psb_success_ - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - - call x%v%sync() - call y%v%sync() - call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) - call y%v%set_host() - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine z_sludist_solver_apply_vect - - subroutine z_sludist_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - - Implicit None - - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_sludist_solver_type), intent(inout) :: sv - integer, intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - type(psb_zspmat_type) :: atmp - type(psb_z_csr_sparse_mat) :: acsr - integer :: n_row,n_col, nrow_a, nztota, nglob, nzt, npr, npc - integer :: ifrst, ibcheck - integer :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='z_sludist_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - npr = np - npc = 1 - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - - n_row = desc_a%get_local_rows() - n_col = desc_a%get_local_cols() - nglob = desc_a%get_global_rows() - - call a%cscnv(atmp,info,type='coo') - call psb_rwextd(n_row,atmp,info,b=b) - call atmp%cscnv(info,type='csr',dupl=psb_dupl_add_) - call atmp%mv_to(acsr) - nrow_a = acsr%get_nrows() - nztota = acsr%get_nzeros() - ! Fix the entries to call C-base SuperLU - call psb_loc_to_glob(1,ifrst,desc_a,info) - call psb_loc_to_glob(nrow_a,ibcheck,desc_a,info) - call psb_loc_to_glob(acsr%ja(1:nztota),desc_a,info,iact='I') - acsr%ja(:) = acsr%ja(:) - 1 - acsr%irp(:) = acsr%irp(:) - 1 - ifrst = ifrst - 1 - info = mld_zsludist_fact(nglob,nrow_a,nztota,ifrst,& - & acsr%val,acsr%irp,acsr%ja,sv%lufactors,& - & npr,npc) - - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='mld_zsludist_fact' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - call acsr%free() - call atmp%free() - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_sludist_solver_bld - - subroutine z_sludist_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_z_sludist_solver_type), intent(inout) :: sv - integer, intent(out) :: info - Integer :: err_act - character(len=20) :: name='z_sludist_solver_free' - - call psb_erractionsave(err_act) - info = 0 - call sv%clear_data(info) - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_sludist_solver_free - - subroutine z_sludist_solver_clear_data(sv,info) - - Implicit None - - ! Arguments - class(mld_z_sludist_solver_type), intent(inout) :: sv - integer, intent(out) :: info - Integer :: err_act - character(len=20) :: name='z_sludist_solver_clear_data' - - call psb_erractionsave(err_act) - - info = psb_success_ - if (c_associated(sv%lufactors)) info = mld_zsludist_free(sv%lufactors) - sv%lufactors = c_null_ptr - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_sludist_solver_clear_data - - ! - function z_sludist_solver_is_global(sv) result(val) - implicit none - class(mld_z_sludist_solver_type), intent(in) :: sv - logical :: val - - val = .true. - end function z_sludist_solver_is_global - - subroutine z_sludist_solver_finalize(sv) - - Implicit None - - ! Arguments - type(mld_z_sludist_solver_type), intent(inout) :: sv - integer :: info - Integer :: err_act - character(len=20) :: name='z_sludist_solver_finalize' - - call sv%free(info) - - return - - end subroutine z_sludist_solver_finalize - - subroutine z_sludist_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_z_sludist_solver_type), intent(in) :: sv - integer, intent(out) :: info - integer, intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer :: err_act - integer :: ictxt, me, np - character(len=20), parameter :: name='mld_z_sludist_solver_descr' - integer :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' SuperLU_Dist Sparse Factorization Solver. ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_sludist_solver_descr - - function z_sludist_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_z_sludist_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer :: i - - val = 2*psb_sizeof_ip + psb_sizeof_dp - val = val + sv%symbsize - val = val + sv%numsize - return - end function z_sludist_solver_sizeof - - function z_sludist_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "SuperLU_Dist solver" - end function z_sludist_solver_get_fmt - - function z_sludist_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_sludist_ - end function z_sludist_solver_get_id -#endif -end module mld_z_sludist_solver diff --git a/mlprec/mld_z_symdec_aggregator_mod.f90 b/mlprec/mld_z_symdec_aggregator_mod.f90 deleted file mode 100644 index a385748a..00000000 --- a/mlprec/mld_z_symdec_aggregator_mod.f90 +++ /dev/null @@ -1,105 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! -! Locally symmetrized (decoupled) aggregation algorithm. -! This version differs from the basic decoupled aggregation algorithm -! only because it works on (the pattern of) A+A^T instead of A. -! -! -module mld_z_symdec_aggregator_mod - - use mld_z_dec_aggregator_mod - !> \namespace mld_z_symdec_aggregator_mod \class mld_z_symdec_aggregator_type - !! \extends mld_z_dec_aggregator_mod::mld_z_dec_aggregator_type - !! - !! This version differs from the basic decoupled aggregation algorithm - !! only because it works on (the pattern of) A+A^T instead of A. - !! - ! - type, extends(mld_z_dec_aggregator_type) :: mld_z_symdec_aggregator_type - - contains - procedure, pass(ag) :: bld_tprol => mld_z_symdec_aggregator_build_tprol - procedure, pass(ag) :: descr => mld_z_symdec_aggregator_descr - procedure, nopass :: fmt => mld_z_symdec_aggregator_fmt - end type mld_z_symdec_aggregator_type - - - interface - subroutine mld_z_symdec_aggregator_build_tprol(ag,parms,ag_data,& - & a,desc_a,ilaggr,nlaggr,t_prol,info) - import :: mld_z_symdec_aggregator_type, psb_desc_type, psb_zspmat_type, psb_dpk_, & - & psb_ipk_, psb_lpk_, psb_lzspmat_type, mld_dml_parms, mld_daggr_data - implicit none - class(mld_z_symdec_aggregator_type), target, intent(inout) :: ag - type(mld_dml_parms), intent(inout) :: parms - type(mld_daggr_data), intent(in) :: ag_data - type(psb_zspmat_type), intent(inout) :: a - type(psb_desc_type), intent(inout) :: desc_a - integer(psb_lpk_), allocatable, intent(out) :: ilaggr(:),nlaggr(:) - type(psb_lzspmat_type), intent(out) :: t_prol - integer(psb_ipk_), intent(out) :: info - end subroutine mld_z_symdec_aggregator_build_tprol - end interface - - -contains - - function mld_z_symdec_aggregator_fmt() result(val) - implicit none - character(len=32) :: val - - val = "Symmetric Decoupled aggregation" - end function mld_z_symdec_aggregator_fmt - - subroutine mld_z_symdec_aggregator_descr(ag,parms,iout,info) - implicit none - class(mld_z_symdec_aggregator_type), intent(in) :: ag - type(mld_dml_parms), intent(in) :: parms - integer(psb_ipk_), intent(in) :: iout - integer(psb_ipk_), intent(out) :: info - - write(iout,*) 'Decoupled Aggregator locally-symmetrized' - write(iout,*) 'Aggregator object type: ',ag%fmt() - call parms%mldescr(iout,info) - - return - end subroutine mld_z_symdec_aggregator_descr - -end module mld_z_symdec_aggregator_mod diff --git a/mlprec/mld_z_umf_solver.F90 b/mlprec/mld_z_umf_solver.F90 deleted file mode 100644 index 3ea111aa..00000000 --- a/mlprec/mld_z_umf_solver.F90 +++ /dev/null @@ -1,453 +0,0 @@ -! -! -! MLD2P4 version 2.2 -! MultiLevel Domain Decomposition Parallel Preconditioners Package -! based on PSBLAS (Parallel Sparse BLAS version 3.5) -! -! (C) Copyright 2008-2018 -! -! Salvatore Filippone -! Pasqua D'Ambra -! Daniela di Serafino -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions -! are met: -! 1. Redistributions of source code must retain the above copyright -! notice, this list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright -! notice, this list of conditions, and the following disclaimer in the -! documentation and/or other materials provided with the distribution. -! 3. The name of the MLD2P4 group or the names of its contributors may -! not be used to endorse or promote products derived from this -! software without specific written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE MLD2P4 GROUP OR ITS CONTRIBUTORS -! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. -! -! -! -! File: mld_z_umf_solver_mod.f90 -! -! Module: mld_z_umf_solver_mod -! -! This module defines: -! - the mld_z_umf_solver_type data structure containing the ingredients -! to interface with the UMFPACK package. -! 1. The factorization is restricted to the diagonal block of the -! current image. -! -module mld_z_umf_solver - - use iso_c_binding - use mld_z_base_solver_mod - -#if defined(IPK8) - type, extends(mld_z_base_solver_type) :: mld_z_umf_solver_type - - end type mld_z_umf_solver_type - -#else - - type, extends(mld_z_base_solver_type) :: mld_z_umf_solver_type - type(c_ptr) :: symbolic=c_null_ptr, numeric=c_null_ptr - integer(c_long_long) :: symbsize=0, numsize=0 - contains - procedure, pass(sv) :: build => z_umf_solver_bld - procedure, pass(sv) :: apply_a => z_umf_solver_apply - procedure, pass(sv) :: apply_v => z_umf_solver_apply_vect - procedure, pass(sv) :: free => z_umf_solver_free - procedure, pass(sv) :: clear_data => z_umf_solver_clear_data - procedure, pass(sv) :: descr => z_umf_solver_descr - procedure, pass(sv) :: sizeof => z_umf_solver_sizeof - procedure, nopass :: get_fmt => z_umf_solver_get_fmt - procedure, nopass :: get_id => z_umf_solver_get_id - final :: z_umf_solver_finalize - end type mld_z_umf_solver_type - - - private :: z_umf_solver_bld, z_umf_solver_apply, & - & z_umf_solver_free, z_umf_solver_descr, & - & z_umf_solver_sizeof, z_umf_solver_apply_vect, & - & z_umf_solver_get_fmt, z_umf_solver_get_id, & - & z_umf_solver_clear_data - private :: z_umf_solver_finalize - - - - interface - function mld_zumf_fact(n,nnz,values,rowind,colptr,& - & symptr,numptr,ssize,nsize)& - & bind(c,name='mld_zumf_fact') result(info) - use iso_c_binding - integer(c_int), value :: n,nnz - integer(c_int) :: info - integer(c_long_long) :: ssize, nsize - integer(c_int) :: rowind(*),colptr(*) - complex(c_double_complex) :: values(*) - type(c_ptr) :: symptr, numptr - end function mld_zumf_fact - end interface - - interface - function mld_zumf_solve(itrans,n,x, b, ldb, numptr)& - & bind(c,name='mld_zumf_solve') result(info) - use iso_c_binding - integer(c_int) :: info - integer(c_int), value :: itrans,n,ldb - complex(c_double_complex) :: x(*), b(ldb,*) - type(c_ptr), value :: numptr - end function mld_zumf_solve - end interface - - interface - function mld_zumf_free(symptr, numptr)& - & bind(c,name='mld_zumf_free') result(info) - use iso_c_binding - integer(c_int) :: info - type(c_ptr), value :: symptr, numptr - end function mld_zumf_free - end interface - -contains - - subroutine z_umf_solver_apply(alpha,sv,x,beta,y,desc_data,& - & trans,work,info,init,initu) - use psb_base_mod - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_umf_solver_type), intent(inout) :: sv - complex(psb_dpk_),intent(inout) :: x(:) - complex(psb_dpk_),intent(inout) :: y(:) - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - integer, intent(out) :: info - character, intent(in), optional :: init - complex(psb_dpk_),intent(inout), optional :: initu(:) - - integer :: n_row,n_col - complex(psb_dpk_), pointer :: ww(:) - integer :: ictxt,np,me,i, err_act - character :: trans_ - character(len=20) :: name='z_umf_solver_apply' - - call psb_erractionsave(err_act) - - info = psb_success_ - - trans_ = psb_toupper(trans) - select case(trans_) - case('N') - case('T','C') - case default - call psb_errpush(psb_err_iarg_invalid_i_,name) - goto 9999 - end select - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - n_row = desc_data%get_local_rows() - n_col = desc_data%get_local_cols() - - if (n_col <= size(work)) then - ww => work(1:n_col) - else - allocate(ww(n_col),stat=info) - if (info /= psb_success_) then - info=psb_err_alloc_request_ - call psb_errpush(info,name,i_err=(/n_col,0,0,0,0/),& - & a_err='complex(psb_dpk_)') - goto 9999 - end if - endif - - select case(trans_) - case('N') - info = mld_zumf_solve(0,n_row,ww,x,n_row,sv%numeric) - case('T') - ! - ! Note: with UMF, 1 meand Ctranspose, 2 means transpose - ! even for complex data. - ! - if (psb_z_is_complex_) then - info = mld_zumf_solve(2,n_row,ww,x,n_row,sv%numeric) - else - info = mld_zumf_solve(1,n_row,ww,x,n_row,sv%numeric) - end if - case('C') - info = mld_zumf_solve(1,n_row,ww,x,n_row,sv%numeric) - case default - call psb_errpush(psb_err_internal_error_,name,a_err='Invalid TRANS in ILU subsolve') - goto 9999 - end select - - if (info == psb_success_) call psb_geaxpby(alpha,ww,beta,y,desc_data,info) - - - if (info /= psb_success_) then - call psb_errpush(psb_err_internal_error_,name,a_err='Error in subsolve') - goto 9999 - endif - - if (n_col > size(work)) then - deallocate(ww) - endif - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine z_umf_solver_apply - - subroutine z_umf_solver_apply_vect(alpha,sv,x,beta,y,desc_data,& - & trans,work,wv,info,init,initu) - use psb_base_mod - implicit none - type(psb_desc_type), intent(in) :: desc_data - class(mld_z_umf_solver_type), intent(inout) :: sv - type(psb_z_vect_type),intent(inout) :: x - type(psb_z_vect_type),intent(inout) :: y - complex(psb_dpk_),intent(in) :: alpha,beta - character(len=1),intent(in) :: trans - complex(psb_dpk_),target, intent(inout) :: work(:) - type(psb_z_vect_type),intent(inout) :: wv(:) - integer, intent(out) :: info - character, intent(in), optional :: init - type(psb_z_vect_type),intent(inout), optional :: initu - - integer :: err_act - character(len=20) :: name='z_umf_solver_apply_vect' - - call psb_erractionsave(err_act) - - info = psb_success_ - ! - ! For non-iterative solvers, init and initu are ignored. - ! - - call x%v%sync() - call y%v%sync() - call sv%apply(alpha,x%v%v,beta,y%v%v,desc_data,trans,work,info) - call y%v%set_host() - if (info /= 0) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - - end subroutine z_umf_solver_apply_vect - - subroutine z_umf_solver_bld(a,desc_a,sv,info,b,amold,vmold,imold) - - use psb_base_mod - - Implicit None - - ! Arguments - type(psb_zspmat_type), intent(in), target :: a - Type(psb_desc_type), Intent(inout) :: desc_a - class(mld_z_umf_solver_type), intent(inout) :: sv - integer, intent(out) :: info - type(psb_zspmat_type), intent(in), target, optional :: b - class(psb_z_base_sparse_mat), intent(in), optional :: amold - class(psb_z_base_vect_type), intent(in), optional :: vmold - class(psb_i_base_vect_type), intent(in), optional :: imold - ! Local variables - type(psb_zspmat_type) :: atmp - type(psb_z_csc_sparse_mat) :: acsc - integer :: n_row,n_col, nrow_a, nztota - integer :: ictxt,np,me,i, err_act, debug_unit, debug_level - character(len=20) :: name='z_umf_solver_bld', ch_err - - info=psb_success_ - call psb_erractionsave(err_act) - debug_unit = psb_get_debug_unit() - debug_level = psb_get_debug_level() - ictxt = desc_a%get_context() - call psb_info(ictxt, me, np) - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' start' - - - n_row = desc_a%get_local_rows() - n_col = desc_a%get_local_cols() - - call a%cscnv(atmp,info,type='coo') - call psb_rwextd(n_row,atmp,info,b=b) - call atmp%cscnv(info,type='csc',dupl=psb_dupl_add_) - call atmp%mv_to(acsc) - nrow_a = acsc%get_nrows() - nztota = acsc%get_nzeros() - ! Fix the entres to call C-base UMFPACK. - acsc%ia(:) = acsc%ia(:) - 1 - acsc%icp(:) = acsc%icp(:) - 1 - info = mld_zumf_fact(nrow_a,nztota,acsc%val,& - & acsc%ia,acsc%icp,sv%symbolic,sv%numeric,& - & sv%symbsize,sv%numsize) - - if (info /= psb_success_) then - info=psb_err_from_subroutine_ - ch_err='mld_zumf_fact' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - call acsc%free() - call atmp%free() - - if (debug_level >= psb_debug_outer_) & - & write(debug_unit,*) me,' ',trim(name),' end' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_umf_solver_bld - - subroutine z_umf_solver_free(sv,info) - - Implicit None - - ! Arguments - class(mld_z_umf_solver_type), intent(inout) :: sv - integer, intent(out) :: info - Integer :: err_act - character(len=20) :: name='z_umf_solver_free' - - call psb_erractionsave(err_act) - - call sv%clear_data(info) - - if (info /= psb_success_) goto 9999 - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_umf_solver_free - - - subroutine z_umf_solver_clear_data(sv,info) - - Implicit None - - ! Arguments - class(mld_z_umf_solver_type), intent(inout) :: sv - integer, intent(out) :: info - Integer :: err_act - character(len=20) :: name='z_umf_solver_clear_data' - - call psb_erractionsave(err_act) - info = 0 - if (c_associated(sv%symbolic).and.c_associated(sv%numeric)) then - info = mld_zumf_free(sv%symbolic,sv%numeric) - - if (info /= psb_success_) goto 9999 - sv%symbolic = c_null_ptr - sv%numeric = c_null_ptr - sv%symbsize = 0 - sv%numsize = 0 - end if - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_umf_solver_clear_data - - subroutine z_umf_solver_finalize(sv) - - Implicit None - - ! Arguments - type(mld_z_umf_solver_type), intent(inout) :: sv - integer :: info - Integer :: err_act - character(len=20) :: name='z_umf_solver_finalize' - - call sv%free(info) - - return - - end subroutine z_umf_solver_finalize - - subroutine z_umf_solver_descr(sv,info,iout,coarse) - - Implicit None - - ! Arguments - class(mld_z_umf_solver_type), intent(in) :: sv - integer, intent(out) :: info - integer, intent(in), optional :: iout - logical, intent(in), optional :: coarse - - ! Local variables - integer :: err_act - integer :: ictxt, me, np - character(len=20), parameter :: name='mld_z_umf_solver_descr' - integer :: iout_ - - call psb_erractionsave(err_act) - info = psb_success_ - if (present(iout)) then - iout_ = iout - else - iout_ = psb_out_unit - endif - - write(iout_,*) ' UMFPACK Sparse Factorization Solver. ' - - call psb_erractionrestore(err_act) - return - -9999 call psb_error_handler(err_act) - return - end subroutine z_umf_solver_descr - - function z_umf_solver_sizeof(sv) result(val) - - implicit none - ! Arguments - class(mld_z_umf_solver_type), intent(in) :: sv - integer(psb_epk_) :: val - integer :: i - - val = 2*psb_sizeof_lp - val = val + sv%symbsize - val = val + sv%numsize - return - end function z_umf_solver_sizeof - - function z_umf_solver_get_fmt() result(val) - implicit none - character(len=32) :: val - - val = "UMFPACK solver" - end function z_umf_solver_get_fmt - - function z_umf_solver_get_id() result(val) - implicit none - integer(psb_ipk_) :: val - - val = mld_umf_ - end function z_umf_solver_get_id -#endif -end module mld_z_umf_solver diff --git a/tests/Bcmatch/mld_d_bcmatch_aggregator_mat_asb.f90 b/tests/Bcmatch/amg_d_bcmatch_aggregator_mat_asb.f90 similarity index 100% rename from tests/Bcmatch/mld_d_bcmatch_aggregator_mat_asb.f90 rename to tests/Bcmatch/amg_d_bcmatch_aggregator_mat_asb.f90 diff --git a/tests/Bcmatch/mld_d_bcmatch_aggregator_mod.F90 b/tests/Bcmatch/amg_d_bcmatch_aggregator_mod.F90 similarity index 100% rename from tests/Bcmatch/mld_d_bcmatch_aggregator_mod.F90 rename to tests/Bcmatch/amg_d_bcmatch_aggregator_mod.F90 diff --git a/tests/Bcmatch/mld_d_bcmatch_aggregator_tprol.f90 b/tests/Bcmatch/amg_d_bcmatch_aggregator_tprol.f90 similarity index 100% rename from tests/Bcmatch/mld_d_bcmatch_aggregator_tprol.f90 rename to tests/Bcmatch/amg_d_bcmatch_aggregator_tprol.f90 diff --git a/tests/Bcmatch/mld_d_bcmatch_map_to_tprol.f90 b/tests/Bcmatch/amg_d_bcmatch_map_to_tprol.f90 similarity index 100% rename from tests/Bcmatch/mld_d_bcmatch_map_to_tprol.f90 rename to tests/Bcmatch/amg_d_bcmatch_map_to_tprol.f90 diff --git a/tests/Bcmatch/mld_d_pde3d.f90 b/tests/Bcmatch/amg_d_pde3d.f90 similarity index 100% rename from tests/Bcmatch/mld_d_pde3d.f90 rename to tests/Bcmatch/amg_d_pde3d.f90 diff --git a/tests/Bcmatch/mld_daggrmat_unsmth_spmm_asb.f90 b/tests/Bcmatch/amg_daggrmat_unsmth_spmm_asb.f90 similarity index 100% rename from tests/Bcmatch/mld_daggrmat_unsmth_spmm_asb.f90 rename to tests/Bcmatch/amg_daggrmat_unsmth_spmm_asb.f90 diff --git a/tests/fileread/mld_cf_sample.f90 b/tests/fileread/amg_cf_sample.f90 similarity index 100% rename from tests/fileread/mld_cf_sample.f90 rename to tests/fileread/amg_cf_sample.f90 diff --git a/tests/fileread/mld_df_sample.f90 b/tests/fileread/amg_df_sample.f90 similarity index 100% rename from tests/fileread/mld_df_sample.f90 rename to tests/fileread/amg_df_sample.f90 diff --git a/tests/fileread/mld_sf_sample.f90 b/tests/fileread/amg_sf_sample.f90 similarity index 100% rename from tests/fileread/mld_sf_sample.f90 rename to tests/fileread/amg_sf_sample.f90 diff --git a/tests/fileread/mld_zf_sample.f90 b/tests/fileread/amg_zf_sample.f90 similarity index 100% rename from tests/fileread/mld_zf_sample.f90 rename to tests/fileread/amg_zf_sample.f90 diff --git a/tests/newslv/mld_d_tlu_solver.f90 b/tests/newslv/amg_d_tlu_solver.f90 similarity index 100% rename from tests/newslv/mld_d_tlu_solver.f90 rename to tests/newslv/amg_d_tlu_solver.f90 diff --git a/tests/newslv/mld_d_tlu_solver_impl.f90 b/tests/newslv/amg_d_tlu_solver_impl.f90 similarity index 100% rename from tests/newslv/mld_d_tlu_solver_impl.f90 rename to tests/newslv/amg_d_tlu_solver_impl.f90 diff --git a/tests/newslv/mld_pde3d_newslv.f90 b/tests/newslv/amg_pde3d_newslv.f90 similarity index 100% rename from tests/newslv/mld_pde3d_newslv.f90 rename to tests/newslv/amg_pde3d_newslv.f90 diff --git a/tests/pdegen/mld_d_pde2d.f90 b/tests/pdegen/amg_d_pde2d.f90 similarity index 100% rename from tests/pdegen/mld_d_pde2d.f90 rename to tests/pdegen/amg_d_pde2d.f90 diff --git a/tests/pdegen/mld_d_pde3d.f90 b/tests/pdegen/amg_d_pde3d.f90 similarity index 100% rename from tests/pdegen/mld_d_pde3d.f90 rename to tests/pdegen/amg_d_pde3d.f90 diff --git a/tests/pdegen/mld_s_pde2d.f90 b/tests/pdegen/amg_s_pde2d.f90 similarity index 100% rename from tests/pdegen/mld_s_pde2d.f90 rename to tests/pdegen/amg_s_pde2d.f90 diff --git a/tests/pdegen/mld_s_pde3d.f90 b/tests/pdegen/amg_s_pde3d.f90 similarity index 100% rename from tests/pdegen/mld_s_pde3d.f90 rename to tests/pdegen/amg_s_pde3d.f90 diff --git a/tests/pdegen/runs/mld_pde2d.inp b/tests/pdegen/runs/mld_pde2d.inp index ce59195b..50f2e9ad 100644 --- a/tests/pdegen/runs/mld_pde2d.inp +++ b/tests/pdegen/runs/mld_pde2d.inp @@ -11,7 +11,7 @@ CG ! Iterative method: BiCGSTAB BiCGSTABL BiCG CG CGS F ML-VCYCLE-FBGS-R-UMF ! Longer descriptive name for preconditioner (up to 20 chars) ML ! Preconditioner type: NONE JACOBI GS FBGS BJAC AS ML %%%%%%%%%%% First smoother (for all levels but coarsest) %%%%%%%%%%%%%%%% -FBGS ! Smoother type JACOBI FBGS GS BWGS BJAC AS. For 1-level, repeats previous. +BJAC ! Smoother type JACOBI FBGS GS BWGS BJAC AS. For 1-level, repeats previous. 1 ! Number of sweeps for smoother 0 ! Number of overlap layers for AS preconditioner HALO ! AS restriction operator: NONE HALO